// src/integrations/paloalto/urls.js // // Prisma Strata Cloud Manager (UI) URL builders. Lives beside the // API client so any new deep-link pattern we discover has one // obvious home and one obvious set of tests. // // Kept intentionally tiny: no HTTP, no async, no fancy templating — // each function is pure ("give me the URL for X"). Consumers should // pass ids they already have from the API (site.id, appAudio.appId, // etc.); nothing in here should do its own API lookups. const PRISMA_UI_DEFAULT_BASE = 'https://stratacloudmanager.paloaltonetworks.com'; /** * Resolve the Strata Cloud Manager base URL. * * Defaults to the production hostname. Overridable via * `PRISMA_UI_BASE_URL` for tenants using a partner-branded or * region-specific SCM domain, and for tests. Read at call time so * tests can toggle without a module cache reset. * * The trailing slash is normalized off so all builders below can * safely concatenate `${base}/path/…`. */ export function getPrismaUiBaseUrl() { const raw = process.env.PRISMA_UI_BASE_URL; const base = raw && raw.trim() ? raw.trim() : PRISMA_UI_DEFAULT_BASE; return base.replace(/\/+$/, ''); } /** * Deep link into the SCM "Application Path Details" view for a * single app + site combination. This is the exact page the Prisma * UI opens when the operator clicks an app on the site's dashboard — * the RTP/MOS/loss/jitter charts we scrape via `getAppMetric()`. * * Sample: * https://stratacloudmanager.paloaltonetworks.com/insights/ * operational/sdwan-applications/{appId}/site/{siteId}/details * * Returns null when either id is missing so callers can no-op * without a null guard on every render path. * * @param {string|number} siteId Numeric Prisma site id * @param {string|number} appId Numeric Prisma app id * @returns {string|null} */ export function buildAppDetailsUrl(siteId, appId) { if (!siteId || !appId) return null; const base = getPrismaUiBaseUrl(); return `${base}/insights/operational/sdwan-applications/${appId}/site/${siteId}/details`; }