diff --git a/crates/forge_analyzer/src/definitions.rs b/crates/forge_analyzer/src/definitions.rs index 0e48f71..d50a952 100644 --- a/crates/forge_analyzer/src/definitions.rs +++ b/crates/forge_analyzer/src/definitions.rs @@ -996,19 +996,41 @@ impl FunctionAnalyzer<'_> { [PropPath::Def(def), ref authn @ .., PropPath::Static(ref last)] if (*last == *"requestJira" || *last == *"requestConfluence" - || *last == *"requestBitbucket") // TODO: resolve Jira API requests to the correct permission map, here JSM (and likely JS) is bundled inside Jira + || *last == *"requestBitbucket") && Some(&ImportKind::Default) == self.res.is_imported_from(def, "@forge/api") => { + let first_arg = first_arg?; + let is_as_app = authn.first() == Some(&PropPath::MemberCall("asApp".into())); + let function_name = if *last == "requestJira" { - IntrinsicName::RequestJira + // Resolve Jira API requests to either JSM/JS/Jira as all are bundled within requestJira + match first_arg { + Expr::Tpl(template) => { + let url = template + .quasis + .iter() + .map(|quasi| quasi.raw.as_str()) + .collect::(); + match url.as_str() { + url if url.starts_with("/rest/servicedeskapi/") => { + IntrinsicName::RequestJiraServiceManagement + } + url if url.starts_with("/rest/agile/") => { + IntrinsicName::RequestJiraSoftware + } + url if url.starts_with("/rest/api/") => IntrinsicName::RequestJira, + _ => IntrinsicName::RequestJira, + } + } + _ => IntrinsicName::RequestJira, + } } else if *last == "requestBitbucket" { IntrinsicName::RequestBitbucket } else { IntrinsicName::RequestConfluence }; - let first_arg = first_arg?; - let is_as_app = authn.first() == Some(&PropPath::MemberCall("asApp".into())); + match classify_api_call(first_arg) { ApiCallKind::Unknown => { if is_as_app {