@contentful/experiences-client 0.2.1 → 0.3.1

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,104 @@
1
+ ## 0.3.1 (2026-08-07)
2
+
3
+ ### 🚀 Features
4
+
5
+ - server-side design pre-resolution against a fallback viewport [AIS-386] ([#119](https://github.com/contentful/experiences/pull/119))
6
+
7
+ ### 🧱 Updated Dependencies
8
+
9
+ - Updated core to 0.7.1
10
+
11
+ ## 0.3.0 (2026-08-07)
12
+
13
+ ### 🩹 Fixes
14
+
15
+ - ⚠️ bump @contentful/experience-delivery to 1.0.0-dev.6 + migrate to renamed API [AIS-339] ([#120](https://github.com/contentful/experiences/pull/120))
16
+
17
+ ### ⚠️ Breaking Changes
18
+
19
+ - bump @contentful/experience-delivery to 1.0.0-dev.6 + migrate to renamed API [AIS-339] ([#120](https://github.com/contentful/experiences/pull/120))
20
+ the public API uses the component / experienceTemplate vocabulary.
21
+ - `registration.componentTypeId` -> `registration.componentId`
22
+ - `plan.template` -> `plan.experienceTemplate`
23
+ - `PortableTemplate` -> `PortableExperienceTemplate` (`templateId` ->
24
+ `experienceTemplateId`)
25
+ - `Config.templates` -> `Config.experienceTemplates`; `Templates` ->
26
+ `ExperienceTemplates`
27
+ - `defineTemplate` -> `defineExperienceTemplate`; `TemplateConfig` ->
28
+ `ExperienceTemplateConfig`; `TemplateRegistration` ->
29
+ `ExperienceTemplateRegistration`; `normalizeTemplateRegistration` ->
30
+ `normalizeExperienceTemplateRegistration`
31
+ - `useContentfulTemplate()` / `getContentfulTemplate()` ->
32
+ `useContentfulExperienceTemplate()` / `getContentfulExperienceTemplate()`;
33
+ `ContentfulTemplate` -> `ContentfulExperienceTemplate`
34
+ - `MissingComponentProps.componentTypeId` -> `componentId`
35
+ - Core payload types: `ComponentTypeNode`/`ComponentTypeRef` ->
36
+ `ComponentNode`/`ComponentRef`; `TemplateNode`/`TemplateRef` ->
37
+ `ExperienceTemplateNode`/`ExperienceTemplateRef`
38
+ `packages/core` stays zero-dep, so its payload types are hand-mirrored from the
39
+ delivery package rather than imported; each carries a doc comment naming its
40
+ upstream counterpart, and `client:typecheck` catches drift when the delivery SDK
41
+ regenerates. Documented in AGENTS.md.
42
+ `examples/scripts/` is intentionally unchanged: it targets the management SDK
43
+ (`contentful-management`), which has its own entity-type surface, and adopting it
44
+ would require changing that dependency. The seed script therefore still
45
+ provisions the shapes that SDK produces.
46
+ Verified: build, typecheck, and 157 tests pass across all five packages.
47
+ Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
48
+ * docs: describe current state only in comments and docs
49
+ Drop ticket ids, tracker links, and before/after narrative from doc comments and
50
+ prose so they explain what the code does now rather than how it got here.
51
+ - `alpha-feature.ts`: state what the header selects and why it is required,
52
+ without the two-shapes-in-transition framing or the removal timeline.
53
+ - `core/src/types.ts`: keep each type's upstream counterpart in
54
+ `@contentful/experience-delivery` (load-bearing for maintenance) but drop the
55
+ "formerly known as" and old-link-type asides.
56
+ - README: replace the rename migration table with a description of the
57
+ alpha-feature header and when a caller needs to send it.
58
+ - AGENTS.md: reframe the rationale entries that opened on prior designs to state
59
+ the current design and its reason.
60
+ - Drop stale option-shape asides ("was nested under ...") and a test name that
61
+ described superseded behaviour.
62
+ Generated CHANGELOG.md files are untouched — they are release history.
63
+ Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
64
+ * feat!: migrate bootstrap fixture script to component/experienceTemplate entities
65
+ contentful-management@12.14.0 exposes the renamed ExO entities (Component,
66
+ ExperienceTemplate) alongside the deprecated ComponentType/Template ones. Adopt
67
+ the renamed shapes throughout examples/scripts so a freshly bootstrapped demo
68
+ Experience uses the same entity vocabulary the delivery-consuming packages now
69
+ read.
70
+ - Bump contentful-management to ^12.14.0 (existing dependency, version only —
71
+ no new packages).
72
+ - fixture/component-types.ts -> fixture/components.ts: ComponentTypeFixture ->
73
+ ComponentFixture.
74
+ - fixture/templates.ts -> fixture/experience-templates.ts:
75
+ TemplateFixture -> ExperienceTemplateFixture, TemplateTreeNode ->
76
+ ExperienceTemplateTreeNode.
77
+ - fixture/types.ts, fixture/experience.ts: ExperienceFixture.templateId ->
78
+ experienceTemplateId; node nodeType 'InlineFragment' ->
79
+ 'InlineExperienceFragment' with componentTypeId -> componentId, matching
80
+ contentful-management's InlineExperienceFragmentNode.
81
+ - fixture/data-assemblies.ts: dataAssemblyComponentTypeLinks ->
82
+ dataAssemblyComponentLinks (componentTypeId -> componentId).
83
+ - bootstrap-example.ts: cma.componentType -> cma.component,
84
+ cma.template -> cma.experienceTemplate; sys.type 'ComponentType' ->
85
+ 'Component', 'Template' -> 'ExperienceTemplate'; resource-link types
86
+ Contentful:ComponentType -> Contentful:Component and Contentful:Template ->
87
+ Contentful:ExperienceTemplate; URN segments components/ and
88
+ experienceTemplates/; seedComponentType -> seedComponent, seedTemplate ->
89
+ seedExperienceTemplate, linkDataAssembliesToComponentTypes ->
90
+ linkDataAssembliesToComponents.
91
+ The metadata.annotations.Template composed/coded-implementation marker is
92
+ unrelated to this rename (identical shape in 12.10.0 and 12.14.0) and is left
93
+ untouched.
94
+ Verified: examples/scripts typechecks clean; the main workspace's build,
95
+ typecheck, and 157 tests are unaffected.
96
+ Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
97
+
98
+ ### 🧱 Updated Dependencies
99
+
100
+ - Updated core to 0.7.0
101
+
1
102
  ## 0.2.1 (2026-08-06)
2
103
 
3
104
  ### 🧱 Updated Dependencies
@@ -0,0 +1,6 @@
1
+ declare const ALPHA_FEATURE_HEADER = "x-contentful-enable-alpha-feature";
2
+ declare const NEW_EXO_ENTITY_TYPES = "new-exo-entity-types";
3
+ /** Ready-to-spread header bag selecting the ExO entity shapes this SDK reads. */
4
+ declare const NEW_EXO_ENTITY_TYPES_HEADERS: Record<string, string>;
5
+
6
+ export { ALPHA_FEATURE_HEADER, NEW_EXO_ENTITY_TYPES, NEW_EXO_ENTITY_TYPES_HEADERS };
@@ -0,0 +1,11 @@
1
+ const ALPHA_FEATURE_HEADER = "x-contentful-enable-alpha-feature";
2
+ const NEW_EXO_ENTITY_TYPES = "new-exo-entity-types";
3
+ const NEW_EXO_ENTITY_TYPES_HEADERS = {
4
+ [ALPHA_FEATURE_HEADER]: NEW_EXO_ENTITY_TYPES
5
+ };
6
+ export {
7
+ ALPHA_FEATURE_HEADER,
8
+ NEW_EXO_ENTITY_TYPES,
9
+ NEW_EXO_ENTITY_TYPES_HEADERS
10
+ };
11
+ //# sourceMappingURL=alpha-feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/alpha-feature.ts"],"sourcesContent":["/*\n * The Experience Delivery API gates the ExO entity shapes this SDK reads —\n * nodes linking `component` / `experienceTemplate`, and `sys.experienceTemplate`\n * for the page-level reference — behind an alpha-feature header. A request\n * without the header gets a different shape, which this SDK does not parse.\n *\n * The header is therefore required, not optional, and is sent from two places:\n * `createClient` sets it as a client default, and `fetchExperience` sends it\n * per request so a caller-supplied client is covered too.\n *\n * It also makes the response type unambiguous: the delivery client types\n * `GetExperienceResponse` as a union of the shapes the endpoint can return,\n * because it cannot know which header the caller sent. Sending the header is\n * what lets `fetch-experience.ts` narrow to `HydratedExperienceView`.\n */\n\nexport const ALPHA_FEATURE_HEADER = 'x-contentful-enable-alpha-feature';\n\nexport const NEW_EXO_ENTITY_TYPES = 'new-exo-entity-types';\n\n/** Ready-to-spread header bag selecting the ExO entity shapes this SDK reads. */\nexport const NEW_EXO_ENTITY_TYPES_HEADERS: Record<string, string> = {\n [ALPHA_FEATURE_HEADER]: NEW_EXO_ENTITY_TYPES,\n};\n"],"mappings":"AAgBO,MAAM,uBAAuB;AAE7B,MAAM,uBAAuB;AAG7B,MAAM,+BAAuD;AAAA,EAClE,CAAC,oBAAoB,GAAG;AAC1B;","names":[]}
@@ -1,10 +1,17 @@
1
1
  import { ContentfulViewDeliveryClient } from "@contentful/experience-delivery";
2
+ import { ALPHA_FEATURE_HEADER, NEW_EXO_ENTITY_TYPES } from "./alpha-feature.js";
2
3
  function createClient(options) {
3
- const { accessToken, host, ...rest } = options;
4
+ const { accessToken, host, headers, ...rest } = options;
4
5
  return new ContentfulViewDeliveryClient({
5
6
  ...rest,
6
7
  token: accessToken,
7
- baseUrl: host
8
+ baseUrl: host,
9
+ // Selects the ExO entity shapes this SDK reads (`component` /
10
+ // `experienceTemplate` links). Set as a client default so direct
11
+ // `client.experience.get(...)` calls get them too, not just
12
+ // `fetchExperience`. A caller-supplied `headers` entry for the same key
13
+ // wins, so a caller can pin a different alpha-feature set if they need to.
14
+ headers: { [ALPHA_FEATURE_HEADER]: NEW_EXO_ENTITY_TYPES, ...headers }
8
15
  });
9
16
  }
10
17
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/create-client.ts"],"sourcesContent":["import { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\n\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, ...rest } = options;\n return new ContentfulViewDeliveryClient({\n ...rest,\n token: accessToken,\n baseUrl: host,\n });\n}\n"],"mappings":"AAAA,SAAS,oCAAoC;AAYtC,SAAS,aAAa,SAA4D;AACvF,QAAM,EAAE,aAAa,MAAM,GAAG,KAAK,IAAI;AACvC,SAAO,IAAI,6BAA6B;AAAA,IACtC,GAAG;AAAA,IACH,OAAO;AAAA,IACP,SAAS;AAAA,EACX,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../src/create-client.ts"],"sourcesContent":["import { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\n\nimport { ALPHA_FEATURE_HEADER, NEW_EXO_ENTITY_TYPES } from './alpha-feature.js';\n\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 token: accessToken,\n baseUrl: host,\n // Selects the ExO entity shapes this SDK reads (`component` /\n // `experienceTemplate` links). Set as a client default so direct\n // `client.experience.get(...)` calls get them too, not just\n // `fetchExperience`. A caller-supplied `headers` entry for the same key\n // wins, so a caller can pin a different alpha-feature set if they need to.\n headers: { [ALPHA_FEATURE_HEADER]: NEW_EXO_ENTITY_TYPES, ...headers },\n });\n}\n"],"mappings":"AAAA,SAAS,oCAAoC;AAE7C,SAAS,sBAAsB,4BAA4B;AAYpD,SAAS,aAAa,SAA4D;AACvF,QAAM,EAAE,aAAa,MAAM,SAAS,GAAG,KAAK,IAAI;AAChD,SAAO,IAAI,6BAA6B;AAAA,IACtC,GAAG;AAAA,IACH,OAAO;AAAA,IACP,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMT,SAAS,EAAE,CAAC,oBAAoB,GAAG,sBAAsB,GAAG,QAAQ;AAAA,EACtE,CAAC;AACH;","names":[]}
@@ -35,8 +35,7 @@ type ResolveOptions = {
35
35
  /**
36
36
  * Arbitrary per-render metadata exposed to every resolver as
37
37
  * `ctx.experience.metadata` and readable at render time via the framework
38
- * adapter's `useExperience()` / `getExperience()`. Flattened to a top-level
39
- * option (previously nested under `context.metadata`).
38
+ * adapter's `useExperience()` / `getExperience()`.
40
39
  */
41
40
  metadata?: Record<string, unknown>;
42
41
  /**
@@ -46,6 +45,12 @@ type ResolveOptions = {
46
45
  * debug fallback). A single boolean across fetch + resolve + render.
47
46
  */
48
47
  debug?: boolean;
48
+ /**
49
+ * Per-request fallback viewport for server-side design pre-resolution. Pass
50
+ * the same id you seed the renderer's `initialViewportId` with (e.g. a
51
+ * User-Agent-derived viewport) so SSR paints correct design on first render.
52
+ */
53
+ initialViewportId?: string;
49
54
  };
50
55
  declare function fetchExperience(experienceOptions: ExperienceOptions, clientOptions: ClientOptions, resolveOptions: ResolveOptions): Promise<PortableRenderPlan>;
51
56
 
@@ -1,9 +1,10 @@
1
1
  import { createDebugLogger, resolveExperience } from "@contentful/experiences-sdk-core";
2
+ import { NEW_EXO_ENTITY_TYPES_HEADERS } from "./alpha-feature.js";
2
3
  import { createClient } from "./create-client.js";
3
4
  import { PREVIEW_HOST } from "./hosts.js";
4
5
  async function fetchExperience(experienceOptions, clientOptions, resolveOptions) {
5
6
  const { spaceId, environmentId, experienceId, locale } = experienceOptions;
6
- const { config, metadata, debug } = resolveOptions;
7
+ const { config, metadata, debug, initialViewportId } = resolveOptions;
7
8
  const log = createDebugLogger(debug, "client");
8
9
  let client;
9
10
  if ("client" in clientOptions) {
@@ -24,11 +25,20 @@ async function fetchExperience(experienceOptions, clientOptions, resolveOptions)
24
25
  log.log("created delivery client", { preview: Boolean(preview), host: resolvedHost });
25
26
  }
26
27
  log.log("fetching experience", { spaceId, environmentId, experienceId, locale });
27
- const payload = await client.view.getExperience(spaceId, environmentId, experienceId, {
28
- locale
29
- });
28
+ const response = await client.experience.get(
29
+ spaceId,
30
+ environmentId,
31
+ experienceId,
32
+ { locale },
33
+ { headers: NEW_EXO_ENTITY_TYPES_HEADERS }
34
+ );
35
+ const payload = response;
30
36
  log.lazy("received raw payload", () => payload);
31
- return resolveExperience(payload, config, { metadata, debug });
37
+ return resolveExperience(payload, config, {
38
+ metadata,
39
+ debug,
40
+ initialViewportId
41
+ });
32
42
  }
33
43
  export {
34
44
  fetchExperience
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/fetch-experience.ts"],"sourcesContent":["import type { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { createDebugLogger, resolveExperience } from '@contentful/experiences-sdk-core';\nimport type {\n ExperiencePayload,\n PortableRenderPlan,\n ResolverConfig,\n} from '@contentful/experiences-sdk-core';\nimport { createClient } from './create-client.js';\nimport { PREVIEW_HOST } from './hosts.js';\n\nexport type ExperienceOptions = {\n spaceId: string;\n environmentId: string;\n experienceId: string;\n locale?: string;\n};\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`, `fetchExperience` uses `previewToken` and the preview host;\n * when `false` or unset, it uses `accessToken` and the delivery host.\n * Ignored when a 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\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()`. Flattened to a top-level\n * option (previously nested under `context.metadata`).\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\nexport async function fetchExperience(\n experienceOptions: ExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan> {\n const { spaceId, environmentId, experienceId, locale } = experienceOptions;\n const { config, metadata, debug } = resolveOptions;\n const log = createDebugLogger(debug, 'client');\n\n let client: ContentfulViewDeliveryClient;\n if ('client' in clientOptions) {\n client = clientOptions.client;\n log.log('using caller-supplied delivery client');\n } else {\n const { accessToken, previewToken, preview, host } = clientOptions;\n if (preview && !previewToken) {\n throw new Error(\n 'fetchExperience() called with preview: true but no previewToken was provided'\n );\n }\n const resolvedHost = host ?? (preview ? PREVIEW_HOST : undefined);\n 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 }\n\n log.log('fetching experience', { spaceId, environmentId, experienceId, locale });\n\n // Response from the experience delivery client is structurally compatible with ExperiencePayload (superset)\n const payload = (await client.view.getExperience(spaceId, environmentId, experienceId, {\n locale,\n })) as unknown as ExperiencePayload;\n\n log.lazy('received raw payload', () => payload);\n\n return resolveExperience(payload, config, { metadata, debug });\n}\n"],"mappings":"AACA,SAAS,mBAAmB,yBAAyB;AAMrD,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAmD7B,eAAsB,gBACpB,mBACA,eACA,gBAC6B;AAC7B,QAAM,EAAE,SAAS,eAAe,cAAc,OAAO,IAAI;AACzD,QAAM,EAAE,QAAQ,UAAU,MAAM,IAAI;AACpC,QAAM,MAAM,kBAAkB,OAAO,QAAQ;AAE7C,MAAI;AACJ,MAAI,YAAY,eAAe;AAC7B,aAAS,cAAc;AACvB,QAAI,IAAI,uCAAuC;AAAA,EACjD,OAAO;AACL,UAAM,EAAE,aAAa,cAAc,SAAS,KAAK,IAAI;AACrD,QAAI,WAAW,CAAC,cAAc;AAC5B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,UAAM,eAAe,SAAS,UAAU,eAAe;AACvD,aAAS,aAAa;AAAA,MACpB,aAAa,UAAW,eAA0B;AAAA,MAClD,MAAM;AAAA,IACR,CAAC;AACD,QAAI,IAAI,2BAA2B,EAAE,SAAS,QAAQ,OAAO,GAAG,MAAM,aAAa,CAAC;AAAA,EACtF;AAEA,MAAI,IAAI,uBAAuB,EAAE,SAAS,eAAe,cAAc,OAAO,CAAC;AAG/E,QAAM,UAAW,MAAM,OAAO,KAAK,cAAc,SAAS,eAAe,cAAc;AAAA,IACrF;AAAA,EACF,CAAC;AAED,MAAI,KAAK,wBAAwB,MAAM,OAAO;AAE9C,SAAO,kBAAkB,SAAS,QAAQ,EAAE,UAAU,MAAM,CAAC;AAC/D;","names":[]}
1
+ {"version":3,"sources":["../src/fetch-experience.ts"],"sourcesContent":["import type {\n ContentfulViewDelivery,\n ContentfulViewDeliveryClient,\n} from '@contentful/experience-delivery';\nimport { createDebugLogger, resolveExperience } from '@contentful/experiences-sdk-core';\nimport type {\n ExperiencePayload,\n PortableRenderPlan,\n ResolverConfig,\n} from '@contentful/experiences-sdk-core';\nimport { NEW_EXO_ENTITY_TYPES_HEADERS } from './alpha-feature.js';\nimport { createClient } from './create-client.js';\nimport { PREVIEW_HOST } from './hosts.js';\n\nexport type ExperienceOptions = {\n spaceId: string;\n environmentId: string;\n experienceId: string;\n locale?: string;\n};\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`, `fetchExperience` uses `previewToken` and the preview host;\n * when `false` or unset, it uses `accessToken` and the delivery host.\n * Ignored when a 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\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 * Per-request fallback viewport for server-side design pre-resolution. Pass\n * the same id you seed the renderer's `initialViewportId` with (e.g. a\n * User-Agent-derived viewport) so SSR paints correct design on first render.\n */\n initialViewportId?: string;\n};\n\nexport async function fetchExperience(\n experienceOptions: ExperienceOptions,\n clientOptions: ClientOptions,\n resolveOptions: ResolveOptions\n): Promise<PortableRenderPlan> {\n const { spaceId, environmentId, experienceId, locale } = experienceOptions;\n const { config, metadata, debug, initialViewportId } = resolveOptions;\n const log = createDebugLogger(debug, 'client');\n\n let client: ContentfulViewDeliveryClient;\n if ('client' in clientOptions) {\n client = clientOptions.client;\n log.log('using caller-supplied delivery client');\n } else {\n const { accessToken, previewToken, preview, host } = clientOptions;\n if (preview && !previewToken) {\n throw new Error(\n 'fetchExperience() called with preview: true but no previewToken was provided'\n );\n }\n const resolvedHost = host ?? (preview ? PREVIEW_HOST : undefined);\n 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 }\n\n log.log('fetching experience', { spaceId, environmentId, experienceId, locale });\n\n // The alpha-feature header goes on the request as well as on clients built by\n // `createClient`, so a caller-supplied `{ client }` also gets the ExO entity\n // shapes this SDK reads.\n const response = await client.experience.get(\n spaceId,\n environmentId,\n experienceId,\n { locale },\n { headers: NEW_EXO_ENTITY_TYPES_HEADERS }\n );\n\n // `GetExperienceResponse` is a union of the shapes the endpoint can return;\n // the header above pins it to `HydratedExperienceView`, which is a structural\n // superset of `ExperiencePayload`.\n const payload = response as ContentfulViewDelivery.HydratedExperienceView as ExperiencePayload;\n\n log.lazy('received raw payload', () => payload);\n\n return resolveExperience(payload, config, {\n metadata,\n debug,\n initialViewportId,\n });\n}\n"],"mappings":"AAIA,SAAS,mBAAmB,yBAAyB;AAMrD,SAAS,oCAAoC;AAC7C,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAwD7B,eAAsB,gBACpB,mBACA,eACA,gBAC6B;AAC7B,QAAM,EAAE,SAAS,eAAe,cAAc,OAAO,IAAI;AACzD,QAAM,EAAE,QAAQ,UAAU,OAAO,kBAAkB,IAAI;AACvD,QAAM,MAAM,kBAAkB,OAAO,QAAQ;AAE7C,MAAI;AACJ,MAAI,YAAY,eAAe;AAC7B,aAAS,cAAc;AACvB,QAAI,IAAI,uCAAuC;AAAA,EACjD,OAAO;AACL,UAAM,EAAE,aAAa,cAAc,SAAS,KAAK,IAAI;AACrD,QAAI,WAAW,CAAC,cAAc;AAC5B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,UAAM,eAAe,SAAS,UAAU,eAAe;AACvD,aAAS,aAAa;AAAA,MACpB,aAAa,UAAW,eAA0B;AAAA,MAClD,MAAM;AAAA,IACR,CAAC;AACD,QAAI,IAAI,2BAA2B,EAAE,SAAS,QAAQ,OAAO,GAAG,MAAM,aAAa,CAAC;AAAA,EACtF;AAEA,MAAI,IAAI,uBAAuB,EAAE,SAAS,eAAe,cAAc,OAAO,CAAC;AAK/E,QAAM,WAAW,MAAM,OAAO,WAAW;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA,EAAE,OAAO;AAAA,IACT,EAAE,SAAS,6BAA6B;AAAA,EAC1C;AAKA,QAAM,UAAU;AAEhB,MAAI,KAAK,wBAAwB,MAAM,OAAO;AAE9C,SAAO,kBAAkB,SAAS,QAAQ;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ContentfulViewDelivery } from '@contentful/experience-delivery';
2
2
  export { ContentfulViewDelivery, ContentfulViewDeliveryClient } from '@contentful/experience-delivery';
3
3
  export { CreateClientOptions, createClient } from './create-client.js';
4
+ export { ALPHA_FEATURE_HEADER, NEW_EXO_ENTITY_TYPES, NEW_EXO_ENTITY_TYPES_HEADERS } from './alpha-feature.js';
4
5
  export { ClientOptions, ExperienceOptions, ResolveOptions, fetchExperience } from './fetch-experience.js';
5
6
  export { DELIVERY_HOST, PREVIEW_HOST } from './hosts.js';
6
7
  import '@contentful/experiences-sdk-core';
package/dist/index.js CHANGED
@@ -5,12 +5,20 @@ import {
5
5
  } from "@contentful/experience-delivery";
6
6
  const NotFoundError = ContentfulViewDelivery.NotFoundError;
7
7
  import { createClient } from "./create-client.js";
8
+ import {
9
+ ALPHA_FEATURE_HEADER,
10
+ NEW_EXO_ENTITY_TYPES,
11
+ NEW_EXO_ENTITY_TYPES_HEADERS
12
+ } from "./alpha-feature.js";
8
13
  import { fetchExperience } from "./fetch-experience.js";
9
14
  import { DELIVERY_HOST, PREVIEW_HOST } from "./hosts.js";
10
15
  export {
16
+ ALPHA_FEATURE_HEADER,
11
17
  ContentfulViewDelivery2 as ContentfulViewDelivery,
12
18
  ContentfulViewDeliveryClient,
13
19
  DELIVERY_HOST,
20
+ NEW_EXO_ENTITY_TYPES,
21
+ NEW_EXO_ENTITY_TYPES_HEADERS,
14
22
  NotFoundError,
15
23
  PREVIEW_HOST,
16
24
  createClient,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { ContentfulViewDelivery } from '@contentful/experience-delivery';\n\nexport {\n ContentfulViewDelivery,\n ContentfulViewDeliveryClient,\n} from '@contentful/experience-delivery';\nexport const NotFoundError = ContentfulViewDelivery.NotFoundError;\nexport type NotFoundError = InstanceType<typeof ContentfulViewDelivery.NotFoundError>;\nexport { createClient } from './create-client.js';\nexport type { CreateClientOptions } from './create-client.js';\nexport { fetchExperience } from './fetch-experience.js';\nexport type { ExperienceOptions, ClientOptions, ResolveOptions } from './fetch-experience.js';\nexport { DELIVERY_HOST, PREVIEW_HOST } from './hosts.js';\n"],"mappings":"AAAA,SAAS,8BAA8B;AAEvC;AAAA,EACE,0BAAAA;AAAA,EACA;AAAA,OACK;AACA,MAAM,gBAAgB,uBAAuB;AAEpD,SAAS,oBAAoB;AAE7B,SAAS,uBAAuB;AAEhC,SAAS,eAAe,oBAAoB;","names":["ContentfulViewDelivery"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { ContentfulViewDelivery } from '@contentful/experience-delivery';\n\nexport {\n ContentfulViewDelivery,\n ContentfulViewDeliveryClient,\n} from '@contentful/experience-delivery';\nexport const NotFoundError = ContentfulViewDelivery.NotFoundError;\nexport type NotFoundError = InstanceType<typeof ContentfulViewDelivery.NotFoundError>;\nexport { createClient } from './create-client.js';\nexport type { CreateClientOptions } from './create-client.js';\n// Exported so customers who drive `ContentfulViewDeliveryClient` themselves and\n// call `resolveExperience` on the raw payload can select the same ExO entity\n// shapes this SDK expects. `createClient` / `fetchExperience` send it for you.\nexport {\n ALPHA_FEATURE_HEADER,\n NEW_EXO_ENTITY_TYPES,\n NEW_EXO_ENTITY_TYPES_HEADERS,\n} from './alpha-feature.js';\nexport { fetchExperience } from './fetch-experience.js';\nexport type { ExperienceOptions, ClientOptions, ResolveOptions } from './fetch-experience.js';\nexport { DELIVERY_HOST, PREVIEW_HOST } from './hosts.js';\n"],"mappings":"AAAA,SAAS,8BAA8B;AAEvC;AAAA,EACE,0BAAAA;AAAA,EACA;AAAA,OACK;AACA,MAAM,gBAAgB,uBAAuB;AAEpD,SAAS,oBAAoB;AAK7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAEhC,SAAS,eAAe,oBAAoB;","names":["ContentfulViewDelivery"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experiences-client",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "Delivery client + fetchExperience for Contentful Experiences",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,7 +30,7 @@
30
30
  "directory": "packages/client"
31
31
  },
32
32
  "dependencies": {
33
- "@contentful/experience-delivery": "1.0.0-dev.3",
34
- "@contentful/experiences-sdk-core": "0.6.1"
33
+ "@contentful/experience-delivery": "1.0.0-dev.6",
34
+ "@contentful/experiences-sdk-core": "0.7.1"
35
35
  }
36
36
  }