diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 71795239a7..5b4452fbca 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -14913,6 +14913,7 @@ dependencies = [ "url", "uuid", "windmill-macros", + "windmill-parser", "windmill-parser-py", "windmill-parser-sql", "windmill-parser-ts", diff --git a/backend/windmill-common/Cargo.toml b/backend/windmill-common/Cargo.toml index 250f48e336..0e4cc83591 100644 --- a/backend/windmill-common/Cargo.toml +++ b/backend/windmill-common/Cargo.toml @@ -75,6 +75,7 @@ windmill-macros.workspace = true windmill-parser-sql.workspace = true windmill-parser-ts.workspace = true windmill-parser-py.workspace = true +windmill-parser.workspace = true jsonwebtoken.workspace = true backon.workspace = true openidconnect = { workspace = true, optional = true } diff --git a/backend/windmill-common/src/assets.rs b/backend/windmill-common/src/assets.rs index 3d5cd75801..5a617d7dd8 100644 --- a/backend/windmill-common/src/assets.rs +++ b/backend/windmill-common/src/assets.rs @@ -1,4 +1,7 @@ use serde::{Deserialize, Serialize}; +use windmill_parser::asset_parser::ParseAssetsResult; + +use crate::scripts::ScriptLang; #[derive(Serialize, Deserialize, Debug, PartialEq, Copy, Clone, Hash, Eq, sqlx::Type)] #[sqlx(type_name = "ASSET_KIND", rename_all = "lowercase")] @@ -35,3 +38,19 @@ pub struct AssetUsage { pub kind: AssetUsageKind, pub access_type: AssetUsageAccessType, } + +pub fn parse_assets<'a>( + input: &'a str, + lang: ScriptLang, + paths_storage: &'a mut Vec, +) -> anyhow::Result>>> { + let r = match lang { + ScriptLang::Python3 => windmill_parser_py::parse_assets(input, paths_storage), + ScriptLang::DuckDb => windmill_parser_sql::parse_assets(input), + ScriptLang::Deno | ScriptLang::Bun | ScriptLang::Nativets => { + windmill_parser_ts::parse_assets(input, paths_storage) + } + _ => return Ok(None), + }; + return r.map(Some); +}