@salesforce/ui-bundle-template-feature-cms-toolkit 12.1.1 → 12.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -70,6 +70,7 @@ getCmsContentByKeys(keys, options?) // bulk (best-effort; per-key resul
70
70
 
71
71
  // Utilities
72
72
  resolveCmsImageUrl(field, options?) // CMS image field → loadable URL
73
+ resolveMediaUrl(url, options?) // raw media URL string → loadable URL
73
74
  resolveEffectiveContentKey(key, catalogUrl?) // catalog source→target key remap
74
75
  getCmsDefaultChannelId(catalogUrl?) // catalog default channelId (fail-open)
75
76
  getCmsInstanceOrigin() // instance origin for media prefixing
package/dist/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [12.2.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v12.1.2...v12.2.0) (2026-08-28)
7
+
8
+ **Note:** Version bump only for package @salesforce/ui-bundle-template-base-sfdx-project
9
+
10
+
11
+
12
+
13
+
14
+ ## [12.1.2](https://github.com/salesforce-experience-platform-emu/webapps/compare/v12.1.1...v12.1.2) (2026-08-28)
15
+
16
+ **Note:** Version bump only for package @salesforce/ui-bundle-template-base-sfdx-project
17
+
18
+
19
+
20
+
21
+
6
22
  ## [12.1.1](https://github.com/salesforce-experience-platform-emu/webapps/compare/v12.1.0...v12.1.1) (2026-08-28)
7
23
 
8
24
  **Note:** Version bump only for package @salesforce/ui-bundle-template-base-sfdx-project
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@salesforce/platform-sdk": "^12.0.0",
22
- "@salesforce/ui-bundle": "^12.1.1",
22
+ "@salesforce/ui-bundle": "^12.2.0",
23
23
  "@tailwindcss/vite": "^4.1.17",
24
24
  "class-variance-authority": "^0.7.1",
25
25
  "clsx": "^2.1.1",
@@ -44,8 +44,8 @@
44
44
  "@graphql-eslint/eslint-plugin": "^4.1.0",
45
45
  "@graphql-tools/utils": "^11.0.0",
46
46
  "@playwright/test": "^1.49.0",
47
- "@salesforce/graphiti": "^12.1.1",
48
- "@salesforce/vite-plugin-ui-bundle": "^12.1.1",
47
+ "@salesforce/graphiti": "^12.2.0",
48
+ "@salesforce/vite-plugin-ui-bundle": "^12.2.0",
49
49
  "@testing-library/jest-dom": "^6.6.3",
50
50
  "@testing-library/react": "^16.1.0",
51
51
  "@testing-library/user-event": "^14.5.2",
@@ -2,7 +2,7 @@
2
2
  * content-metadata.json loader + resolvers for the authenticated (byKey) read path.
3
3
  *
4
4
  * The catalog is a deploy-specific public JSON asset at `CONTENT_CATALOG_URL`
5
- * (`{ channelId, contents }`), fetched once and memoized. Fail-open: a missing /
5
+ * (`{ channelId, regeneratedContents }`), fetched once and memoized. Fail-open: a missing /
6
6
  * unreachable / malformed catalog resolves to `{}` and never throws.
7
7
  */
8
8
  import { CONTENT_CATALOG_URL } from "../config/env";
@@ -15,8 +15,8 @@ const catalogPromises = new Map<string, Promise<CmsContentCatalog>>();
15
15
  // Guards the single fail-open warning so a missing catalog doesn't spam the console.
16
16
  let warned = false;
17
17
 
