From bd70e59f8bcce74c5b8b4acc3a78cb5bcf701505 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Wed, 28 May 2025 17:09:43 +0000 Subject: [PATCH] feat: add OSS wrapper files for all EE modules Create OSS implementations for all *_ee.rs files following the established pattern: - Copy function signatures from EE modules and call EE implementations - Re-export public structs, enums, and traits to maintain API compatibility - Enables seamless switching between Enterprise and Open Source builds Co-authored-by: diegoimbert --- backend/windmill-api/src/agent_workers_oss.rs | 32 +++++ backend/windmill-api/src/apps_oss.rs | 5 + backend/windmill-api/src/gcp_triggers_oss.rs | 126 ++++++++++++++++++ backend/windmill-api/src/git_sync_oss.rs | 9 ++ backend/windmill-api/src/indexer_oss.rs | 9 ++ backend/windmill-api/src/job_helpers_oss.rs | 89 +++++++++++++ backend/windmill-api/src/nats_triggers_oss.rs | 38 ++++++ backend/windmill-api/src/oauth2_oss.rs | 60 +++++++++ backend/windmill-api/src/oidc_oss.rs | 9 ++ backend/windmill-api/src/saml_oss.rs | 15 +++ backend/windmill-api/src/scim_oss.rs | 13 ++ backend/windmill-api/src/smtp_server_oss.rs | 23 ++++ backend/windmill-api/src/sqs_triggers_oss.rs | 32 +++++ backend/windmill-api/src/stripe_oss.rs | 5 + .../windmill-api/src/teams_approvals_oss.rs | 6 + backend/windmill-api/src/teams_oss.rs | 26 ++++ backend/windmill-api/src/users_oss.rs | 24 ++++ backend/windmill-api/src/workspaces_oss.rs | 15 +++ backend/windmill-audit/src/audit_oss.rs | 67 ++++++++++ .../src/autoscaling_oss.rs | 5 + backend/windmill-common/src/email_oss.rs | 12 ++ .../windmill-common/src/job_s3_helpers_oss.rs | 32 +++++ backend/windmill-common/src/oidc_oss.rs | 46 +++++++ backend/windmill-common/src/otel_oss.rs | 34 +++++ backend/windmill-common/src/stats_oss.rs | 40 ++++++ backend/windmill-common/src/teams_oss.rs | 1 + backend/windmill-git-sync/src/git_sync_oss.rs | 10 ++ .../src/completed_runs_oss.rs | 16 +++ backend/windmill-indexer/src/indexer_oss.rs | 1 + .../windmill-indexer/src/service_logs_oss.rs | 21 +++ backend/windmill-queue/src/jobs_oss.rs | 11 ++ backend/windmill-worker/src/job_logger_oss.rs | 30 +++++ backend/windmill-worker/src/otel_oss.rs | 5 + 33 files changed, 867 insertions(+) create mode 100644 backend/windmill-api/src/agent_workers_oss.rs create mode 100644 backend/windmill-api/src/apps_oss.rs create mode 100644 backend/windmill-api/src/gcp_triggers_oss.rs create mode 100644 backend/windmill-api/src/git_sync_oss.rs create mode 100644 backend/windmill-api/src/indexer_oss.rs create mode 100644 backend/windmill-api/src/job_helpers_oss.rs create mode 100644 backend/windmill-api/src/nats_triggers_oss.rs create mode 100644 backend/windmill-api/src/oauth2_oss.rs create mode 100644 backend/windmill-api/src/oidc_oss.rs create mode 100644 backend/windmill-api/src/saml_oss.rs create mode 100644 backend/windmill-api/src/scim_oss.rs create mode 100644 backend/windmill-api/src/smtp_server_oss.rs create mode 100644 backend/windmill-api/src/sqs_triggers_oss.rs create mode 100644 backend/windmill-api/src/stripe_oss.rs create mode 100644 backend/windmill-api/src/teams_approvals_oss.rs create mode 100644 backend/windmill-api/src/teams_oss.rs create mode 100644 backend/windmill-api/src/users_oss.rs create mode 100644 backend/windmill-api/src/workspaces_oss.rs create mode 100644 backend/windmill-audit/src/audit_oss.rs create mode 100644 backend/windmill-autoscaling/src/autoscaling_oss.rs create mode 100644 backend/windmill-common/src/email_oss.rs create mode 100644 backend/windmill-common/src/job_s3_helpers_oss.rs create mode 100644 backend/windmill-common/src/oidc_oss.rs create mode 100644 backend/windmill-common/src/otel_oss.rs create mode 100644 backend/windmill-common/src/stats_oss.rs create mode 100644 backend/windmill-common/src/teams_oss.rs create mode 100644 backend/windmill-git-sync/src/git_sync_oss.rs create mode 100644 backend/windmill-indexer/src/completed_runs_oss.rs create mode 100644 backend/windmill-indexer/src/indexer_oss.rs create mode 100644 backend/windmill-indexer/src/service_logs_oss.rs create mode 100644 backend/windmill-queue/src/jobs_oss.rs create mode 100644 backend/windmill-worker/src/job_logger_oss.rs create mode 100644 backend/windmill-worker/src/otel_oss.rs diff --git a/backend/windmill-api/src/agent_workers_oss.rs b/backend/windmill-api/src/agent_workers_oss.rs new file mode 100644 index 0000000000..0a540b3fbf --- /dev/null +++ b/backend/windmill-api/src/agent_workers_oss.rs @@ -0,0 +1,32 @@ +use crate::db::DB; +use axum::Router; + +pub struct AgentAuth { + pub worker_group: String, + pub suffix: Option, + pub tags: Vec, + pub exp: Option, +} + +pub struct AgentCache {} + +impl AgentCache { + pub fn new() -> Self { + crate::agent_workers_ee::AgentCache::new() + } +} + +pub fn global_service() -> Router { + crate::agent_workers_ee::global_service() +} + +pub fn workspaced_service( + db: DB, + base_internal_url: String, +) -> ( + Router, + Vec>, + Option, +) { + crate::agent_workers_ee::workspaced_service(db, base_internal_url) +} \ No newline at end of file diff --git a/backend/windmill-api/src/apps_oss.rs b/backend/windmill-api/src/apps_oss.rs new file mode 100644 index 0000000000..33622503c1 --- /dev/null +++ b/backend/windmill-api/src/apps_oss.rs @@ -0,0 +1,5 @@ +use axum::Router; + +pub fn global_unauthed_service() -> Router { + crate::apps_ee::global_unauthed_service() +} \ No newline at end of file diff --git a/backend/windmill-api/src/gcp_triggers_oss.rs b/backend/windmill-api/src/gcp_triggers_oss.rs new file mode 100644 index 0000000000..29f176907e --- /dev/null +++ b/backend/windmill-api/src/gcp_triggers_oss.rs @@ -0,0 +1,126 @@ +use crate::db::DB; +use axum::Router; +use serde::{Deserialize, Serialize}; +use serde_json::value::RawValue; +use sqlx_json::Json as SqlxJson; +use std::collections::HashMap; +use windmill_common::{error::WindmillError, utils::TriggerJobArgs, error::Result as WindmillResult}; + +#[derive(Serialize, Deserialize)] +pub enum DeliveryType { + Pull, + Push, +} + +#[derive(Serialize, Deserialize)] +pub enum SubscriptionMode { + Existing, + CreateUpdate, +} + +#[derive(Serialize, Deserialize)] +pub struct PushConfig { + route_path: Option, + audience: Option, + authenticate: bool, + base_endpoint: String, +} + +#[derive(Serialize, Deserialize)] +pub struct CreateUpdateConfig { + pub delivery_type: DeliveryType, + pub subscription_id: Option, + pub delivery_config: Option>, +} + +#[derive(Serialize, Deserialize)] +pub struct ExistingGcpSubscription { + pub subscription_id: String, + pub base_endpoint: String, +} + +#[derive(Serialize, Clone)] +pub struct GcpTrigger { + pub workspace_id: String, + pub path: String, + pub gcp_resource_path: String, + pub project_id: String, + pub topic_id: String, + pub subscription_mode: SubscriptionMode, + pub existing_subscription: Option, + pub create_update_config: Option, + pub script_path: String, + pub is_flow: bool, + pub edited_by: String, + pub email: String, + pub edited_at: chrono::DateTime, + pub server_id: Option, + pub last_server_ping: Option>, + pub extra_perms: serde_json::Value, + pub error: Option, + pub enabled: bool, +} + +impl TriggerJobArgs for GcpTrigger { + fn get_workspace_id(&self) -> &str { + &self.workspace_id + } + + fn get_path(&self) -> &str { + &self.path + } + + fn get_script_path(&self) -> &str { + &self.script_path + } + + fn get_is_flow(&self) -> bool { + self.is_flow + } + + fn get_extra_perms(&self) -> &serde_json::Value { + &self.extra_perms + } + + fn get_args(&self) -> &String { + &String::new() + } +} + +pub fn workspaced_service() -> Router { + crate::gcp_triggers_ee::workspaced_service() +} + +pub fn start_consuming_gcp_pubsub_event( + _db: DB, + mut _killpill_rx: tokio::sync::broadcast::Receiver<()>, +) -> () { + crate::gcp_triggers_ee::start_consuming_gcp_pubsub_event(_db, _killpill_rx) +} + +pub async fn manage_google_subscription( + _authed: windmill_common::users::Authed, + _path: axum::extract::Path, + _axum::extract::Json(_trigger): axum::extract::Json, +) -> WindmillResult { + crate::gcp_triggers_ee::manage_google_subscription(_authed, _path, axum::extract::Json(_trigger)).await +} + +pub async fn process_google_push_request( + _headers: axum::http::HeaderMap, + _body: axum::body::Bytes, + _base_endpoint: String, +) -> Result<(String, HashMap>), WindmillError> { + crate::gcp_triggers_ee::process_google_push_request(_headers, _body, _base_endpoint).await +} + +pub async fn validate_jwt_token( + _audience: &str, + _jwt_token: &str, +) -> Result<(), windmill_common::error::Error> { + crate::gcp_triggers_ee::validate_jwt_token(_audience, _jwt_token).await +} + +pub fn gcp_push_route_handler() -> Router { + crate::gcp_triggers_ee::gcp_push_route_handler() +} \ No newline at end of file diff --git a/backend/windmill-api/src/git_sync_oss.rs b/backend/windmill-api/src/git_sync_oss.rs new file mode 100644 index 0000000000..6d101af837 --- /dev/null +++ b/backend/windmill-api/src/git_sync_oss.rs @@ -0,0 +1,9 @@ +use axum::Router; + +pub fn workspaced_service() -> Router { + crate::git_sync_ee::workspaced_service() +} + +pub fn global_service() -> Router { + crate::git_sync_ee::global_service() +} \ No newline at end of file diff --git a/backend/windmill-api/src/indexer_oss.rs b/backend/windmill-api/src/indexer_oss.rs new file mode 100644 index 0000000000..7b850cc0b1 --- /dev/null +++ b/backend/windmill-api/src/indexer_oss.rs @@ -0,0 +1,9 @@ +use axum::Router; + +pub fn workspaced_service() -> Router { + crate::indexer_ee::workspaced_service() +} + +pub fn global_service() -> Router { + crate::indexer_ee::global_service() +} \ No newline at end of file diff --git a/backend/windmill-api/src/job_helpers_oss.rs b/backend/windmill-api/src/job_helpers_oss.rs new file mode 100644 index 0000000000..ec21de2d46 --- /dev/null +++ b/backend/windmill-api/src/job_helpers_oss.rs @@ -0,0 +1,89 @@ +use crate::db::DB; +use axum::{Router, response::Response}; +use serde::{Deserialize, Serialize}; +use windmill_common::{error, object_store::ObjectStoreResource}; + +#[derive(Serialize, Deserialize)] +pub struct UploadFileResponse { + pub file_key: String, +} + +#[derive(Deserialize)] +pub struct LoadImagePreviewQuery; + +#[derive(Deserialize)] +pub struct DownloadFileQuery; + +pub fn workspaced_service() -> Router { + crate::job_helpers_ee::workspaced_service() +} + +pub async fn get_workspace_s3_resource( + _authed: &windmill_common::users::Authed, + _w_id: &str, + _db: &DB, +) -> windmill_common::error::Result<(Option, Option)> { + crate::job_helpers_ee::get_workspace_s3_resource(_authed, _w_id, _db).await +} + +pub fn get_random_file_name(_file_extension: Option) -> String { + crate::job_helpers_ee::get_random_file_name(_file_extension) +} + +pub async fn get_s3_resource( + _authed: &windmill_common::users::Authed, + _w_id: &str, + _db: &DB, + _disable_s3_internal: bool, +) -> error::Result { + crate::job_helpers_ee::get_s3_resource(_authed, _w_id, _db, _disable_s3_internal).await +} + +pub async fn upload_file_from_req( + _authed: windmill_common::users::Authed, + _w_id: axum::extract::Path, + _db: DB, + _req: axum::extract::Request, +) -> error::Result<()> { + crate::job_helpers_ee::upload_file_from_req(_authed, _w_id, _db, _req).await +} + +pub async fn upload_file_internal( + _authed: &windmill_common::users::Authed, + _w_id: &str, + _db: &DB, + _file_content: bytes::Bytes, + _file_extension: Option, + _file_name: Option, + _s3_resource_opt: Option, + _disable_s3_internal: bool, +) -> error::Result<()> { + crate::job_helpers_ee::upload_file_internal( + _authed, + _w_id, + _db, + _file_content, + _file_extension, + _file_name, + _s3_resource_opt, + _disable_s3_internal, + ).await +} + +pub async fn download_s3_file_internal( + _authed: &windmill_common::users::Authed, + _w_id: &str, + _db: &DB, + _file_key: &str, + _s3_resource_opt: Option, + _disable_s3_internal: bool, +) -> error::Result { + crate::job_helpers_ee::download_s3_file_internal( + _authed, + _w_id, + _db, + _file_key, + _s3_resource_opt, + _disable_s3_internal, + ).await +} \ No newline at end of file diff --git a/backend/windmill-api/src/nats_triggers_oss.rs b/backend/windmill-api/src/nats_triggers_oss.rs new file mode 100644 index 0000000000..eb4ded723e --- /dev/null +++ b/backend/windmill-api/src/nats_triggers_oss.rs @@ -0,0 +1,38 @@ +use crate::db::DB; +use axum::Router; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize)] +pub struct NatsResourceAuth {} + +#[derive(Serialize, Deserialize)] +pub enum NatsTriggerConfigConnection {} + +#[derive(Serialize, Clone)] +pub struct NatsTrigger { + pub workspace_id: String, + pub path: String, + pub nats_resource_path: String, + pub subject: String, + pub script_path: String, + pub is_flow: bool, + pub edited_by: String, + pub email: String, + pub edited_at: chrono::DateTime, + pub server_id: Option, + pub last_server_ping: Option>, + pub extra_perms: serde_json::Value, + pub error: Option, + pub enabled: bool, +} + +pub fn workspaced_service() -> Router { + crate::nats_triggers_ee::workspaced_service() +} + +pub fn start_nats_consumers( + _db: DB, + mut _killpill_rx: tokio::sync::broadcast::Receiver<()>, +) -> () { + crate::nats_triggers_ee::start_nats_consumers(_db, _killpill_rx) +} \ No newline at end of file diff --git a/backend/windmill-api/src/oauth2_oss.rs b/backend/windmill-api/src/oauth2_oss.rs new file mode 100644 index 0000000000..6717b00449 --- /dev/null +++ b/backend/windmill-api/src/oauth2_oss.rs @@ -0,0 +1,60 @@ +use crate::db::DB; +use axum::Router; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; +use windmill_common::error; + +#[derive(Serialize, Deserialize)] +pub struct ClientWithScopes; + +pub type BasicClientsMap = HashMap; + +#[derive(Serialize, Deserialize)] +pub struct OAuthConfig; + +#[derive(Serialize, Deserialize)] +pub struct OAuthClient; + +#[derive(Serialize, Deserialize)] +pub struct AllClients; + +#[derive(Serialize, Deserialize)] +pub struct TokenResponse; + +pub struct SlackVerifier; + +impl SlackVerifier { + pub fn new>(secret: S) -> anyhow::Result { + crate::oauth2_ee::SlackVerifier::new(secret) + } +} + +pub fn global_service() -> Router { + crate::oauth2_ee::global_service() +} + +pub fn workspaced_service() -> Router { + crate::oauth2_ee::workspaced_service() +} + +pub async fn build_oauth_clients( + _db: &DB, + _w_id: &str, + _base_url: &str, +) -> anyhow::Result { + crate::oauth2_ee::build_oauth_clients(_db, _w_id, _base_url).await +} + +pub async fn _refresh_token( + _workspace_id: &str, + _path: &str, + _db: &DB, + _token: &str, + _http_client: &reqwest::Client, +) -> error::Result { + crate::oauth2_ee::_refresh_token(_workspace_id, _path, _db, _token, _http_client).await +} + +pub async fn check_nb_of_user(db: &DB) -> error::Result<()> { + crate::oauth2_ee::check_nb_of_user(db).await +} \ No newline at end of file diff --git a/backend/windmill-api/src/oidc_oss.rs b/backend/windmill-api/src/oidc_oss.rs new file mode 100644 index 0000000000..9dc541e54c --- /dev/null +++ b/backend/windmill-api/src/oidc_oss.rs @@ -0,0 +1,9 @@ +use axum::Router; + +pub fn global_service() -> Router { + crate::oidc_ee::global_service() +} + +pub fn workspaced_service() -> Router { + crate::oidc_ee::workspaced_service() +} \ No newline at end of file diff --git a/backend/windmill-api/src/saml_oss.rs b/backend/windmill-api/src/saml_oss.rs new file mode 100644 index 0000000000..21ac3d5bfa --- /dev/null +++ b/backend/windmill-api/src/saml_oss.rs @@ -0,0 +1,15 @@ +use axum::Router; + +pub struct ServiceProviderExt(); + +pub async fn build_sp_extension() -> anyhow::Result { + crate::saml_ee::build_sp_extension().await +} + +pub fn global_service() -> Router { + crate::saml_ee::global_service() +} + +pub async fn acs() -> String { + crate::saml_ee::acs().await +} \ No newline at end of file diff --git a/backend/windmill-api/src/scim_oss.rs b/backend/windmill-api/src/scim_oss.rs new file mode 100644 index 0000000000..3fe7476ac7 --- /dev/null +++ b/backend/windmill-api/src/scim_oss.rs @@ -0,0 +1,13 @@ +use axum::{http::Request, middleware::Next, response::Response, Router}; + +pub fn global_service() -> Router { + crate::scim_ee::global_service() +} + +pub async fn ee() -> String { + crate::scim_ee::ee().await +} + +pub async fn has_scim_token(_request: Request, _next: Next) -> Response { + crate::scim_ee::has_scim_token(_request, _next).await +} \ No newline at end of file diff --git a/backend/windmill-api/src/smtp_server_oss.rs b/backend/windmill-api/src/smtp_server_oss.rs new file mode 100644 index 0000000000..c6ba7ffb29 --- /dev/null +++ b/backend/windmill-api/src/smtp_server_oss.rs @@ -0,0 +1,23 @@ +use crate::{db::DB, users::AuthCache, users::UserDB}; +use std::{net::SocketAddr, sync::Arc}; + +pub struct SmtpServer { + pub auth_cache: Arc, + pub db: DB, + pub user_db: UserDB, + pub base_internal_url: String, +} + +impl SmtpServer { + pub async fn start_listener_thread( + self: Arc, + _addr: SocketAddr, + ) -> anyhow::Result<()> { + crate::smtp_server_ee::SmtpServer { + auth_cache: self.auth_cache, + db: self.db, + user_db: self.user_db, + base_internal_url: self.base_internal_url, + }.start_listener_thread(_addr).await + } +} \ No newline at end of file diff --git a/backend/windmill-api/src/sqs_triggers_oss.rs b/backend/windmill-api/src/sqs_triggers_oss.rs new file mode 100644 index 0000000000..b482d8e01d --- /dev/null +++ b/backend/windmill-api/src/sqs_triggers_oss.rs @@ -0,0 +1,32 @@ +use crate::db::DB; +use axum::Router; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Clone)] +pub struct SqsTrigger { + pub workspace_id: String, + pub path: String, + pub sqs_resource_path: String, + pub queue_url: String, + pub script_path: String, + pub is_flow: bool, + pub edited_by: String, + pub email: String, + pub edited_at: chrono::DateTime, + pub server_id: Option, + pub last_server_ping: Option>, + pub extra_perms: serde_json::Value, + pub error: Option, + pub enabled: bool, +} + +pub fn workspaced_service() -> Router { + crate::sqs_triggers_ee::workspaced_service() +} + +pub fn start_sqs( + _db: DB, + mut _killpill_rx: tokio::sync::broadcast::Receiver<()>, +) -> () { + crate::sqs_triggers_ee::start_sqs(_db, _killpill_rx) +} \ No newline at end of file diff --git a/backend/windmill-api/src/stripe_oss.rs b/backend/windmill-api/src/stripe_oss.rs new file mode 100644 index 0000000000..cb9d0b48f2 --- /dev/null +++ b/backend/windmill-api/src/stripe_oss.rs @@ -0,0 +1,5 @@ +use axum::Router; + +pub fn add_stripe_routes(router: Router) -> Router { + crate::stripe_ee::add_stripe_routes(router) +} \ No newline at end of file diff --git a/backend/windmill-api/src/teams_approvals_oss.rs b/backend/windmill-api/src/teams_approvals_oss.rs new file mode 100644 index 0000000000..5075dcf2a5 --- /dev/null +++ b/backend/windmill-api/src/teams_approvals_oss.rs @@ -0,0 +1,6 @@ +use axum::http::StatusCode; +use windmill_common::error::Error; + +pub async fn request_teams_approval() -> Result { + crate::teams_approvals_ee::request_teams_approval().await +} \ No newline at end of file diff --git a/backend/windmill-api/src/teams_oss.rs b/backend/windmill-api/src/teams_oss.rs new file mode 100644 index 0000000000..dc71bd9480 --- /dev/null +++ b/backend/windmill-api/src/teams_oss.rs @@ -0,0 +1,26 @@ +use axum::{http::StatusCode, Router}; +use windmill_common::error::Error; + +pub async fn edit_teams_command() -> Result { + crate::teams_ee::edit_teams_command().await +} + +pub async fn workspaces_list_available_teams_ids() -> Result { + crate::teams_ee::workspaces_list_available_teams_ids().await +} + +pub async fn connect_teams() -> Result { + crate::teams_ee::connect_teams().await +} + +pub async fn run_teams_message_test_job() -> Result { + crate::teams_ee::run_teams_message_test_job().await +} + +pub async fn workspaces_list_available_teams_channels() -> Result { + crate::teams_ee::workspaces_list_available_teams_channels().await +} + +pub fn teams_service() -> Router { + crate::teams_ee::teams_service() +} \ No newline at end of file diff --git a/backend/windmill-api/src/users_oss.rs b/backend/windmill-api/src/users_oss.rs new file mode 100644 index 0000000000..67a64f9cc1 --- /dev/null +++ b/backend/windmill-api/src/users_oss.rs @@ -0,0 +1,24 @@ +use axum::http::StatusCode; +use windmill_common::error::Error; + +pub async fn create_user( + _authed: windmill_common::users::Authed, + _extract_path: axum::extract::Path, + _db: crate::db::DB, + _new_user: axum::extract::Json, +) -> Result<(StatusCode, String), Error> { + crate::users_ee::create_user(_authed, _extract_path, _db, _new_user).await +} + +pub async fn set_password( + _authed: windmill_common::users::Authed, + _extract_path: axum::extract::Path, + _db: crate::db::DB, + _set_password: axum::extract::Json, +) -> Result { + crate::users_ee::set_password(_authed, _extract_path, _db, _set_password).await +} + +pub fn send_email_if_possible(_subject: &str, _content: &str, _to: &str) { + crate::users_ee::send_email_if_possible(_subject, _content, _to) +} \ No newline at end of file diff --git a/backend/windmill-api/src/workspaces_oss.rs b/backend/windmill-api/src/workspaces_oss.rs new file mode 100644 index 0000000000..aea14276b7 --- /dev/null +++ b/backend/windmill-api/src/workspaces_oss.rs @@ -0,0 +1,15 @@ +use crate::db::DB; +use windmill_common::users::ApiAuthed; +use serde::Deserialize; + +#[derive(Deserialize)] +pub struct EditAutoInvite; + +pub async fn edit_auto_invite( + _authed: ApiAuthed, + _db: DB, + _w_id: String, + _ea: EditAutoInvite, +) -> windmill_common::error::Result { + crate::workspaces_ee::edit_auto_invite(_authed, _db, _w_id, _ea).await +} \ No newline at end of file diff --git a/backend/windmill-audit/src/audit_oss.rs b/backend/windmill-audit/src/audit_oss.rs new file mode 100644 index 0000000000..4823802294 --- /dev/null +++ b/backend/windmill-audit/src/audit_oss.rs @@ -0,0 +1,67 @@ +use serde::{Deserialize, Serialize}; +use sqlx::{Postgres, Transaction}; +use windmill_common::error::Result; + +#[derive(Serialize, Deserialize)] +pub struct AuditAuthor { + pub username: String, + pub email: String, + pub username_override: Option, +} + +pub trait AuditAuthorable { + fn username(&self) -> &str; + fn email(&self) -> &str; + fn username_override(&self) -> Option<&str>; +} + +impl AuditAuthorable for AuditAuthor { + fn username(&self) -> &str { + &self.username + } + + fn email(&self) -> &str { + &self.email + } + + fn username_override(&self) -> Option<&str> { + self.username_override.as_deref() + } +} + +pub struct AuditLog; + +pub async fn audit_log( + _tx: &mut Transaction<'_, Postgres>, + _author: &A, + _operation: &str, + _action_kind: &str, + _workspace_id: &str, + _resource: Option<&str>, + _parameters: Option>, +) -> Result<()> { + crate::audit_ee::audit_log(_tx, _author, _operation, _action_kind, _workspace_id, _resource, _parameters).await +} + +pub async fn list_audit( + _tx: Transaction<'_, Postgres>, + _workspace_id: &str, + _username: Option, + _operation: Option, + _action_kind: Option, + _resource: Option, + _before: Option>, + _after: Option>, + _per_page: usize, + _offset: usize, +) -> Result> { + crate::audit_ee::list_audit(_tx, _workspace_id, _username, _operation, _action_kind, _resource, _before, _after, _per_page, _offset).await +} + +pub async fn get_audit( + tx: Transaction<'_, Postgres>, + _id: i32, + _w_id: &str, +) -> Result { + crate::audit_ee::get_audit(tx, _id, _w_id).await +} \ No newline at end of file diff --git a/backend/windmill-autoscaling/src/autoscaling_oss.rs b/backend/windmill-autoscaling/src/autoscaling_oss.rs new file mode 100644 index 0000000000..811b6f1181 --- /dev/null +++ b/backend/windmill-autoscaling/src/autoscaling_oss.rs @@ -0,0 +1,5 @@ +use windmill_common::DB; + +pub async fn apply_all_autoscaling(_db: &DB) -> anyhow::Result<()> { + crate::autoscaling_ee::apply_all_autoscaling(_db).await +} \ No newline at end of file diff --git a/backend/windmill-common/src/email_oss.rs b/backend/windmill-common/src/email_oss.rs new file mode 100644 index 0000000000..67d985568a --- /dev/null +++ b/backend/windmill-common/src/email_oss.rs @@ -0,0 +1,12 @@ +use crate::{error::Result, DB}; + +pub async fn send_email( + _to: &str, + _subject: &str, + _body: &str, + _html_body: Option<&str>, + _workspace_id: &str, + _db: &DB, +) -> Result<()> { + crate::email_ee::send_email(_to, _subject, _body, _html_body, _workspace_id, _db).await +} \ No newline at end of file diff --git a/backend/windmill-common/src/job_s3_helpers_oss.rs b/backend/windmill-common/src/job_s3_helpers_oss.rs new file mode 100644 index 0000000000..086b18931e --- /dev/null +++ b/backend/windmill-common/src/job_s3_helpers_oss.rs @@ -0,0 +1,32 @@ +use crate::{error::Result, object_store::ObjectStoreResource, DB}; + +pub enum TokenGenerator<'c> { + AsClient(&'c crate::client::AuthedClient), + AsServerInstance(), +} + +impl<'c> TokenGenerator<'c> { + pub async fn gen_token(&self, _audience: &str, _db: Option<&DB>) -> anyhow::Result { + crate::job_s3_helpers_ee::TokenGenerator::gen_token(self, _audience, _db).await + } +} + +pub async fn get_s3_resource_internal( + _token_generator: &TokenGenerator<'_>, + _audience: &str, + _workspace_id: &str, + _resource_path: &str, + _db: Option<&DB>, +) -> Result { + crate::job_s3_helpers_ee::get_s3_resource_internal(_token_generator, _audience, _workspace_id, _resource_path, _db).await +} + +pub(crate) async fn generate_s3_aws_oidc_resource( + _token_generator: &TokenGenerator<'_>, + _audience: &str, + _role_arn: &str, + _region: &str, + _db: Option<&DB>, +) -> Result { + crate::job_s3_helpers_ee::generate_s3_aws_oidc_resource(_token_generator, _audience, _role_arn, _region, _db).await +} \ No newline at end of file diff --git a/backend/windmill-common/src/oidc_oss.rs b/backend/windmill-common/src/oidc_oss.rs new file mode 100644 index 0000000000..9ef155c046 --- /dev/null +++ b/backend/windmill-common/src/oidc_oss.rs @@ -0,0 +1,46 @@ +use crate::{error::Result as WindmillResult, DB}; +use serde::{Deserialize, Serialize}; + +pub trait AdditionalClaims: Serialize + for<'de> Deserialize<'de> {} + +#[derive(Serialize, Deserialize)] +pub struct WorkspaceClaim { + pub workspace: String, +} + +impl AdditionalClaims for WorkspaceClaim {} + +#[derive(Serialize, Deserialize)] +pub struct InstanceClaim {} + +impl AdditionalClaims for InstanceClaim {} + +#[derive(Serialize, Deserialize)] +pub struct JobClaim { + pub workspace: String, + pub job: String, + pub path: Option, + pub groups: Vec, + pub email: String, + pub username: String, + pub is_operator: bool, + pub is_admin: bool, + pub is_super_admin: bool, + pub folders: Vec, +} + +impl AdditionalClaims for JobClaim {} + +pub struct WindmillIdToken; + +pub async fn generate_id_token( + _additional_claims: T, + _audience: &str, + _db: Option<&DB>, +) -> anyhow::Result { + crate::oidc_ee::generate_id_token(_additional_claims, _audience, _db).await +} + +pub async fn get_private_key(db: Option<&DB>) -> anyhow::Result { + crate::oidc_ee::get_private_key(db).await +} \ No newline at end of file diff --git a/backend/windmill-common/src/otel_oss.rs b/backend/windmill-common/src/otel_oss.rs new file mode 100644 index 0000000000..2a883ee265 --- /dev/null +++ b/backend/windmill-common/src/otel_oss.rs @@ -0,0 +1,34 @@ +use crate::{jobs::QueuedJob, server::Mode}; +use std::future::Future; +use tracing_subscriber::filter::EnvFilter; +use uuid::Uuid; + +pub(crate) type OtelProvider = Option<()>; + +pub fn set_span_parent(_span: &tracing::Span, _rj: &Uuid) { + crate::otel_ee::set_span_parent(_span, _rj) +} + +pub fn otel_ctx() -> () { + crate::otel_ee::otel_ctx() +} + +pub(crate) fn init_logs_bridge(_mode: &Mode, _hostname: &str, _env: &str) -> Option { + crate::otel_ee::init_logs_bridge(_mode, _hostname, _env) +} + +pub(crate) fn init_meter_provider(_mode: &Mode, _hostname: &str, _env: &str) -> OtelProvider { + crate::otel_ee::init_meter_provider(_mode, _hostname, _env) +} + +pub fn add_root_flow_job_to_otlp(_queued_job: &QueuedJob, _success: bool) { + crate::otel_ee::add_root_flow_job_to_otlp(_queued_job, _success) +} + +pub trait FutureExt: Sized { + fn with_context(self, _otel_cx: ()) -> Self { + self + } +} + +impl FutureExt for T {} \ No newline at end of file diff --git a/backend/windmill-common/src/stats_oss.rs b/backend/windmill-common/src/stats_oss.rs new file mode 100644 index 0000000000..39452b0eb9 --- /dev/null +++ b/backend/windmill-common/src/stats_oss.rs @@ -0,0 +1,40 @@ +use crate::DB; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize)] +pub struct ActiveUserUsage { + pub author_count: Option, + pub operator_count: Option, +} + +#[derive(Clone)] +pub enum SendStatsReason { + Manual, + Schedule, + OnStart, +} + +pub async fn get_disable_stats_setting(_db: &DB) -> bool { + crate::stats_ee::get_disable_stats_setting(_db).await +} + +pub async fn schedule_stats(_db: &DB, _http_client: &reqwest::Client) -> () { + crate::stats_ee::schedule_stats(_db, _http_client).await +} + +pub async fn send_stats( + _db: &DB, + _http_client: &reqwest::Client, + _reason: SendStatsReason, + _basic_auth: Option, +) -> anyhow::Result<()> { + crate::stats_ee::send_stats(_db, _http_client, _reason, _basic_auth).await +} + +pub async fn get_user_usage( + _db: &DB, + _workspace_id: Option<&str>, + _days: Option, +) -> anyhow::Result { + crate::stats_ee::get_user_usage(_db, _workspace_id, _days).await +} \ No newline at end of file diff --git a/backend/windmill-common/src/teams_oss.rs b/backend/windmill-common/src/teams_oss.rs new file mode 100644 index 0000000000..a65663d69c --- /dev/null +++ b/backend/windmill-common/src/teams_oss.rs @@ -0,0 +1 @@ +// Empty OSS implementation for teams_ee \ No newline at end of file diff --git a/backend/windmill-git-sync/src/git_sync_oss.rs b/backend/windmill-git-sync/src/git_sync_oss.rs new file mode 100644 index 0000000000..c8be6c7ff8 --- /dev/null +++ b/backend/windmill-git-sync/src/git_sync_oss.rs @@ -0,0 +1,10 @@ +use sqlx::{Postgres, Transaction}; + +pub async fn handle_deployment_metadata( + _tx: &mut Transaction<'_, Postgres>, + _workspace_id: &str, + _path: &str, + _raw_value: &serde_json::Value, +) -> anyhow::Result<()> { + crate::git_sync_ee::handle_deployment_metadata(_tx, _workspace_id, _path, _raw_value).await +} \ No newline at end of file diff --git a/backend/windmill-indexer/src/completed_runs_oss.rs b/backend/windmill-indexer/src/completed_runs_oss.rs new file mode 100644 index 0000000000..4b3fa0bcaf --- /dev/null +++ b/backend/windmill-indexer/src/completed_runs_oss.rs @@ -0,0 +1,16 @@ +use sqlx::{Pool, Postgres}; + +pub struct IndexReader; +pub struct IndexWriter; + +pub async fn init_index(_db: &Pool) -> Result<(IndexReader, IndexWriter), anyhow::Error> { + crate::completed_runs_ee::init_index(_db).await +} + +pub async fn run_indexer( + _db: Pool, + _writer: IndexWriter, + _mut killpill_rx: tokio::sync::broadcast::Receiver<()>, +) -> Result<(), anyhow::Error> { + crate::completed_runs_ee::run_indexer(_db, _writer, _mut killpill_rx).await +} \ No newline at end of file diff --git a/backend/windmill-indexer/src/indexer_oss.rs b/backend/windmill-indexer/src/indexer_oss.rs new file mode 100644 index 0000000000..9bf2f17164 --- /dev/null +++ b/backend/windmill-indexer/src/indexer_oss.rs @@ -0,0 +1 @@ +// Empty OSS implementation for indexer_ee \ No newline at end of file diff --git a/backend/windmill-indexer/src/service_logs_oss.rs b/backend/windmill-indexer/src/service_logs_oss.rs new file mode 100644 index 0000000000..9bb5b4ad8a --- /dev/null +++ b/backend/windmill-indexer/src/service_logs_oss.rs @@ -0,0 +1,21 @@ +use sqlx::{Pool, Postgres}; + +pub struct ServiceLogIndexReader; +pub struct ServiceLogIndexWriter; + +pub async fn init_index( + _db: &Pool, + _index_name: &str, + _index_location: &str, + _tantivy_buffer_size_mb: usize, +) -> Result<(ServiceLogIndexReader, ServiceLogIndexWriter), anyhow::Error> { + crate::service_logs_ee::init_index(_db, _index_name, _index_location, _tantivy_buffer_size_mb).await +} + +pub async fn run_indexer( + _db: Pool, + _writer: ServiceLogIndexWriter, + _mut killpill_rx: tokio::sync::broadcast::Receiver<()>, +) -> Result<(), anyhow::Error> { + crate::service_logs_ee::run_indexer(_db, _writer, _mut killpill_rx).await +} \ No newline at end of file diff --git a/backend/windmill-queue/src/jobs_oss.rs b/backend/windmill-queue/src/jobs_oss.rs new file mode 100644 index 0000000000..428ef3369c --- /dev/null +++ b/backend/windmill-queue/src/jobs_oss.rs @@ -0,0 +1,11 @@ +use chrono::{DateTime, Utc}; + +pub(crate) async fn update_concurrency_counter( + _tx: &mut sqlx::Transaction<'_, sqlx::Postgres>, + _w_id: &str, + _job_id: uuid::Uuid, + _concurrency_key: &str, + _cancel: bool, +) -> anyhow::Result<(bool, Option>)> { + crate::jobs_ee::update_concurrency_counter(_tx, _w_id, _job_id, _concurrency_key, _cancel).await +} \ No newline at end of file diff --git a/backend/windmill-worker/src/job_logger_oss.rs b/backend/windmill-worker/src/job_logger_oss.rs new file mode 100644 index 0000000000..c2f045aa28 --- /dev/null +++ b/backend/windmill-worker/src/job_logger_oss.rs @@ -0,0 +1,30 @@ +use std::io; + +pub(crate) async fn s3_storage( + _value: &str, + _job_id: &uuid::Uuid, + _w_id: &str, + _db: &windmill_common::DB, + _offset: usize, +) { + crate::job_logger_ee::s3_storage(_value, _job_id, _w_id, _db, _offset).await +} + +pub(crate) async fn default_disk_log_storage( + _value: &str, + _job_id: &uuid::Uuid, + _w_id: &str, + _offset: usize, +) { + crate::job_logger_ee::default_disk_log_storage(_value, _job_id, _w_id, _offset).await +} + +pub(crate) fn process_streaming_log_lines( + _line: &str, + _job_id: &uuid::Uuid, + _w_id: &str, + _logs: &[String], + _offset: usize, +) -> Option> { + crate::job_logger_ee::process_streaming_log_lines(_line, _job_id, _w_id, _logs, _offset) +} \ No newline at end of file diff --git a/backend/windmill-worker/src/otel_oss.rs b/backend/windmill-worker/src/otel_oss.rs new file mode 100644 index 0000000000..f1a4f27e2b --- /dev/null +++ b/backend/windmill-worker/src/otel_oss.rs @@ -0,0 +1,5 @@ +use windmill_queue::MiniPulledJob; + +pub fn add_root_flow_job_to_otlp(_queued_job: &MiniPulledJob, _success: bool) { + crate::otel_ee::add_root_flow_job_to_otlp(_queued_job, _success) +} \ No newline at end of file