@contentful/experiences-client 0.10.9 → 0.10.10

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## 0.10.10 (2026-10-30)
2
+
3
+ ### 🚀 Features
4
+
5
+ - support personalization on Destination fetches [AIS-812] ([#282](https://github.com/contentful/experiences/pull/282))
6
+
7
+ ### 🩹 Fixes
8
+
9
+ - **deps:** update dependency @contentful/experience-delivery to v1.0.0-dev.11 ([#277](https://github.com/contentful/experiences/pull/277))
10
+
11
+ ### 🧱 Updated Dependencies
12
+
13
+ - Updated core to 0.13.9
14
+
1
15
  ## 0.10.9 (2026-10-30)
2
16
 
3
17
  ### 🧱 Updated Dependencies
package/dist/index.cjs CHANGED
@@ -40,7 +40,7 @@ var DestinationPreviewNotSupportedError = class extends Error {
40
40
  var USER_AGENT_HEADER = "X-Contentful-User-Agent";
41
41
  var EXPERIENCES_CLIENT_SDK = {
42
42
  name: true ? "@contentful/experiences-client" : "@contentful/experiences-client",
43
- version: true ? "0.10.9" : "0.0.0"
43
+ version: true ? "0.10.10" : "0.0.0"
44
44
  };
45
45
  function getProcess() {
46
46
  return globalThis.process;
@@ -153,16 +153,39 @@ function createClient(options) {
153
153
 
154
154
 
155
155
  // src/personalization.ts
156
- var _serialization = require('@contentful/experience-delivery/serialization');
156
+ var EVENT_TYPES = ["page", "track", "identify", "screen", "component"];
157
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
157
158
  function serializePersonalization(personalization) {
158
159
  try {
159
- return _serialization.GetWithOverridesExperienceRequestExtensionsPersonalization.parseOrThrow(personalization, {
160
- unrecognizedObjectKeys: "strip"
161
- });
160
+ if (!isRecord(personalization)) throw new Error("Expected an object");
161
+ const { profileId, events } = personalization;
162
+ if (profileId !== void 0 && typeof profileId !== "string") {
163
+ throw new Error("profileId must be a string");
164
+ }
165
+ if (events !== void 0 && !Array.isArray(events)) throw new Error("events must be an array");
166
+ return {
167
+ ...profileId === void 0 ? {} : { profileId },
168
+ ...events === void 0 ? {} : { events: events.map(serializeEvent) }
169
+ };
162
170
  } catch (cause) {
163
171
  throw new TypeError("Invalid Experience personalization options", { cause });
164
172
  }
165
173
  }
174
+ function serializeEvent(event) {
175
+ if (!isRecord(event) || !EVENT_TYPES.includes(event.type)) {
176
+ throw new Error("Unknown event type");
177
+ }
178
+ for (const key of ["channel", "messageId", "timestamp"]) {
179
+ if (typeof event[key] !== "string") throw new Error(`${key} must be a string`);
180
+ }
181
+ if (!isRecord(event.context) || !isRecord(event.context.library)) {
182
+ throw new Error("context.library is required");
183
+ }
184
+ const { gdpr: _gdpr, screen: _screen, page, ...context } = event.context;
185
+ if (!isRecord(page)) return { ...event, context };
186
+ const { title: _title, ...xdaPage } = page;
187
+ return { ...event, context: { ...context, page: xdaPage } };
188
+ }
166
189
 
167
190
  // src/fetch-experience.ts
168
191
  var _experiencessdkcore = require('@contentful/experiences-sdk-core');
@@ -250,19 +273,26 @@ async function fetchExperience(experienceOptions, clientOptions, resolveOptions)
250
273
  }
251
274
  const client = resolveDeliveryClient(clientOptions, log, "fetchExperience");
252
275
  if ("nodeId" in experienceOptions) {
253
- const { spaceId: spaceId2, destinationId, nodeId } = experienceOptions;
276
+ const { spaceId: spaceId2, destinationId, nodeId, personalization: personalization2 } = experienceOptions;
277
+ const extensions2 = destinationExtensions(personalization2);
254
278
  return fetchByDestination(
255
279
  { spaceId: spaceId2, destinationId, locator: nodeId },
256
- () => client.destination.resolveByNodeId(spaceId2, destinationId, nodeId),
280
+ () => extensions2 === void 0 ? client.destination.resolveByNodeId(spaceId2, destinationId, nodeId) : client.destination.resolveByNodeIdWithOverrides(spaceId2, destinationId, nodeId, {
281
+ extensions: extensions2
282
+ }),
257
283
  log,
258
284
  { config, metadata, debug }
259
285
  );
260
286
  }
261
287
  if ("path" in experienceOptions) {
262
- const { spaceId: spaceId2, destinationId, path } = experienceOptions;
288
+ const { spaceId: spaceId2, destinationId, path, personalization: personalization2 } = experienceOptions;
289
+ const extensions2 = destinationExtensions(personalization2);
263
290
  return fetchByDestination(
264
291
  { spaceId: spaceId2, destinationId, locator: path },
265
- () => client.destination.resolveByPath(spaceId2, destinationId, { path }),
292
+ () => client.destination.resolveByPath(spaceId2, destinationId, {
293
+ path,
294
+ ...extensions2 === void 0 ? {} : { extensions: extensions2 }
295
+ }),
266
296
  log,
267
297
  { config, metadata, debug }
268
298
  );
@@ -361,6 +391,10 @@ async function fetchByDestination(identity, resolve, log, resolveOptions) {
361
391
  debug
362
392
  });
363
393
  }
394
+ function destinationExtensions(personalization) {
395
+ if (personalization === void 0) return void 0;
396
+ return { personalization: serializePersonalization(personalization) };
397
+ }
364
398
  function hasRequestExtensions(extensions) {
365
399
  return extensions !== void 0 && Object.values(extensions).some((extension) => extension !== void 0);
366
400
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/experiences/experiences/packages/client/dist/index.cjs","../src/index.ts","../src/errors.ts","../src/create-delivery-client.ts","../src/user-agent.ts","../src/fetch-experience.ts","../src/personalization.ts","../src/destination-guards.ts","../src/hosts.ts","../src/client-resolution.ts","../src/experience-parameters.ts","../src/to-experience-payload.ts","../src/fetch-destination-sitemap.ts"],"names":["spaceId","ContentfulViewDelivery"],"mappings":"AAAA;ACAA,qEAAuC;AAEvC;AACE;AACA;AAAA;ADEF;AACA;AEUO,IAAM,qBAAA,EAAN,MAAA,QAAmC,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EAET,WAAA,CACE,OAAA,EACA,OAAA,EAMA;AACA,IAAA,KAAA,CAAM,OAAA,EAAS,OAAA,CAAQ,MAAA,IAAU,KAAA,EAAA,EAAY,EAAE,KAAA,EAAO,OAAA,CAAQ,MAAM,EAAA,EAAI,KAAA,CAAS,CAAA;AACjF,IAAA,IAAA,CAAK,KAAA,EAAO,sBAAA;AACZ,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA,CAAQ,O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,EAAA;AACA,EAAA;AACmD,IAAA;AACnD,MAAA;AACA,MAAA;AACA,MAAA;AACD,IAAA;AACW,EAAA;AAC8B,IAAA;AAClC,MAAA;AACR,IAAA;AACoD,IAAA;AAC1C,IAAA;AACoC,MAAA;AAGO,MAAA;AACrD,IAAA;AACF,EAAA;AAEe,EAAA;AAC8B,IAAA;AAC9B,MAAA;AACsC,MAAA;AAClC,MAAA;AACf,IAAA;AACoB,IAAA;AACA,IAAA;AACxB,EAAA;AAE8C,EAAA;AAEvC,EAAA;AACT;AAU+C;AACa,EAAA;AAClB,EAAA;AAC1C;AZoT6D;AACA;ACtZT;ADwZS;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/experiences/experiences/packages/client/dist/index.cjs","sourcesContent":[null,"import { ContentfulViewDelivery } from '@contentful/experience-delivery';\n\nexport {\n ContentfulViewDelivery,\n ContentfulViewDeliveryClient,\n} from '@contentful/experience-delivery';\nexport const NotFoundError = ContentfulViewDelivery.NotFoundError;\n// eslint-disable-next-line no-redeclare -- value + type share a name across separate TS namespaces, not a real redeclaration\nexport type NotFoundError = InstanceType<typeof ContentfulViewDelivery.NotFoundError>;\nexport { ExperienceFetchError, DestinationPreviewNotSupportedError } from './errors.js';\nexport { createClient } from './create-delivery-client.js';\nexport type { CreateClientOptions } from './create-delivery-client.js';\nexport { createUserAgentHeaders, EXPERIENCES_CLIENT_SDK, USER_AGENT_HEADER } from './user-agent.js';\nexport type { SdkIdentity } from './user-agent.js';\nexport { fetchExperience } from './fetch-experience.js';\nexport { fetchDestinationSitemap } from './fetch-destination-sitemap.js';\nexport type {\n FetchDestinationSitemapOptions,\n FetchDestinationSitemapPaginationOptions,\n SitemapPathItem,\n DestinationSitemapResult,\n} from './fetch-destination-sitemap.js';\nexport {\n readSourceMap,\n toExperiencePayload,\n toExperiencePayloadFromDestination,\n} from './to-experience-payload.js';\nexport type { ExperienceResponse } from './to-experience-payload.js';\nexport type {\n ExperienceOptions,\n ExperienceRequestExtensions,\n PersonalizationOptions,\n ByIdExperienceOptions,\n ByDestinationNodeIdExperienceOptions,\n ByDestinationPathExperienceOptions,\n ClientOptions,\n ResolveOptions,\n DestinationRedirectResult,\n} from './fetch-experience.js';\nexport { DELIVERY_HOST, PREVIEW_HOST, PREVIEW_WEBSOCKET_HOST } from './hosts.js';\nexport type {\n ExperienceParameters,\n ExperienceParameterValue,\n ExperienceParameterRecord,\n ExperienceParameterOrder,\n} from './experience-parameters.js';\nexport { serializePersonalization } from './personalization.js';\n","/**\n * Thrown by `fetchExperience` for a fetch failure that is not \"experience not\n * found\" — network failure, an invalid/expired token, a 5xx from the\n * delivery API, etc. This failure mode is \"surface clearly to the host app,\"\n * unlike the diagnostics `resolveExperience` collects for resolve/render-time\n * issues — there's no partial payload to render around a fetch that never\n * returned one, so a real thrown class is the right shape.\n *\n * `NotFoundError` (the delivery client's class, re-exported from this\n * package) is the one exception: it passes through undisturbed so callers\n * can route it to their framework's 404 idiom, per the existing\n * distinguishable-404 contract.\n *\n * `environmentId` is `undefined` for the destination-shaped `fetchExperience`\n * branches — the destinations delivery endpoints are space-scoped only, with\n * no environment segment, unlike the by-id path.\n */\nexport class ExperienceFetchError extends Error {\n readonly spaceId: string;\n readonly environmentId: string | undefined;\n readonly experienceId: string;\n\n constructor(\n message: string,\n options: {\n spaceId: string;\n environmentId?: string;\n experienceId: string;\n cause?: unknown;\n }\n ) {\n super(message, options.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = 'ExperienceFetchError';\n this.spaceId = options.spaceId;\n this.environmentId = options.environmentId;\n this.experienceId = options.experienceId;\n }\n}\n\n/**\n * Thrown by `fetchExperience` and `fetchDestinationSitemap` when\n * `clientOptions.preview` is `true` for a destination-shaped call\n * (`destinationId` + `nodeId`/`path`, or a sitemap fetch). The Destinations\n * Delivery API has no preview host or preview-token support yet, so this\n * guards against silently hitting the production host with a preview token\n * it doesn't accept.\n *\n * This is a bridge, not a permanent design: revisit once the platform ships\n * preview support for destinations.\n *\n * Only fires for the inline-credentials branch of `ClientOptions`. A\n * caller-supplied `{ client }` already ignores `preview` entirely, per that\n * branch's existing contract.\n */\nexport class DestinationPreviewNotSupportedError extends Error {\n readonly spaceId: string;\n readonly destinationId: string;\n readonly nodeId: string | undefined;\n readonly path: string | undefined;\n\n constructor(\n message: string,\n options: { spaceId: string; destinationId: string; nodeId?: string; path?: string }\n ) {\n super(message);\n this.name = 'DestinationPreviewNotSupportedError';\n this.spaceId = options.spaceId;\n this.destinationId = options.destinationId;\n this.nodeId = options.nodeId;\n this.path = options.path;\n }\n}\n","import { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { createUserAgentHeaders, EXPERIENCES_CLIENT_SDK } from './user-agent.js';\n\n/** Options for the legacy functional Delivery client constructor. */\nexport type CreateClientOptions = {\n accessToken: string;\n /**\n * Base URL for the delivery client. Defaults to `DELIVERY_HOST` when omitted.\n * Pass `PREVIEW_HOST` for preview mode, or any custom URL (staging, proxy,\n * per-region). Both constants are exported from this package.\n */\n host?: string;\n} & Omit<ContentfulViewDeliveryClient.Options, 'token' | 'baseUrl'>;\n\nexport function createClient(options: CreateClientOptions): ContentfulViewDeliveryClient {\n const { accessToken, host, headers, ...rest } = options;\n return new ContentfulViewDeliveryClient({\n ...rest,\n headers: { ...createUserAgentHeaders(EXPERIENCES_CLIENT_SDK), ...headers },\n token: accessToken,\n baseUrl: host,\n });\n}\n","declare const __EXPERIENCES_CLIENT_NAME__: string | undefined;\ndeclare const __EXPERIENCES_CLIENT_VERSION__: string | undefined;\n\n/** Header the Contentful JS SDKs use to report SDK identity, platform, and OS. */\nexport const USER_AGENT_HEADER = 'X-Contentful-User-Agent';\n\n/** Package identity reported in the user-agent header. */\nexport type SdkIdentity = { name: string; version: string };\n\n/**\n * Identity of this package. Build artifacts receive package metadata through\n * tsup defines; source execution (including tests) uses stable fallbacks.\n */\nexport const EXPERIENCES_CLIENT_SDK: SdkIdentity = {\n name:\n typeof __EXPERIENCES_CLIENT_NAME__ === 'string'\n ? __EXPERIENCES_CLIENT_NAME__\n : '@contentful/experiences-client',\n version:\n typeof __EXPERIENCES_CLIENT_VERSION__ === 'string' ? __EXPERIENCES_CLIENT_VERSION__ : '0.0.0',\n};\n\n// Ported from contentful-sdk-core `src/get-user-agent.ts` and `src/utils.ts` so\n// the header matches contentful.js. `process` is read from `globalThis` instead\n// of importing the `process` polyfill.\n\ntype NodeProcess = {\n browser?: boolean;\n platform?: string;\n version?: string;\n versions?: { node?: string };\n};\n\nfunction getProcess(): NodeProcess | undefined {\n return (globalThis as { process?: NodeProcess }).process;\n}\n\nfunction isNode(): boolean {\n // Polyfills of `process` might set `process.browser === true`.\n const process = getProcess();\n return typeof process !== 'undefined' && !process.browser;\n}\n\nfunction isReactNative(): boolean {\n return (\n typeof window !== 'undefined' &&\n 'navigator' in window &&\n 'product' in window.navigator &&\n window.navigator.product === 'ReactNative'\n );\n}\n\nfunction getNodeVersion(): string | undefined {\n const process = getProcess();\n return process?.versions?.node ? `v${process.versions.node}` : process?.version;\n}\n\nfunction getBrowserOS(): string | null {\n if (typeof window === 'undefined') {\n return null;\n }\n const userAgent = window.navigator.userAgent;\n // `platform` is deprecated but still the most reliable signal here.\n const platform = window.navigator.platform;\n const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];\n const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];\n const iosPlatforms = ['iPhone', 'iPad', 'iPod'];\n\n if (macosPlatforms.indexOf(platform) !== -1) {\n return 'macOS';\n } else if (iosPlatforms.indexOf(platform) !== -1) {\n return 'iOS';\n } else if (windowsPlatforms.indexOf(platform) !== -1) {\n return 'Windows';\n } else if (/Android/.test(userAgent)) {\n return 'Android';\n } else if (/Linux/.test(platform)) {\n return 'Linux';\n }\n\n return null;\n}\n\ntype PlatformMap = Record<string, 'Android' | 'Linux' | 'Windows' | 'macOS'>;\n\nfunction getNodeOS(): string | null {\n const process = getProcess();\n const platform = process?.platform || 'linux';\n const version = process?.version || '0.0.0';\n const platformMap: PlatformMap = {\n android: 'Android',\n aix: 'Linux',\n darwin: 'macOS',\n freebsd: 'Linux',\n linux: 'Linux',\n openbsd: 'Linux',\n sunos: 'Linux',\n win32: 'Windows',\n };\n if (platform in platformMap) {\n return `${platformMap[platform] || 'Linux'}/${version}`;\n }\n return null;\n}\n\nexport function getUserAgentHeader(\n sdk: string,\n application?: string,\n integration?: string,\n feature?: string\n): string {\n const headerParts = [];\n\n if (application) {\n headerParts.push(`app ${application}`);\n }\n\n if (integration) {\n headerParts.push(`integration ${integration}`);\n }\n\n if (feature) {\n headerParts.push('feature ' + feature);\n }\n\n headerParts.push(`sdk ${sdk}`);\n\n let platform: string | null;\n try {\n if (isReactNative()) {\n platform = getBrowserOS();\n headerParts.push('platform ReactNative');\n } else if (isNode()) {\n platform = getNodeOS();\n headerParts.push(`platform node.js/${getNodeVersion()}`);\n } else {\n platform = getBrowserOS();\n headerParts.push('platform browser');\n }\n } catch {\n platform = null;\n }\n\n if (platform) {\n headerParts.push(`os ${platform}`);\n }\n\n return `${headerParts.filter((item) => item !== '').join('; ')};`;\n}\n\nfunction format({ name, version }: SdkIdentity): string {\n return `${name.replace(/^@contentful\\//, '')}/${version}`;\n}\n\n/**\n * Builds the `X-Contentful-User-Agent` header for Delivery and Preview\n * requests, e.g. `app my-site/1.0.0; sdk experiences-node/0.6.0; platform node.js/v22.17.0; os macOS/v22.17.0;`.\n */\nexport function createUserAgentHeaders(\n sdk: SdkIdentity,\n app?: SdkIdentity\n): Record<string, string> {\n return {\n [USER_AGENT_HEADER]: getUserAgentHeader(format(sdk), app ? format(app) : undefined),\n };\n}\n","import type { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { ContentfulViewDelivery } from '@contentful/experience-delivery';\nimport { serializePersonalization } from './personalization.js';\nimport { createDebugLogger, resolveExperience } from '@contentful/experiences-sdk-core';\nimport type { PortableRenderPlan, ResolverConfig } from '@contentful/experiences-sdk-core';\nimport { assertDestinationPreviewSupported } from './destination-guards.js';\nimport { resolveDeliveryClient, type ClientOptions } from './client-resolution.js';\nimport { ExperienceFetchError } from './errors.js';\nimport { parameterQuery, type ExperienceParameters } from './experience-parameters.js';\nimport {\n toExperiencePayload,\n toExperiencePayloadFromDestination,\n type ExperienceResponse,\n} from './to-experience-payload.js';\n\nexport type { ClientOptions };\n\ntype DeliveryExperienceRequestExtensions =\n ContentfulViewDelivery.GetWithOverridesExperienceRequestExtensions;\n\nexport type PersonalizationOptions = NonNullable<\n DeliveryExperienceRequestExtensions['personalization']\n>;\n\nexport type ExperienceRequestExtensions = Omit<\n DeliveryExperienceRequestExtensions,\n 'personalization'\n>;\n\nexport type ByIdExperienceOptions = {\n spaceId: string;\n environmentId: string;\n experienceId: string;\n locale?: string;\n /** Values for declared Experience parameters. Refetch with new values to swap content. */\n parameters?: ExperienceParameters;\n /**\n * Profile and events used by XDA to personalize the resolved Experience.\n */\n personalization?: PersonalizationOptions;\n /**\n * Additional XDA request extensions such as source maps. Supplying a defined\n * extension switches the request to POST.\n */\n extensions?: ExperienceRequestExtensions;\n};\n\n/**\n * Resolve an Experience by the Destination Node instead of `experienceId`\n * The destinations delivery endpoints are space-scoped only and have no locale\n * param, unlike the by-id path.\n */\nexport type ByDestinationNodeIdExperienceOptions = {\n spaceId: string;\n destinationId: string;\n nodeId: string;\n};\n\n/**\n * Resolve an Experience by the absolute path wired up to a\n * Destination Node, instead of a node id directly. Same scoping as\n * `ByDestinationNodeIdExperienceOptions` — no `environmentId` or `locale`.\n */\nexport type ByDestinationPathExperienceOptions = {\n spaceId: string;\n destinationId: string;\n /** Absolute path to resolve. Must start with `/`. */\n path: string;\n};\n\nexport type ExperienceOptions =\n ByIdExperienceOptions | ByDestinationNodeIdExperienceOptions | ByDestinationPathExperienceOptions;\n\n/**\n * A Destination resolution that the app must act on as control flow — honor\n * it by navigating or re-resolving at the new path — rather than a hydrated\n * Experience to render. Modeled as a normal return value, not a thrown error,\n * per the Destinations delivery API's own framing of a redirect response.\n */\nexport interface DestinationRedirectResult {\n redirect: { path: string };\n}\n\nexport type ResolveOptions = {\n config: ResolverConfig;\n /**\n * Arbitrary per-render metadata exposed to every resolver as\n * `ctx.experience.metadata` and readable at render time via the framework\n * adapter's `useExperience()` / `getExperience()`.\n */\n metadata?: Record<string, unknown>;\n /**\n * Observability switch. When on: logs the fetch (host, ids) and the raw\n * payload here, and threads through to `resolveExperience` (resolution steps\n * + `resolveData` timings) and the renderer (visible missing-component box,\n * debug fallback). A single boolean across fetch + resolve + render.\n */\n debug?: boolean;\n};\n\n// TS overload signatures, not real redeclarations — base ESLint's no-redeclare doesn't know the\n// overload form (@typescript-eslint's own version does), so each repeated signature needs a\n// disable comment.\nexport async function fetchExperience(\n experienceOptions: ByIdExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan>;\n// eslint-disable-next-line no-redeclare -- see above\nexport async function fetchExperience(\n experienceOptions: ByDestinationNodeIdExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan | DestinationRedirectResult>;\n// eslint-disable-next-line no-redeclare -- see above\nexport async function fetchExperience(\n experienceOptions: ByDestinationPathExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan | DestinationRedirectResult>;\n// eslint-disable-next-line no-redeclare -- see above\nexport async function fetchExperience(\n experienceOptions: ExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan | DestinationRedirectResult> {\n const { config, metadata, debug } = resolveOptions;\n const log = createDebugLogger(debug, 'client');\n\n if (!('client' in clientOptions) && 'destinationId' in experienceOptions) {\n const { spaceId, destinationId } = experienceOptions;\n const locator =\n 'nodeId' in experienceOptions\n ? { nodeId: experienceOptions.nodeId }\n : { path: experienceOptions.path };\n assertDestinationPreviewSupported(clientOptions.preview, {\n spaceId,\n destinationId,\n ...locator,\n });\n }\n\n const client = resolveDeliveryClient(clientOptions, log, 'fetchExperience');\n\n if ('nodeId' in experienceOptions) {\n const { spaceId, destinationId, nodeId } = experienceOptions;\n return fetchByDestination(\n { spaceId, destinationId, locator: nodeId },\n () => client.destination.resolveByNodeId(spaceId, destinationId, nodeId),\n log,\n { config, metadata, debug }\n );\n }\n\n if ('path' in experienceOptions) {\n const { spaceId, destinationId, path } = experienceOptions;\n return fetchByDestination(\n { spaceId, destinationId, locator: path },\n () => client.destination.resolveByPath(spaceId, destinationId, { path }),\n log,\n { config, metadata, debug }\n );\n }\n\n const { spaceId, environmentId, experienceId, locale, personalization, extensions } =\n experienceOptions;\n\n log.log('fetching experience', {\n spaceId,\n environmentId,\n experienceId,\n locale,\n // avoiding log any personalization sensitive data\n personalization: personalization !== undefined,\n extensions,\n });\n\n const response = await fetchByExperienceId(client, experienceOptions);\n\n const payload = toExperiencePayload(response);\n log.lazy('received raw payload', () => payload);\n\n return resolveExperience(payload, config, { metadata, debug });\n}\n\nasync function fetchByExperienceId(\n client: ContentfulViewDeliveryClient,\n options: ByIdExperienceOptions\n): Promise<ExperienceResponse> {\n const { spaceId, environmentId, experienceId, locale, parameters, personalization, extensions } =\n options;\n const requestExtensions: DeliveryExperienceRequestExtensions = { ...extensions };\n if (personalization !== undefined) {\n requestExtensions.personalization = serializePersonalization(personalization);\n }\n\n try {\n // GET uses namespaced query leaves. POST preserves values that cannot be\n // represented by leaves and carries existing request extensions.\n // The generated delivery client owns the alpha-feature header on both\n // paths, including when the caller supplied the client instance.\n //\n // Await inside the try so rejected requests are normalized below.\n const queryParams = parameterQuery(parameters);\n if (hasRequestExtensions(requestExtensions) || queryParams === undefined) {\n // dev.10's POST serializer passes through extra body keys. Its generated\n // request type omits parameters, so retain our typed extension locally.\n // TODO: Remove this intersection once contentful-experience-delivery.js\n // generates parameters on GetWithOverridesExperienceRequest and we upgrade.\n const request: ContentfulViewDelivery.GetWithOverridesExperienceRequest & {\n parameters?: ExperienceParameters;\n } = {\n locale,\n extensions: requestExtensions,\n ...(parameters === undefined ? {} : { parameters }),\n };\n return await client.experience.getWithOverrides(\n spaceId,\n environmentId,\n experienceId,\n request\n );\n }\n\n if (Object.keys(queryParams).length > 0) {\n return await client.experience.get(\n spaceId,\n environmentId,\n experienceId,\n { locale },\n {\n queryParams,\n }\n );\n }\n return await client.experience.get(spaceId, environmentId, experienceId, { locale });\n } catch (err) {\n // Preserve expected 404 control flow for framework routers. Other failures\n // are wrapped with stable SDK context instead of exposing transport-specific\n // error shapes.\n if (err instanceof ContentfulViewDelivery.NotFoundError) {\n throw err;\n }\n const reason = err instanceof Error ? err.message : String(err);\n throw new ExperienceFetchError(\n `Failed to fetch Experience \"${experienceId}\" (space \"${spaceId}\", environment ` +\n `\"${environmentId}\"): ${reason}. Check network connectivity, the access token, and ` +\n `that the space/environment/experience ids are correct.`,\n { spaceId, environmentId, experienceId, cause: err }\n );\n }\n}\n\n/**\n * Shared response-handling for both destination-shaped `fetchExperience`\n * branches (by node id, by path).\n */\nasync function fetchByDestination(\n identity: { spaceId: string; destinationId: string; locator: string },\n resolve: () => Promise<ContentfulViewDelivery.DestinationExperienceResolutionResponse>,\n log: ReturnType<typeof createDebugLogger>,\n resolveOptions: {\n config: ResolverConfig;\n metadata: Record<string, unknown> | undefined;\n debug: boolean | undefined;\n }\n): Promise<PortableRenderPlan | DestinationRedirectResult> {\n const { spaceId, destinationId, locator } = identity;\n const { config, metadata, debug } = resolveOptions;\n\n log.log('resolving destination experience', { spaceId, destinationId, locator });\n\n let response: ContentfulViewDelivery.DestinationExperienceResolutionResponse;\n try {\n response = await resolve();\n } catch (err) {\n if (err instanceof ContentfulViewDelivery.NotFoundError) {\n throw err;\n }\n const reason = err instanceof Error ? err.message : String(err);\n throw new ExperienceFetchError(\n `Failed to resolve Destination \"${destinationId}\" at \"${locator}\" (space \"${spaceId}\"): ` +\n `${reason}. Check network connectivity, the access token, and that the space/` +\n `destination/node-or-path values are correct.`,\n { spaceId, experienceId: locator, cause: err }\n );\n }\n\n if ('redirect' in response) {\n log.log('destination resolved to a redirect', response.redirect);\n return { redirect: response.redirect };\n }\n\n const [firstExperience] = response.experiences;\n if (!firstExperience) {\n throw new ExperienceFetchError(\n `Destination \"${destinationId}\" resolved \"${locator}\" to zero Experiences ` +\n `(space \"${spaceId}\"). Expected exactly one hydrated Experience or a redirect.`,\n { spaceId, experienceId: locator }\n );\n }\n\n const payload = toExperiencePayloadFromDestination(firstExperience.experience);\n log.lazy('received raw payload', () => payload);\n\n return resolveExperience(payload, config, {\n metadata,\n debug,\n });\n}\n\nfunction hasRequestExtensions(\n extensions: DeliveryExperienceRequestExtensions | undefined\n): extensions is DeliveryExperienceRequestExtensions {\n return (\n extensions !== undefined &&\n Object.values(extensions).some((extension) => extension !== undefined)\n );\n}\n","import { GetWithOverridesExperienceRequestExtensionsPersonalization as personalizationSchema } from '@contentful/experience-delivery/serialization';\nimport type { PersonalizationOptions } from './fetch-experience.js';\n\n/** Validate and serialize events to the generated XDA request contract. */\nexport function serializePersonalization(personalization: unknown): PersonalizationOptions {\n try {\n // XDA rejects EventBuilder's context.gdpr with HTTP 422. Keep caller-built\n // events intact and serialize to its generated schema, which omits consent.\n return personalizationSchema.parseOrThrow(personalization, {\n unrecognizedObjectKeys: 'strip',\n });\n } catch (cause) {\n throw new TypeError('Invalid Experience personalization options', { cause });\n }\n}\n","import { DestinationPreviewNotSupportedError } from './errors.js';\n\n/**\n * Throws `DestinationPreviewNotSupportedError` when `clientOptions.preview` is\n * `true` and `experienceOptions` is destination-shaped (a caller-supplied\n * `{ client }` already ignores `preview` entirely, so this only fires for the\n * inline-credentials branch). Shared by `fetchExperience` and\n * `fetchDestinationSitemap` — both call into the same preview-less\n * Destinations Delivery API.\n */\nexport function assertDestinationPreviewSupported(\n isPreview: boolean | undefined,\n destination: { spaceId: string; destinationId: string; nodeId?: string; path?: string }\n): void {\n if (!isPreview) return;\n\n const { spaceId, destinationId, nodeId, path } = destination;\n const locator = nodeId !== undefined ? `nodeId \"${nodeId}\"` : `path \"${path}\"`;\n throw new DestinationPreviewNotSupportedError(\n `preview: true was combined with a destination-shaped call (destinationId ` +\n `\"${destinationId}\", ${locator}). The Destinations Delivery API does not support ` +\n `preview mode yet — pass preview: false (or omit it) for destination-based fetches.`,\n { spaceId, destinationId, nodeId, path }\n );\n}\n","export const DELIVERY_HOST = 'https://xdn.contentful.com';\nexport const PREVIEW_HOST = 'https://preview.xdn.contentful.com';\nexport const PREVIEW_WEBSOCKET_HOST = 'wss://preview.xdn.contentful.com';\n","import type { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { createClient } from './create-delivery-client.js';\nimport { createDebugLogger } from '@contentful/experiences-sdk-core';\nimport { PREVIEW_HOST } from './hosts.js';\n\nexport type ClientOptions =\n | {\n accessToken: string;\n /**\n * Preview access token. Required when calling with `preview: true`.\n */\n previewToken?: string;\n /**\n * Flip between delivery (default) and preview at request time. When\n * `true`, uses `previewToken` and the preview host; when `false` or\n * unset, uses `accessToken` and the delivery host. Ignored when a\n * pre-made `client` is passed instead of inline creds.\n */\n preview?: boolean;\n /**\n * Custom base URL for the delivery client (staging, proxy, per-region).\n * Wins over the `preview`-derived default host — combine `host` with\n * `preview: true` to point preview mode at a non-prod endpoint.\n * Omit for the standard delivery / preview hosts.\n */\n host?: string;\n }\n | { client: ContentfulViewDeliveryClient };\n\n/**\n * Resolve a `ClientOptions` union into a real delivery client. Shared by\n * `fetchExperience` and `fetchDestinationSitemap` — both accept the same\n * inline-creds-or-pre-made-client shape.\n */\nexport function resolveDeliveryClient(\n clientOptions: ClientOptions,\n log: ReturnType<typeof createDebugLogger>,\n callerName: string\n): ContentfulViewDeliveryClient {\n if ('client' in clientOptions) {\n log.log('using caller-supplied delivery client');\n return clientOptions.client;\n }\n\n const { accessToken, previewToken, preview, host } = clientOptions;\n if (preview && !previewToken) {\n throw new Error(`${callerName}() called with preview: true but no previewToken was provided`);\n }\n const resolvedHost = host ?? (preview ? PREVIEW_HOST : undefined);\n const client = createClient({\n accessToken: preview ? (previewToken as string) : accessToken,\n host: resolvedHost,\n });\n log.log('created delivery client', { preview: Boolean(preview), host: resolvedHost });\n return client;\n}\n","/** One collection order path; `-` selects descending order. Delivery validates the path. */\nexport type ExperienceParameterOrder =\n `fields.${string}` | `sys.${string}` | `-fields.${string}` | `-sys.${string}`;\n\n/** Runtime values for one Record parameter. Nested records and arrays are not supported. */\nexport type ExperienceParameterRecord = Record<string, string | number>;\n\nexport type ExperienceParameterValue = string | number | ExperienceParameterRecord;\n\n/** Unprefixed IDs declared in Experience.parameters and referenced as `$parameters/<id>`. */\nexport type ExperienceParameters = Record<string, ExperienceParameterValue>;\n\n/**\n * Flatten values for the generated client's GET queryParams escape hatch.\n * An empty Record cannot be represented by query leaves: preserve it via POST.\n * Delivery owns name, requiredness, fallback and value validation.\n */\nexport function parameterQuery(\n parameters: ExperienceParameters | undefined\n): Record<string, string | number> | undefined {\n const entries: [string, string | number][] = [];\n for (const [id, value] of Object.entries(parameters ?? {})) {\n // A dotted ID could masquerade as another parameter's Record leaf on GET.\n // Preserve the original name on POST and let delivery validate it.\n if (id.includes('.')) return undefined;\n if (typeof value === 'string' || typeof value === 'number') {\n entries.push([`parameter.${id}`, value]);\n } else {\n // Untyped callers can supply other JSON shapes. Use POST so delivery\n // sees their original value rather than a lossy query string coercion.\n if (value === null || typeof value !== 'object' || Array.isArray(value)) return undefined;\n const leaves = Object.entries(value);\n if (leaves.length === 0) return undefined;\n for (const [field, leaf] of leaves) {\n if (field.includes('.')) return undefined;\n if (typeof leaf !== 'string' && typeof leaf !== 'number') return undefined;\n entries.push([`parameter.${id}.${field}`, leaf]);\n }\n }\n }\n return Object.fromEntries(entries);\n}\n","/*\n * Typed narrowing from a delivery-client response to the payload shape the\n * renderer consumes.\n */\n\nimport type { ContentfulViewDelivery } from '@contentful/experience-delivery';\nimport type { ExperiencePayload, ExperienceSourceMap } from '@contentful/experiences-sdk-core';\n\n/** Either shape the experience endpoint can return — `get()` and `getWithOverrides()` share it. */\nexport type ExperienceResponse =\n | ContentfulViewDelivery.GetExperienceResponse\n | ContentfulViewDelivery.GetWithOverridesExperienceResponse;\n\n/**\n * Narrow a delivery response to `ExperiencePayload`.\n *\n * The endpoint types its response as `HydratedView | HydratedExperienceView`.\n * The alpha-feature header the delivery client always sends guarantees the\n * latter, but TypeScript cannot know that, so callers were left casting by hand.\n *\n * `fetchExperience` uses this internally; it is exported for anyone driving the\n * delivery client directly. Type-level only — no validation, no copying.\n *\n * A legacy-shaped response carries `componentType` / `template` links instead;\n * `resolveExperience` reports those through `warnUnrenderableNode`.\n */\nexport function toExperiencePayload(response: ExperienceResponse): ExperiencePayload {\n return response as ContentfulViewDelivery.HydratedExperienceView as ExperiencePayload;\n}\n\n/** Read `extensions.sourceMap` off a response. `undefined` when the request did not opt in. */\nexport function readSourceMap(response: ExperienceResponse): ExperienceSourceMap | undefined {\n const extensions = (response as ContentfulViewDelivery.HydratedExperienceView).extensions;\n return extensions?.sourceMap as ExperienceSourceMap | undefined;\n}\n\n/**\n * Narrow a `ResolvedDestinationExperience.experience` to `ExperiencePayload`.\n *\n * Same cast rationale as `toExperiencePayload` above, for the destination\n * resolution endpoints' `HydratedExperience` shape instead of the by-id\n * endpoints' `HydratedExperienceView`.\n */\nexport function toExperiencePayloadFromDestination(\n experience: ContentfulViewDelivery.HydratedExperience\n): ExperiencePayload {\n return experience as unknown as ExperiencePayload;\n}\n","import { ContentfulViewDelivery } from '@contentful/experience-delivery';\nimport { createDebugLogger } from '@contentful/experiences-sdk-core';\nimport { assertDestinationPreviewSupported } from './destination-guards.js';\nimport { resolveDeliveryClient, type ClientOptions } from './client-resolution.js';\nimport { ExperienceFetchError } from './errors.js';\n\nexport type FetchDestinationSitemapOptions = {\n spaceId: string;\n destinationId: string;\n};\n\nexport type FetchDestinationSitemapPaginationOptions = {\n /** Maximum number of paths to return. Defaults to `100`, maximum `1000`. */\n limit?: number;\n /** Cursor from a previous call's `pages.next`. Treat as opaque; don't combine with `pagePrev`. */\n pageNext?: string;\n /** Cursor from a previous call's `pages.prev`. Treat as opaque; don't combine with `pageNext`. */\n pagePrev?: string;\n};\n\nexport type SitemapPathItem = {\n /** Path this entry routes. */\n path: string;\n /** Flat id extracted from the entry's `experienceUrn`. */\n experienceId: string;\n /** Type of the Destination Node that claims this path, e.g. `\"DestinationExperienceNode\"`. */\n type: string;\n};\n\nexport type DestinationSitemapResult = {\n items: SitemapPathItem[];\n limit: number;\n pages: { next?: string; prev?: string };\n};\n\n/**\n * List every routable path in a published Destination. Bulk enumeration —\n * pairs with `fetchExperience`'s `destinationId` + `nodeId`/`path` branches,\n * which resolve one path at a time. Does not hydrate any Experience itself\n * and does not call `fetchExperience` internally.\n */\nexport async function fetchDestinationSitemap(\n destinationOptions: FetchDestinationSitemapOptions,\n clientOptions: ClientOptions,\n paginationOptions: FetchDestinationSitemapPaginationOptions = {}\n): Promise<DestinationSitemapResult> {\n const { spaceId, destinationId } = destinationOptions;\n const log = createDebugLogger(false, 'client');\n\n if (!('client' in clientOptions)) {\n assertDestinationPreviewSupported(clientOptions.preview, { spaceId, destinationId });\n }\n\n const client = resolveDeliveryClient(clientOptions, log, 'fetchDestinationSitemap');\n\n const { limit, pageNext, pagePrev } = paginationOptions;\n\n let response: ContentfulViewDelivery.DestinationSitemap;\n try {\n response = await client.destination.sitemap(spaceId, destinationId, {\n limit,\n pageNext,\n pagePrev,\n });\n } catch (err) {\n if (err instanceof ContentfulViewDelivery.NotFoundError) {\n throw err;\n }\n const reason = err instanceof Error ? err.message : String(err);\n throw new ExperienceFetchError(\n `Failed to fetch sitemap for Destination \"${destinationId}\" (space \"${spaceId}\"): ` +\n `${reason}. Check network connectivity, the access token, and that the space/` +\n `destination ids are correct.`,\n { spaceId, experienceId: destinationId, cause: err }\n );\n }\n\n const result = {\n items: response.paths.items.map((item) => ({\n path: item.path,\n experienceId: extractIdFromUrn(item.experienceUrn),\n type: item.sys.type,\n })),\n limit: response.paths.limit,\n pages: response.paths.pages,\n };\n\n log.lazy('received sitemap page', () => result);\n\n return result;\n}\n\n/**\n * Extract the flat id from an `experienceUrn`. Real shape:\n * crn:contentful:::experience:spaces/$self/environments/$self/experiences/<id>\n *\n * Same one-line logic as the private `extractIdFromUrn` in\n * `packages/core/src/resolve-experience.ts` — not shared across the\n * `core`/`client` package boundary (core stays zero-dep) for one line.\n */\nfunction extractIdFromUrn(urn: string): string {\n const segments = urn.split('/').filter((s) => s.length > 0);\n return segments[segments.length - 1] ?? urn;\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/experiences/experiences/packages/client/dist/index.cjs","../src/index.ts","../src/errors.ts","../src/create-delivery-client.ts","../src/user-agent.ts","../src/fetch-experience.ts","../src/personalization.ts","../src/destination-guards.ts","../src/hosts.ts","../src/client-resolution.ts","../src/experience-parameters.ts","../src/to-experience-payload.ts","../src/fetch-destination-sitemap.ts"],"names":["spaceId","personalization","extensions","ContentfulViewDelivery"],"mappings":"AAAA;ACAA,qEAAuC;AAEvC;AACE;AACA;AAAA;ADEF;AACA;AEUO,IAAM,qBAAA,EAAN,MAAA,QAAmC,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EAET,WAAA,CACE,OAAA,EACA,OAAA,EAMA;AACA,IAAA,KAAA,CAAM,OAAA,EAAS,OAAA,CAAQ,MAAA,IAAU,KAAA,EAAA,EAAY,EAAE,KAAA,EAAO,OAAA,CAAQ,MAAM,EAAA,EAAI,KAAA,CAAS,CAAA;AACjF,IAAA,IAAA,CAAK,KAAA,EAAO,sBAAA;AACZ,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA,CAAQ,OAAA;AACvB,IAAA,IAAA,CAAK,cAAA,EAAgB,OAAA,CAAQ,aAAA;AAC7B,IAAA,IAAA,CAAK,aAAA,EAAe,OAAA,CAAQ,YAAA;AAAA,EAC9B;AACF,CAAA;AAiBO,IAAM,oCAAA,EAAN,MAAA,QAAkD,MAAM;AA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;AAIuE;AAC3B,EAAA;AACS,EAAA;AACrD;AAIqD;AAGvB,EAAA;AAE9B;AL0D6D;AACA;AYjZpDC;AACyB;AA0ChC;AAGmC,EAAA;AACU,EAAA;AAEX,EAAA;AACyB,IAAA;AAC3D,EAAA;AAEyD,EAAA;AAEnB,EAAA;AAElC,EAAA;AACA,EAAA;AACmD,IAAA;AACnD,MAAA;AACA,MAAA;AACA,MAAA;AACD,IAAA;AACW,EAAA;AAC8B,IAAA;AAClC,MAAA;AACR,IAAA;AACoD,IAAA;AAC1C,IAAA;AACoC,MAAA;AAGO,MAAA;AACrD,IAAA;AACF,EAAA;AAEe,EAAA;AAC8B,IAAA;AAC9B,MAAA;AACsC,MAAA;AAClC,MAAA;AACf,IAAA;AACoB,IAAA;AACA,IAAA;AACxB,EAAA;AAE8C,EAAA;AAEvC,EAAA;AACT;AAU+C;AACa,EAAA;AAClB,EAAA;AAC1C;AZsV6D;AACA;ACxbT;AD0bS;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/experiences/experiences/packages/client/dist/index.cjs","sourcesContent":[null,"import { ContentfulViewDelivery } from '@contentful/experience-delivery';\n\nexport {\n ContentfulViewDelivery,\n ContentfulViewDeliveryClient,\n} from '@contentful/experience-delivery';\nexport const NotFoundError = ContentfulViewDelivery.NotFoundError;\n// eslint-disable-next-line no-redeclare -- value + type share a name across separate TS namespaces, not a real redeclaration\nexport type NotFoundError = InstanceType<typeof ContentfulViewDelivery.NotFoundError>;\nexport { ExperienceFetchError, DestinationPreviewNotSupportedError } from './errors.js';\nexport { createClient } from './create-delivery-client.js';\nexport type { CreateClientOptions } from './create-delivery-client.js';\nexport { createUserAgentHeaders, EXPERIENCES_CLIENT_SDK, USER_AGENT_HEADER } from './user-agent.js';\nexport type { SdkIdentity } from './user-agent.js';\nexport { fetchExperience } from './fetch-experience.js';\nexport { fetchDestinationSitemap } from './fetch-destination-sitemap.js';\nexport type {\n FetchDestinationSitemapOptions,\n FetchDestinationSitemapPaginationOptions,\n SitemapPathItem,\n DestinationSitemapResult,\n} from './fetch-destination-sitemap.js';\nexport {\n readSourceMap,\n toExperiencePayload,\n toExperiencePayloadFromDestination,\n} from './to-experience-payload.js';\nexport type { ExperienceResponse } from './to-experience-payload.js';\nexport type {\n ExperienceOptions,\n ExperienceRequestExtensions,\n PersonalizationOptions,\n ByIdExperienceOptions,\n ByDestinationNodeIdExperienceOptions,\n ByDestinationPathExperienceOptions,\n ClientOptions,\n ResolveOptions,\n DestinationRedirectResult,\n} from './fetch-experience.js';\nexport { DELIVERY_HOST, PREVIEW_HOST, PREVIEW_WEBSOCKET_HOST } from './hosts.js';\nexport type {\n ExperienceParameters,\n ExperienceParameterValue,\n ExperienceParameterRecord,\n ExperienceParameterOrder,\n} from './experience-parameters.js';\nexport { serializePersonalization } from './personalization.js';\n","/**\n * Thrown by `fetchExperience` for a fetch failure that is not \"experience not\n * found\" — network failure, an invalid/expired token, a 5xx from the\n * delivery API, etc. This failure mode is \"surface clearly to the host app,\"\n * unlike the diagnostics `resolveExperience` collects for resolve/render-time\n * issues — there's no partial payload to render around a fetch that never\n * returned one, so a real thrown class is the right shape.\n *\n * `NotFoundError` (the delivery client's class, re-exported from this\n * package) is the one exception: it passes through undisturbed so callers\n * can route it to their framework's 404 idiom, per the existing\n * distinguishable-404 contract.\n *\n * `environmentId` is `undefined` for the destination-shaped `fetchExperience`\n * branches — the destinations delivery endpoints are space-scoped only, with\n * no environment segment, unlike the by-id path.\n */\nexport class ExperienceFetchError extends Error {\n readonly spaceId: string;\n readonly environmentId: string | undefined;\n readonly experienceId: string;\n\n constructor(\n message: string,\n options: {\n spaceId: string;\n environmentId?: string;\n experienceId: string;\n cause?: unknown;\n }\n ) {\n super(message, options.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = 'ExperienceFetchError';\n this.spaceId = options.spaceId;\n this.environmentId = options.environmentId;\n this.experienceId = options.experienceId;\n }\n}\n\n/**\n * Thrown by `fetchExperience` and `fetchDestinationSitemap` when\n * `clientOptions.preview` is `true` for a destination-shaped call\n * (`destinationId` + `nodeId`/`path`, or a sitemap fetch). The Destinations\n * Delivery API has no preview host or preview-token support yet, so this\n * guards against silently hitting the production host with a preview token\n * it doesn't accept.\n *\n * This is a bridge, not a permanent design: revisit once the platform ships\n * preview support for destinations.\n *\n * Only fires for the inline-credentials branch of `ClientOptions`. A\n * caller-supplied `{ client }` already ignores `preview` entirely, per that\n * branch's existing contract.\n */\nexport class DestinationPreviewNotSupportedError extends Error {\n readonly spaceId: string;\n readonly destinationId: string;\n readonly nodeId: string | undefined;\n readonly path: string | undefined;\n\n constructor(\n message: string,\n options: { spaceId: string; destinationId: string; nodeId?: string; path?: string }\n ) {\n super(message);\n this.name = 'DestinationPreviewNotSupportedError';\n this.spaceId = options.spaceId;\n this.destinationId = options.destinationId;\n this.nodeId = options.nodeId;\n this.path = options.path;\n }\n}\n","import { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { createUserAgentHeaders, EXPERIENCES_CLIENT_SDK } from './user-agent.js';\n\n/** Options for the legacy functional Delivery client constructor. */\nexport type CreateClientOptions = {\n accessToken: string;\n /**\n * Base URL for the delivery client. Defaults to `DELIVERY_HOST` when omitted.\n * Pass `PREVIEW_HOST` for preview mode, or any custom URL (staging, proxy,\n * per-region). Both constants are exported from this package.\n */\n host?: string;\n} & Omit<ContentfulViewDeliveryClient.Options, 'token' | 'baseUrl'>;\n\nexport function createClient(options: CreateClientOptions): ContentfulViewDeliveryClient {\n const { accessToken, host, headers, ...rest } = options;\n return new ContentfulViewDeliveryClient({\n ...rest,\n headers: { ...createUserAgentHeaders(EXPERIENCES_CLIENT_SDK), ...headers },\n token: accessToken,\n baseUrl: host,\n });\n}\n","declare const __EXPERIENCES_CLIENT_NAME__: string | undefined;\ndeclare const __EXPERIENCES_CLIENT_VERSION__: string | undefined;\n\n/** Header the Contentful JS SDKs use to report SDK identity, platform, and OS. */\nexport const USER_AGENT_HEADER = 'X-Contentful-User-Agent';\n\n/** Package identity reported in the user-agent header. */\nexport type SdkIdentity = { name: string; version: string };\n\n/**\n * Identity of this package. Build artifacts receive package metadata through\n * tsup defines; source execution (including tests) uses stable fallbacks.\n */\nexport const EXPERIENCES_CLIENT_SDK: SdkIdentity = {\n name:\n typeof __EXPERIENCES_CLIENT_NAME__ === 'string'\n ? __EXPERIENCES_CLIENT_NAME__\n : '@contentful/experiences-client',\n version:\n typeof __EXPERIENCES_CLIENT_VERSION__ === 'string' ? __EXPERIENCES_CLIENT_VERSION__ : '0.0.0',\n};\n\n// Ported from contentful-sdk-core `src/get-user-agent.ts` and `src/utils.ts` so\n// the header matches contentful.js. `process` is read from `globalThis` instead\n// of importing the `process` polyfill.\n\ntype NodeProcess = {\n browser?: boolean;\n platform?: string;\n version?: string;\n versions?: { node?: string };\n};\n\nfunction getProcess(): NodeProcess | undefined {\n return (globalThis as { process?: NodeProcess }).process;\n}\n\nfunction isNode(): boolean {\n // Polyfills of `process` might set `process.browser === true`.\n const process = getProcess();\n return typeof process !== 'undefined' && !process.browser;\n}\n\nfunction isReactNative(): boolean {\n return (\n typeof window !== 'undefined' &&\n 'navigator' in window &&\n 'product' in window.navigator &&\n window.navigator.product === 'ReactNative'\n );\n}\n\nfunction getNodeVersion(): string | undefined {\n const process = getProcess();\n return process?.versions?.node ? `v${process.versions.node}` : process?.version;\n}\n\nfunction getBrowserOS(): string | null {\n if (typeof window === 'undefined') {\n return null;\n }\n const userAgent = window.navigator.userAgent;\n // `platform` is deprecated but still the most reliable signal here.\n const platform = window.navigator.platform;\n const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];\n const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];\n const iosPlatforms = ['iPhone', 'iPad', 'iPod'];\n\n if (macosPlatforms.indexOf(platform) !== -1) {\n return 'macOS';\n } else if (iosPlatforms.indexOf(platform) !== -1) {\n return 'iOS';\n } else if (windowsPlatforms.indexOf(platform) !== -1) {\n return 'Windows';\n } else if (/Android/.test(userAgent)) {\n return 'Android';\n } else if (/Linux/.test(platform)) {\n return 'Linux';\n }\n\n return null;\n}\n\ntype PlatformMap = Record<string, 'Android' | 'Linux' | 'Windows' | 'macOS'>;\n\nfunction getNodeOS(): string | null {\n const process = getProcess();\n const platform = process?.platform || 'linux';\n const version = process?.version || '0.0.0';\n const platformMap: PlatformMap = {\n android: 'Android',\n aix: 'Linux',\n darwin: 'macOS',\n freebsd: 'Linux',\n linux: 'Linux',\n openbsd: 'Linux',\n sunos: 'Linux',\n win32: 'Windows',\n };\n if (platform in platformMap) {\n return `${platformMap[platform] || 'Linux'}/${version}`;\n }\n return null;\n}\n\nexport function getUserAgentHeader(\n sdk: string,\n application?: string,\n integration?: string,\n feature?: string\n): string {\n const headerParts = [];\n\n if (application) {\n headerParts.push(`app ${application}`);\n }\n\n if (integration) {\n headerParts.push(`integration ${integration}`);\n }\n\n if (feature) {\n headerParts.push('feature ' + feature);\n }\n\n headerParts.push(`sdk ${sdk}`);\n\n let platform: string | null;\n try {\n if (isReactNative()) {\n platform = getBrowserOS();\n headerParts.push('platform ReactNative');\n } else if (isNode()) {\n platform = getNodeOS();\n headerParts.push(`platform node.js/${getNodeVersion()}`);\n } else {\n platform = getBrowserOS();\n headerParts.push('platform browser');\n }\n } catch {\n platform = null;\n }\n\n if (platform) {\n headerParts.push(`os ${platform}`);\n }\n\n return `${headerParts.filter((item) => item !== '').join('; ')};`;\n}\n\nfunction format({ name, version }: SdkIdentity): string {\n return `${name.replace(/^@contentful\\//, '')}/${version}`;\n}\n\n/**\n * Builds the `X-Contentful-User-Agent` header for Delivery and Preview\n * requests, e.g. `app my-site/1.0.0; sdk experiences-node/0.6.0; platform node.js/v22.17.0; os macOS/v22.17.0;`.\n */\nexport function createUserAgentHeaders(\n sdk: SdkIdentity,\n app?: SdkIdentity\n): Record<string, string> {\n return {\n [USER_AGENT_HEADER]: getUserAgentHeader(format(sdk), app ? format(app) : undefined),\n };\n}\n","import type { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { ContentfulViewDelivery } from '@contentful/experience-delivery';\nimport { serializePersonalization } from './personalization.js';\nimport { createDebugLogger, resolveExperience } from '@contentful/experiences-sdk-core';\nimport type { PortableRenderPlan, ResolverConfig } from '@contentful/experiences-sdk-core';\nimport { assertDestinationPreviewSupported } from './destination-guards.js';\nimport { resolveDeliveryClient, type ClientOptions } from './client-resolution.js';\nimport { ExperienceFetchError } from './errors.js';\nimport { parameterQuery, type ExperienceParameters } from './experience-parameters.js';\nimport {\n toExperiencePayload,\n toExperiencePayloadFromDestination,\n type ExperienceResponse,\n} from './to-experience-payload.js';\n\nexport type { ClientOptions };\n\ntype DeliveryExperienceRequestExtensions =\n ContentfulViewDelivery.GetWithOverridesExperienceRequest.Extensions;\n\nexport type PersonalizationOptions = NonNullable<\n DeliveryExperienceRequestExtensions['personalization']\n>;\n\nexport type ExperienceRequestExtensions = Omit<\n DeliveryExperienceRequestExtensions,\n 'personalization'\n>;\n\nexport type ByIdExperienceOptions = {\n spaceId: string;\n environmentId: string;\n experienceId: string;\n locale?: string;\n /** Values for declared Experience parameters. Refetch with new values to swap content. */\n parameters?: ExperienceParameters;\n /**\n * Profile and events used by XDA to personalize the resolved Experience.\n */\n personalization?: PersonalizationOptions;\n /**\n * Additional XDA request extensions such as source maps. Supplying a defined\n * extension switches the request to POST.\n */\n extensions?: ExperienceRequestExtensions;\n};\n\n/**\n * Resolve an Experience by the Destination Node instead of `experienceId`\n * The destinations delivery endpoints are space-scoped only and have no locale\n * param, unlike the by-id path. Supplying `personalization` switches the\n * request from the cacheable GET to the POST that carries it.\n */\nexport type ByDestinationNodeIdExperienceOptions = {\n spaceId: string;\n destinationId: string;\n nodeId: string;\n /** Profile and events used by XDA to personalize the resolved Experience. */\n personalization?: PersonalizationOptions;\n};\n\n/**\n * Resolve an Experience by the absolute path wired up to a\n * Destination Node, instead of a node id directly. Same scoping as\n * `ByDestinationNodeIdExperienceOptions` — no `environmentId` or `locale`.\n */\nexport type ByDestinationPathExperienceOptions = {\n spaceId: string;\n destinationId: string;\n /** Absolute path to resolve. Must start with `/`. */\n path: string;\n /** Profile and events used by XDA to personalize the resolved Experience. */\n personalization?: PersonalizationOptions;\n};\n\nexport type ExperienceOptions =\n ByIdExperienceOptions | ByDestinationNodeIdExperienceOptions | ByDestinationPathExperienceOptions;\n\n/**\n * A Destination resolution that the app must act on as control flow — honor\n * it by navigating or re-resolving at the new path — rather than a hydrated\n * Experience to render. Modeled as a normal return value, not a thrown error,\n * per the Destinations delivery API's own framing of a redirect response.\n */\nexport interface DestinationRedirectResult {\n redirect: { path: string };\n}\n\nexport type ResolveOptions = {\n config: ResolverConfig;\n /**\n * Arbitrary per-render metadata exposed to every resolver as\n * `ctx.experience.metadata` and readable at render time via the framework\n * adapter's `useExperience()` / `getExperience()`.\n */\n metadata?: Record<string, unknown>;\n /**\n * Observability switch. When on: logs the fetch (host, ids) and the raw\n * payload here, and threads through to `resolveExperience` (resolution steps\n * + `resolveData` timings) and the renderer (visible missing-component box,\n * debug fallback). A single boolean across fetch + resolve + render.\n */\n debug?: boolean;\n};\n\n// TS overload signatures, not real redeclarations — base ESLint's no-redeclare doesn't know the\n// overload form (@typescript-eslint's own version does), so each repeated signature needs a\n// disable comment.\nexport async function fetchExperience(\n experienceOptions: ByIdExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan>;\n// eslint-disable-next-line no-redeclare -- see above\nexport async function fetchExperience(\n experienceOptions: ByDestinationNodeIdExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan | DestinationRedirectResult>;\n// eslint-disable-next-line no-redeclare -- see above\nexport async function fetchExperience(\n experienceOptions: ByDestinationPathExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan | DestinationRedirectResult>;\n// eslint-disable-next-line no-redeclare -- see above\nexport async function fetchExperience(\n experienceOptions: ExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan | DestinationRedirectResult> {\n const { config, metadata, debug } = resolveOptions;\n const log = createDebugLogger(debug, 'client');\n\n if (!('client' in clientOptions) && 'destinationId' in experienceOptions) {\n const { spaceId, destinationId } = experienceOptions;\n const locator =\n 'nodeId' in experienceOptions\n ? { nodeId: experienceOptions.nodeId }\n : { path: experienceOptions.path };\n assertDestinationPreviewSupported(clientOptions.preview, {\n spaceId,\n destinationId,\n ...locator,\n });\n }\n\n const client = resolveDeliveryClient(clientOptions, log, 'fetchExperience');\n\n if ('nodeId' in experienceOptions) {\n const { spaceId, destinationId, nodeId, personalization } = experienceOptions;\n // Serialize before the request so invalid input is a TypeError, as on the by-id path.\n const extensions = destinationExtensions(personalization);\n return fetchByDestination(\n { spaceId, destinationId, locator: nodeId },\n () =>\n extensions === undefined\n ? client.destination.resolveByNodeId(spaceId, destinationId, nodeId)\n : client.destination.resolveByNodeIdWithOverrides(spaceId, destinationId, nodeId, {\n extensions,\n }),\n log,\n { config, metadata, debug }\n );\n }\n\n if ('path' in experienceOptions) {\n const { spaceId, destinationId, path, personalization } = experienceOptions;\n const extensions = destinationExtensions(personalization);\n return fetchByDestination(\n { spaceId, destinationId, locator: path },\n () =>\n client.destination.resolveByPath(spaceId, destinationId, {\n path,\n ...(extensions === undefined ? {} : { extensions }),\n }),\n log,\n { config, metadata, debug }\n );\n }\n\n const { spaceId, environmentId, experienceId, locale, personalization, extensions } =\n experienceOptions;\n\n log.log('fetching experience', {\n spaceId,\n environmentId,\n experienceId,\n locale,\n // avoiding log any personalization sensitive data\n personalization: personalization !== undefined,\n extensions,\n });\n\n const response = await fetchByExperienceId(client, experienceOptions);\n\n const payload = toExperiencePayload(response);\n log.lazy('received raw payload', () => payload);\n\n return resolveExperience(payload, config, { metadata, debug });\n}\n\nasync function fetchByExperienceId(\n client: ContentfulViewDeliveryClient,\n options: ByIdExperienceOptions\n): Promise<ExperienceResponse> {\n const { spaceId, environmentId, experienceId, locale, parameters, personalization, extensions } =\n options;\n const requestExtensions: DeliveryExperienceRequestExtensions = { ...extensions };\n if (personalization !== undefined) {\n requestExtensions.personalization = serializePersonalization(personalization);\n }\n\n try {\n // GET uses namespaced query leaves. POST preserves values that cannot be\n // represented by leaves and carries existing request extensions.\n // The generated delivery client owns the alpha-feature header on both\n // paths, including when the caller supplied the client instance.\n //\n // Await inside the try so rejected requests are normalized below.\n const queryParams = parameterQuery(parameters);\n if (hasRequestExtensions(requestExtensions) || queryParams === undefined) {\n // dev.10's POST serializer passes through extra body keys. Its generated\n // request type omits parameters, so retain our typed extension locally.\n // TODO: Remove this intersection once contentful-experience-delivery.js\n // generates parameters on GetWithOverridesExperienceRequest and we upgrade.\n const request: ContentfulViewDelivery.GetWithOverridesExperienceRequest & {\n parameters?: ExperienceParameters;\n } = {\n locale,\n extensions: requestExtensions,\n ...(parameters === undefined ? {} : { parameters }),\n };\n return await client.experience.getWithOverrides(\n spaceId,\n environmentId,\n experienceId,\n request\n );\n }\n\n if (Object.keys(queryParams).length > 0) {\n return await client.experience.get(\n spaceId,\n environmentId,\n experienceId,\n { locale },\n {\n queryParams,\n }\n );\n }\n return await client.experience.get(spaceId, environmentId, experienceId, { locale });\n } catch (err) {\n // Preserve expected 404 control flow for framework routers. Other failures\n // are wrapped with stable SDK context instead of exposing transport-specific\n // error shapes.\n if (err instanceof ContentfulViewDelivery.NotFoundError) {\n throw err;\n }\n const reason = err instanceof Error ? err.message : String(err);\n throw new ExperienceFetchError(\n `Failed to fetch Experience \"${experienceId}\" (space \"${spaceId}\", environment ` +\n `\"${environmentId}\"): ${reason}. Check network connectivity, the access token, and ` +\n `that the space/environment/experience ids are correct.`,\n { spaceId, environmentId, experienceId, cause: err }\n );\n }\n}\n\n/**\n * Shared response-handling for both destination-shaped `fetchExperience`\n * branches (by node id, by path).\n */\nasync function fetchByDestination(\n identity: { spaceId: string; destinationId: string; locator: string },\n resolve: () => Promise<ContentfulViewDelivery.DestinationExperienceResolutionResponse>,\n log: ReturnType<typeof createDebugLogger>,\n resolveOptions: {\n config: ResolverConfig;\n metadata: Record<string, unknown> | undefined;\n debug: boolean | undefined;\n }\n): Promise<PortableRenderPlan | DestinationRedirectResult> {\n const { spaceId, destinationId, locator } = identity;\n const { config, metadata, debug } = resolveOptions;\n\n log.log('resolving destination experience', { spaceId, destinationId, locator });\n\n let response: ContentfulViewDelivery.DestinationExperienceResolutionResponse;\n try {\n response = await resolve();\n } catch (err) {\n if (err instanceof ContentfulViewDelivery.NotFoundError) {\n throw err;\n }\n const reason = err instanceof Error ? err.message : String(err);\n throw new ExperienceFetchError(\n `Failed to resolve Destination \"${destinationId}\" at \"${locator}\" (space \"${spaceId}\"): ` +\n `${reason}. Check network connectivity, the access token, and that the space/` +\n `destination/node-or-path values are correct.`,\n { spaceId, experienceId: locator, cause: err }\n );\n }\n\n if ('redirect' in response) {\n log.log('destination resolved to a redirect', response.redirect);\n return { redirect: response.redirect };\n }\n\n const [firstExperience] = response.experiences;\n if (!firstExperience) {\n throw new ExperienceFetchError(\n `Destination \"${destinationId}\" resolved \"${locator}\" to zero Experiences ` +\n `(space \"${spaceId}\"). Expected exactly one hydrated Experience or a redirect.`,\n { spaceId, experienceId: locator }\n );\n }\n\n const payload = toExperiencePayloadFromDestination(firstExperience.experience);\n log.lazy('received raw payload', () => payload);\n\n return resolveExperience(payload, config, {\n metadata,\n debug,\n });\n}\n\nfunction destinationExtensions(\n personalization: PersonalizationOptions | undefined\n): ContentfulViewDelivery.DestinationExperiencesExtensions | undefined {\n if (personalization === undefined) return undefined;\n return { personalization: serializePersonalization(personalization) };\n}\n\nfunction hasRequestExtensions(\n extensions: DeliveryExperienceRequestExtensions | undefined\n): extensions is DeliveryExperienceRequestExtensions {\n return (\n extensions !== undefined &&\n Object.values(extensions).some((extension) => extension !== undefined)\n );\n}\n","import type { PersonalizationOptions } from './fetch-experience.js';\n\nconst EVENT_TYPES = ['page', 'track', 'identify', 'screen', 'component'];\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\n/**\n * Validate the envelope of caller-built events and drop what XDA rejects.\n *\n * `@contentful/experience-delivery` no longer ships request schemas (dev.11 removed\n * `./serialization`, AIS-809), so this checks the fields every event shares rather\n * than each event type's full shape.\n */\nexport function serializePersonalization(personalization: unknown): PersonalizationOptions {\n try {\n if (!isRecord(personalization)) throw new Error('Expected an object');\n const { profileId, events } = personalization;\n if (profileId !== undefined && typeof profileId !== 'string') {\n throw new Error('profileId must be a string');\n }\n if (events !== undefined && !Array.isArray(events)) throw new Error('events must be an array');\n return {\n ...(profileId === undefined ? {} : { profileId }),\n ...(events === undefined ? {} : { events: events.map(serializeEvent) }),\n } as PersonalizationOptions;\n } catch (cause) {\n throw new TypeError('Invalid Experience personalization options', { cause });\n }\n}\n\nfunction serializeEvent(event: unknown): unknown {\n if (!isRecord(event) || !EVENT_TYPES.includes(event.type as string)) {\n throw new Error('Unknown event type');\n }\n for (const key of ['channel', 'messageId', 'timestamp']) {\n if (typeof event[key] !== 'string') throw new Error(`${key} must be a string`);\n }\n if (!isRecord(event.context) || !isRecord(event.context.library)) {\n throw new Error('context.library is required');\n }\n // XDA's embedded event schema is narrower than EventBuilder's: it rejects\n // context.gdpr (consent), context.screen and context.page.title. Serialize without them.\n const { gdpr: _gdpr, screen: _screen, page, ...context } = event.context;\n if (!isRecord(page)) return { ...event, context };\n const { title: _title, ...xdaPage } = page;\n return { ...event, context: { ...context, page: xdaPage } };\n}\n","import { DestinationPreviewNotSupportedError } from './errors.js';\n\n/**\n * Throws `DestinationPreviewNotSupportedError` when `clientOptions.preview` is\n * `true` and `experienceOptions` is destination-shaped (a caller-supplied\n * `{ client }` already ignores `preview` entirely, so this only fires for the\n * inline-credentials branch). Shared by `fetchExperience` and\n * `fetchDestinationSitemap` — both call into the same preview-less\n * Destinations Delivery API.\n */\nexport function assertDestinationPreviewSupported(\n isPreview: boolean | undefined,\n destination: { spaceId: string; destinationId: string; nodeId?: string; path?: string }\n): void {\n if (!isPreview) return;\n\n const { spaceId, destinationId, nodeId, path } = destination;\n const locator = nodeId !== undefined ? `nodeId \"${nodeId}\"` : `path \"${path}\"`;\n throw new DestinationPreviewNotSupportedError(\n `preview: true was combined with a destination-shaped call (destinationId ` +\n `\"${destinationId}\", ${locator}). The Destinations Delivery API does not support ` +\n `preview mode yet — pass preview: false (or omit it) for destination-based fetches.`,\n { spaceId, destinationId, nodeId, path }\n );\n}\n","export const DELIVERY_HOST = 'https://xdn.contentful.com';\nexport const PREVIEW_HOST = 'https://preview.xdn.contentful.com';\nexport const PREVIEW_WEBSOCKET_HOST = 'wss://preview.xdn.contentful.com';\n","import type { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { createClient } from './create-delivery-client.js';\nimport { createDebugLogger } from '@contentful/experiences-sdk-core';\nimport { PREVIEW_HOST } from './hosts.js';\n\nexport type ClientOptions =\n | {\n accessToken: string;\n /**\n * Preview access token. Required when calling with `preview: true`.\n */\n previewToken?: string;\n /**\n * Flip between delivery (default) and preview at request time. When\n * `true`, uses `previewToken` and the preview host; when `false` or\n * unset, uses `accessToken` and the delivery host. Ignored when a\n * pre-made `client` is passed instead of inline creds.\n */\n preview?: boolean;\n /**\n * Custom base URL for the delivery client (staging, proxy, per-region).\n * Wins over the `preview`-derived default host — combine `host` with\n * `preview: true` to point preview mode at a non-prod endpoint.\n * Omit for the standard delivery / preview hosts.\n */\n host?: string;\n }\n | { client: ContentfulViewDeliveryClient };\n\n/**\n * Resolve a `ClientOptions` union into a real delivery client. Shared by\n * `fetchExperience` and `fetchDestinationSitemap` — both accept the same\n * inline-creds-or-pre-made-client shape.\n */\nexport function resolveDeliveryClient(\n clientOptions: ClientOptions,\n log: ReturnType<typeof createDebugLogger>,\n callerName: string\n): ContentfulViewDeliveryClient {\n if ('client' in clientOptions) {\n log.log('using caller-supplied delivery client');\n return clientOptions.client;\n }\n\n const { accessToken, previewToken, preview, host } = clientOptions;\n if (preview && !previewToken) {\n throw new Error(`${callerName}() called with preview: true but no previewToken was provided`);\n }\n const resolvedHost = host ?? (preview ? PREVIEW_HOST : undefined);\n const client = createClient({\n accessToken: preview ? (previewToken as string) : accessToken,\n host: resolvedHost,\n });\n log.log('created delivery client', { preview: Boolean(preview), host: resolvedHost });\n return client;\n}\n","/** One collection order path; `-` selects descending order. Delivery validates the path. */\nexport type ExperienceParameterOrder =\n `fields.${string}` | `sys.${string}` | `-fields.${string}` | `-sys.${string}`;\n\n/** Runtime values for one Record parameter. Nested records and arrays are not supported. */\nexport type ExperienceParameterRecord = Record<string, string | number>;\n\nexport type ExperienceParameterValue = string | number | ExperienceParameterRecord;\n\n/** Unprefixed IDs declared in Experience.parameters and referenced as `$parameters/<id>`. */\nexport type ExperienceParameters = Record<string, ExperienceParameterValue>;\n\n/**\n * Flatten values for the generated client's GET queryParams escape hatch.\n * An empty Record cannot be represented by query leaves: preserve it via POST.\n * Delivery owns name, requiredness, fallback and value validation.\n */\nexport function parameterQuery(\n parameters: ExperienceParameters | undefined\n): Record<string, string | number> | undefined {\n const entries: [string, string | number][] = [];\n for (const [id, value] of Object.entries(parameters ?? {})) {\n // A dotted ID could masquerade as another parameter's Record leaf on GET.\n // Preserve the original name on POST and let delivery validate it.\n if (id.includes('.')) return undefined;\n if (typeof value === 'string' || typeof value === 'number') {\n entries.push([`parameter.${id}`, value]);\n } else {\n // Untyped callers can supply other JSON shapes. Use POST so delivery\n // sees their original value rather than a lossy query string coercion.\n if (value === null || typeof value !== 'object' || Array.isArray(value)) return undefined;\n const leaves = Object.entries(value);\n if (leaves.length === 0) return undefined;\n for (const [field, leaf] of leaves) {\n if (field.includes('.')) return undefined;\n if (typeof leaf !== 'string' && typeof leaf !== 'number') return undefined;\n entries.push([`parameter.${id}.${field}`, leaf]);\n }\n }\n }\n return Object.fromEntries(entries);\n}\n","/*\n * Typed narrowing from a delivery-client response to the payload shape the\n * renderer consumes.\n */\n\nimport type { ContentfulViewDelivery } from '@contentful/experience-delivery';\nimport type { ExperiencePayload, ExperienceSourceMap } from '@contentful/experiences-sdk-core';\n\n/** Either shape the experience endpoint can return — `get()` and `getWithOverrides()` share it. */\nexport type ExperienceResponse =\n | ContentfulViewDelivery.GetExperienceResponse\n | ContentfulViewDelivery.GetWithOverridesExperienceResponse;\n\n/**\n * Narrow a delivery response to `ExperiencePayload`.\n *\n * The endpoint types its response as `HydratedView | HydratedExperienceView`.\n * The alpha-feature header the delivery client always sends guarantees the\n * latter, but TypeScript cannot know that, so callers were left casting by hand.\n *\n * `fetchExperience` uses this internally; it is exported for anyone driving the\n * delivery client directly. Type-level only — no validation, no copying.\n *\n * A legacy-shaped response carries `componentType` / `template` links instead;\n * `resolveExperience` reports those through `warnUnrenderableNode`.\n */\nexport function toExperiencePayload(response: ExperienceResponse): ExperiencePayload {\n return response as ContentfulViewDelivery.HydratedExperienceView as ExperiencePayload;\n}\n\n/** Read `extensions.sourceMap` off a response. `undefined` when the request did not opt in. */\nexport function readSourceMap(response: ExperienceResponse): ExperienceSourceMap | undefined {\n const extensions = (response as ContentfulViewDelivery.HydratedExperienceView).extensions;\n return extensions?.sourceMap as ExperienceSourceMap | undefined;\n}\n\n/**\n * Narrow a `ResolvedDestinationExperience.experience` to `ExperiencePayload`.\n *\n * Same cast rationale as `toExperiencePayload` above, for the destination\n * resolution endpoints' `HydratedExperience` shape instead of the by-id\n * endpoints' `HydratedExperienceView`.\n */\nexport function toExperiencePayloadFromDestination(\n experience: ContentfulViewDelivery.HydratedExperience\n): ExperiencePayload {\n return experience as unknown as ExperiencePayload;\n}\n","import { ContentfulViewDelivery } from '@contentful/experience-delivery';\nimport { createDebugLogger } from '@contentful/experiences-sdk-core';\nimport { assertDestinationPreviewSupported } from './destination-guards.js';\nimport { resolveDeliveryClient, type ClientOptions } from './client-resolution.js';\nimport { ExperienceFetchError } from './errors.js';\n\nexport type FetchDestinationSitemapOptions = {\n spaceId: string;\n destinationId: string;\n};\n\nexport type FetchDestinationSitemapPaginationOptions = {\n /** Maximum number of paths to return. Defaults to `100`, maximum `1000`. */\n limit?: number;\n /** Cursor from a previous call's `pages.next`. Treat as opaque; don't combine with `pagePrev`. */\n pageNext?: string;\n /** Cursor from a previous call's `pages.prev`. Treat as opaque; don't combine with `pageNext`. */\n pagePrev?: string;\n};\n\nexport type SitemapPathItem = {\n /** Path this entry routes. */\n path: string;\n /** Flat id extracted from the entry's `experienceUrn`. */\n experienceId: string;\n /** Type of the Destination Node that claims this path, e.g. `\"DestinationExperienceNode\"`. */\n type: string;\n};\n\nexport type DestinationSitemapResult = {\n items: SitemapPathItem[];\n limit: number;\n pages: { next?: string; prev?: string };\n};\n\n/**\n * List every routable path in a published Destination. Bulk enumeration —\n * pairs with `fetchExperience`'s `destinationId` + `nodeId`/`path` branches,\n * which resolve one path at a time. Does not hydrate any Experience itself\n * and does not call `fetchExperience` internally.\n */\nexport async function fetchDestinationSitemap(\n destinationOptions: FetchDestinationSitemapOptions,\n clientOptions: ClientOptions,\n paginationOptions: FetchDestinationSitemapPaginationOptions = {}\n): Promise<DestinationSitemapResult> {\n const { spaceId, destinationId } = destinationOptions;\n const log = createDebugLogger(false, 'client');\n\n if (!('client' in clientOptions)) {\n assertDestinationPreviewSupported(clientOptions.preview, { spaceId, destinationId });\n }\n\n const client = resolveDeliveryClient(clientOptions, log, 'fetchDestinationSitemap');\n\n const { limit, pageNext, pagePrev } = paginationOptions;\n\n let response: ContentfulViewDelivery.DestinationSitemap;\n try {\n response = await client.destination.sitemap(spaceId, destinationId, {\n limit,\n pageNext,\n pagePrev,\n });\n } catch (err) {\n if (err instanceof ContentfulViewDelivery.NotFoundError) {\n throw err;\n }\n const reason = err instanceof Error ? err.message : String(err);\n throw new ExperienceFetchError(\n `Failed to fetch sitemap for Destination \"${destinationId}\" (space \"${spaceId}\"): ` +\n `${reason}. Check network connectivity, the access token, and that the space/` +\n `destination ids are correct.`,\n { spaceId, experienceId: destinationId, cause: err }\n );\n }\n\n const result = {\n items: response.paths.items.map((item) => ({\n path: item.path,\n experienceId: extractIdFromUrn(item.experienceUrn),\n type: item.sys.type,\n })),\n limit: response.paths.limit,\n pages: response.paths.pages,\n };\n\n log.lazy('received sitemap page', () => result);\n\n return result;\n}\n\n/**\n * Extract the flat id from an `experienceUrn`. Real shape:\n * crn:contentful:::experience:spaces/$self/environments/$self/experiences/<id>\n *\n * Same one-line logic as the private `extractIdFromUrn` in\n * `packages/core/src/resolve-experience.ts` — not shared across the\n * `core`/`client` package boundary (core stays zero-dep) for one line.\n */\nfunction extractIdFromUrn(urn: string): string {\n const segments = urn.split('/').filter((s) => s.length > 0);\n return segments[segments.length - 1] ?? urn;\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -120,7 +120,7 @@ type ExperienceParameterValue = string | number | ExperienceParameterRecord;
120
120
  /** Unprefixed IDs declared in Experience.parameters and referenced as `$parameters/<id>`. */
121
121
  type ExperienceParameters = Record<string, ExperienceParameterValue>;
122
122
 
123
- type DeliveryExperienceRequestExtensions = ContentfulViewDelivery.GetWithOverridesExperienceRequestExtensions;
123
+ type DeliveryExperienceRequestExtensions = ContentfulViewDelivery.GetWithOverridesExperienceRequest.Extensions;
124
124
  type PersonalizationOptions = NonNullable<DeliveryExperienceRequestExtensions['personalization']>;
125
125
  type ExperienceRequestExtensions = Omit<DeliveryExperienceRequestExtensions, 'personalization'>;
126
126
  type ByIdExperienceOptions = {
@@ -143,12 +143,15 @@ type ByIdExperienceOptions = {
143
143
  /**
144
144
  * Resolve an Experience by the Destination Node instead of `experienceId`
145
145
  * The destinations delivery endpoints are space-scoped only and have no locale
146
- * param, unlike the by-id path.
146
+ * param, unlike the by-id path. Supplying `personalization` switches the
147
+ * request from the cacheable GET to the POST that carries it.
147
148
  */
148
149
  type ByDestinationNodeIdExperienceOptions = {
149
150
  spaceId: string;
150
151
  destinationId: string;
151
152
  nodeId: string;
153
+ /** Profile and events used by XDA to personalize the resolved Experience. */
154
+ personalization?: PersonalizationOptions;
152
155
  };
153
156
  /**
154
157
  * Resolve an Experience by the absolute path wired up to a
@@ -160,6 +163,8 @@ type ByDestinationPathExperienceOptions = {
160
163
  destinationId: string;
161
164
  /** Absolute path to resolve. Must start with `/`. */
162
165
  path: string;
166
+ /** Profile and events used by XDA to personalize the resolved Experience. */
167
+ personalization?: PersonalizationOptions;
163
168
  };
164
169
  type ExperienceOptions = ByIdExperienceOptions | ByDestinationNodeIdExperienceOptions | ByDestinationPathExperienceOptions;
165
170
  /**
@@ -260,7 +265,13 @@ declare const DELIVERY_HOST = "https://xdn.contentful.com";
260
265
  declare const PREVIEW_HOST = "https://preview.xdn.contentful.com";
261
266
  declare const PREVIEW_WEBSOCKET_HOST = "wss://preview.xdn.contentful.com";
262
267
 
263
- /** Validate and serialize events to the generated XDA request contract. */
268
+ /**
269
+ * Validate the envelope of caller-built events and drop what XDA rejects.
270
+ *
271
+ * `@contentful/experience-delivery` no longer ships request schemas (dev.11 removed
272
+ * `./serialization`, AIS-809), so this checks the fields every event shares rather
273
+ * than each event type's full shape.
274
+ */
264
275
  declare function serializePersonalization(personalization: unknown): PersonalizationOptions;
265
276
 
266
277
  declare const NotFoundError: typeof ContentfulViewDelivery.NotFoundError;
package/dist/index.d.mts CHANGED
@@ -120,7 +120,7 @@ type ExperienceParameterValue = string | number | ExperienceParameterRecord;
120
120
  /** Unprefixed IDs declared in Experience.parameters and referenced as `$parameters/<id>`. */
121
121
  type ExperienceParameters = Record<string, ExperienceParameterValue>;
122
122
 
123
- type DeliveryExperienceRequestExtensions = ContentfulViewDelivery.GetWithOverridesExperienceRequestExtensions;
123
+ type DeliveryExperienceRequestExtensions = ContentfulViewDelivery.GetWithOverridesExperienceRequest.Extensions;
124
124
  type PersonalizationOptions = NonNullable<DeliveryExperienceRequestExtensions['personalization']>;
125
125
  type ExperienceRequestExtensions = Omit<DeliveryExperienceRequestExtensions, 'personalization'>;
126
126
  type ByIdExperienceOptions = {
@@ -143,12 +143,15 @@ type ByIdExperienceOptions = {
143
143
  /**
144
144
  * Resolve an Experience by the Destination Node instead of `experienceId`
145
145
  * The destinations delivery endpoints are space-scoped only and have no locale
146
- * param, unlike the by-id path.
146
+ * param, unlike the by-id path. Supplying `personalization` switches the
147
+ * request from the cacheable GET to the POST that carries it.
147
148
  */
148
149
  type ByDestinationNodeIdExperienceOptions = {
149
150
  spaceId: string;
150
151
  destinationId: string;
151
152
  nodeId: string;
153
+ /** Profile and events used by XDA to personalize the resolved Experience. */
154
+ personalization?: PersonalizationOptions;
152
155
  };
153
156
  /**
154
157
  * Resolve an Experience by the absolute path wired up to a
@@ -160,6 +163,8 @@ type ByDestinationPathExperienceOptions = {
160
163
  destinationId: string;
161
164
  /** Absolute path to resolve. Must start with `/`. */
162
165
  path: string;
166
+ /** Profile and events used by XDA to personalize the resolved Experience. */
167
+ personalization?: PersonalizationOptions;
163
168
  };
164
169
  type ExperienceOptions = ByIdExperienceOptions | ByDestinationNodeIdExperienceOptions | ByDestinationPathExperienceOptions;
165
170
  /**
@@ -260,7 +265,13 @@ declare const DELIVERY_HOST = "https://xdn.contentful.com";
260
265
  declare const PREVIEW_HOST = "https://preview.xdn.contentful.com";
261
266
  declare const PREVIEW_WEBSOCKET_HOST = "wss://preview.xdn.contentful.com";
262
267
 
263
- /** Validate and serialize events to the generated XDA request contract. */
268
+ /**
269
+ * Validate the envelope of caller-built events and drop what XDA rejects.
270
+ *
271
+ * `@contentful/experience-delivery` no longer ships request schemas (dev.11 removed
272
+ * `./serialization`, AIS-809), so this checks the fields every event shares rather
273
+ * than each event type's full shape.
274
+ */
264
275
  declare function serializePersonalization(personalization: unknown): PersonalizationOptions;
265
276
 
266
277
  declare const NotFoundError: typeof ContentfulViewDelivery.NotFoundError;
package/dist/index.d.ts CHANGED
@@ -120,7 +120,7 @@ type ExperienceParameterValue = string | number | ExperienceParameterRecord;
120
120
  /** Unprefixed IDs declared in Experience.parameters and referenced as `$parameters/<id>`. */
121
121
  type ExperienceParameters = Record<string, ExperienceParameterValue>;
122
122
 
123
- type DeliveryExperienceRequestExtensions = ContentfulViewDelivery.GetWithOverridesExperienceRequestExtensions;
123
+ type DeliveryExperienceRequestExtensions = ContentfulViewDelivery.GetWithOverridesExperienceRequest.Extensions;
124
124
  type PersonalizationOptions = NonNullable<DeliveryExperienceRequestExtensions['personalization']>;
125
125
  type ExperienceRequestExtensions = Omit<DeliveryExperienceRequestExtensions, 'personalization'>;
126
126
  type ByIdExperienceOptions = {
@@ -143,12 +143,15 @@ type ByIdExperienceOptions = {
143
143
  /**
144
144
  * Resolve an Experience by the Destination Node instead of `experienceId`
145
145
  * The destinations delivery endpoints are space-scoped only and have no locale
146
- * param, unlike the by-id path.
146
+ * param, unlike the by-id path. Supplying `personalization` switches the
147
+ * request from the cacheable GET to the POST that carries it.
147
148
  */
148
149
  type ByDestinationNodeIdExperienceOptions = {
149
150
  spaceId: string;
150
151
  destinationId: string;
151
152
  nodeId: string;
153
+ /** Profile and events used by XDA to personalize the resolved Experience. */
154
+ personalization?: PersonalizationOptions;
152
155
  };
153
156
  /**
154
157
  * Resolve an Experience by the absolute path wired up to a
@@ -160,6 +163,8 @@ type ByDestinationPathExperienceOptions = {
160
163
  destinationId: string;
161
164
  /** Absolute path to resolve. Must start with `/`. */
162
165
  path: string;
166
+ /** Profile and events used by XDA to personalize the resolved Experience. */
167
+ personalization?: PersonalizationOptions;
163
168
  };
164
169
  type ExperienceOptions = ByIdExperienceOptions | ByDestinationNodeIdExperienceOptions | ByDestinationPathExperienceOptions;
165
170
  /**
@@ -260,7 +265,13 @@ declare const DELIVERY_HOST = "https://xdn.contentful.com";
260
265
  declare const PREVIEW_HOST = "https://preview.xdn.contentful.com";
261
266
  declare const PREVIEW_WEBSOCKET_HOST = "wss://preview.xdn.contentful.com";
262
267
 
263
- /** Validate and serialize events to the generated XDA request contract. */
268
+ /**
269
+ * Validate the envelope of caller-built events and drop what XDA rejects.
270
+ *
271
+ * `@contentful/experience-delivery` no longer ships request schemas (dev.11 removed
272
+ * `./serialization`, AIS-809), so this checks the fields every event shares rather
273
+ * than each event type's full shape.
274
+ */
264
275
  declare function serializePersonalization(personalization: unknown): PersonalizationOptions;
265
276
 
266
277
  declare const NotFoundError: typeof ContentfulViewDelivery.NotFoundError;
package/dist/index.js CHANGED
@@ -40,7 +40,7 @@ import { ContentfulViewDeliveryClient } from "@contentful/experience-delivery";
40
40
  var USER_AGENT_HEADER = "X-Contentful-User-Agent";
41
41
  var EXPERIENCES_CLIENT_SDK = {
42
42
  name: true ? "@contentful/experiences-client" : "@contentful/experiences-client",
43
- version: true ? "0.10.9" : "0.0.0"
43
+ version: true ? "0.10.10" : "0.0.0"
44
44
  };
45
45
  function getProcess() {
46
46
  return globalThis.process;
@@ -153,16 +153,39 @@ function createClient(options) {
153
153
  import { ContentfulViewDelivery } from "@contentful/experience-delivery";
154
154
 
155
155
  // src/personalization.ts
156
- import { GetWithOverridesExperienceRequestExtensionsPersonalization as personalizationSchema } from "@contentful/experience-delivery/serialization";
156
+ var EVENT_TYPES = ["page", "track", "identify", "screen", "component"];
157
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
157
158
  function serializePersonalization(personalization) {
158
159
  try {
159
- return personalizationSchema.parseOrThrow(personalization, {
160
- unrecognizedObjectKeys: "strip"
161
- });
160
+ if (!isRecord(personalization)) throw new Error("Expected an object");
161
+ const { profileId, events } = personalization;
162
+ if (profileId !== void 0 && typeof profileId !== "string") {
163
+ throw new Error("profileId must be a string");
164
+ }
165
+ if (events !== void 0 && !Array.isArray(events)) throw new Error("events must be an array");
166
+ return {
167
+ ...profileId === void 0 ? {} : { profileId },
168
+ ...events === void 0 ? {} : { events: events.map(serializeEvent) }
169
+ };
162
170
  } catch (cause) {
163
171
  throw new TypeError("Invalid Experience personalization options", { cause });
164
172
  }
165
173
  }
174
+ function serializeEvent(event) {
175
+ if (!isRecord(event) || !EVENT_TYPES.includes(event.type)) {
176
+ throw new Error("Unknown event type");
177
+ }
178
+ for (const key of ["channel", "messageId", "timestamp"]) {
179
+ if (typeof event[key] !== "string") throw new Error(`${key} must be a string`);
180
+ }
181
+ if (!isRecord(event.context) || !isRecord(event.context.library)) {
182
+ throw new Error("context.library is required");
183
+ }
184
+ const { gdpr: _gdpr, screen: _screen, page, ...context } = event.context;
185
+ if (!isRecord(page)) return { ...event, context };
186
+ const { title: _title, ...xdaPage } = page;
187
+ return { ...event, context: { ...context, page: xdaPage } };
188
+ }
166
189
 
167
190
  // src/fetch-experience.ts
168
191
  import { createDebugLogger, resolveExperience } from "@contentful/experiences-sdk-core";
@@ -250,19 +273,26 @@ async function fetchExperience(experienceOptions, clientOptions, resolveOptions)
250
273
  }
251
274
  const client = resolveDeliveryClient(clientOptions, log, "fetchExperience");
252
275
  if ("nodeId" in experienceOptions) {
253
- const { spaceId: spaceId2, destinationId, nodeId } = experienceOptions;
276
+ const { spaceId: spaceId2, destinationId, nodeId, personalization: personalization2 } = experienceOptions;
277
+ const extensions2 = destinationExtensions(personalization2);
254
278
  return fetchByDestination(
255
279
  { spaceId: spaceId2, destinationId, locator: nodeId },
256
- () => client.destination.resolveByNodeId(spaceId2, destinationId, nodeId),
280
+ () => extensions2 === void 0 ? client.destination.resolveByNodeId(spaceId2, destinationId, nodeId) : client.destination.resolveByNodeIdWithOverrides(spaceId2, destinationId, nodeId, {
281
+ extensions: extensions2
282
+ }),
257
283
  log,
258
284
  { config, metadata, debug }
259
285
  );
260
286
  }
261
287
  if ("path" in experienceOptions) {
262
- const { spaceId: spaceId2, destinationId, path } = experienceOptions;
288
+ const { spaceId: spaceId2, destinationId, path, personalization: personalization2 } = experienceOptions;
289
+ const extensions2 = destinationExtensions(personalization2);
263
290
  return fetchByDestination(
264
291
  { spaceId: spaceId2, destinationId, locator: path },
265
- () => client.destination.resolveByPath(spaceId2, destinationId, { path }),
292
+ () => client.destination.resolveByPath(spaceId2, destinationId, {
293
+ path,
294
+ ...extensions2 === void 0 ? {} : { extensions: extensions2 }
295
+ }),
266
296
  log,
267
297
  { config, metadata, debug }
268
298
  );
@@ -361,6 +391,10 @@ async function fetchByDestination(identity, resolve, log, resolveOptions) {
361
391
  debug
362
392
  });
363
393
  }
394
+ function destinationExtensions(personalization) {
395
+ if (personalization === void 0) return void 0;
396
+ return { personalization: serializePersonalization(personalization) };
397
+ }
364
398
  function hasRequestExtensions(extensions) {
365
399
  return extensions !== void 0 && Object.values(extensions).some((extension) => extension !== void 0);
366
400
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/create-delivery-client.ts","../src/user-agent.ts","../src/fetch-experience.ts","../src/personalization.ts","../src/destination-guards.ts","../src/hosts.ts","../src/client-resolution.ts","../src/experience-parameters.ts","../src/to-experience-payload.ts","../src/fetch-destination-sitemap.ts"],"sourcesContent":["import { ContentfulViewDelivery } from '@contentful/experience-delivery';\n\nexport {\n ContentfulViewDelivery,\n ContentfulViewDeliveryClient,\n} from '@contentful/experience-delivery';\nexport const NotFoundError = ContentfulViewDelivery.NotFoundError;\n// eslint-disable-next-line no-redeclare -- value + type share a name across separate TS namespaces, not a real redeclaration\nexport type NotFoundError = InstanceType<typeof ContentfulViewDelivery.NotFoundError>;\nexport { ExperienceFetchError, DestinationPreviewNotSupportedError } from './errors.js';\nexport { createClient } from './create-delivery-client.js';\nexport type { CreateClientOptions } from './create-delivery-client.js';\nexport { createUserAgentHeaders, EXPERIENCES_CLIENT_SDK, USER_AGENT_HEADER } from './user-agent.js';\nexport type { SdkIdentity } from './user-agent.js';\nexport { fetchExperience } from './fetch-experience.js';\nexport { fetchDestinationSitemap } from './fetch-destination-sitemap.js';\nexport type {\n FetchDestinationSitemapOptions,\n FetchDestinationSitemapPaginationOptions,\n SitemapPathItem,\n DestinationSitemapResult,\n} from './fetch-destination-sitemap.js';\nexport {\n readSourceMap,\n toExperiencePayload,\n toExperiencePayloadFromDestination,\n} from './to-experience-payload.js';\nexport type { ExperienceResponse } from './to-experience-payload.js';\nexport type {\n ExperienceOptions,\n ExperienceRequestExtensions,\n PersonalizationOptions,\n ByIdExperienceOptions,\n ByDestinationNodeIdExperienceOptions,\n ByDestinationPathExperienceOptions,\n ClientOptions,\n ResolveOptions,\n DestinationRedirectResult,\n} from './fetch-experience.js';\nexport { DELIVERY_HOST, PREVIEW_HOST, PREVIEW_WEBSOCKET_HOST } from './hosts.js';\nexport type {\n ExperienceParameters,\n ExperienceParameterValue,\n ExperienceParameterRecord,\n ExperienceParameterOrder,\n} from './experience-parameters.js';\nexport { serializePersonalization } from './personalization.js';\n","/**\n * Thrown by `fetchExperience` for a fetch failure that is not \"experience not\n * found\" — network failure, an invalid/expired token, a 5xx from the\n * delivery API, etc. This failure mode is \"surface clearly to the host app,\"\n * unlike the diagnostics `resolveExperience` collects for resolve/render-time\n * issues — there's no partial payload to render around a fetch that never\n * returned one, so a real thrown class is the right shape.\n *\n * `NotFoundError` (the delivery client's class, re-exported from this\n * package) is the one exception: it passes through undisturbed so callers\n * can route it to their framework's 404 idiom, per the existing\n * distinguishable-404 contract.\n *\n * `environmentId` is `undefined` for the destination-shaped `fetchExperience`\n * branches — the destinations delivery endpoints are space-scoped only, with\n * no environment segment, unlike the by-id path.\n */\nexport class ExperienceFetchError extends Error {\n readonly spaceId: string;\n readonly environmentId: string | undefined;\n readonly experienceId: string;\n\n constructor(\n message: string,\n options: {\n spaceId: string;\n environmentId?: string;\n experienceId: string;\n cause?: unknown;\n }\n ) {\n super(message, options.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = 'ExperienceFetchError';\n this.spaceId = options.spaceId;\n this.environmentId = options.environmentId;\n this.experienceId = options.experienceId;\n }\n}\n\n/**\n * Thrown by `fetchExperience` and `fetchDestinationSitemap` when\n * `clientOptions.preview` is `true` for a destination-shaped call\n * (`destinationId` + `nodeId`/`path`, or a sitemap fetch). The Destinations\n * Delivery API has no preview host or preview-token support yet, so this\n * guards against silently hitting the production host with a preview token\n * it doesn't accept.\n *\n * This is a bridge, not a permanent design: revisit once the platform ships\n * preview support for destinations.\n *\n * Only fires for the inline-credentials branch of `ClientOptions`. A\n * caller-supplied `{ client }` already ignores `preview` entirely, per that\n * branch's existing contract.\n */\nexport class DestinationPreviewNotSupportedError extends Error {\n readonly spaceId: string;\n readonly destinationId: string;\n readonly nodeId: string | undefined;\n readonly path: string | undefined;\n\n constructor(\n message: string,\n options: { spaceId: string; destinationId: string; nodeId?: string; path?: string }\n ) {\n super(message);\n this.name = 'DestinationPreviewNotSupportedError';\n this.spaceId = options.spaceId;\n this.destinationId = options.destinationId;\n this.nodeId = options.nodeId;\n this.path = options.path;\n }\n}\n","import { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { createUserAgentHeaders, EXPERIENCES_CLIENT_SDK } from './user-agent.js';\n\n/** Options for the legacy functional Delivery client constructor. */\nexport type CreateClientOptions = {\n accessToken: string;\n /**\n * Base URL for the delivery client. Defaults to `DELIVERY_HOST` when omitted.\n * Pass `PREVIEW_HOST` for preview mode, or any custom URL (staging, proxy,\n * per-region). Both constants are exported from this package.\n */\n host?: string;\n} & Omit<ContentfulViewDeliveryClient.Options, 'token' | 'baseUrl'>;\n\nexport function createClient(options: CreateClientOptions): ContentfulViewDeliveryClient {\n const { accessToken, host, headers, ...rest } = options;\n return new ContentfulViewDeliveryClient({\n ...rest,\n headers: { ...createUserAgentHeaders(EXPERIENCES_CLIENT_SDK), ...headers },\n token: accessToken,\n baseUrl: host,\n });\n}\n","declare const __EXPERIENCES_CLIENT_NAME__: string | undefined;\ndeclare const __EXPERIENCES_CLIENT_VERSION__: string | undefined;\n\n/** Header the Contentful JS SDKs use to report SDK identity, platform, and OS. */\nexport const USER_AGENT_HEADER = 'X-Contentful-User-Agent';\n\n/** Package identity reported in the user-agent header. */\nexport type SdkIdentity = { name: string; version: string };\n\n/**\n * Identity of this package. Build artifacts receive package metadata through\n * tsup defines; source execution (including tests) uses stable fallbacks.\n */\nexport const EXPERIENCES_CLIENT_SDK: SdkIdentity = {\n name:\n typeof __EXPERIENCES_CLIENT_NAME__ === 'string'\n ? __EXPERIENCES_CLIENT_NAME__\n : '@contentful/experiences-client',\n version:\n typeof __EXPERIENCES_CLIENT_VERSION__ === 'string' ? __EXPERIENCES_CLIENT_VERSION__ : '0.0.0',\n};\n\n// Ported from contentful-sdk-core `src/get-user-agent.ts` and `src/utils.ts` so\n// the header matches contentful.js. `process` is read from `globalThis` instead\n// of importing the `process` polyfill.\n\ntype NodeProcess = {\n browser?: boolean;\n platform?: string;\n version?: string;\n versions?: { node?: string };\n};\n\nfunction getProcess(): NodeProcess | undefined {\n return (globalThis as { process?: NodeProcess }).process;\n}\n\nfunction isNode(): boolean {\n // Polyfills of `process` might set `process.browser === true`.\n const process = getProcess();\n return typeof process !== 'undefined' && !process.browser;\n}\n\nfunction isReactNative(): boolean {\n return (\n typeof window !== 'undefined' &&\n 'navigator' in window &&\n 'product' in window.navigator &&\n window.navigator.product === 'ReactNative'\n );\n}\n\nfunction getNodeVersion(): string | undefined {\n const process = getProcess();\n return process?.versions?.node ? `v${process.versions.node}` : process?.version;\n}\n\nfunction getBrowserOS(): string | null {\n if (typeof window === 'undefined') {\n return null;\n }\n const userAgent = window.navigator.userAgent;\n // `platform` is deprecated but still the most reliable signal here.\n const platform = window.navigator.platform;\n const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];\n const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];\n const iosPlatforms = ['iPhone', 'iPad', 'iPod'];\n\n if (macosPlatforms.indexOf(platform) !== -1) {\n return 'macOS';\n } else if (iosPlatforms.indexOf(platform) !== -1) {\n return 'iOS';\n } else if (windowsPlatforms.indexOf(platform) !== -1) {\n return 'Windows';\n } else if (/Android/.test(userAgent)) {\n return 'Android';\n } else if (/Linux/.test(platform)) {\n return 'Linux';\n }\n\n return null;\n}\n\ntype PlatformMap = Record<string, 'Android' | 'Linux' | 'Windows' | 'macOS'>;\n\nfunction getNodeOS(): string | null {\n const process = getProcess();\n const platform = process?.platform || 'linux';\n const version = process?.version || '0.0.0';\n const platformMap: PlatformMap = {\n android: 'Android',\n aix: 'Linux',\n darwin: 'macOS',\n freebsd: 'Linux',\n linux: 'Linux',\n openbsd: 'Linux',\n sunos: 'Linux',\n win32: 'Windows',\n };\n if (platform in platformMap) {\n return `${platformMap[platform] || 'Linux'}/${version}`;\n }\n return null;\n}\n\nexport function getUserAgentHeader(\n sdk: string,\n application?: string,\n integration?: string,\n feature?: string\n): string {\n const headerParts = [];\n\n if (application) {\n headerParts.push(`app ${application}`);\n }\n\n if (integration) {\n headerParts.push(`integration ${integration}`);\n }\n\n if (feature) {\n headerParts.push('feature ' + feature);\n }\n\n headerParts.push(`sdk ${sdk}`);\n\n let platform: string | null;\n try {\n if (isReactNative()) {\n platform = getBrowserOS();\n headerParts.push('platform ReactNative');\n } else if (isNode()) {\n platform = getNodeOS();\n headerParts.push(`platform node.js/${getNodeVersion()}`);\n } else {\n platform = getBrowserOS();\n headerParts.push('platform browser');\n }\n } catch {\n platform = null;\n }\n\n if (platform) {\n headerParts.push(`os ${platform}`);\n }\n\n return `${headerParts.filter((item) => item !== '').join('; ')};`;\n}\n\nfunction format({ name, version }: SdkIdentity): string {\n return `${name.replace(/^@contentful\\//, '')}/${version}`;\n}\n\n/**\n * Builds the `X-Contentful-User-Agent` header for Delivery and Preview\n * requests, e.g. `app my-site/1.0.0; sdk experiences-node/0.6.0; platform node.js/v22.17.0; os macOS/v22.17.0;`.\n */\nexport function createUserAgentHeaders(\n sdk: SdkIdentity,\n app?: SdkIdentity\n): Record<string, string> {\n return {\n [USER_AGENT_HEADER]: getUserAgentHeader(format(sdk), app ? format(app) : undefined),\n };\n}\n","import type { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { ContentfulViewDelivery } from '@contentful/experience-delivery';\nimport { serializePersonalization } from './personalization.js';\nimport { createDebugLogger, resolveExperience } from '@contentful/experiences-sdk-core';\nimport type { PortableRenderPlan, ResolverConfig } from '@contentful/experiences-sdk-core';\nimport { assertDestinationPreviewSupported } from './destination-guards.js';\nimport { resolveDeliveryClient, type ClientOptions } from './client-resolution.js';\nimport { ExperienceFetchError } from './errors.js';\nimport { parameterQuery, type ExperienceParameters } from './experience-parameters.js';\nimport {\n toExperiencePayload,\n toExperiencePayloadFromDestination,\n type ExperienceResponse,\n} from './to-experience-payload.js';\n\nexport type { ClientOptions };\n\ntype DeliveryExperienceRequestExtensions =\n ContentfulViewDelivery.GetWithOverridesExperienceRequestExtensions;\n\nexport type PersonalizationOptions = NonNullable<\n DeliveryExperienceRequestExtensions['personalization']\n>;\n\nexport type ExperienceRequestExtensions = Omit<\n DeliveryExperienceRequestExtensions,\n 'personalization'\n>;\n\nexport type ByIdExperienceOptions = {\n spaceId: string;\n environmentId: string;\n experienceId: string;\n locale?: string;\n /** Values for declared Experience parameters. Refetch with new values to swap content. */\n parameters?: ExperienceParameters;\n /**\n * Profile and events used by XDA to personalize the resolved Experience.\n */\n personalization?: PersonalizationOptions;\n /**\n * Additional XDA request extensions such as source maps. Supplying a defined\n * extension switches the request to POST.\n */\n extensions?: ExperienceRequestExtensions;\n};\n\n/**\n * Resolve an Experience by the Destination Node instead of `experienceId`\n * The destinations delivery endpoints are space-scoped only and have no locale\n * param, unlike the by-id path.\n */\nexport type ByDestinationNodeIdExperienceOptions = {\n spaceId: string;\n destinationId: string;\n nodeId: string;\n};\n\n/**\n * Resolve an Experience by the absolute path wired up to a\n * Destination Node, instead of a node id directly. Same scoping as\n * `ByDestinationNodeIdExperienceOptions` — no `environmentId` or `locale`.\n */\nexport type ByDestinationPathExperienceOptions = {\n spaceId: string;\n destinationId: string;\n /** Absolute path to resolve. Must start with `/`. */\n path: string;\n};\n\nexport type ExperienceOptions =\n ByIdExperienceOptions | ByDestinationNodeIdExperienceOptions | ByDestinationPathExperienceOptions;\n\n/**\n * A Destination resolution that the app must act on as control flow — honor\n * it by navigating or re-resolving at the new path — rather than a hydrated\n * Experience to render. Modeled as a normal return value, not a thrown error,\n * per the Destinations delivery API's own framing of a redirect response.\n */\nexport interface DestinationRedirectResult {\n redirect: { path: string };\n}\n\nexport type ResolveOptions = {\n config: ResolverConfig;\n /**\n * Arbitrary per-render metadata exposed to every resolver as\n * `ctx.experience.metadata` and readable at render time via the framework\n * adapter's `useExperience()` / `getExperience()`.\n */\n metadata?: Record<string, unknown>;\n /**\n * Observability switch. When on: logs the fetch (host, ids) and the raw\n * payload here, and threads through to `resolveExperience` (resolution steps\n * + `resolveData` timings) and the renderer (visible missing-component box,\n * debug fallback). A single boolean across fetch + resolve + render.\n */\n debug?: boolean;\n};\n\n// TS overload signatures, not real redeclarations — base ESLint's no-redeclare doesn't know the\n// overload form (@typescript-eslint's own version does), so each repeated signature needs a\n// disable comment.\nexport async function fetchExperience(\n experienceOptions: ByIdExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan>;\n// eslint-disable-next-line no-redeclare -- see above\nexport async function fetchExperience(\n experienceOptions: ByDestinationNodeIdExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan | DestinationRedirectResult>;\n// eslint-disable-next-line no-redeclare -- see above\nexport async function fetchExperience(\n experienceOptions: ByDestinationPathExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan | DestinationRedirectResult>;\n// eslint-disable-next-line no-redeclare -- see above\nexport async function fetchExperience(\n experienceOptions: ExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan | DestinationRedirectResult> {\n const { config, metadata, debug } = resolveOptions;\n const log = createDebugLogger(debug, 'client');\n\n if (!('client' in clientOptions) && 'destinationId' in experienceOptions) {\n const { spaceId, destinationId } = experienceOptions;\n const locator =\n 'nodeId' in experienceOptions\n ? { nodeId: experienceOptions.nodeId }\n : { path: experienceOptions.path };\n assertDestinationPreviewSupported(clientOptions.preview, {\n spaceId,\n destinationId,\n ...locator,\n });\n }\n\n const client = resolveDeliveryClient(clientOptions, log, 'fetchExperience');\n\n if ('nodeId' in experienceOptions) {\n const { spaceId, destinationId, nodeId } = experienceOptions;\n return fetchByDestination(\n { spaceId, destinationId, locator: nodeId },\n () => client.destination.resolveByNodeId(spaceId, destinationId, nodeId),\n log,\n { config, metadata, debug }\n );\n }\n\n if ('path' in experienceOptions) {\n const { spaceId, destinationId, path } = experienceOptions;\n return fetchByDestination(\n { spaceId, destinationId, locator: path },\n () => client.destination.resolveByPath(spaceId, destinationId, { path }),\n log,\n { config, metadata, debug }\n );\n }\n\n const { spaceId, environmentId, experienceId, locale, personalization, extensions } =\n experienceOptions;\n\n log.log('fetching experience', {\n spaceId,\n environmentId,\n experienceId,\n locale,\n // avoiding log any personalization sensitive data\n personalization: personalization !== undefined,\n extensions,\n });\n\n const response = await fetchByExperienceId(client, experienceOptions);\n\n const payload = toExperiencePayload(response);\n log.lazy('received raw payload', () => payload);\n\n return resolveExperience(payload, config, { metadata, debug });\n}\n\nasync function fetchByExperienceId(\n client: ContentfulViewDeliveryClient,\n options: ByIdExperienceOptions\n): Promise<ExperienceResponse> {\n const { spaceId, environmentId, experienceId, locale, parameters, personalization, extensions } =\n options;\n const requestExtensions: DeliveryExperienceRequestExtensions = { ...extensions };\n if (personalization !== undefined) {\n requestExtensions.personalization = serializePersonalization(personalization);\n }\n\n try {\n // GET uses namespaced query leaves. POST preserves values that cannot be\n // represented by leaves and carries existing request extensions.\n // The generated delivery client owns the alpha-feature header on both\n // paths, including when the caller supplied the client instance.\n //\n // Await inside the try so rejected requests are normalized below.\n const queryParams = parameterQuery(parameters);\n if (hasRequestExtensions(requestExtensions) || queryParams === undefined) {\n // dev.10's POST serializer passes through extra body keys. Its generated\n // request type omits parameters, so retain our typed extension locally.\n // TODO: Remove this intersection once contentful-experience-delivery.js\n // generates parameters on GetWithOverridesExperienceRequest and we upgrade.\n const request: ContentfulViewDelivery.GetWithOverridesExperienceRequest & {\n parameters?: ExperienceParameters;\n } = {\n locale,\n extensions: requestExtensions,\n ...(parameters === undefined ? {} : { parameters }),\n };\n return await client.experience.getWithOverrides(\n spaceId,\n environmentId,\n experienceId,\n request\n );\n }\n\n if (Object.keys(queryParams).length > 0) {\n return await client.experience.get(\n spaceId,\n environmentId,\n experienceId,\n { locale },\n {\n queryParams,\n }\n );\n }\n return await client.experience.get(spaceId, environmentId, experienceId, { locale });\n } catch (err) {\n // Preserve expected 404 control flow for framework routers. Other failures\n // are wrapped with stable SDK context instead of exposing transport-specific\n // error shapes.\n if (err instanceof ContentfulViewDelivery.NotFoundError) {\n throw err;\n }\n const reason = err instanceof Error ? err.message : String(err);\n throw new ExperienceFetchError(\n `Failed to fetch Experience \"${experienceId}\" (space \"${spaceId}\", environment ` +\n `\"${environmentId}\"): ${reason}. Check network connectivity, the access token, and ` +\n `that the space/environment/experience ids are correct.`,\n { spaceId, environmentId, experienceId, cause: err }\n );\n }\n}\n\n/**\n * Shared response-handling for both destination-shaped `fetchExperience`\n * branches (by node id, by path).\n */\nasync function fetchByDestination(\n identity: { spaceId: string; destinationId: string; locator: string },\n resolve: () => Promise<ContentfulViewDelivery.DestinationExperienceResolutionResponse>,\n log: ReturnType<typeof createDebugLogger>,\n resolveOptions: {\n config: ResolverConfig;\n metadata: Record<string, unknown> | undefined;\n debug: boolean | undefined;\n }\n): Promise<PortableRenderPlan | DestinationRedirectResult> {\n const { spaceId, destinationId, locator } = identity;\n const { config, metadata, debug } = resolveOptions;\n\n log.log('resolving destination experience', { spaceId, destinationId, locator });\n\n let response: ContentfulViewDelivery.DestinationExperienceResolutionResponse;\n try {\n response = await resolve();\n } catch (err) {\n if (err instanceof ContentfulViewDelivery.NotFoundError) {\n throw err;\n }\n const reason = err instanceof Error ? err.message : String(err);\n throw new ExperienceFetchError(\n `Failed to resolve Destination \"${destinationId}\" at \"${locator}\" (space \"${spaceId}\"): ` +\n `${reason}. Check network connectivity, the access token, and that the space/` +\n `destination/node-or-path values are correct.`,\n { spaceId, experienceId: locator, cause: err }\n );\n }\n\n if ('redirect' in response) {\n log.log('destination resolved to a redirect', response.redirect);\n return { redirect: response.redirect };\n }\n\n const [firstExperience] = response.experiences;\n if (!firstExperience) {\n throw new ExperienceFetchError(\n `Destination \"${destinationId}\" resolved \"${locator}\" to zero Experiences ` +\n `(space \"${spaceId}\"). Expected exactly one hydrated Experience or a redirect.`,\n { spaceId, experienceId: locator }\n );\n }\n\n const payload = toExperiencePayloadFromDestination(firstExperience.experience);\n log.lazy('received raw payload', () => payload);\n\n return resolveExperience(payload, config, {\n metadata,\n debug,\n });\n}\n\nfunction hasRequestExtensions(\n extensions: DeliveryExperienceRequestExtensions | undefined\n): extensions is DeliveryExperienceRequestExtensions {\n return (\n extensions !== undefined &&\n Object.values(extensions).some((extension) => extension !== undefined)\n );\n}\n","import { GetWithOverridesExperienceRequestExtensionsPersonalization as personalizationSchema } from '@contentful/experience-delivery/serialization';\nimport type { PersonalizationOptions } from './fetch-experience.js';\n\n/** Validate and serialize events to the generated XDA request contract. */\nexport function serializePersonalization(personalization: unknown): PersonalizationOptions {\n try {\n // XDA rejects EventBuilder's context.gdpr with HTTP 422. Keep caller-built\n // events intact and serialize to its generated schema, which omits consent.\n return personalizationSchema.parseOrThrow(personalization, {\n unrecognizedObjectKeys: 'strip',\n });\n } catch (cause) {\n throw new TypeError('Invalid Experience personalization options', { cause });\n }\n}\n","import { DestinationPreviewNotSupportedError } from './errors.js';\n\n/**\n * Throws `DestinationPreviewNotSupportedError` when `clientOptions.preview` is\n * `true` and `experienceOptions` is destination-shaped (a caller-supplied\n * `{ client }` already ignores `preview` entirely, so this only fires for the\n * inline-credentials branch). Shared by `fetchExperience` and\n * `fetchDestinationSitemap` — both call into the same preview-less\n * Destinations Delivery API.\n */\nexport function assertDestinationPreviewSupported(\n isPreview: boolean | undefined,\n destination: { spaceId: string; destinationId: string; nodeId?: string; path?: string }\n): void {\n if (!isPreview) return;\n\n const { spaceId, destinationId, nodeId, path } = destination;\n const locator = nodeId !== undefined ? `nodeId \"${nodeId}\"` : `path \"${path}\"`;\n throw new DestinationPreviewNotSupportedError(\n `preview: true was combined with a destination-shaped call (destinationId ` +\n `\"${destinationId}\", ${locator}). The Destinations Delivery API does not support ` +\n `preview mode yet — pass preview: false (or omit it) for destination-based fetches.`,\n { spaceId, destinationId, nodeId, path }\n );\n}\n","export const DELIVERY_HOST = 'https://xdn.contentful.com';\nexport const PREVIEW_HOST = 'https://preview.xdn.contentful.com';\nexport const PREVIEW_WEBSOCKET_HOST = 'wss://preview.xdn.contentful.com';\n","import type { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { createClient } from './create-delivery-client.js';\nimport { createDebugLogger } from '@contentful/experiences-sdk-core';\nimport { PREVIEW_HOST } from './hosts.js';\n\nexport type ClientOptions =\n | {\n accessToken: string;\n /**\n * Preview access token. Required when calling with `preview: true`.\n */\n previewToken?: string;\n /**\n * Flip between delivery (default) and preview at request time. When\n * `true`, uses `previewToken` and the preview host; when `false` or\n * unset, uses `accessToken` and the delivery host. Ignored when a\n * pre-made `client` is passed instead of inline creds.\n */\n preview?: boolean;\n /**\n * Custom base URL for the delivery client (staging, proxy, per-region).\n * Wins over the `preview`-derived default host — combine `host` with\n * `preview: true` to point preview mode at a non-prod endpoint.\n * Omit for the standard delivery / preview hosts.\n */\n host?: string;\n }\n | { client: ContentfulViewDeliveryClient };\n\n/**\n * Resolve a `ClientOptions` union into a real delivery client. Shared by\n * `fetchExperience` and `fetchDestinationSitemap` — both accept the same\n * inline-creds-or-pre-made-client shape.\n */\nexport function resolveDeliveryClient(\n clientOptions: ClientOptions,\n log: ReturnType<typeof createDebugLogger>,\n callerName: string\n): ContentfulViewDeliveryClient {\n if ('client' in clientOptions) {\n log.log('using caller-supplied delivery client');\n return clientOptions.client;\n }\n\n const { accessToken, previewToken, preview, host } = clientOptions;\n if (preview && !previewToken) {\n throw new Error(`${callerName}() called with preview: true but no previewToken was provided`);\n }\n const resolvedHost = host ?? (preview ? PREVIEW_HOST : undefined);\n const client = createClient({\n accessToken: preview ? (previewToken as string) : accessToken,\n host: resolvedHost,\n });\n log.log('created delivery client', { preview: Boolean(preview), host: resolvedHost });\n return client;\n}\n","/** One collection order path; `-` selects descending order. Delivery validates the path. */\nexport type ExperienceParameterOrder =\n `fields.${string}` | `sys.${string}` | `-fields.${string}` | `-sys.${string}`;\n\n/** Runtime values for one Record parameter. Nested records and arrays are not supported. */\nexport type ExperienceParameterRecord = Record<string, string | number>;\n\nexport type ExperienceParameterValue = string | number | ExperienceParameterRecord;\n\n/** Unprefixed IDs declared in Experience.parameters and referenced as `$parameters/<id>`. */\nexport type ExperienceParameters = Record<string, ExperienceParameterValue>;\n\n/**\n * Flatten values for the generated client's GET queryParams escape hatch.\n * An empty Record cannot be represented by query leaves: preserve it via POST.\n * Delivery owns name, requiredness, fallback and value validation.\n */\nexport function parameterQuery(\n parameters: ExperienceParameters | undefined\n): Record<string, string | number> | undefined {\n const entries: [string, string | number][] = [];\n for (const [id, value] of Object.entries(parameters ?? {})) {\n // A dotted ID could masquerade as another parameter's Record leaf on GET.\n // Preserve the original name on POST and let delivery validate it.\n if (id.includes('.')) return undefined;\n if (typeof value === 'string' || typeof value === 'number') {\n entries.push([`parameter.${id}`, value]);\n } else {\n // Untyped callers can supply other JSON shapes. Use POST so delivery\n // sees their original value rather than a lossy query string coercion.\n if (value === null || typeof value !== 'object' || Array.isArray(value)) return undefined;\n const leaves = Object.entries(value);\n if (leaves.length === 0) return undefined;\n for (const [field, leaf] of leaves) {\n if (field.includes('.')) return undefined;\n if (typeof leaf !== 'string' && typeof leaf !== 'number') return undefined;\n entries.push([`parameter.${id}.${field}`, leaf]);\n }\n }\n }\n return Object.fromEntries(entries);\n}\n","/*\n * Typed narrowing from a delivery-client response to the payload shape the\n * renderer consumes.\n */\n\nimport type { ContentfulViewDelivery } from '@contentful/experience-delivery';\nimport type { ExperiencePayload, ExperienceSourceMap } from '@contentful/experiences-sdk-core';\n\n/** Either shape the experience endpoint can return — `get()` and `getWithOverrides()` share it. */\nexport type ExperienceResponse =\n | ContentfulViewDelivery.GetExperienceResponse\n | ContentfulViewDelivery.GetWithOverridesExperienceResponse;\n\n/**\n * Narrow a delivery response to `ExperiencePayload`.\n *\n * The endpoint types its response as `HydratedView | HydratedExperienceView`.\n * The alpha-feature header the delivery client always sends guarantees the\n * latter, but TypeScript cannot know that, so callers were left casting by hand.\n *\n * `fetchExperience` uses this internally; it is exported for anyone driving the\n * delivery client directly. Type-level only — no validation, no copying.\n *\n * A legacy-shaped response carries `componentType` / `template` links instead;\n * `resolveExperience` reports those through `warnUnrenderableNode`.\n */\nexport function toExperiencePayload(response: ExperienceResponse): ExperiencePayload {\n return response as ContentfulViewDelivery.HydratedExperienceView as ExperiencePayload;\n}\n\n/** Read `extensions.sourceMap` off a response. `undefined` when the request did not opt in. */\nexport function readSourceMap(response: ExperienceResponse): ExperienceSourceMap | undefined {\n const extensions = (response as ContentfulViewDelivery.HydratedExperienceView).extensions;\n return extensions?.sourceMap as ExperienceSourceMap | undefined;\n}\n\n/**\n * Narrow a `ResolvedDestinationExperience.experience` to `ExperiencePayload`.\n *\n * Same cast rationale as `toExperiencePayload` above, for the destination\n * resolution endpoints' `HydratedExperience` shape instead of the by-id\n * endpoints' `HydratedExperienceView`.\n */\nexport function toExperiencePayloadFromDestination(\n experience: ContentfulViewDelivery.HydratedExperience\n): ExperiencePayload {\n return experience as unknown as ExperiencePayload;\n}\n","import { ContentfulViewDelivery } from '@contentful/experience-delivery';\nimport { createDebugLogger } from '@contentful/experiences-sdk-core';\nimport { assertDestinationPreviewSupported } from './destination-guards.js';\nimport { resolveDeliveryClient, type ClientOptions } from './client-resolution.js';\nimport { ExperienceFetchError } from './errors.js';\n\nexport type FetchDestinationSitemapOptions = {\n spaceId: string;\n destinationId: string;\n};\n\nexport type FetchDestinationSitemapPaginationOptions = {\n /** Maximum number of paths to return. Defaults to `100`, maximum `1000`. */\n limit?: number;\n /** Cursor from a previous call's `pages.next`. Treat as opaque; don't combine with `pagePrev`. */\n pageNext?: string;\n /** Cursor from a previous call's `pages.prev`. Treat as opaque; don't combine with `pageNext`. */\n pagePrev?: string;\n};\n\nexport type SitemapPathItem = {\n /** Path this entry routes. */\n path: string;\n /** Flat id extracted from the entry's `experienceUrn`. */\n experienceId: string;\n /** Type of the Destination Node that claims this path, e.g. `\"DestinationExperienceNode\"`. */\n type: string;\n};\n\nexport type DestinationSitemapResult = {\n items: SitemapPathItem[];\n limit: number;\n pages: { next?: string; prev?: string };\n};\n\n/**\n * List every routable path in a published Destination. Bulk enumeration —\n * pairs with `fetchExperience`'s `destinationId` + `nodeId`/`path` branches,\n * which resolve one path at a time. Does not hydrate any Experience itself\n * and does not call `fetchExperience` internally.\n */\nexport async function fetchDestinationSitemap(\n destinationOptions: FetchDestinationSitemapOptions,\n clientOptions: ClientOptions,\n paginationOptions: FetchDestinationSitemapPaginationOptions = {}\n): Promise<DestinationSitemapResult> {\n const { spaceId, destinationId } = destinationOptions;\n const log = createDebugLogger(false, 'client');\n\n if (!('client' in clientOptions)) {\n assertDestinationPreviewSupported(clientOptions.preview, { spaceId, destinationId });\n }\n\n const client = resolveDeliveryClient(clientOptions, log, 'fetchDestinationSitemap');\n\n const { limit, pageNext, pagePrev } = paginationOptions;\n\n let response: ContentfulViewDelivery.DestinationSitemap;\n try {\n response = await client.destination.sitemap(spaceId, destinationId, {\n limit,\n pageNext,\n pagePrev,\n });\n } catch (err) {\n if (err instanceof ContentfulViewDelivery.NotFoundError) {\n throw err;\n }\n const reason = err instanceof Error ? err.message : String(err);\n throw new ExperienceFetchError(\n `Failed to fetch sitemap for Destination \"${destinationId}\" (space \"${spaceId}\"): ` +\n `${reason}. Check network connectivity, the access token, and that the space/` +\n `destination ids are correct.`,\n { spaceId, experienceId: destinationId, cause: err }\n );\n }\n\n const result = {\n items: response.paths.items.map((item) => ({\n path: item.path,\n experienceId: extractIdFromUrn(item.experienceUrn),\n type: item.sys.type,\n })),\n limit: response.paths.limit,\n pages: response.paths.pages,\n };\n\n log.lazy('received sitemap page', () => result);\n\n return result;\n}\n\n/**\n * Extract the flat id from an `experienceUrn`. Real shape:\n * crn:contentful:::experience:spaces/$self/environments/$self/experiences/<id>\n *\n * Same one-line logic as the private `extractIdFromUrn` in\n * `packages/core/src/resolve-experience.ts` — not shared across the\n * `core`/`client` package boundary (core stays zero-dep) for one line.\n */\nfunction extractIdFromUrn(urn: string): string {\n const segments = urn.split('/').filter((s) => s.length > 0);\n return segments[segments.length - 1] ?? urn;\n}\n"],"mappings":";AAAA,SAAS,0BAAAA,+BAA8B;AAEvC;AAAA,EACE,0BAAAA;AAAA,EACA,gCAAAC;AAAA,OACK;;;ACYA,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EAET,YACE,SACA,SAMA;AACA,UAAM,SAAS,QAAQ,UAAU,SAAY,EAAE,OAAO,QAAQ,MAAM,IAAI,MAAS;AACjF,SAAK,OAAO;AACZ,SAAK,UAAU,QAAQ;AACvB,SAAK,gBAAgB,QAAQ;AAC7B,SAAK,eAAe,QAAQ;AAAA,EAC9B;AACF;AAiBO,IAAM,sCAAN,cAAkD,MAAM;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YACE,SACA,SACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,UAAU,QAAQ;AACvB,SAAK,gBAAgB,QAAQ;AAC7B,SAAK,SAAS,QAAQ;AACtB,SAAK,OAAO,QAAQ;AAAA,EACtB;AACF;;;ACvEA,SAAS,oCAAoC;;;ACItC,IAAM,oBAAoB;AAS1B,IAAM,yBAAsC;AAAA,EACjD,MACE,OACI,mCACA;AAAA,EACN,SACE,OAAqD,WAAiC;AAC1F;AAaA,SAAS,aAAsC;AAC7C,SAAQ,WAAyC;AACnD;AAEA,SAAS,SAAkB;AAEzB,QAAM,UAAU,WAAW;AAC3B,SAAO,OAAO,YAAY,eAAe,C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R;AACA,UAAM,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC9D,UAAM,IAAI;AAAA,MACR,4CAA4C,aAAa,aAAa,OAAO,OACxE,MAAM;AAAA,MAEX,EAAE,SAAS,cAAc,eAAe,OAAO,IAAI;AAAA,IACrD;AAAA,EACF;AAEA,QAAM,SAAS;AAAA,IACb,OAAO,SAAS,MAAM,MAAM,IAAI,CAAC,UAAU;AAAA,MACzC,MAAM,KAAK;AAAA,MACX,cAAc,iBAAiB,KAAK,aAAa;AAAA,MACjD,MAAM,KAAK,IAAI;AAAA,IACjB,EAAE;AAAA,IACF,OAAO,SAAS,MAAM;AAAA,IACtB,OAAO,SAAS,MAAM;AAAA,EACxB;AAEA,MAAI,KAAK,yBAAyB,MAAM,MAAM;AAE9C,SAAO;AACT;AAUA,SAAS,iBAAiB,KAAqB;AAC7C,QAAM,WAAW,IAAI,MAAM,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC;AAC1D,SAAO,SAAS,SAAS,SAAS,CAAC,KAAK;AAC1C;;;AXjGO,IAAM,gBAAgBC,wBAAuB;","names":["ContentfulViewDelivery","ContentfulViewDeliveryClient","spaceId","ContentfulViewDelivery","createDebugLogger","createDebugLogger","ContentfulViewDelivery","ContentfulViewDelivery"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/create-delivery-client.ts","../src/user-agent.ts","../src/fetch-experience.ts","../src/personalization.ts","../src/destination-guards.ts","../src/hosts.ts","../src/client-resolution.ts","../src/experience-parameters.ts","../src/to-experience-payload.ts","../src/fetch-destination-sitemap.ts"],"sourcesContent":["import { ContentfulViewDelivery } from '@contentful/experience-delivery';\n\nexport {\n ContentfulViewDelivery,\n ContentfulViewDeliveryClient,\n} from '@contentful/experience-delivery';\nexport const NotFoundError = ContentfulViewDelivery.NotFoundError;\n// eslint-disable-next-line no-redeclare -- value + type share a name across separate TS namespaces, not a real redeclaration\nexport type NotFoundError = InstanceType<typeof ContentfulViewDelivery.NotFoundError>;\nexport { ExperienceFetchError, DestinationPreviewNotSupportedError } from './errors.js';\nexport { createClient } from './create-delivery-client.js';\nexport type { CreateClientOptions } from './create-delivery-client.js';\nexport { createUserAgentHeaders, EXPERIENCES_CLIENT_SDK, USER_AGENT_HEADER } from './user-agent.js';\nexport type { SdkIdentity } from './user-agent.js';\nexport { fetchExperience } from './fetch-experience.js';\nexport { fetchDestinationSitemap } from './fetch-destination-sitemap.js';\nexport type {\n FetchDestinationSitemapOptions,\n FetchDestinationSitemapPaginationOptions,\n SitemapPathItem,\n DestinationSitemapResult,\n} from './fetch-destination-sitemap.js';\nexport {\n readSourceMap,\n toExperiencePayload,\n toExperiencePayloadFromDestination,\n} from './to-experience-payload.js';\nexport type { ExperienceResponse } from './to-experience-payload.js';\nexport type {\n ExperienceOptions,\n ExperienceRequestExtensions,\n PersonalizationOptions,\n ByIdExperienceOptions,\n ByDestinationNodeIdExperienceOptions,\n ByDestinationPathExperienceOptions,\n ClientOptions,\n ResolveOptions,\n DestinationRedirectResult,\n} from './fetch-experience.js';\nexport { DELIVERY_HOST, PREVIEW_HOST, PREVIEW_WEBSOCKET_HOST } from './hosts.js';\nexport type {\n ExperienceParameters,\n ExperienceParameterValue,\n ExperienceParameterRecord,\n ExperienceParameterOrder,\n} from './experience-parameters.js';\nexport { serializePersonalization } from './personalization.js';\n","/**\n * Thrown by `fetchExperience` for a fetch failure that is not \"experience not\n * found\" — network failure, an invalid/expired token, a 5xx from the\n * delivery API, etc. This failure mode is \"surface clearly to the host app,\"\n * unlike the diagnostics `resolveExperience` collects for resolve/render-time\n * issues — there's no partial payload to render around a fetch that never\n * returned one, so a real thrown class is the right shape.\n *\n * `NotFoundError` (the delivery client's class, re-exported from this\n * package) is the one exception: it passes through undisturbed so callers\n * can route it to their framework's 404 idiom, per the existing\n * distinguishable-404 contract.\n *\n * `environmentId` is `undefined` for the destination-shaped `fetchExperience`\n * branches — the destinations delivery endpoints are space-scoped only, with\n * no environment segment, unlike the by-id path.\n */\nexport class ExperienceFetchError extends Error {\n readonly spaceId: string;\n readonly environmentId: string | undefined;\n readonly experienceId: string;\n\n constructor(\n message: string,\n options: {\n spaceId: string;\n environmentId?: string;\n experienceId: string;\n cause?: unknown;\n }\n ) {\n super(message, options.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = 'ExperienceFetchError';\n this.spaceId = options.spaceId;\n this.environmentId = options.environmentId;\n this.experienceId = options.experienceId;\n }\n}\n\n/**\n * Thrown by `fetchExperience` and `fetchDestinationSitemap` when\n * `clientOptions.preview` is `true` for a destination-shaped call\n * (`destinationId` + `nodeId`/`path`, or a sitemap fetch). The Destinations\n * Delivery API has no preview host or preview-token support yet, so this\n * guards against silently hitting the production host with a preview token\n * it doesn't accept.\n *\n * This is a bridge, not a permanent design: revisit once the platform ships\n * preview support for destinations.\n *\n * Only fires for the inline-credentials branch of `ClientOptions`. A\n * caller-supplied `{ client }` already ignores `preview` entirely, per that\n * branch's existing contract.\n */\nexport class DestinationPreviewNotSupportedError extends Error {\n readonly spaceId: string;\n readonly destinationId: string;\n readonly nodeId: string | undefined;\n readonly path: string | undefined;\n\n constructor(\n message: string,\n options: { spaceId: string; destinationId: string; nodeId?: string; path?: string }\n ) {\n super(message);\n this.name = 'DestinationPreviewNotSupportedError';\n this.spaceId = options.spaceId;\n this.destinationId = options.destinationId;\n this.nodeId = options.nodeId;\n this.path = options.path;\n }\n}\n","import { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { createUserAgentHeaders, EXPERIENCES_CLIENT_SDK } from './user-agent.js';\n\n/** Options for the legacy functional Delivery client constructor. */\nexport type CreateClientOptions = {\n accessToken: string;\n /**\n * Base URL for the delivery client. Defaults to `DELIVERY_HOST` when omitted.\n * Pass `PREVIEW_HOST` for preview mode, or any custom URL (staging, proxy,\n * per-region). Both constants are exported from this package.\n */\n host?: string;\n} & Omit<ContentfulViewDeliveryClient.Options, 'token' | 'baseUrl'>;\n\nexport function createClient(options: CreateClientOptions): ContentfulViewDeliveryClient {\n const { accessToken, host, headers, ...rest } = options;\n return new ContentfulViewDeliveryClient({\n ...rest,\n headers: { ...createUserAgentHeaders(EXPERIENCES_CLIENT_SDK), ...headers },\n token: accessToken,\n baseUrl: host,\n });\n}\n","declare const __EXPERIENCES_CLIENT_NAME__: string | undefined;\ndeclare const __EXPERIENCES_CLIENT_VERSION__: string | undefined;\n\n/** Header the Contentful JS SDKs use to report SDK identity, platform, and OS. */\nexport const USER_AGENT_HEADER = 'X-Contentful-User-Agent';\n\n/** Package identity reported in the user-agent header. */\nexport type SdkIdentity = { name: string; version: string };\n\n/**\n * Identity of this package. Build artifacts receive package metadata through\n * tsup defines; source execution (including tests) uses stable fallbacks.\n */\nexport const EXPERIENCES_CLIENT_SDK: SdkIdentity = {\n name:\n typeof __EXPERIENCES_CLIENT_NAME__ === 'string'\n ? __EXPERIENCES_CLIENT_NAME__\n : '@contentful/experiences-client',\n version:\n typeof __EXPERIENCES_CLIENT_VERSION__ === 'string' ? __EXPERIENCES_CLIENT_VERSION__ : '0.0.0',\n};\n\n// Ported from contentful-sdk-core `src/get-user-agent.ts` and `src/utils.ts` so\n// the header matches contentful.js. `process` is read from `globalThis` instead\n// of importing the `process` polyfill.\n\ntype NodeProcess = {\n browser?: boolean;\n platform?: string;\n version?: string;\n versions?: { node?: string };\n};\n\nfunction getProcess(): NodeProcess | undefined {\n return (globalThis as { process?: NodeProcess }).process;\n}\n\nfunction isNode(): boolean {\n // Polyfills of `process` might set `process.browser === true`.\n const process = getProcess();\n return typeof process !== 'undefined' && !process.browser;\n}\n\nfunction isReactNative(): boolean {\n return (\n typeof window !== 'undefined' &&\n 'navigator' in window &&\n 'product' in window.navigator &&\n window.navigator.product === 'ReactNative'\n );\n}\n\nfunction getNodeVersion(): string | undefined {\n const process = getProcess();\n return process?.versions?.node ? `v${process.versions.node}` : process?.version;\n}\n\nfunction getBrowserOS(): string | null {\n if (typeof window === 'undefined') {\n return null;\n }\n const userAgent = window.navigator.userAgent;\n // `platform` is deprecated but still the most reliable signal here.\n const platform = window.navigator.platform;\n const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];\n const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];\n const iosPlatforms = ['iPhone', 'iPad', 'iPod'];\n\n if (macosPlatforms.indexOf(platform) !== -1) {\n return 'macOS';\n } else if (iosPlatforms.indexOf(platform) !== -1) {\n return 'iOS';\n } else if (windowsPlatforms.indexOf(platform) !== -1) {\n return 'Windows';\n } else if (/Android/.test(userAgent)) {\n return 'Android';\n } else if (/Linux/.test(platform)) {\n return 'Linux';\n }\n\n return null;\n}\n\ntype PlatformMap = Record<string, 'Android' | 'Linux' | 'Windows' | 'macOS'>;\n\nfunction getNodeOS(): string | null {\n const process = getProcess();\n const platform = process?.platform || 'linux';\n const version = process?.version || '0.0.0';\n const platformMap: PlatformMap = {\n android: 'Android',\n aix: 'Linux',\n darwin: 'macOS',\n freebsd: 'Linux',\n linux: 'Linux',\n openbsd: 'Linux',\n sunos: 'Linux',\n win32: 'Windows',\n };\n if (platform in platformMap) {\n return `${platformMap[platform] || 'Linux'}/${version}`;\n }\n return null;\n}\n\nexport function getUserAgentHeader(\n sdk: string,\n application?: string,\n integration?: string,\n feature?: string\n): string {\n const headerParts = [];\n\n if (application) {\n headerParts.push(`app ${application}`);\n }\n\n if (integration) {\n headerParts.push(`integration ${integration}`);\n }\n\n if (feature) {\n headerParts.push('feature ' + feature);\n }\n\n headerParts.push(`sdk ${sdk}`);\n\n let platform: string | null;\n try {\n if (isReactNative()) {\n platform = getBrowserOS();\n headerParts.push('platform ReactNative');\n } else if (isNode()) {\n platform = getNodeOS();\n headerParts.push(`platform node.js/${getNodeVersion()}`);\n } else {\n platform = getBrowserOS();\n headerParts.push('platform browser');\n }\n } catch {\n platform = null;\n }\n\n if (platform) {\n headerParts.push(`os ${platform}`);\n }\n\n return `${headerParts.filter((item) => item !== '').join('; ')};`;\n}\n\nfunction format({ name, version }: SdkIdentity): string {\n return `${name.replace(/^@contentful\\//, '')}/${version}`;\n}\n\n/**\n * Builds the `X-Contentful-User-Agent` header for Delivery and Preview\n * requests, e.g. `app my-site/1.0.0; sdk experiences-node/0.6.0; platform node.js/v22.17.0; os macOS/v22.17.0;`.\n */\nexport function createUserAgentHeaders(\n sdk: SdkIdentity,\n app?: SdkIdentity\n): Record<string, string> {\n return {\n [USER_AGENT_HEADER]: getUserAgentHeader(format(sdk), app ? format(app) : undefined),\n };\n}\n","import type { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { ContentfulViewDelivery } from '@contentful/experience-delivery';\nimport { serializePersonalization } from './personalization.js';\nimport { createDebugLogger, resolveExperience } from '@contentful/experiences-sdk-core';\nimport type { PortableRenderPlan, ResolverConfig } from '@contentful/experiences-sdk-core';\nimport { assertDestinationPreviewSupported } from './destination-guards.js';\nimport { resolveDeliveryClient, type ClientOptions } from './client-resolution.js';\nimport { ExperienceFetchError } from './errors.js';\nimport { parameterQuery, type ExperienceParameters } from './experience-parameters.js';\nimport {\n toExperiencePayload,\n toExperiencePayloadFromDestination,\n type ExperienceResponse,\n} from './to-experience-payload.js';\n\nexport type { ClientOptions };\n\ntype DeliveryExperienceRequestExtensions =\n ContentfulViewDelivery.GetWithOverridesExperienceRequest.Extensions;\n\nexport type PersonalizationOptions = NonNullable<\n DeliveryExperienceRequestExtensions['personalization']\n>;\n\nexport type ExperienceRequestExtensions = Omit<\n DeliveryExperienceRequestExtensions,\n 'personalization'\n>;\n\nexport type ByIdExperienceOptions = {\n spaceId: string;\n environmentId: string;\n experienceId: string;\n locale?: string;\n /** Values for declared Experience parameters. Refetch with new values to swap content. */\n parameters?: ExperienceParameters;\n /**\n * Profile and events used by XDA to personalize the resolved Experience.\n */\n personalization?: PersonalizationOptions;\n /**\n * Additional XDA request extensions such as source maps. Supplying a defined\n * extension switches the request to POST.\n */\n extensions?: ExperienceRequestExtensions;\n};\n\n/**\n * Resolve an Experience by the Destination Node instead of `experienceId`\n * The destinations delivery endpoints are space-scoped only and have no locale\n * param, unlike the by-id path. Supplying `personalization` switches the\n * request from the cacheable GET to the POST that carries it.\n */\nexport type ByDestinationNodeIdExperienceOptions = {\n spaceId: string;\n destinationId: string;\n nodeId: string;\n /** Profile and events used by XDA to personalize the resolved Experience. */\n personalization?: PersonalizationOptions;\n};\n\n/**\n * Resolve an Experience by the absolute path wired up to a\n * Destination Node, instead of a node id directly. Same scoping as\n * `ByDestinationNodeIdExperienceOptions` — no `environmentId` or `locale`.\n */\nexport type ByDestinationPathExperienceOptions = {\n spaceId: string;\n destinationId: string;\n /** Absolute path to resolve. Must start with `/`. */\n path: string;\n /** Profile and events used by XDA to personalize the resolved Experience. */\n personalization?: PersonalizationOptions;\n};\n\nexport type ExperienceOptions =\n ByIdExperienceOptions | ByDestinationNodeIdExperienceOptions | ByDestinationPathExperienceOptions;\n\n/**\n * A Destination resolution that the app must act on as control flow — honor\n * it by navigating or re-resolving at the new path — rather than a hydrated\n * Experience to render. Modeled as a normal return value, not a thrown error,\n * per the Destinations delivery API's own framing of a redirect response.\n */\nexport interface DestinationRedirectResult {\n redirect: { path: string };\n}\n\nexport type ResolveOptions = {\n config: ResolverConfig;\n /**\n * Arbitrary per-render metadata exposed to every resolver as\n * `ctx.experience.metadata` and readable at render time via the framework\n * adapter's `useExperience()` / `getExperience()`.\n */\n metadata?: Record<string, unknown>;\n /**\n * Observability switch. When on: logs the fetch (host, ids) and the raw\n * payload here, and threads through to `resolveExperience` (resolution steps\n * + `resolveData` timings) and the renderer (visible missing-component box,\n * debug fallback). A single boolean across fetch + resolve + render.\n */\n debug?: boolean;\n};\n\n// TS overload signatures, not real redeclarations — base ESLint's no-redeclare doesn't know the\n// overload form (@typescript-eslint's own version does), so each repeated signature needs a\n// disable comment.\nexport async function fetchExperience(\n experienceOptions: ByIdExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan>;\n// eslint-disable-next-line no-redeclare -- see above\nexport async function fetchExperience(\n experienceOptions: ByDestinationNodeIdExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan | DestinationRedirectResult>;\n// eslint-disable-next-line no-redeclare -- see above\nexport async function fetchExperience(\n experienceOptions: ByDestinationPathExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan | DestinationRedirectResult>;\n// eslint-disable-next-line no-redeclare -- see above\nexport async function fetchExperience(\n experienceOptions: ExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan | DestinationRedirectResult> {\n const { config, metadata, debug } = resolveOptions;\n const log = createDebugLogger(debug, 'client');\n\n if (!('client' in clientOptions) && 'destinationId' in experienceOptions) {\n const { spaceId, destinationId } = experienceOptions;\n const locator =\n 'nodeId' in experienceOptions\n ? { nodeId: experienceOptions.nodeId }\n : { path: experienceOptions.path };\n assertDestinationPreviewSupported(clientOptions.preview, {\n spaceId,\n destinationId,\n ...locator,\n });\n }\n\n const client = resolveDeliveryClient(clientOptions, log, 'fetchExperience');\n\n if ('nodeId' in experienceOptions) {\n const { spaceId, destinationId, nodeId, personalization } = experienceOptions;\n // Serialize before the request so invalid input is a TypeError, as on the by-id path.\n const extensions = destinationExtensions(personalization);\n return fetchByDestination(\n { spaceId, destinationId, locator: nodeId },\n () =>\n extensions === undefined\n ? client.destination.resolveByNodeId(spaceId, destinationId, nodeId)\n : client.destination.resolveByNodeIdWithOverrides(spaceId, destinationId, nodeId, {\n extensions,\n }),\n log,\n { config, metadata, debug }\n );\n }\n\n if ('path' in experienceOptions) {\n const { spaceId, destinationId, path, personalization } = experienceOptions;\n const extensions = destinationExtensions(personalization);\n return fetchByDestination(\n { spaceId, destinationId, locator: path },\n () =>\n client.destination.resolveByPath(spaceId, destinationId, {\n path,\n ...(extensions === undefined ? {} : { extensions }),\n }),\n log,\n { config, metadata, debug }\n );\n }\n\n const { spaceId, environmentId, experienceId, locale, personalization, extensions } =\n experienceOptions;\n\n log.log('fetching experience', {\n spaceId,\n environmentId,\n experienceId,\n locale,\n // avoiding log any personalization sensitive data\n personalization: personalization !== undefined,\n extensions,\n });\n\n const response = await fetchByExperienceId(client, experienceOptions);\n\n const payload = toExperiencePayload(response);\n log.lazy('received raw payload', () => payload);\n\n return resolveExperience(payload, config, { metadata, debug });\n}\n\nasync function fetchByExperienceId(\n client: ContentfulViewDeliveryClient,\n options: ByIdExperienceOptions\n): Promise<ExperienceResponse> {\n const { spaceId, environmentId, experienceId, locale, parameters, personalization, extensions } =\n options;\n const requestExtensions: DeliveryExperienceRequestExtensions = { ...extensions };\n if (personalization !== undefined) {\n requestExtensions.personalization = serializePersonalization(personalization);\n }\n\n try {\n // GET uses namespaced query leaves. POST preserves values that cannot be\n // represented by leaves and carries existing request extensions.\n // The generated delivery client owns the alpha-feature header on both\n // paths, including when the caller supplied the client instance.\n //\n // Await inside the try so rejected requests are normalized below.\n const queryParams = parameterQuery(parameters);\n if (hasRequestExtensions(requestExtensions) || queryParams === undefined) {\n // dev.10's POST serializer passes through extra body keys. Its generated\n // request type omits parameters, so retain our typed extension locally.\n // TODO: Remove this intersection once contentful-experience-delivery.js\n // generates parameters on GetWithOverridesExperienceRequest and we upgrade.\n const request: ContentfulViewDelivery.GetWithOverridesExperienceRequest & {\n parameters?: ExperienceParameters;\n } = {\n locale,\n extensions: requestExtensions,\n ...(parameters === undefined ? {} : { parameters }),\n };\n return await client.experience.getWithOverrides(\n spaceId,\n environmentId,\n experienceId,\n request\n );\n }\n\n if (Object.keys(queryParams).length > 0) {\n return await client.experience.get(\n spaceId,\n environmentId,\n experienceId,\n { locale },\n {\n queryParams,\n }\n );\n }\n return await client.experience.get(spaceId, environmentId, experienceId, { locale });\n } catch (err) {\n // Preserve expected 404 control flow for framework routers. Other failures\n // are wrapped with stable SDK context instead of exposing transport-specific\n // error shapes.\n if (err instanceof ContentfulViewDelivery.NotFoundError) {\n throw err;\n }\n const reason = err instanceof Error ? err.message : String(err);\n throw new ExperienceFetchError(\n `Failed to fetch Experience \"${experienceId}\" (space \"${spaceId}\", environment ` +\n `\"${environmentId}\"): ${reason}. Check network connectivity, the access token, and ` +\n `that the space/environment/experience ids are correct.`,\n { spaceId, environmentId, experienceId, cause: err }\n );\n }\n}\n\n/**\n * Shared response-handling for both destination-shaped `fetchExperience`\n * branches (by node id, by path).\n */\nasync function fetchByDestination(\n identity: { spaceId: string; destinationId: string; locator: string },\n resolve: () => Promise<ContentfulViewDelivery.DestinationExperienceResolutionResponse>,\n log: ReturnType<typeof createDebugLogger>,\n resolveOptions: {\n config: ResolverConfig;\n metadata: Record<string, unknown> | undefined;\n debug: boolean | undefined;\n }\n): Promise<PortableRenderPlan | DestinationRedirectResult> {\n const { spaceId, destinationId, locator } = identity;\n const { config, metadata, debug } = resolveOptions;\n\n log.log('resolving destination experience', { spaceId, destinationId, locator });\n\n let response: ContentfulViewDelivery.DestinationExperienceResolutionResponse;\n try {\n response = await resolve();\n } catch (err) {\n if (err instanceof ContentfulViewDelivery.NotFoundError) {\n throw err;\n }\n const reason = err instanceof Error ? err.message : String(err);\n throw new ExperienceFetchError(\n `Failed to resolve Destination \"${destinationId}\" at \"${locator}\" (space \"${spaceId}\"): ` +\n `${reason}. Check network connectivity, the access token, and that the space/` +\n `destination/node-or-path values are correct.`,\n { spaceId, experienceId: locator, cause: err }\n );\n }\n\n if ('redirect' in response) {\n log.log('destination resolved to a redirect', response.redirect);\n return { redirect: response.redirect };\n }\n\n const [firstExperience] = response.experiences;\n if (!firstExperience) {\n throw new ExperienceFetchError(\n `Destination \"${destinationId}\" resolved \"${locator}\" to zero Experiences ` +\n `(space \"${spaceId}\"). Expected exactly one hydrated Experience or a redirect.`,\n { spaceId, experienceId: locator }\n );\n }\n\n const payload = toExperiencePayloadFromDestination(firstExperience.experience);\n log.lazy('received raw payload', () => payload);\n\n return resolveExperience(payload, config, {\n metadata,\n debug,\n });\n}\n\nfunction destinationExtensions(\n personalization: PersonalizationOptions | undefined\n): ContentfulViewDelivery.DestinationExperiencesExtensions | undefined {\n if (personalization === undefined) return undefined;\n return { personalization: serializePersonalization(personalization) };\n}\n\nfunction hasRequestExtensions(\n extensions: DeliveryExperienceRequestExtensions | undefined\n): extensions is DeliveryExperienceRequestExtensions {\n return (\n extensions !== undefined &&\n Object.values(extensions).some((extension) => extension !== undefined)\n );\n}\n","import type { PersonalizationOptions } from './fetch-experience.js';\n\nconst EVENT_TYPES = ['page', 'track', 'identify', 'screen', 'component'];\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\n/**\n * Validate the envelope of caller-built events and drop what XDA rejects.\n *\n * `@contentful/experience-delivery` no longer ships request schemas (dev.11 removed\n * `./serialization`, AIS-809), so this checks the fields every event shares rather\n * than each event type's full shape.\n */\nexport function serializePersonalization(personalization: unknown): PersonalizationOptions {\n try {\n if (!isRecord(personalization)) throw new Error('Expected an object');\n const { profileId, events } = personalization;\n if (profileId !== undefined && typeof profileId !== 'string') {\n throw new Error('profileId must be a string');\n }\n if (events !== undefined && !Array.isArray(events)) throw new Error('events must be an array');\n return {\n ...(profileId === undefined ? {} : { profileId }),\n ...(events === undefined ? {} : { events: events.map(serializeEvent) }),\n } as PersonalizationOptions;\n } catch (cause) {\n throw new TypeError('Invalid Experience personalization options', { cause });\n }\n}\n\nfunction serializeEvent(event: unknown): unknown {\n if (!isRecord(event) || !EVENT_TYPES.includes(event.type as string)) {\n throw new Error('Unknown event type');\n }\n for (const key of ['channel', 'messageId', 'timestamp']) {\n if (typeof event[key] !== 'string') throw new Error(`${key} must be a string`);\n }\n if (!isRecord(event.context) || !isRecord(event.context.library)) {\n throw new Error('context.library is required');\n }\n // XDA's embedded event schema is narrower than EventBuilder's: it rejects\n // context.gdpr (consent), context.screen and context.page.title. Serialize without them.\n const { gdpr: _gdpr, screen: _screen, page, ...context } = event.context;\n if (!isRecord(page)) return { ...event, context };\n const { title: _title, ...xdaPage } = page;\n return { ...event, context: { ...context, page: xdaPage } };\n}\n","import { DestinationPreviewNotSupportedError } from './errors.js';\n\n/**\n * Throws `DestinationPreviewNotSupportedError` when `clientOptions.preview` is\n * `true` and `experienceOptions` is destination-shaped (a caller-supplied\n * `{ client }` already ignores `preview` entirely, so this only fires for the\n * inline-credentials branch). Shared by `fetchExperience` and\n * `fetchDestinationSitemap` — both call into the same preview-less\n * Destinations Delivery API.\n */\nexport function assertDestinationPreviewSupported(\n isPreview: boolean | undefined,\n destination: { spaceId: string; destinationId: string; nodeId?: string; path?: string }\n): void {\n if (!isPreview) return;\n\n const { spaceId, destinationId, nodeId, path } = destination;\n const locator = nodeId !== undefined ? `nodeId \"${nodeId}\"` : `path \"${path}\"`;\n throw new DestinationPreviewNotSupportedError(\n `preview: true was combined with a destination-shaped call (destinationId ` +\n `\"${destinationId}\", ${locator}). The Destinations Delivery API does not support ` +\n `preview mode yet — pass preview: false (or omit it) for destination-based fetches.`,\n { spaceId, destinationId, nodeId, path }\n );\n}\n","export const DELIVERY_HOST = 'https://xdn.contentful.com';\nexport const PREVIEW_HOST = 'https://preview.xdn.contentful.com';\nexport const PREVIEW_WEBSOCKET_HOST = 'wss://preview.xdn.contentful.com';\n","import type { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { createClient } from './create-delivery-client.js';\nimport { createDebugLogger } from '@contentful/experiences-sdk-core';\nimport { PREVIEW_HOST } from './hosts.js';\n\nexport type ClientOptions =\n | {\n accessToken: string;\n /**\n * Preview access token. Required when calling with `preview: true`.\n */\n previewToken?: string;\n /**\n * Flip between delivery (default) and preview at request time. When\n * `true`, uses `previewToken` and the preview host; when `false` or\n * unset, uses `accessToken` and the delivery host. Ignored when a\n * pre-made `client` is passed instead of inline creds.\n */\n preview?: boolean;\n /**\n * Custom base URL for the delivery client (staging, proxy, per-region).\n * Wins over the `preview`-derived default host — combine `host` with\n * `preview: true` to point preview mode at a non-prod endpoint.\n * Omit for the standard delivery / preview hosts.\n */\n host?: string;\n }\n | { client: ContentfulViewDeliveryClient };\n\n/**\n * Resolve a `ClientOptions` union into a real delivery client. Shared by\n * `fetchExperience` and `fetchDestinationSitemap` — both accept the same\n * inline-creds-or-pre-made-client shape.\n */\nexport function resolveDeliveryClient(\n clientOptions: ClientOptions,\n log: ReturnType<typeof createDebugLogger>,\n callerName: string\n): ContentfulViewDeliveryClient {\n if ('client' in clientOptions) {\n log.log('using caller-supplied delivery client');\n return clientOptions.client;\n }\n\n const { accessToken, previewToken, preview, host } = clientOptions;\n if (preview && !previewToken) {\n throw new Error(`${callerName}() called with preview: true but no previewToken was provided`);\n }\n const resolvedHost = host ?? (preview ? PREVIEW_HOST : undefined);\n const client = createClient({\n accessToken: preview ? (previewToken as string) : accessToken,\n host: resolvedHost,\n });\n log.log('created delivery client', { preview: Boolean(preview), host: resolvedHost });\n return client;\n}\n","/** One collection order path; `-` selects descending order. Delivery validates the path. */\nexport type ExperienceParameterOrder =\n `fields.${string}` | `sys.${string}` | `-fields.${string}` | `-sys.${string}`;\n\n/** Runtime values for one Record parameter. Nested records and arrays are not supported. */\nexport type ExperienceParameterRecord = Record<string, string | number>;\n\nexport type ExperienceParameterValue = string | number | ExperienceParameterRecord;\n\n/** Unprefixed IDs declared in Experience.parameters and referenced as `$parameters/<id>`. */\nexport type ExperienceParameters = Record<string, ExperienceParameterValue>;\n\n/**\n * Flatten values for the generated client's GET queryParams escape hatch.\n * An empty Record cannot be represented by query leaves: preserve it via POST.\n * Delivery owns name, requiredness, fallback and value validation.\n */\nexport function parameterQuery(\n parameters: ExperienceParameters | undefined\n): Record<string, string | number> | undefined {\n const entries: [string, string | number][] = [];\n for (const [id, value] of Object.entries(parameters ?? {})) {\n // A dotted ID could masquerade as another parameter's Record leaf on GET.\n // Preserve the original name on POST and let delivery validate it.\n if (id.includes('.')) return undefined;\n if (typeof value === 'string' || typeof value === 'number') {\n entries.push([`parameter.${id}`, value]);\n } else {\n // Untyped callers can supply other JSON shapes. Use POST so delivery\n // sees their original value rather than a lossy query string coercion.\n if (value === null || typeof value !== 'object' || Array.isArray(value)) return undefined;\n const leaves = Object.entries(value);\n if (leaves.length === 0) return undefined;\n for (const [field, leaf] of leaves) {\n if (field.includes('.')) return undefined;\n if (typeof leaf !== 'string' && typeof leaf !== 'number') return undefined;\n entries.push([`parameter.${id}.${field}`, leaf]);\n }\n }\n }\n return Object.fromEntries(entries);\n}\n","/*\n * Typed narrowing from a delivery-client response to the payload shape the\n * renderer consumes.\n */\n\nimport type { ContentfulViewDelivery } from '@contentful/experience-delivery';\nimport type { ExperiencePayload, ExperienceSourceMap } from '@contentful/experiences-sdk-core';\n\n/** Either shape the experience endpoint can return — `get()` and `getWithOverrides()` share it. */\nexport type ExperienceResponse =\n | ContentfulViewDelivery.GetExperienceResponse\n | ContentfulViewDelivery.GetWithOverridesExperienceResponse;\n\n/**\n * Narrow a delivery response to `ExperiencePayload`.\n *\n * The endpoint types its response as `HydratedView | HydratedExperienceView`.\n * The alpha-feature header the delivery client always sends guarantees the\n * latter, but TypeScript cannot know that, so callers were left casting by hand.\n *\n * `fetchExperience` uses this internally; it is exported for anyone driving the\n * delivery client directly. Type-level only — no validation, no copying.\n *\n * A legacy-shaped response carries `componentType` / `template` links instead;\n * `resolveExperience` reports those through `warnUnrenderableNode`.\n */\nexport function toExperiencePayload(response: ExperienceResponse): ExperiencePayload {\n return response as ContentfulViewDelivery.HydratedExperienceView as ExperiencePayload;\n}\n\n/** Read `extensions.sourceMap` off a response. `undefined` when the request did not opt in. */\nexport function readSourceMap(response: ExperienceResponse): ExperienceSourceMap | undefined {\n const extensions = (response as ContentfulViewDelivery.HydratedExperienceView).extensions;\n return extensions?.sourceMap as ExperienceSourceMap | undefined;\n}\n\n/**\n * Narrow a `ResolvedDestinationExperience.experience` to `ExperiencePayload`.\n *\n * Same cast rationale as `toExperiencePayload` above, for the destination\n * resolution endpoints' `HydratedExperience` shape instead of the by-id\n * endpoints' `HydratedExperienceView`.\n */\nexport function toExperiencePayloadFromDestination(\n experience: ContentfulViewDelivery.HydratedExperience\n): ExperiencePayload {\n return experience as unknown as ExperiencePayload;\n}\n","import { ContentfulViewDelivery } from '@contentful/experience-delivery';\nimport { createDebugLogger } from '@contentful/experiences-sdk-core';\nimport { assertDestinationPreviewSupported } from './destination-guards.js';\nimport { resolveDeliveryClient, type ClientOptions } from './client-resolution.js';\nimport { ExperienceFetchError } from './errors.js';\n\nexport type FetchDestinationSitemapOptions = {\n spaceId: string;\n destinationId: string;\n};\n\nexport type FetchDestinationSitemapPaginationOptions = {\n /** Maximum number of paths to return. Defaults to `100`, maximum `1000`. */\n limit?: number;\n /** Cursor from a previous call's `pages.next`. Treat as opaque; don't combine with `pagePrev`. */\n pageNext?: string;\n /** Cursor from a previous call's `pages.prev`. Treat as opaque; don't combine with `pageNext`. */\n pagePrev?: string;\n};\n\nexport type SitemapPathItem = {\n /** Path this entry routes. */\n path: string;\n /** Flat id extracted from the entry's `experienceUrn`. */\n experienceId: string;\n /** Type of the Destination Node that claims this path, e.g. `\"DestinationExperienceNode\"`. */\n type: string;\n};\n\nexport type DestinationSitemapResult = {\n items: SitemapPathItem[];\n limit: number;\n pages: { next?: string; prev?: string };\n};\n\n/**\n * List every routable path in a published Destination. Bulk enumeration —\n * pairs with `fetchExperience`'s `destinationId` + `nodeId`/`path` branches,\n * which resolve one path at a time. Does not hydrate any Experience itself\n * and does not call `fetchExperience` internally.\n */\nexport async function fetchDestinationSitemap(\n destinationOptions: FetchDestinationSitemapOptions,\n clientOptions: ClientOptions,\n paginationOptions: FetchDestinationSitemapPaginationOptions = {}\n): Promise<DestinationSitemapResult> {\n const { spaceId, destinationId } = destinationOptions;\n const log = createDebugLogger(false, 'client');\n\n if (!('client' in clientOptions)) {\n assertDestinationPreviewSupported(clientOptions.preview, { spaceId, destinationId });\n }\n\n const client = resolveDeliveryClient(clientOptions, log, 'fetchDestinationSitemap');\n\n const { limit, pageNext, pagePrev } = paginationOptions;\n\n let response: ContentfulViewDelivery.DestinationSitemap;\n try {\n response = await client.destination.sitemap(spaceId, destinationId, {\n limit,\n pageNext,\n pagePrev,\n });\n } catch (err) {\n if (err instanceof ContentfulViewDelivery.NotFoundError) {\n throw err;\n }\n const reason = err instanceof Error ? err.message : String(err);\n throw new ExperienceFetchError(\n `Failed to fetch sitemap for Destination \"${destinationId}\" (space \"${spaceId}\"): ` +\n `${reason}. Check network connectivity, the access token, and that the space/` +\n `destination ids are correct.`,\n { spaceId, experienceId: destinationId, cause: err }\n );\n }\n\n const result = {\n items: response.paths.items.map((item) => ({\n path: item.path,\n experienceId: extractIdFromUrn(item.experienceUrn),\n type: item.sys.type,\n })),\n limit: response.paths.limit,\n pages: response.paths.pages,\n };\n\n log.lazy('received sitemap page', () => result);\n\n return result;\n}\n\n/**\n * Extract the flat id from an `experienceUrn`. Real shape:\n * crn:contentful:::experience:spaces/$self/environments/$self/experiences/<id>\n *\n * Same one-line logic as the private `extractIdFromUrn` in\n * `packages/core/src/resolve-experience.ts` — not shared across the\n * `core`/`client` package boundary (core stays zero-dep) for one line.\n */\nfunction extractIdFromUrn(urn: string): string {\n const segments = urn.split('/').filter((s) => s.length > 0);\n return segments[segments.length - 1] ?? urn;\n}\n"],"mappings":";AAAA,SAAS,0BAAAA,+BAA8B;AAEvC;AAAA,EACE,0BAAAA;AAAA,EACA,gCAAAC;AAAA,OACK;;;ACYA,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EAET,YACE,SACA,SAMA;AACA,UAAM,SAAS,QAAQ,UAAU,SAAY,EAAE,OAAO,QAAQ,MAAM,IAAI,MAAS;AACjF,SAAK,OAAO;AACZ,SAAK,UAAU,QAAQ;AACvB,SAAK,gBAAgB,QAAQ;AAC7B,SAAK,eAAe,QAAQ;AAAA,EAC9B;AACF;AAiBO,IAAM,sCAAN,cAAkD,MAAM;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YACE,SACA,SACA;AACA,UAAM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KAAqB;AAC7C,QAAM,WAAW,IAAI,MAAM,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC;AAC1D,SAAO,SAAS,SAAS,SAAS,CAAC,KAAK;AAC1C;;;AXjGO,IAAM,gBAAgBC,wBAAuB;","names":["ContentfulViewDelivery","ContentfulViewDeliveryClient","spaceId","personalization","extensions","ContentfulViewDelivery","createDebugLogger","createDebugLogger","ContentfulViewDelivery","ContentfulViewDelivery"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experiences-client",
3
- "version": "0.10.9",
3
+ "version": "0.10.10",
4
4
  "description": "Delivery client + fetchExperience for Contentful Experiences",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -35,7 +35,7 @@
35
35
  "directory": "packages/client"
36
36
  },
37
37
  "dependencies": {
38
- "@contentful/experience-delivery": "1.0.0-dev.10",
39
- "@contentful/experiences-sdk-core": "0.13.8"
38
+ "@contentful/experience-delivery": "1.0.0-dev.11",
39
+ "@contentful/experiences-sdk-core": "0.13.9"
40
40
  }
41
41
  }