18
- /** Parse the raw `contents` array into a source→target contentKey Map, skipping any
19
- * entry missing either string key. Returns undefined when nothing usable is present. */
18
+ /** Parse the raw `regeneratedContents` array into a source→target contentKey Map, skipping
19
+ * any entry missing either string key. Returns undefined when nothing usable is present. */
20
20
  function parseContentKeyMap(rawContents: unknown): ReadonlyMap<string, string> | undefined {
21
21
  if (!Array.isArray(rawContents)) return undefined;
22
22
  const contentKeyMap = new Map<string, string>();
@@ -36,10 +36,13 @@ function parseContentKeyMap(rawContents: unknown): ReadonlyMap<string, string> |
36
36
  /** Parse a raw catalog payload into a CmsContentCatalog. Tolerates any shape. */
37
37
  function parseCatalog(payload: unknown): CmsContentCatalog {
38
38
  if (!payload || typeof payload !== "object") return {};
39
- const { channelId, contents } = payload as { channelId?: unknown; contents?: unknown };
39
+ const { channelId, regeneratedContents } = payload as {
40
+ channelId?: unknown;
41
+ regeneratedContents?: unknown;
42
+ };
40
43
  const catalog: CmsContentCatalog = {};
41
44
  if (typeof channelId === "string") catalog.channelId = channelId;
42
- const contentKeyMap = parseContentKeyMap(contents);
45
+ const contentKeyMap = parseContentKeyMap(regeneratedContents);
43
46
  if (contentKeyMap) catalog.contentKeyMap = contentKeyMap;
44
47
  return catalog;
45
48
  }
@@ -21,25 +21,13 @@ import {
21
21
  // Unauthenticated public CDN transport
22
22
  // ─────────────────────────────────────────────────────────────────────────────
23
23
 
24
- // Dev CORS: the browser can't reach the CDN cross-origin from localhost, and
25
- // createDataSDK().fetch doesn't proxy absolute URLs. So in dev fetch the
26
- // same-origin relative path (Vite `server.proxy['/cms']` forwards it); in prod
27
- // fetch the absolute URL.
28
- function resolveFetchUrl(deliveryUrl: string): string {
29
- if (import.meta.env.DEV) {
30
- const parsedUrl = new URL(deliveryUrl);
31
- return parsedUrl.pathname + parsedUrl.search;
32
- }
33
- return deliveryUrl;
34
- }
35
-
36
24
  /**
37
25
  * Fetch a public CMS delivery URL directly (unauthenticated). `signal` is only for a
38
26
  * genuinely per-consumer request.
39
27
  */
40
28
  export async function cmsDeliveryGet<T>(url: string, signal?: AbortSignal): Promise<T> {
41
29
  try {
42
- const response = await fetch(resolveFetchUrl(url), {
30
+ const response = await fetch(url, {
43
31
  // Public CDN endpoint — carries no session;
44
32
  credentials: "omit",
45
33
  signal,
@@ -8,6 +8,7 @@
8
8
  * - getCmsContentByKey(key, options?) — one item by contentKey (throws)
9
9
  * - getCmsContentByKeys(keys, options?) — many by contentKey (best-effort)
10
10
  * - resolveCmsImageUrl(field, options?) — image field → loadable URL (sync)
11
+ * - resolveMediaUrl(url, options?) — raw media URL → loadable URL (sync)
11
12
  * - localiseMediaUrl(url, language?) — add the active `language` to a URL (sync)
12
13
  * - localiseCmsUrl(url, options?) — add the active `language` to a URL (async)
13
14
  * - resolveCmsLanguage(options?) — active language, async (SFDC_ENV / i18n); warms cache
@@ -30,7 +31,7 @@
30
31
  // ── reads + utility ─────────────────────────────────────────────────────────
31
32
  export { getCmsContentByUrl, getCmsContentByKey, getCmsContentByKeys } from "./api/cmsContent";
32
33
  export { decodeRichHtmlEntities } from "./utils/htmlEntities";
33
- export { resolveCmsImageUrl } from "./utils/imageUrl";
34
+ export { resolveCmsImageUrl, resolveMediaUrl } from "./utils/imageUrl";
34
35
  export { getCmsInstanceOrigin } from "./config/env";
35
36
  export { resolveEffectiveContentKey, getCmsDefaultChannelId } from "./api/catalog";
36
37
 
@@ -100,6 +100,29 @@ function extractRawUrl(
100
100
  return undefined;
101
101
  }
102
102
 
103
+ /**
104
+ * Turn a delivered (un-prefixed) media URL into a loadable one: localise root-relative CMS
105
+ * media with the active `language`, then prefix it with `options.instanceOrigin`. Foreign
106
+ * absolute/protocol-relative CDN urls are left untouched (no language, no prefix). Shared by
107
+ * {@link resolveCmsImageUrl} (image-field variant) and {@link resolveMediaUrl} (raw-url variant).
108
+ */
109
+ function localiseAndPrefix(rawUrl: string, options?: CmsImageOptions): string {
110
+ // Only Salesforce-served CMS media (root-relative, not protocol-relative) is
111
+ // localizable — a foreign absolute CDN url doesn't understand the `language` param.
112
+ const isCmsMedia = rawUrl.startsWith("/") && !rawUrl.startsWith("//");
113
+ // Synchronous resolution: explicit option → SFDC_ENV.language → cached i18n language
114
+ // (warmed by a prior resolveCmsLanguage()). Localise BEFORE prefixing the origin so the
115
+ // param lands on the raw media path.
116
+ const language = getResolvedCmsLanguage(options);
117
+ // Dev-only nudge: CMS media with no language AND a cold (never-warmed) i18n cache is the
118
+ // "forgot to warm up" footgun on internal apps — warn once so it's not silently untranslated.
119
+ if (import.meta.env.DEV && isCmsMedia && !language && !hasAttemptedCmsLanguage()) {
120
+ warnUnwarmedLanguageOnce();
121
+ }
122
+ const localisedUrl = isCmsMedia ? appendLanguageParam(rawUrl, language) : rawUrl;
123
+ return prefixOrigin(localisedUrl, options?.instanceOrigin);
124
+ }
125
+
103
126
  /**
104
127
  * Resolve a `CmsImageField` to a loadable image URL — external (absolute CDN) or CMS
105
128
  * imageReference (root-relative, prefixed with `options.instanceOrigin`). Returns
@@ -133,18 +156,37 @@ export function resolveCmsImageUrl(
133
156
  if (!field || typeof field !== "object") return undefined;
134
157
  const rawUrl = extractRawUrl(field, options?.resolveRef);
135
158
  if (!rawUrl) return undefined;
136
- // Only Salesforce-served CMS media (root-relative, not protocol-relative) is
137
- // localizable — a foreign absolute CDN url doesn't understand the `language` param.
138
- const isCmsMedia = rawUrl.startsWith("/") && !rawUrl.startsWith("//");
139
- // Synchronous resolution: explicit option → SFDC_ENV.language → cached i18n language
140
- // (warmed by a prior resolveCmsLanguage()). Localise BEFORE prefixing the origin so the
141
- // param lands on the raw media path.
142
- const language = getResolvedCmsLanguage(options);
143
- // Dev-only nudge: CMS media with no language AND a cold (never-warmed) i18n cache is the
144
- // "forgot to warm up" footgun on internal apps — warn once so it's not silently untranslated.
145
- if (import.meta.env.DEV && isCmsMedia && !language && !hasAttemptedCmsLanguage()) {
146
- warnUnwarmedLanguageOnce();
147
- }
148
- const localisedUrl = isCmsMedia ? appendLanguageParam(rawUrl, language) : rawUrl;
149
- return prefixOrigin(localisedUrl, options?.instanceOrigin);
159
+ return localiseAndPrefix(rawUrl, options);
160
+ }
161
+
162
+ /**
163
+ * Resolve a raw (delivered) media URL string to a loadable one — the string-input sibling of
164
+ * {@link resolveCmsImageUrl}. Localises root-relative CMS media with the active `language`,
165
+ * then prefixes it with `options.instanceOrigin`; a foreign absolute/protocol-relative CDN
166
+ * url is returned untouched (no language, no prefix). Returns undefined for an empty url so
167
+ * an absent field can pass straight through.
168
+ *
169
+ * Use this when you already hold a media URL string (e.g. a `document`/`video` content field
170
+ * that is a plain url, not a {@link CmsImageField}) and want the same localise-then-prefix
171
+ * treatment `<img>` sources get.
172
+ *
173
+ * SYNCHRONOUS — same language chain and one-time internal-app warm-up as
174
+ * {@link resolveCmsImageUrl} (explicit `options.language` → `SFDC_ENV.language` → the i18n
175
+ * language cached by a prior `resolveCmsLanguage()`). It differs from `localiseMediaUrl`,
176
+ * which localises but does NOT origin-prefix.
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * // Root-relative CMS media — localised and prefixed to load:
181
+ * resolveMediaUrl(body.documentUrl, { instanceOrigin });
182
+ * // Foreign/CDN url — returned as-is:
183
+ * resolveMediaUrl("https://cdn.example.com/report.pdf"); // → same url
184
+ * ```
185
+ */
186
+ export function resolveMediaUrl(
187
+ url: string | undefined,
188
+ options?: CmsImageOptions,
189
+ ): string | undefined {
190
+ if (!url) return undefined;
191
+ return localiseAndPrefix(url, options);
150
192
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@salesforce/ui-bundle-template-base-sfdx-project",
3
- "version": "12.1.1",
3
+ "version": "12.2.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@salesforce/ui-bundle-template-base-sfdx-project",
9
- "version": "12.1.1",
9
+ "version": "12.2.0",
10
10
  "license": "SEE LICENSE IN LICENSE.txt",
11
11
  "dependencies": {
12
12
  "fast-xml-parser": "^5.9.3",
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/ui-bundle-template-base-sfdx-project",
3
- "version": "12.1.1",
3
+ "version": "12.2.0",
4
4
  "description": "Base SFDX project template",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "publishConfig": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/ui-bundle-template-feature-cms-toolkit",
3
- "version": "12.1.1",
3
+ "version": "12.2.0",
4
4
  "description": "CMS toolkit — framework-agnostic APIs for reading Salesforce CMS delivery content (by public URL or contentKey, single or bulk) and decoding RichText and other utility functions",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "",
@@ -28,10 +28,10 @@
28
28
  "test:coverage": "vitest run --coverage"
29
29
  },
30
30
  "dependencies": {
31
- "@salesforce/platform-sdk": "^12.1.1"
31
+ "@salesforce/platform-sdk": "^12.2.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@salesforce/ui-bundle": "^12.1.1",
34
+ "@salesforce/ui-bundle": "^12.2.0",
35
35
  "@vitest/coverage-v8": "^4.1.0",
36
36
  "vite": "^7.3.5",
37
37
  "vitest": "^4.1.0"
@@ -2,7 +2,7 @@
2
2
  * content-metadata.json loader + resolvers for the authenticated (byKey) read path.
3
3
  *
4
4
  * The catalog is a deploy-specific public JSON asset at `CONTENT_CATALOG_URL`
5
- * (`{ channelId, contents }`), fetched once and memoized. Fail-open: a missing /
5
+ * (`{ channelId, regeneratedContents }`), fetched once and memoized. Fail-open: a missing /
6
6
  * unreachable / malformed catalog resolves to `{}` and never throws.
7
7
  */
8
8
  import { CONTENT_CATALOG_URL } from "../config/env";
@@ -15,8 +15,8 @@ const catalogPromises = new Map<string, Promise<CmsContentCatalog>>();
15
15
  // Guards the single fail-open warning so a missing catalog doesn't spam the console.
16
16
  let warned = false;
17
17
 
18
- /** Parse the raw `contents` array into a source→target contentKey Map, skipping any
19
- * entry missing either string key. Returns undefined when nothing usable is present. */
18
+ /** Parse the raw `regeneratedContents` array into a source→target contentKey Map, skipping
19
+ * any entry missing either string key. Returns undefined when nothing usable is present. */
20
20
  function parseContentKeyMap(rawContents: unknown): ReadonlyMap<string, string> | undefined {
21
21
  if (!Array.isArray(rawContents)) return undefined;
22
22
  const contentKeyMap = new Map<string, string>();
@@ -36,10 +36,13 @@ function parseContentKeyMap(rawContents: unknown): ReadonlyMap<string, string> |
36
36
  /** Parse a raw catalog payload into a CmsContentCatalog. Tolerates any shape. */
37
37
  function parseCatalog(payload: unknown): CmsContentCatalog {
38
38
  if (!payload || typeof payload !== "object") return {};
39
- const { channelId, contents } = payload as { channelId?: unknown; contents?: unknown };
39
+ const { channelId, regeneratedContents } = payload as {
40
+ channelId?: unknown;
41
+ regeneratedContents?: unknown;
42
+ };
40
43
  const catalog: CmsContentCatalog = {};
41
44
  if (typeof channelId === "string") catalog.channelId = channelId;
42
- const contentKeyMap = parseContentKeyMap(contents);
45
+ const contentKeyMap = parseContentKeyMap(regeneratedContents);
43
46
  if (contentKeyMap) catalog.contentKeyMap = contentKeyMap;
44
47
  return catalog;
45
48
  }
@@ -21,25 +21,13 @@ import {
21
21
  // Unauthenticated public CDN transport
22
22
  // ─────────────────────────────────────────────────────────────────────────────
23
23
 
24
- // Dev CORS: the browser can't reach the CDN cross-origin from localhost, and
25
- // createDataSDK().fetch doesn't proxy absolute URLs. So in dev fetch the
26
- // same-origin relative path (Vite `server.proxy['/cms']` forwards it); in prod
27
- // fetch the absolute URL.
28
- function resolveFetchUrl(deliveryUrl: string): string {
29
- if (import.meta.env.DEV) {
30
- const parsedUrl = new URL(deliveryUrl);
31
- return parsedUrl.pathname + parsedUrl.search;
32
- }
33
- return deliveryUrl;
34
- }
35
-
36
24
  /**
37
25
  * Fetch a public CMS delivery URL directly (unauthenticated). `signal` is only for a
38
26
  * genuinely per-consumer request.
39
27
  */
40
28
  export async function cmsDeliveryGet<T>(url: string, signal?: AbortSignal): Promise<T> {
41
29
  try {
42
- const response = await fetch(resolveFetchUrl(url), {
30
+ const response = await fetch(url, {
43
31
  // Public CDN endpoint — carries no session;
44
32
  credentials: "omit",
45
33
  signal,
@@ -8,6 +8,7 @@
8
8
  * - getCmsContentByKey(key, options?) — one item by contentKey (throws)
9
9
  * - getCmsContentByKeys(keys, options?) — many by contentKey (best-effort)
10
10
  * - resolveCmsImageUrl(field, options?) — image field → loadable URL (sync)
11
+ * - resolveMediaUrl(url, options?) — raw media URL → loadable URL (sync)
11
12
  * - localiseMediaUrl(url, language?) — add the active `language` to a URL (sync)
12
13
  * - localiseCmsUrl(url, options?) — add the active `language` to a URL (async)
13
14
  * - resolveCmsLanguage(options?) — active language, async (SFDC_ENV / i18n); warms cache
@@ -30,7 +31,7 @@
30
31
  // ── reads + utility ─────────────────────────────────────────────────────────
31
32
  export { getCmsContentByUrl, getCmsContentByKey, getCmsContentByKeys } from "./api/cmsContent";
32
33
  export { decodeRichHtmlEntities } from "./utils/htmlEntities";
33
- export { resolveCmsImageUrl } from "./utils/imageUrl";
34
+ export { resolveCmsImageUrl, resolveMediaUrl } from "./utils/imageUrl";
34
35
  export { getCmsInstanceOrigin } from "./config/env";
35
36
  export { resolveEffectiveContentKey, getCmsDefaultChannelId } from "./api/catalog";
36
37
 
@@ -100,6 +100,29 @@ function extractRawUrl(
100
100
  return undefined;
101
101
  }
102
102
 
103
+ /**
104
+ * Turn a delivered (un-prefixed) media URL into a loadable one: localise root-relative CMS
105
+ * media with the active `language`, then prefix it with `options.instanceOrigin`. Foreign
106
+ * absolute/protocol-relative CDN urls are left untouched (no language, no prefix). Shared by
107
+ * {@link resolveCmsImageUrl} (image-field variant) and {@link resolveMediaUrl} (raw-url variant).
108
+ */
109
+ function localiseAndPrefix(rawUrl: string, options?: CmsImageOptions): string {
110
+ // Only Salesforce-served CMS media (root-relative, not protocol-relative) is
111
+ // localizable — a foreign absolute CDN url doesn't understand the `language` param.
112
+ const isCmsMedia = rawUrl.startsWith("/") && !rawUrl.startsWith("//");
113
+ // Synchronous resolution: explicit option → SFDC_ENV.language → cached i18n language
114
+ // (warmed by a prior resolveCmsLanguage()). Localise BEFORE prefixing the origin so the
115
+ // param lands on the raw media path.
116
+ const language = getResolvedCmsLanguage(options);
117
+ // Dev-only nudge: CMS media with no language AND a cold (never-warmed) i18n cache is the
118
+ // "forgot to warm up" footgun on internal apps — warn once so it's not silently untranslated.
119
+ if (import.meta.env.DEV && isCmsMedia && !language && !hasAttemptedCmsLanguage()) {
120
+ warnUnwarmedLanguageOnce();
121
+ }
122
+ const localisedUrl = isCmsMedia ? appendLanguageParam(rawUrl, language) : rawUrl;
123
+ return prefixOrigin(localisedUrl, options?.instanceOrigin);
124
+ }
125
+
103
126
  /**
104
127
  * Resolve a `CmsImageField` to a loadable image URL — external (absolute CDN) or CMS
105
128
  * imageReference (root-relative, prefixed with `options.instanceOrigin`). Returns
@@ -133,18 +156,37 @@ export function resolveCmsImageUrl(
133
156
  if (!field || typeof field !== "object") return undefined;
134
157
  const rawUrl = extractRawUrl(field, options?.resolveRef);
135
158
  if (!rawUrl) return undefined;
136
- // Only Salesforce-served CMS media (root-relative, not protocol-relative) is
137
- // localizable — a foreign absolute CDN url doesn't understand the `language` param.
138
- const isCmsMedia = rawUrl.startsWith("/") && !rawUrl.startsWith("//");
139
- // Synchronous resolution: explicit option → SFDC_ENV.language → cached i18n language
140
- // (warmed by a prior resolveCmsLanguage()). Localise BEFORE prefixing the origin so the
141
- // param lands on the raw media path.
142
- const language = getResolvedCmsLanguage(options);
143
- // Dev-only nudge: CMS media with no language AND a cold (never-warmed) i18n cache is the
144
- // "forgot to warm up" footgun on internal apps — warn once so it's not silently untranslated.
145
- if (import.meta.env.DEV && isCmsMedia && !language && !hasAttemptedCmsLanguage()) {
146
- warnUnwarmedLanguageOnce();
147
- }
148
- const localisedUrl = isCmsMedia ? appendLanguageParam(rawUrl, language) : rawUrl;
149
- return prefixOrigin(localisedUrl, options?.instanceOrigin);
159
+ return localiseAndPrefix(rawUrl, options);
160
+ }
161
+
162
+ /**
163
+ * Resolve a raw (delivered) media URL string to a loadable one — the string-input sibling of
164
+ * {@link resolveCmsImageUrl}. Localises root-relative CMS media with the active `language`,
165
+ * then prefixes it with `options.instanceOrigin`; a foreign absolute/protocol-relative CDN
166
+ * url is returned untouched (no language, no prefix). Returns undefined for an empty url so
167
+ * an absent field can pass straight through.
168
+ *
169
+ * Use this when you already hold a media URL string (e.g. a `document`/`video` content field
170
+ * that is a plain url, not a {@link CmsImageField}) and want the same localise-then-prefix
171
+ * treatment `<img>` sources get.
172
+ *
173
+ * SYNCHRONOUS — same language chain and one-time internal-app warm-up as
174
+ * {@link resolveCmsImageUrl} (explicit `options.language` → `SFDC_ENV.language` → the i18n
175
+ * language cached by a prior `resolveCmsLanguage()`). It differs from `localiseMediaUrl`,
176
+ * which localises but does NOT origin-prefix.
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * // Root-relative CMS media — localised and prefixed to load:
181
+ * resolveMediaUrl(body.documentUrl, { instanceOrigin });
182
+ * // Foreign/CDN url — returned as-is:
183
+ * resolveMediaUrl("https://cdn.example.com/report.pdf"); // → same url
184
+ * ```
185
+ */
186
+ export function resolveMediaUrl(
187
+ url: string | undefined,
188
+ options?: CmsImageOptions,
189
+ ): string | undefined {
190
+ if (!url) return undefined;
191
+ return localiseAndPrefix(url, options);
150
192
  }