Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s0 #4964

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open

s0 #4964

Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b458c23
all
rubenfiszel Dec 10, 2024
4f134d5
Merge branch 'main' into rf/sandpack
rubenfiszel Dec 10, 2024
e8354b7
all
rubenfiszel Dec 10, 2024
980a44f
Merge branch 'main' into rf/sandpack
rubenfiszel Dec 10, 2024
736262e
all
rubenfiszel Dec 10, 2024
1ed99d9
all
rubenfiszel Dec 11, 2024
1e11a9d
all
rubenfiszel Dec 11, 2024
543f6f9
Merge branch 'main' into rf/sandpack
rubenfiszel Dec 12, 2024
42d2b06
all
rubenfiszel Dec 12, 2024
0fdf730
all
rubenfiszel Dec 13, 2024
ef2a333
Merge branch 'main' into rf/sandpack
rubenfiszel Dec 13, 2024
2749932
all
rubenfiszel Dec 14, 2024
9b23293
all
rubenfiszel Dec 14, 2024
16b7636
Merge branch 'main' into rf/sandpack
rubenfiszel Dec 14, 2024
f0185d3
Merge branch 'main' into rf/sandpack
rubenfiszel Dec 16, 2024
331d26d
all
rubenfiszel Dec 17, 2024
4b70b11
Merge branch 'main' into rf/sandpack
rubenfiszel Dec 17, 2024
97513de
all
rubenfiszel Dec 17, 2024
23388cc
all
rubenfiszel Dec 18, 2024
172a69b
all
rubenfiszel Dec 19, 2024
dd9de78
Merge branch 'main' into rf/sandpack
rubenfiszel Dec 19, 2024
b459f77
all
rubenfiszel Dec 20, 2024
7ac93eb
Merge branch 'main' into rf/sandpack
rubenfiszel Dec 20, 2024
f8e31c2
all
rubenfiszel Dec 20, 2024
3ec7bda
all
rubenfiszel Dec 20, 2024
3e3271d
all
rubenfiszel Dec 20, 2024
8a9736d
merge
rubenfiszel Dec 20, 2024
b4171be
avoid localsettings
rubenfiszel Dec 21, 2024
b0f2626
all
rubenfiszel Dec 25, 2024
6387245
all
rubenfiszel Dec 25, 2024
334a62e
merge
rubenfiszel Dec 25, 2024
a424edf
before esbuild refactor
rubenfiszel Jan 3, 2025
10b850a
before esbuild refactor
rubenfiszel Jan 3, 2025
ec9e44e
before esbuild
rubenfiszel Jan 4, 2025
b0c10c6
progress
rubenfiszel Jan 5, 2025
b02412e
progress
rubenfiszel Jan 5, 2025
f3d1c77
prevscode editor
rubenfiszel Jan 6, 2025
ea0d0f7
all
rubenfiszel Jan 8, 2025
410e03f
all
rubenfiszel Jan 8, 2025
1bba278
Merge branch 'main' into rf/sandpack
rubenfiszel Jan 8, 2025
a18edd3
all
rubenfiszel Jan 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/migrations/20241223155748_raw_apps_v2.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Add down migration script here
ALTER TABLE app_version DROP COLUMN IF EXISTS raw_app;
2 changes: 2 additions & 0 deletions backend/migrations/20241223155748_raw_apps_v2.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Add up migration script here
ALTER TABLE app_version ADD COLUMN IF NOT EXISTS raw_app BOOLEAN NOT NULL DEFAULT FALSE;
6 changes: 5 additions & 1 deletion backend/parsers/windmill-parser-ts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ impl Visit for ImportsFinder {
pub fn parse_expr_for_imports(code: &str) -> anyhow::Result<Vec<String>> {
let cm: Lrc<SourceMap> = Default::default();
let fm = cm.new_source_file(FileName::Custom("main.d.ts".into()).into(), code.into());
let mut tss = TsSyntax::default();
tss.disallow_ambiguous_jsx_like;
tss.tsx = true;
tss.no_early_errors = true;
let lexer = Lexer::new(
Syntax::Typescript(TsSyntax::default()),
Syntax::Typescript(tss),
// EsVersion defaults to es5
Default::default(),
StringInput::from(&*fm),
Expand Down
6 changes: 6 additions & 0 deletions backend/windmill-api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5422,6 +5422,8 @@ paths:
type: string
custom_path:
type: string
raw_app:
type: boolean
required:
- path
- value
Expand Down Expand Up @@ -5766,6 +5768,8 @@ paths:
type: string
custom_path:
type: string
raw_app:
type: boolean
responses:
"200":
description: app updated
Expand Down Expand Up @@ -12914,6 +12918,8 @@ components:
execution_mode:
type: string
enum: [viewer, publisher, anonymous]
raw_app:
type: boolean
required:
- id
- workspace_id
Expand Down
69 changes: 60 additions & 9 deletions backend/windmill-api/src/apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ use crate::{
users::fetch_api_authed_from_permissioned_as,
};
use axum::{
body::Body,
extract::{Extension, Json, Path, Query},
response::IntoResponse,
response::{IntoResponse, Response},
routing::{delete, get, post},
Router,
};
Expand Down Expand Up @@ -78,6 +79,7 @@ pub fn workspaced_service() -> Router {
.route("/get/draft/*path", get(get_app_w_draft))
.route("/secret_of/*path", get(get_secret_id))
.route("/get/v/*id", get(get_app_by_id))
.route("/get_data/v/*id", get(get_raw_app_data))
.route("/exists/*path", get(exists_app))
.route("/update/*path", post(update_app))
.route("/delete/*path", delete(delete_app))
Expand Down Expand Up @@ -118,6 +120,12 @@ pub struct ListableApp {
#[sqlx(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub deployment_msg: Option<String>,
#[serde(skip_serializing_if = "is_false")]
pub raw_app: bool,
}

fn is_false(b: &bool) -> bool {
!b
}

#[derive(FromRow, Serialize, Deserialize)]
Expand Down Expand Up @@ -240,6 +248,7 @@ pub struct CreateApp {
pub draft_only: Option<bool>,
pub deployment_message: Option<String>,
pub custom_path: Option<String>,
pub raw_app: Option<bool>,
}

#[derive(Deserialize)]
Expand All @@ -250,6 +259,7 @@ pub struct EditApp {
pub policy: Option<Policy>,
pub deployment_message: Option<String>,
pub custom_path: Option<String>,
pub raw_app: Option<bool>,
}

#[derive(Serialize, FromRow)]
Expand Down Expand Up @@ -303,7 +313,8 @@ async fn list_apps(
"app.extra_perms",
"favorite.path IS NOT NULL as starred",
"draft.path IS NOT NULL as has_draft",
"draft_only"
"draft_only",
"app_version.raw_app",
])
.left()
.join("favorite")
Expand Down Expand Up @@ -362,6 +373,44 @@ async fn list_apps(
Ok(Json(rows))
}

async fn get_raw_app_data(Path((w_id, version_id)): Path<(String, String)>) -> Result<Response> {
let file_path = format!("/home/rfiszel/wmill/{}/{}", w_id, version_id);
let file = tokio::fs::File::open(file_path).await?;
let stream = tokio_util::io::ReaderStream::new(file);
let res = Response::builder().header(
http::header::CONTENT_TYPE,
if version_id.ends_with(".css") {
"text/css"
} else {
"text/javascript"
},
);
Ok(res.body(Body::from_stream(stream)).unwrap())
}

// async fn get_app_version(
// authed: ApiAuthed,
// Extension(user_db): Extension<UserDB>,
// Path((w_id, path)): Path<(String, StripPath)>,
// ) -> JsonResult<i64> {
// let path = path.to_path();
// let mut tx = user_db.begin(&authed).await?;

// let version_o = sqlx::query_scalar!(
// "SELECT app.versions[array_upper(app.versions, 1)] as version FROM app
// WHERE app.path = $1 AND app.workspace_id = $2",
// path,
// &w_id,
// )
// .fetch_optional(&mut *tx)
// .await?
// .flatten();
// tx.commit().await?;

// let version = not_found_if_none(version_o, "App", path)?;
// Ok(Json(version))
// }

async fn get_app(
authed: ApiAuthed,
Extension(user_db): Extension<UserDB>,
Expand Down Expand Up @@ -780,12 +829,13 @@ async fn create_app(

let v_id = sqlx::query_scalar!(
"INSERT INTO app_version
(app_id, value, created_by)
VALUES ($1, $2::text::json, $3) RETURNING id",
(app_id, value, created_by, raw_app)
VALUES ($1, $2::text::json, $3, $4) RETURNING id",
id,
//to preserve key orders
serde_json::to_string(&app.value).unwrap(),
authed.username,
app.raw_app.unwrap_or(false)
)
.fetch_one(&mut *tx)
.await?;
Expand Down Expand Up @@ -1069,12 +1119,13 @@ async fn update_app(

let v_id = sqlx::query_scalar!(
"INSERT INTO app_version
(app_id, value, created_by)
VALUES ($1, $2::text::json, $3) RETURNING id",
(app_id, value, created_by, raw_app)
VALUES ($1, $2::text::json, $3, $4) RETURNING id",
app_id,
//to preserve key orders
serde_json::to_string(&nvalue).unwrap(),
authed.username,
ns.raw_app.unwrap_or(false)
)
.fetch_one(&mut *tx)
.await?;
Expand Down Expand Up @@ -1197,7 +1248,7 @@ fn digest(code: &str) -> String {
format!("rawscript/{:x}", result)
}

async fn get_on_behalf_details_from_policy_and_authed(
fn get_on_behalf_details_from_policy_and_authed(
policy: &Policy,
opt_authed: &Option<ApiAuthed>,
) -> Result<(String, String, String)> {
Expand Down Expand Up @@ -1375,7 +1426,7 @@ async fn execute_component(
};

let (username, permissioned_as, email) =
get_on_behalf_details_from_policy_and_authed(&policy, &opt_authed).await?;
get_on_behalf_details_from_policy_and_authed(&policy, &opt_authed)?;

let (args, job_id) = build_args(
policy,
Expand Down Expand Up @@ -1501,7 +1552,7 @@ async fn upload_s3_file_from_app(
let s3_inputs = policy.s3_inputs.as_ref().unwrap();

let (username, permissioned_as, email) =
get_on_behalf_details_from_policy_and_authed(&policy, &opt_authed).await?;
get_on_behalf_details_from_policy_and_authed(&policy, &opt_authed)?;

let on_behalf_authed = fetch_api_authed_from_permissioned_as(
permissioned_as,
Expand Down
7 changes: 5 additions & 2 deletions backend/windmill-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ mod scim_ee;
mod scripts;
mod service_logs;
mod settings;
mod slack_approvals;
#[cfg(feature = "smtp")]
mod smtp_server_ee;
mod static_assets;
Expand All @@ -109,7 +110,6 @@ mod websocket_triggers;
mod workers;
mod workspaces;
mod workspaces_ee;
mod slack_approvals;
mod workspaces_export;
mod workspaces_extra;

Expand Down Expand Up @@ -417,7 +417,10 @@ pub async fn run_server(
jobs::workspace_unauthed_service().layer(cors.clone()),
)
.route("/slack", post(slack_approvals::slack_app_callback_handler))
.route("/w/:workspace_id/jobs/slack_approval/:job_id", get(slack_approvals::request_slack_approval))
.route(
"/w/:workspace_id/jobs/slack_approval/:job_id",
get(slack_approvals::request_slack_approval),
)
.nest(
"/w/:workspace_id/resources_u",
resources::public_service().layer(cors.clone()),
Expand Down
2 changes: 1 addition & 1 deletion backend/windmill-api/src/workspaces_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ pub(crate) async fn tarball_workspace(
"SELECT app.id, app.path, app.summary, app.versions, app.policy, app.custom_path,
app.extra_perms, app_version.value,
app_version.created_at, app_version.created_by from app, app_version
WHERE app.workspace_id = $1 AND app_version.id = app.versions[array_upper(app.versions, 1)]",
WHERE app.workspace_id = $1 AND app_version.id = app.versions[array_upper(app.versions, 1)] AND app_version.raw_app IS false",
)
.bind(&w_id)
.fetch_all(&mut *tx)
Expand Down
7 changes: 7 additions & 0 deletions backend/windmill-common/src/apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* LICENSE-AGPL for a copy of the license.
*/

use std::collections::HashMap;

use serde::{Deserialize, Serialize};

/// Id in the `app_script` table.
Expand All @@ -21,3 +23,8 @@ pub struct ListAppQuery {
pub include_draft_only: Option<bool>,
pub with_deployment_msg: Option<bool>,
}

#[derive(Deserialize)]
pub struct RawAppValue {
pub files: HashMap<String, String>,
}
4 changes: 4 additions & 0 deletions backend/windmill-common/src/s3_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,7 @@ impl CredentialProvider for AwsCredentialAdapter {
pub fn bundle(w_id: &str, hash: &str) -> String {
format!("script_bundle/{}/{}", w_id, hash)
}

pub fn raw_app(w_id: &str, version: &i64) -> String {
format!("/home/rfiszel/raw_app/{}/{}", w_id, version)
}
1 change: 1 addition & 0 deletions backend/windmill-queue/src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3465,6 +3465,7 @@ pub async fn push<'c, 'd>(
} else if job_kind == JobKind::Dependencies
|| job_kind == JobKind::FlowDependencies
|| job_kind == JobKind::DeploymentCallback
|| job_kind == JobKind::AppDependencies
{
// using the dependency tag for deployment callback for now. We can create a separate tag when we need
"dependency".to_string()
Expand Down
Loading
Loading