@contentful/experiences-client 0.4.9 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +10 -10
- package/dist/contentful-experiences.d.ts +2 -2
- package/dist/contentful-experiences.js +3 -5
- package/dist/contentful-experiences.js.map +1 -1
- package/dist/sdk-info.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
## 0.5.0 (2026-09-28)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- ⚠️ add request-scoped Node SDK ([#207](https://github.com/contentful/experiences/pull/207))
|
|
6
|
+
|
|
7
|
+
### ⚠️ Breaking Changes
|
|
8
|
+
|
|
9
|
+
- add request-scoped Node SDK ([#207](https://github.com/contentful/experiences/pull/207))
|
|
10
|
+
ContentfulExperiencesConfig now requires eventBuilder.channel."
|
|
11
|
+
M .husky/pre-commit
|
|
12
|
+
M AGENTS.md
|
|
13
|
+
M ARCHITECTURE.md
|
|
14
|
+
M README.md
|
|
15
|
+
M package-lock.json
|
|
16
|
+
M packages/client/README.md
|
|
17
|
+
M packages/client/src/contentful-experiences.test.ts
|
|
18
|
+
M packages/client/src/contentful-experiences.ts
|
|
19
|
+
A packages/node/README.md
|
|
20
|
+
A packages/node/package.json
|
|
21
|
+
A packages/node/project.json
|
|
22
|
+
A packages/node/src/contentful-experiences.test.ts
|
|
23
|
+
A packages/node/src/contentful-experiences.ts
|
|
24
|
+
A packages/node/src/index.ts
|
|
25
|
+
A packages/node/src/sdk-info.ts
|
|
26
|
+
A packages/node/tsconfig.json
|
|
27
|
+
A packages/node/tsconfig.lib.json
|
|
28
|
+
A packages/node/tsup.config.ts
|
|
29
|
+
A packages/node/vitest.config.ts
|
|
30
|
+
|
|
31
|
+
### 🧱 Updated Dependencies
|
|
32
|
+
|
|
33
|
+
- Updated core to 0.9.0
|
|
34
|
+
|
|
1
35
|
## 0.4.9 (2026-09-28)
|
|
2
36
|
|
|
3
37
|
### 🚀 Features
|
package/README.md
CHANGED
|
@@ -16,16 +16,16 @@ remain supported for adapter and application integration.
|
|
|
16
16
|
|
|
17
17
|
`ContentfulExperiences` is an internal shared runtime contract for future
|
|
18
18
|
Node/Web SDKs. Construct it with a space, environment, resolver configuration,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
client.
|
|
24
|
-
|
|
25
|
-
The runtime constructs and owns one `EventBuilder`.
|
|
26
|
-
channel, this SDK's library identity
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
a delivery client source, and an `eventBuilder` config with an explicit
|
|
20
|
+
`channel`; optionally provide a preview client source. It retains those clients,
|
|
21
|
+
merges configured resolve defaults with per-call options, and exposes
|
|
22
|
+
`resolveExperience` and by-id/destination `fetchExperience` methods. Calling
|
|
23
|
+
`fetchExperience` with `preview: true` requires the optional preview client.
|
|
24
|
+
|
|
25
|
+
The runtime constructs and owns one `EventBuilder`. The caller supplies its
|
|
26
|
+
channel, while the runtime retains this SDK's default library identity and the
|
|
27
|
+
runtime locale unless overridden. This is the owner of event construction for
|
|
28
|
+
the lower layer, rather than Core.
|
|
29
29
|
|
|
30
30
|
This package's direct dependencies are the generated delivery client,
|
|
31
31
|
`@contentful/optimization-api-client` (event schemas and logger), `es-toolkit`
|
|
@@ -15,7 +15,7 @@ type RuntimeResolveOptions = {
|
|
|
15
15
|
initialViewportId?: string;
|
|
16
16
|
};
|
|
17
17
|
type RuntimeEventBuilderConfig = Omit<EventBuilderConfig, 'channel' | 'library'> & {
|
|
18
|
-
channel
|
|
18
|
+
channel: EventBuilderConfig['channel'];
|
|
19
19
|
library?: Partial<EventBuilderConfig['library']>;
|
|
20
20
|
};
|
|
21
21
|
type RuntimeFetchExperienceOptions = {
|
|
@@ -51,7 +51,7 @@ type ContentfulExperiencesConfig = {
|
|
|
51
51
|
delivery: RuntimeClientSource;
|
|
52
52
|
preview?: RuntimeClientSource;
|
|
53
53
|
resolveDefaults?: Pick<RuntimeResolveOptions, 'metadata' | 'debug'>;
|
|
54
|
-
eventBuilder
|
|
54
|
+
eventBuilder: RuntimeEventBuilderConfig;
|
|
55
55
|
};
|
|
56
56
|
declare class ContentfulExperiences implements ExperienceRuntime {
|
|
57
57
|
#private;
|
|
@@ -21,12 +21,10 @@ class ContentfulExperiences {
|
|
|
21
21
|
this.#deliveryClient = resolveClient(config.delivery);
|
|
22
22
|
this.#previewClient = config.preview === void 0 ? void 0 : resolveClient(config.preview, PREVIEW_HOST);
|
|
23
23
|
this.#resolveDefaults = config.resolveDefaults ?? {};
|
|
24
|
-
const eventBuilder = config.eventBuilder ?? {};
|
|
25
24
|
this.eventBuilder = new EventBuilder({
|
|
26
|
-
...eventBuilder,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
getLocale: eventBuilder.getLocale ?? (() => this.locale)
|
|
25
|
+
...config.eventBuilder,
|
|
26
|
+
library: { ...DEFAULT_EVENT_CONTEXT_LIBRARY, ...config.eventBuilder.library },
|
|
27
|
+
getLocale: config.eventBuilder.getLocale ?? (() => this.locale)
|
|
30
28
|
});
|
|
31
29
|
}
|
|
32
30
|
resolveExperience(payload, resolveOptions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/contentful-experiences.ts"],"sourcesContent":["import type { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { resolveExperience as resolveCoreExperience } from '@contentful/experiences-sdk-core';\nimport type {\n ExperiencePayload,\n PortableRenderPlan,\n ResolverConfig,\n} from '@contentful/experiences-sdk-core';\nimport EventBuilder from './event-builder.js';\nimport type { EventBuilderConfig } from './event-builder.js';\nimport { createClient } from './create-client.js';\nimport { fetchExperience, type DestinationRedirectResult } from './fetch-experience.js';\nimport type { CreateClientOptions } from './create-client.js';\nimport { PREVIEW_HOST } from './hosts.js';\nimport { DEFAULT_EVENT_CONTEXT_LIBRARY } from './sdk-info.js';\n\nexport type RuntimeClientSource = CreateClientOptions | { client: ContentfulViewDeliveryClient };\n\nexport type RuntimeResolveOptions = {\n metadata?: Record<string, unknown>;\n debug?: boolean;\n initialViewportId?: string;\n};\n\nexport type RuntimeEventBuilderConfig = Omit<EventBuilderConfig, 'channel' | 'library'> & {\n channel
|
|
1
|
+
{"version":3,"sources":["../src/contentful-experiences.ts"],"sourcesContent":["import type { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\nimport { resolveExperience as resolveCoreExperience } from '@contentful/experiences-sdk-core';\nimport type {\n ExperiencePayload,\n PortableRenderPlan,\n ResolverConfig,\n} from '@contentful/experiences-sdk-core';\nimport EventBuilder from './event-builder.js';\nimport type { EventBuilderConfig } from './event-builder.js';\nimport { createClient } from './create-client.js';\nimport { fetchExperience, type DestinationRedirectResult } from './fetch-experience.js';\nimport type { CreateClientOptions } from './create-client.js';\nimport { PREVIEW_HOST } from './hosts.js';\nimport { DEFAULT_EVENT_CONTEXT_LIBRARY } from './sdk-info.js';\n\nexport type RuntimeClientSource = CreateClientOptions | { client: ContentfulViewDeliveryClient };\n\nexport type RuntimeResolveOptions = {\n metadata?: Record<string, unknown>;\n debug?: boolean;\n initialViewportId?: string;\n};\n\nexport type RuntimeEventBuilderConfig = Omit<EventBuilderConfig, 'channel' | 'library'> & {\n channel: EventBuilderConfig['channel'];\n library?: Partial<EventBuilderConfig['library']>;\n};\n\nexport type RuntimeFetchExperienceOptions = {\n experienceId: string;\n locale?: string;\n preview?: boolean;\n withSourceMap?: boolean;\n};\n\nexport type RuntimeFetchByDestinationNodeOptions = {\n destinationId: string;\n nodeId: string;\n};\n\nexport type RuntimeFetchByDestinationPathOptions = {\n destinationId: string;\n path: string;\n};\n\n/** Structural contract implemented by the Client runtime. */\nexport interface ExperienceRuntime {\n readonly spaceId: string;\n readonly environmentId: string;\n readonly locale: string | undefined;\n readonly eventBuilder: EventBuilder;\n resolveExperience(\n payload: ExperiencePayload,\n resolveOptions?: RuntimeResolveOptions\n ): Promise<PortableRenderPlan>;\n fetchExperience(\n options: RuntimeFetchExperienceOptions,\n resolveOptions?: RuntimeResolveOptions\n ): Promise<PortableRenderPlan>;\n fetchByDestinationNode(\n options: RuntimeFetchByDestinationNodeOptions,\n resolveOptions?: RuntimeResolveOptions\n ): Promise<PortableRenderPlan | DestinationRedirectResult>;\n fetchByDestinationPath(\n options: RuntimeFetchByDestinationPathOptions,\n resolveOptions?: RuntimeResolveOptions\n ): Promise<PortableRenderPlan | DestinationRedirectResult>;\n}\n\nexport type ContentfulExperiencesConfig = {\n spaceId: string;\n environmentId: string;\n locale?: string;\n resolverConfig: ResolverConfig;\n delivery: RuntimeClientSource;\n preview?: RuntimeClientSource;\n resolveDefaults?: Pick<RuntimeResolveOptions, 'metadata' | 'debug'>;\n eventBuilder: RuntimeEventBuilderConfig;\n};\n\nexport class ContentfulExperiences implements ExperienceRuntime {\n readonly spaceId: string;\n readonly environmentId: string;\n readonly locale: string | undefined;\n readonly eventBuilder: EventBuilder;\n\n readonly #resolverConfig: ResolverConfig;\n readonly #deliveryClient: ContentfulViewDeliveryClient;\n readonly #previewClient: ContentfulViewDeliveryClient | undefined;\n readonly #resolveDefaults: Pick<RuntimeResolveOptions, 'metadata' | 'debug'>;\n\n constructor(config: ContentfulExperiencesConfig) {\n this.spaceId = config.spaceId;\n this.environmentId = config.environmentId;\n this.locale = config.locale;\n this.#resolverConfig = config.resolverConfig;\n this.#deliveryClient = resolveClient(config.delivery);\n this.#previewClient =\n config.preview === undefined ? undefined : resolveClient(config.preview, PREVIEW_HOST);\n this.#resolveDefaults = config.resolveDefaults ?? {};\n\n this.eventBuilder = new EventBuilder({\n ...config.eventBuilder,\n library: { ...DEFAULT_EVENT_CONTEXT_LIBRARY, ...config.eventBuilder.library },\n getLocale: config.eventBuilder.getLocale ?? (() => this.locale),\n });\n }\n\n resolveExperience(\n payload: ExperiencePayload,\n resolveOptions?: RuntimeResolveOptions\n ): Promise<PortableRenderPlan> {\n return resolveCoreExperience(\n payload,\n this.#resolverConfig,\n this.#mergeResolveOptions(resolveOptions)\n );\n }\n\n fetchExperience(\n options: RuntimeFetchExperienceOptions,\n resolveOptions?: RuntimeResolveOptions\n ): Promise<PortableRenderPlan> {\n if (options.preview === true && this.#previewClient === undefined) {\n throw new Error(\n 'fetchExperience() called with preview: true but this runtime has no preview client'\n );\n }\n return fetchExperience(\n {\n spaceId: this.spaceId,\n environmentId: this.environmentId,\n experienceId: options.experienceId,\n locale: options.locale ?? this.locale,\n withSourceMap: options.withSourceMap,\n },\n {\n client: options.preview\n ? (this.#previewClient as ContentfulViewDeliveryClient)\n : this.#deliveryClient,\n },\n { config: this.#resolverConfig, ...this.#mergeResolveOptions(resolveOptions) }\n );\n }\n\n fetchByDestinationNode(\n options: RuntimeFetchByDestinationNodeOptions,\n resolveOptions?: RuntimeResolveOptions\n ): Promise<PortableRenderPlan | DestinationRedirectResult> {\n return fetchExperience(\n { spaceId: this.spaceId, destinationId: options.destinationId, nodeId: options.nodeId },\n { client: this.#deliveryClient },\n { config: this.#resolverConfig, ...this.#mergeResolveOptions(resolveOptions) }\n );\n }\n\n fetchByDestinationPath(\n options: RuntimeFetchByDestinationPathOptions,\n resolveOptions?: RuntimeResolveOptions\n ): Promise<PortableRenderPlan | DestinationRedirectResult> {\n return fetchExperience(\n { spaceId: this.spaceId, destinationId: options.destinationId, path: options.path },\n { client: this.#deliveryClient },\n { config: this.#resolverConfig, ...this.#mergeResolveOptions(resolveOptions) }\n );\n }\n\n #mergeResolveOptions(options: RuntimeResolveOptions | undefined): RuntimeResolveOptions {\n return {\n metadata: { ...this.#resolveDefaults.metadata, ...options?.metadata },\n debug: options?.debug ?? this.#resolveDefaults.debug,\n initialViewportId: options?.initialViewportId,\n };\n }\n}\n\nfunction resolveClient(\n source: RuntimeClientSource,\n defaultHost?: string\n): ContentfulViewDeliveryClient {\n return 'client' in source\n ? source.client\n : createClient({ ...source, host: source.host ?? defaultHost });\n}\n"],"mappings":"AACA,SAAS,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AQ,KAAK,iBAAiB,GAAG,KAAK,qBAAqB,cAAc,EAAE;AAAA,IAC/E;AAAA,EACF;AAAA,EAEA,uBACE,SACA,gBACyD;AACzD,WAAO;AAAA,MACL,EAAE,SAAS,KAAK,SAAS,eAAe,QAAQ,eAAe,QAAQ,QAAQ,OAAO;AAAA,MACtF,EAAE,QAAQ,KAAK,gBAAgB;AAAA,MAC/B,EAAE,QAAQ,KAAK,iBAAiB,GAAG,KAAK,qBAAqB,cAAc,EAAE;AAAA,IAC/E;AAAA,EACF;AAAA,EAEA,uBACE,SACA,gBACyD;AACzD,WAAO;AAAA,MACL,EAAE,SAAS,KAAK,SAAS,eAAe,QAAQ,eAAe,MAAM,QAAQ,KAAK;AAAA,MAClF,EAAE,QAAQ,KAAK,gBAAgB;AAAA,MAC/B,EAAE,QAAQ,KAAK,iBAAiB,GAAG,KAAK,qBAAqB,cAAc,EAAE;AAAA,IAC/E;AAAA,EACF;AAAA,EAEA,qBAAqB,SAAmE;AACtF,WAAO;AAAA,MACL,UAAU,EAAE,GAAG,KAAK,iBAAiB,UAAU,GAAG,SAAS,SAAS;AAAA,MACpE,OAAO,SAAS,SAAS,KAAK,iBAAiB;AAAA,MAC/C,mBAAmB,SAAS;AAAA,IAC9B;AAAA,EACF;AACF;AAEA,SAAS,cACP,QACA,aAC8B;AAC9B,SAAO,YAAY,SACf,OAAO,SACP,aAAa,EAAE,GAAG,QAAQ,MAAM,OAAO,QAAQ,YAAY,CAAC;AAClE;","names":[]}
|
package/dist/sdk-info.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experiences-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Delivery client + fetchExperience for Contentful Experiences",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@contentful/experience-delivery": "1.0.0-dev.8",
|
|
34
|
-
"@contentful/experiences-sdk-core": "0.
|
|
34
|
+
"@contentful/experiences-sdk-core": "0.9.0",
|
|
35
35
|
"@contentful/optimization-api-client": "^2.0.1",
|
|
36
36
|
"es-toolkit": "^1.46.0",
|
|
37
37
|
"zod": "^4.3.6"
|