Skip to main content

hyperdb_bootstrap/
url.rs

1// Copyright (c) 2026, Salesforce, Inc. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4//! Builds canonical download URLs for Tableau's public Hyper **Java** API
5//! release bundles.
6//!
7//! We deliberately use the Java binding's bundle rather than the C++ one:
8//! the C++ `macos-arm64` zip ships an **x86_64** `hyperd` (an upstream
9//! packaging defect), so on Apple Silicon it would only run under Rosetta.
10//! The Java `macos-arm64` bundle carries a native arm64 `hyperd`. Both
11//! bundles share the identical URL template (only the `java`/`cxx` token
12//! differs) and the identical internal layout (`lib/hyper/hyperd`), so the
13//! switch is confined to this token and the pinned sha256s.
14
15use crate::platform::Platform;
16use crate::release::PinnedRelease;
17
18const BASE_URL: &str = "https://downloads.tableau.com/tssoftware";
19
20/// Builds the `downloads.tableau.com` URL for the given release / platform
21/// combination.
22///
23/// The URL template matches
24/// `https://downloads.tableau.com/tssoftware/tableauhyperapi-java-<platform>-release-main.<version>.<build_id>.zip`.
25#[must_use]
26pub fn build_download_url(release: &PinnedRelease, platform: Platform) -> String {
27    format!(
28        "{base}/tableauhyperapi-java-{plat}-release-main.{version}.{build_id}.zip",
29        base = BASE_URL,
30        plat = platform.slug(),
31        version = release.version,
32        build_id = release.build_id,
33    )
34}
35
36#[cfg(test)]
37mod tests {
38    use super::*;
39    use std::collections::HashMap;
40
41    #[test]
42    fn url_matches_expected_template() {
43        let r = PinnedRelease {
44            version: "0.0.24457".to_string(),
45            build_id: "rc36858b6".to_string(),
46            sha256: HashMap::new(),
47        };
48        let url = build_download_url(&r, Platform::MacosArm64);
49        assert_eq!(
50            url,
51            "https://downloads.tableau.com/tssoftware/tableauhyperapi-java-macos-arm64-release-main.0.0.24457.rc36858b6.zip"
52        );
53    }
54}