/** * Region resolution — the single place scai derives a Sitecore * organization's region code (e.g. `euw`) and builds a regional API host. * * Sitecore's regional services share one region per organization and * differ only in hostname: * - Agentic Studio `agentic-studio-{region}.sitecorecloud.io` * - Orchestrate `ai-workflows-{region}.sitecorecloud.io` * - Brief `co-brief-api-{region}.sitecorecloud.io` * * The region itself is read from `platform-inventory` — a versioned * (`v1`), legitimate platform service — keyed by the org id scai already * holds. Three layers, smallest first: * * - `resolveRegion(orgId, token)` — the leaf primitive: one * `platform-inventory` call with a caller-supplied access token. * - `resolveRegionCode({ organizationId, acquireToken })` — env-aware: * mints the token lazily (only on a cache miss) through an injected * callback, so this module depends on nothing but `fetch`. * - `resolveRegionalBaseUrl({ …, hostTemplate, override })` — the * convenience every regional area calls: honour an explicit per-env * host override, else resolve the region and fill a host template. * * The token must carry `platform.tenants:listall` (scai's automation * client is provisioned with it; see `SCAI_API_SCOPES`). The caller owns * how that token is obtained — campaign reuses its no-scope Orchestrate * token, brief/agents mint a fresh no-scope M2M token — which is why the * token enters through a callback rather than a hard dependency. */ /** Region code used when resolution is unavailable — EU West. */ export declare const DEFAULT_REGION = "euw"; /** * Resolve a Sitecore organization's region code from `platform-inventory`. * * **Best-effort.** Any failure — no/invalid token, wrong audience, * network, an org with no regioned tenant — falls back to * `DEFAULT_REGION`, so a caller always gets a usable region and a * regional host is always buildable. Cached per organization. * * `accessToken` must carry `platform.tenants:listall`; scai's automation * client is provisioned with it. */ export declare const resolveRegion: (organizationId: string, accessToken: string) => Promise; /** Options shared by the env-aware resolvers. */ export interface ResolveRegionOptions { /** * Sitecore organization id — the region is derived from it. When * absent, resolution is skipped and `DEFAULT_REGION` is used. */ organizationId?: string; /** * Mints an access token carrying `platform.tenants:listall` for the * `platform-inventory` lookup. Invoked only on a region cache miss. * May reject or resolve `undefined` — resolution then falls back to * `DEFAULT_REGION`. */ acquireToken: () => Promise; } /** * Resolve a region code env-aware: org id → token → `platform-inventory`. * * **Best-effort**, like `resolveRegion`. The `acquireToken` callback is * invoked only when the region isn't already cached for the org and no * id-less short-circuit applies, so a token is never minted needlessly. */ export declare const resolveRegionCode: (options: ResolveRegionOptions) => Promise; /** * Fill a regional host template — the `{region}` placeholder is replaced * with the region code. e.g. `regionalHost("https://ai-workflows-{region}.sitecorecloud.io", "euw")`. */ export declare const regionalHost: (template: string, region: string) => string; /** Options for the regional-base-URL convenience. */ export interface ResolveRegionalBaseUrlOptions extends ResolveRegionOptions { /** * Host template carrying a `{region}` placeholder, scheme included — * e.g. `https://ai-workflows-{region}.sitecorecloud.io`. */ hostTemplate: string; /** * Explicit per-env host override. When set it is returned verbatim — * no region resolution, no token mint. */ override?: string; } /** * Resolve a regional API base URL — the single entry point regional * areas (campaign, brief) call to pick their host. * * An `override` (a per-env pinned host) wins outright. Otherwise the * region is resolved from the org id and `hostTemplate` is filled. * Best-effort throughout — an unresolvable region yields the * `DEFAULT_REGION` host, never an error. */ export declare const resolveRegionalBaseUrl: (options: ResolveRegionalBaseUrlOptions) => Promise; /** Drop a cached region — used by tests; the cache is otherwise permanent. */ export declare const clearRegionCache: () => void;