@contentful/experiences-client 0.9.1 → 0.9.2
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 +10 -0
- package/README.md +1 -87
- package/dist/create-delivery-client.d.ts +1 -15
- package/dist/create-delivery-client.js +1 -15
- package/dist/create-delivery-client.js.map +1 -1
- package/dist/index.d.ts +1 -10
- package/dist/index.js +0 -19
- package/dist/index.js.map +1 -1
- package/package.json +2 -5
- package/dist/constants.d.ts +0 -11
- package/dist/constants.js +0 -7
- package/dist/constants.js.map +0 -1
- package/dist/contentful-experiences.d.ts +0 -76
- package/dist/contentful-experiences.js +0 -104
- package/dist/contentful-experiences.js.map +0 -1
- package/dist/create-optimization-client.d.ts +0 -20
- package/dist/create-optimization-client.js +0 -30
- package/dist/create-optimization-client.js.map +0 -1
- package/dist/event-builder.d.ts +0 -444
- package/dist/event-builder.js +0 -282
- package/dist/event-builder.js.map +0 -1
- package/dist/runtime-event-handoff.d.ts +0 -33
- package/dist/runtime-event-handoff.js +0 -68
- package/dist/runtime-event-handoff.js.map +0 -1
- package/dist/runtime-event-methods.d.ts +0 -52
- package/dist/runtime-event-methods.js +0 -109
- package/dist/runtime-event-methods.js.map +0 -1
- package/dist/sdk-info.d.ts +0 -12
- package/dist/sdk-info.js +0 -8
- package/dist/sdk-info.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 0.9.2 (2026-10-09)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **runtime:** extract shared runtime from client ([#228](https://github.com/contentful/experiences/pull/228))
|
|
6
|
+
|
|
7
|
+
### 🧱 Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- Updated core to 0.12.1
|
|
10
|
+
|
|
1
11
|
## 0.9.1 (2026-10-08)
|
|
2
12
|
|
|
3
13
|
### 🚀 Features
|
package/README.md
CHANGED
|
@@ -2,98 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
> **Internal package.** Published to npm so framework adapters can resolve it at install time, but you're not meant to import it directly. It comes in transitively via the framework adapter (`@contentful/experiences-react`, `@contentful/experiences-svelte`, etc.).
|
|
4
4
|
|
|
5
|
-
Isolates `@contentful/experience-delivery` — the generated
|
|
6
|
-
|
|
7
|
-
`ContentfulExperiences` is intentionally not re-exported by framework adapters
|
|
8
|
-
and is not a new application-facing adapter API. The existing free functions
|
|
9
|
-
remain supported for adapter and application integration.
|
|
5
|
+
Isolates `@contentful/experience-delivery` — the generated Experience Delivery client — and owns the free fetch functions, payload conversion, delivery errors, and XDA-derived request types. The shared runtime and complete `EventBuilder` live in `@contentful/experiences-runtime`, which depends on this package. Client does not build events or depend on Runtime. The existing free functions remain supported for adapter and application integration.
|
|
10
6
|
|
|
11
7
|
---
|
|
12
8
|
|
|
13
9
|
## What's in here
|
|
14
10
|
|
|
15
|
-
### Shared lower-layer runtime
|
|
16
|
-
|
|
17
|
-
`ContentfulExperiences` is an internal shared runtime contract for the public
|
|
18
|
-
Node/Web SDKs. Construct it with a space, environment, resolver configuration,
|
|
19
|
-
a delivery configuration, and an `eventBuilder` config with an explicit
|
|
20
|
-
`channel`; optionally provide a preview configuration. It constructs and retains
|
|
21
|
-
those clients, merges configured resolve defaults with per-call options, and
|
|
22
|
-
exposes `resolveExperience` and by-id/destination `fetchExperience` methods.
|
|
23
|
-
Calling `fetchExperience` with `preview: true` requires preview configuration.
|
|
24
|
-
|
|
25
|
-
The runtime-owned Delivery and Preview clients support two security models. For
|
|
26
|
-
direct API access, provide an `accessToken`; it may be a supplier and is sent to
|
|
27
|
-
the selected endpoint. For a trusted application proxy that adds the upstream
|
|
28
|
-
token itself, omit `accessToken` and provide an explicit `host`; the runtime
|
|
29
|
-
disables generated bearer authentication. `environmentId` is the Contentful
|
|
30
|
-
environment identifier passed to by-ID requests, not the generated delivery
|
|
31
|
-
client's optional endpoint-valued `environment`. Endpoint precedence is
|
|
32
|
-
explicit `host`, then generated-client `environment`, then the delivery or
|
|
33
|
-
preview default.
|
|
34
|
-
|
|
35
|
-
Direct browser tokens are credentials but are intentionally browser-visible
|
|
36
|
-
when an application's scope and CORS policy permit that model. Proxy mode keeps
|
|
37
|
-
the upstream token server-side. In either mode, treat custom endpoints as
|
|
38
|
-
trusted configuration.
|
|
39
|
-
|
|
40
|
-
The optional preview client enables direct CPA fetches by Experience ID through
|
|
41
|
-
the same shared runtime. It is separate from `@contentful/experiences-live-preview`,
|
|
42
|
-
which owns Preview Session HTTP loading, WebSocket subscription, and update state.
|
|
43
|
-
Destination operations continue to use the delivery client.
|
|
44
|
-
|
|
45
|
-
The runtime constructs and owns one `EventBuilder` and one Optimization API
|
|
46
|
-
client. The caller supplies the event channel, while the runtime retains this
|
|
47
|
-
SDK's default library identity and the runtime locale unless overridden. This
|
|
48
|
-
package owns event construction and direct transport for the lower layer,
|
|
49
|
-
rather than Core. It exposes a protected binding point used by the public Node
|
|
50
|
-
and Web leaves; Client itself does not retain a mutable event profile.
|
|
51
|
-
|
|
52
|
-
By default the Optimization client uses the runtime's `spaceId` and maps its
|
|
53
|
-
Contentful `environmentId` to the Optimization client's `environment` option.
|
|
54
|
-
This is the same Contentful environment identifier passed to by-ID delivery
|
|
55
|
-
requests, not the generated delivery client's endpoint-valued `environment`
|
|
56
|
-
setting. The optional `optimization` configuration can provide API-specific
|
|
57
|
-
endpoint, feature, and fetch overrides; the runtime always constructs and owns
|
|
58
|
-
the Optimization client. Custom Optimization base URLs receive complete event
|
|
59
|
-
and profile payloads, so treat them as sensitive-data destinations and use only
|
|
60
|
-
trusted HTTPS origins outside explicit local development.
|
|
61
|
-
|
|
62
|
-
The bound event methods normally send immediately: `identify`, `page`, and
|
|
63
|
-
`track` upsert a profile through the Personalization API; view, click, hover,
|
|
64
|
-
and flag-view events send a one-event batch through Analytics. Queues, durable
|
|
65
|
-
profile persistence, consent gating, lifecycle/beacon delivery, automatic
|
|
66
|
-
interaction tracking, and Live Preview integration are intentionally absent.
|
|
67
|
-
The Node leaf additionally has a request-scoped, one-shot handoff journal for
|
|
68
|
-
paired browser replay; it is not an SDK queue or persistence mechanism. Because
|
|
69
|
-
calls are not serialized, callers must await profile-producing calls before
|
|
70
|
-
starting another profile-producing or Analytics call on the same bound runtime.
|
|
71
|
-
|
|
72
|
-
### Server-to-browser event handoff contract
|
|
73
|
-
|
|
74
|
-
`RuntimeEventHandoff` is the internal replay payload between Node and Web. Node
|
|
75
|
-
alone chooses direct `commit` or paired-browser `handoff` delivery per request.
|
|
76
|
-
The handoff holds a version, Contentful scope, optional initial profile, ordered
|
|
77
|
-
Personalization/Analytics event bodies, and an optional initial-page route key. Its
|
|
78
|
-
internal serialized-payload cap is 64 KiB. Node can preflight the initial
|
|
79
|
-
Personalization sequence as one batch; individual Personalization methods remain
|
|
80
|
-
cumulative and Analytics methods stage without transport. Web validates the
|
|
81
|
-
payload, admits page-bearing journals only for a matching browser route,
|
|
82
|
-
batches compatible adjacent Personalization entries, preserves locale and Analytics
|
|
83
|
-
ordering boundaries, and chains each resulting profile.
|
|
84
|
-
|
|
85
|
-
The payload is browser-visible sensitive data. Application integration must use
|
|
86
|
-
escaped serialization in a private, no-store response and exclude secrets and
|
|
87
|
-
server-only traits. Do not cache, log, or persist it. Replay may partially
|
|
88
|
-
commit, has no automatic retry or distributed exactly-once guarantee, and is
|
|
89
|
-
independent from Live Preview. A failed replay rejects its receipt but releases
|
|
90
|
-
later direct Web calls. See the root [paired replay guide](../../README.md#paired-server-to-browser-replay).
|
|
91
|
-
|
|
92
|
-
This package's direct dependencies are the generated delivery client,
|
|
93
|
-
`@contentful/optimization-api-client` (event schemas, logger, and transport), `es-toolkit`
|
|
94
|
-
(event-property merging), and `zod` (event argument schemas), in addition to
|
|
95
|
-
Core. None of those dependencies are introduced into Core.
|
|
96
|
-
|
|
97
11
|
### `fetchExperience(experienceOptions, clientOptions, resolveOptions)`
|
|
98
12
|
|
|
99
13
|
The primary fetch + resolve entry point. Fetches an Experience payload from the Experience Delivery API and resolves it into a `PortableRenderPlan` in one call.
|
|
@@ -10,20 +10,6 @@ type CreateClientOptions = {
|
|
|
10
10
|
*/
|
|
11
11
|
host?: string;
|
|
12
12
|
} & Omit<ContentfulViewDeliveryClient.Options, 'token' | 'baseUrl'>;
|
|
13
|
-
type RuntimeDeliveryClientBaseOptions = Omit<ContentfulViewDeliveryClient.Options, 'token' | 'baseUrl'>;
|
|
14
|
-
/** Configuration for a Delivery or Preview client owned by a runtime. */
|
|
15
|
-
type RuntimeDeliveryClientOptions = RuntimeDeliveryClientBaseOptions & ({
|
|
16
|
-
/** Bearer token or token supplier used for direct Delivery/Preview API access. */
|
|
17
|
-
accessToken: ContentfulViewDeliveryClient.Options['token'];
|
|
18
|
-
/** Optional endpoint override or endpoint supplier. */
|
|
19
|
-
host?: ContentfulViewDeliveryClient.Options['baseUrl'];
|
|
20
|
-
} | {
|
|
21
|
-
accessToken?: never;
|
|
22
|
-
/** Explicit proxy endpoint that owns upstream authentication. */
|
|
23
|
-
host: NonNullable<ContentfulViewDeliveryClient.Options['baseUrl']>;
|
|
24
|
-
});
|
|
25
13
|
declare function createClient(options: CreateClientOptions): ContentfulViewDeliveryClient;
|
|
26
|
-
/** Constructs a runtime-owned client, disabling generated auth for a tokenless proxy. */
|
|
27
|
-
declare function createRuntimeDeliveryClient(options: RuntimeDeliveryClientOptions, defaultHost?: NonNullable<ContentfulViewDeliveryClient.Options['baseUrl']>): ContentfulViewDeliveryClient;
|
|
28
14
|
|
|
29
|
-
export { type CreateClientOptions,
|
|
15
|
+
export { type CreateClientOptions, createClient };
|
|
@@ -7,21 +7,7 @@ function createClient(options) {
|
|
|
7
7
|
baseUrl: host
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
|
-
function createRuntimeDeliveryClient(options, defaultHost) {
|
|
11
|
-
const { accessToken, host, ...rest } = options;
|
|
12
|
-
if (accessToken === void 0 && host === void 0) {
|
|
13
|
-
throw new Error(
|
|
14
|
-
"Runtime delivery configuration requires accessToken unless an explicit proxy host is provided"
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
const baseUrl = host ?? (rest.environment === void 0 ? defaultHost : void 0);
|
|
18
|
-
const clientOptions = accessToken === void 0 ? { ...rest, auth: rest.auth ?? false, baseUrl } : { ...rest, token: accessToken, baseUrl };
|
|
19
|
-
return new ContentfulViewDeliveryClient(
|
|
20
|
-
clientOptions
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
10
|
export {
|
|
24
|
-
createClient
|
|
25
|
-
createRuntimeDeliveryClient
|
|
11
|
+
createClient
|
|
26
12
|
};
|
|
27
13
|
//# sourceMappingURL=create-delivery-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create-delivery-client.ts"],"sourcesContent":["import { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\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\
|
|
1
|
+
{"version":3,"sources":["../src/create-delivery-client.ts"],"sourcesContent":["import { ContentfulViewDeliveryClient } from '@contentful/experience-delivery';\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, ...rest } = options;\n return new ContentfulViewDeliveryClient({\n ...rest,\n token: accessToken,\n baseUrl: host,\n });\n}\n"],"mappings":"AAAA,SAAS,oCAAoC;AAatC,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":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import { ContentfulViewDelivery } from '@contentful/experience-delivery';
|
|
2
2
|
export { ContentfulViewDelivery, ContentfulViewDeliveryClient } from '@contentful/experience-delivery';
|
|
3
3
|
export { DestinationPreviewNotSupportedError, ExperienceFetchError } from './errors.js';
|
|
4
|
-
export {
|
|
5
|
-
export { CreateClientOptions, RuntimeDeliveryClientOptions, createClient } from './create-delivery-client.js';
|
|
6
|
-
export { RuntimeOptimizationConfig } from './create-optimization-client.js';
|
|
7
|
-
export { ClickBuilderArgs, DEFAULT_PAGE_PROPERTIES, default as EventBuilder, EventBuilderConfig, FlagViewBuilderArgs, HoverBuilderArgs, IdentifyBuilderArgs, InteractionBuilderArgsBase, PageViewBuilderArgs, TrackBuilderArgs, UniversalEventBuilderArgs, ViewBuilderArgs } from './event-builder.js';
|
|
4
|
+
export { CreateClientOptions, createClient } from './create-delivery-client.js';
|
|
8
5
|
export { ByDestinationNodeIdExperienceOptions, ByDestinationPathExperienceOptions, ByIdExperienceOptions, DestinationRedirectResult, ExperienceOptions, ExperienceRequestExtensions, PersonalizationOptions, ResolveOptions, fetchExperience } from './fetch-experience.js';
|
|
9
6
|
export { DestinationSitemapResult, FetchDestinationSitemapOptions, FetchDestinationSitemapPaginationOptions, SitemapPathItem, fetchDestinationSitemap } from './fetch-destination-sitemap.js';
|
|
10
|
-
export { ContentfulExperiences, ContentfulExperiencesConfig, ExperienceRuntime, RuntimeEventBuilderConfig, RuntimeFetchByDestinationNodeOptions, RuntimeFetchByDestinationPathOptions, RuntimeFetchExperienceOptions, RuntimeResolveOptions } from './contentful-experiences.js';
|
|
11
|
-
export { AnalyticsEventMethod, EventProfileRequiredError, PersonalizationEventMethod, RuntimeEventBindings, RuntimeEventMethods } from './runtime-event-methods.js';
|
|
12
|
-
export { RUNTIME_EVENT_HANDOFF_VERSION, RuntimeEventHandoff, RuntimeEventHandoffEvent, RuntimeEventHandoffReceipt, RuntimeServerEventDelivery, assertRuntimeEventHandoffSize, parseRuntimeEventHandoff } from './runtime-event-handoff.js';
|
|
13
7
|
export { ExperienceResponse, readSourceMap, toExperiencePayload, toExperiencePayloadFromDestination } from './to-experience-payload.js';
|
|
14
8
|
export { DELIVERY_HOST, PREVIEW_HOST, PREVIEW_WEBSOCKET_HOST } from './hosts.js';
|
|
15
9
|
export { ClientOptions } from './client-resolution.js';
|
|
16
|
-
export { OptimizationData as EventOptimizationData, PartialProfile as EventProfile, PartialProfile as EventProfileSchema } from '@contentful/optimization-api-client/api-schemas';
|
|
17
|
-
import '@contentful/optimization-api-client';
|
|
18
|
-
import 'zod/mini';
|
|
19
10
|
import '@contentful/experiences-sdk-core';
|
|
20
11
|
|
|
21
12
|
declare const NotFoundError: typeof ContentfulViewDelivery.NotFoundError;
|
package/dist/index.js
CHANGED
|
@@ -5,19 +5,9 @@ import {
|
|
|
5
5
|
} from "@contentful/experience-delivery";
|
|
6
6
|
const NotFoundError = ContentfulViewDelivery.NotFoundError;
|
|
7
7
|
import { ExperienceFetchError, DestinationPreviewNotSupportedError } from "./errors.js";
|
|
8
|
-
import { ANONYMOUS_ID_COOKIE, PROFILE_CACHE_KEY } from "./constants.js";
|
|
9
8
|
import { createClient } from "./create-delivery-client.js";
|
|
10
|
-
import { default as default2 } from "./event-builder.js";
|
|
11
|
-
export * from "./event-builder.js";
|
|
12
9
|
import { fetchExperience } from "./fetch-experience.js";
|
|
13
10
|
import { fetchDestinationSitemap } from "./fetch-destination-sitemap.js";
|
|
14
|
-
import { ContentfulExperiences } from "./contentful-experiences.js";
|
|
15
|
-
import { EventProfileRequiredError, EventProfileSchema } from "./runtime-event-methods.js";
|
|
16
|
-
import {
|
|
17
|
-
assertRuntimeEventHandoffSize,
|
|
18
|
-
parseRuntimeEventHandoff,
|
|
19
|
-
RUNTIME_EVENT_HANDOFF_VERSION
|
|
20
|
-
} from "./runtime-event-handoff.js";
|
|
21
11
|
import {
|
|
22
12
|
readSourceMap,
|
|
23
13
|
toExperiencePayload,
|
|
@@ -25,26 +15,17 @@ import {
|
|
|
25
15
|
} from "./to-experience-payload.js";
|
|
26
16
|
import { DELIVERY_HOST, PREVIEW_HOST, PREVIEW_WEBSOCKET_HOST } from "./hosts.js";
|
|
27
17
|
export {
|
|
28
|
-
ANONYMOUS_ID_COOKIE,
|
|
29
|
-
ContentfulExperiences,
|
|
30
18
|
ContentfulViewDelivery2 as ContentfulViewDelivery,
|
|
31
19
|
ContentfulViewDeliveryClient,
|
|
32
20
|
DELIVERY_HOST,
|
|
33
21
|
DestinationPreviewNotSupportedError,
|
|
34
|
-
default2 as EventBuilder,
|
|
35
|
-
EventProfileRequiredError,
|
|
36
|
-
EventProfileSchema,
|
|
37
22
|
ExperienceFetchError,
|
|
38
23
|
NotFoundError,
|
|
39
24
|
PREVIEW_HOST,
|
|
40
25
|
PREVIEW_WEBSOCKET_HOST,
|
|
41
|
-
PROFILE_CACHE_KEY,
|
|
42
|
-
RUNTIME_EVENT_HANDOFF_VERSION,
|
|
43
|
-
assertRuntimeEventHandoffSize,
|
|
44
26
|
createClient,
|
|
45
27
|
fetchDestinationSitemap,
|
|
46
28
|
fetchExperience,
|
|
47
|
-
parseRuntimeEventHandoff,
|
|
48
29
|
readSourceMap,
|
|
49
30
|
toExperiencePayload,
|
|
50
31
|
toExperiencePayloadFromDestination
|
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;\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 {
|
|
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;\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 { 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';\n"],"mappings":"AAAA,SAAS,8BAA8B;AAEvC;AAAA,EACE,0BAAAA;AAAA,EACA;AAAA,OACK;AACA,MAAM,gBAAgB,uBAAuB;AAGpD,SAAS,sBAAsB,2CAA2C;AAC1E,SAAS,oBAAoB;AAE7B,SAAS,uBAAuB;AAChC,SAAS,+BAA+B;AAOxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAaP,SAAS,eAAe,cAAc,8BAA8B;","names":["ContentfulViewDelivery"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experiences-client",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Delivery client + fetchExperience for Contentful Experiences",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -31,9 +31,6 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@contentful/experience-delivery": "1.0.0-dev.9",
|
|
34
|
-
"@contentful/experiences-sdk-core": "0.12.
|
|
35
|
-
"@contentful/optimization-api-client": "^2.0.1",
|
|
36
|
-
"es-toolkit": "^1.46.0",
|
|
37
|
-
"zod": "^4.3.6"
|
|
34
|
+
"@contentful/experiences-sdk-core": "0.12.1"
|
|
38
35
|
}
|
|
39
36
|
}
|
package/dist/constants.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cookie name used to carry an anonymous/profile id between browser and server
|
|
3
|
-
* runtimes. The value matches the Contentful Optimization SDK.
|
|
4
|
-
*
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
declare const ANONYMOUS_ID_COOKIE = "ctfl-opt-aid";
|
|
8
|
-
/** @internal LocalStorage key for the persisted profile. */
|
|
9
|
-
declare const PROFILE_CACHE_KEY = "__ctfl_opt_profile__";
|
|
10
|
-
|
|
11
|
-
export { ANONYMOUS_ID_COOKIE, PROFILE_CACHE_KEY };
|
package/dist/constants.js
DELETED
package/dist/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Cookie name used to carry an anonymous/profile id between browser and server\n * runtimes. The value matches the Contentful Optimization SDK.\n *\n * @public\n */\nexport const ANONYMOUS_ID_COOKIE = 'ctfl-opt-aid';\n\n/** @internal LocalStorage key for the persisted profile. */\nexport const PROFILE_CACHE_KEY = '__ctfl_opt_profile__';\n"],"mappings":"AAMO,MAAM,sBAAsB;AAG5B,MAAM,oBAAoB;","names":[]}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { ExperiencePayload, PortableRenderPlan, ResolverConfig } from '@contentful/experiences-sdk-core';
|
|
2
|
-
import EventBuilder, { EventBuilderConfig } from './event-builder.js';
|
|
3
|
-
import { RuntimeDeliveryClientOptions } from './create-delivery-client.js';
|
|
4
|
-
import { PersonalizationOptions, ExperienceRequestExtensions, DestinationRedirectResult } from './fetch-experience.js';
|
|
5
|
-
import { RuntimeOptimizationConfig } from './create-optimization-client.js';
|
|
6
|
-
import { RuntimeOptimizationApiClient, RuntimeEventBindings, RuntimeEventDispatch, RuntimeEventMethods } from './runtime-event-methods.js';
|
|
7
|
-
import '@contentful/optimization-api-client/api-schemas';
|
|
8
|
-
import 'zod/mini';
|
|
9
|
-
import '@contentful/experience-delivery';
|
|
10
|
-
import './client-resolution.js';
|
|
11
|
-
import '@contentful/optimization-api-client';
|
|
12
|
-
|
|
13
|
-
type RuntimeResolveOptions = {
|
|
14
|
-
metadata?: Record<string, unknown>;
|
|
15
|
-
debug?: boolean;
|
|
16
|
-
};
|
|
17
|
-
type RuntimeEventBuilderConfig = Omit<EventBuilderConfig, 'channel' | 'library'> & {
|
|
18
|
-
channel: EventBuilderConfig['channel'];
|
|
19
|
-
library?: Partial<EventBuilderConfig['library']>;
|
|
20
|
-
};
|
|
21
|
-
type RuntimeFetchExperienceOptions = {
|
|
22
|
-
experienceId: string;
|
|
23
|
-
locale?: string;
|
|
24
|
-
personalization?: PersonalizationOptions;
|
|
25
|
-
extensions?: ExperienceRequestExtensions;
|
|
26
|
-
preview?: boolean;
|
|
27
|
-
};
|
|
28
|
-
type RuntimeFetchByDestinationNodeOptions = {
|
|
29
|
-
destinationId: string;
|
|
30
|
-
nodeId: string;
|
|
31
|
-
};
|
|
32
|
-
type RuntimeFetchByDestinationPathOptions = {
|
|
33
|
-
destinationId: string;
|
|
34
|
-
path: string;
|
|
35
|
-
};
|
|
36
|
-
/** Structural contract implemented by the Client runtime. */
|
|
37
|
-
interface ExperienceRuntime {
|
|
38
|
-
readonly spaceId: string;
|
|
39
|
-
readonly environmentId: string;
|
|
40
|
-
readonly locale: string | undefined;
|
|
41
|
-
readonly eventBuilder: EventBuilder;
|
|
42
|
-
resolveExperience(payload: ExperiencePayload, resolveOptions?: RuntimeResolveOptions): Promise<PortableRenderPlan>;
|
|
43
|
-
fetchExperience(options: RuntimeFetchExperienceOptions, resolveOptions?: RuntimeResolveOptions): Promise<PortableRenderPlan>;
|
|
44
|
-
fetchByDestinationNode(options: RuntimeFetchByDestinationNodeOptions, resolveOptions?: RuntimeResolveOptions): Promise<PortableRenderPlan | DestinationRedirectResult>;
|
|
45
|
-
fetchByDestinationPath(options: RuntimeFetchByDestinationPathOptions, resolveOptions?: RuntimeResolveOptions): Promise<PortableRenderPlan | DestinationRedirectResult>;
|
|
46
|
-
}
|
|
47
|
-
type ContentfulExperiencesConfig = {
|
|
48
|
-
spaceId: string;
|
|
49
|
-
environmentId: string;
|
|
50
|
-
locale?: string;
|
|
51
|
-
resolverConfig: ResolverConfig;
|
|
52
|
-
/** Configuration for the runtime-owned Content Delivery API client. */
|
|
53
|
-
delivery: RuntimeDeliveryClientOptions;
|
|
54
|
-
/** Optional configuration for the runtime-owned Content Preview API client. */
|
|
55
|
-
preview?: RuntimeDeliveryClientOptions;
|
|
56
|
-
/** Overrides for the runtime-owned Personalization and Analytics event transport. */
|
|
57
|
-
optimization?: RuntimeOptimizationConfig;
|
|
58
|
-
resolveDefaults?: Pick<RuntimeResolveOptions, 'metadata' | 'debug'>;
|
|
59
|
-
eventBuilder: RuntimeEventBuilderConfig;
|
|
60
|
-
};
|
|
61
|
-
declare class ContentfulExperiences implements ExperienceRuntime {
|
|
62
|
-
#private;
|
|
63
|
-
readonly spaceId: string;
|
|
64
|
-
readonly environmentId: string;
|
|
65
|
-
readonly eventBuilder: EventBuilder;
|
|
66
|
-
protected readonly optimizationApi: RuntimeOptimizationApiClient;
|
|
67
|
-
constructor(config: ContentfulExperiencesConfig);
|
|
68
|
-
get locale(): string | undefined;
|
|
69
|
-
protected createEventMethods(bindings: RuntimeEventBindings, dispatch?: RuntimeEventDispatch): RuntimeEventMethods;
|
|
70
|
-
resolveExperience(payload: ExperiencePayload, resolveOptions?: RuntimeResolveOptions): Promise<PortableRenderPlan>;
|
|
71
|
-
fetchExperience(options: RuntimeFetchExperienceOptions, resolveOptions?: RuntimeResolveOptions): Promise<PortableRenderPlan>;
|
|
72
|
-
fetchByDestinationNode(options: RuntimeFetchByDestinationNodeOptions, resolveOptions?: RuntimeResolveOptions): Promise<PortableRenderPlan | DestinationRedirectResult>;
|
|
73
|
-
fetchByDestinationPath(options: RuntimeFetchByDestinationPathOptions, resolveOptions?: RuntimeResolveOptions): Promise<PortableRenderPlan | DestinationRedirectResult>;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export { ContentfulExperiences, type ContentfulExperiencesConfig, type ExperienceRuntime, type RuntimeEventBuilderConfig, type RuntimeFetchByDestinationNodeOptions, type RuntimeFetchByDestinationPathOptions, type RuntimeFetchExperienceOptions, type RuntimeResolveOptions };
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { resolveExperience as resolveCoreExperience } from "@contentful/experiences-sdk-core";
|
|
2
|
-
import EventBuilder from "./event-builder.js";
|
|
3
|
-
import {
|
|
4
|
-
createRuntimeDeliveryClient
|
|
5
|
-
} from "./create-delivery-client.js";
|
|
6
|
-
import {
|
|
7
|
-
fetchExperience
|
|
8
|
-
} from "./fetch-experience.js";
|
|
9
|
-
import {
|
|
10
|
-
createRuntimeOptimizationClient
|
|
11
|
-
} from "./create-optimization-client.js";
|
|
12
|
-
import { PREVIEW_HOST } from "./hosts.js";
|
|
13
|
-
import { DEFAULT_EVENT_CONTEXT_LIBRARY } from "./sdk-info.js";
|
|
14
|
-
import {
|
|
15
|
-
createRuntimeEventMethods
|
|
16
|
-
} from "./runtime-event-methods.js";
|
|
17
|
-
class ContentfulExperiences {
|
|
18
|
-
spaceId;
|
|
19
|
-
environmentId;
|
|
20
|
-
eventBuilder;
|
|
21
|
-
#locale;
|
|
22
|
-
#resolverConfig;
|
|
23
|
-
#deliveryClient;
|
|
24
|
-
#previewClient;
|
|
25
|
-
optimizationApi;
|
|
26
|
-
#resolveDefaults;
|
|
27
|
-
constructor(config) {
|
|
28
|
-
this.spaceId = config.spaceId;
|
|
29
|
-
this.environmentId = config.environmentId;
|
|
30
|
-
this.#locale = config.locale;
|
|
31
|
-
this.#resolverConfig = config.resolverConfig;
|
|
32
|
-
this.#deliveryClient = createRuntimeDeliveryClient(config.delivery);
|
|
33
|
-
this.#previewClient = config.preview === void 0 ? void 0 : createRuntimeDeliveryClient(config.preview, PREVIEW_HOST);
|
|
34
|
-
this.optimizationApi = createRuntimeOptimizationClient({
|
|
35
|
-
spaceId: config.spaceId,
|
|
36
|
-
environmentId: config.environmentId,
|
|
37
|
-
...config.optimization
|
|
38
|
-
});
|
|
39
|
-
this.#resolveDefaults = config.resolveDefaults ?? {};
|
|
40
|
-
this.eventBuilder = new EventBuilder({
|
|
41
|
-
...config.eventBuilder,
|
|
42
|
-
library: { ...DEFAULT_EVENT_CONTEXT_LIBRARY, ...config.eventBuilder.library },
|
|
43
|
-
getLocale: config.eventBuilder.getLocale ?? (() => this.locale)
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
get locale() {
|
|
47
|
-
return this.#locale;
|
|
48
|
-
}
|
|
49
|
-
createEventMethods(bindings, dispatch) {
|
|
50
|
-
return createRuntimeEventMethods(this.optimizationApi, this.eventBuilder, bindings, dispatch);
|
|
51
|
-
}
|
|
52
|
-
resolveExperience(payload, resolveOptions) {
|
|
53
|
-
return resolveCoreExperience(
|
|
54
|
-
payload,
|
|
55
|
-
this.#resolverConfig,
|
|
56
|
-
this.#mergeResolveOptions(resolveOptions)
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
fetchExperience(options, resolveOptions) {
|
|
60
|
-
if (options.preview === true && this.#previewClient === void 0) {
|
|
61
|
-
throw new Error(
|
|
62
|
-
"fetchExperience() called with preview: true but this runtime has no preview client"
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
return fetchExperience(
|
|
66
|
-
{
|
|
67
|
-
spaceId: this.spaceId,
|
|
68
|
-
environmentId: this.environmentId,
|
|
69
|
-
experienceId: options.experienceId,
|
|
70
|
-
locale: options.locale ?? this.locale,
|
|
71
|
-
personalization: options.personalization,
|
|
72
|
-
extensions: options.extensions
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
client: options.preview ? this.#previewClient : this.#deliveryClient
|
|
76
|
-
},
|
|
77
|
-
{ config: this.#resolverConfig, ...this.#mergeResolveOptions(resolveOptions) }
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
fetchByDestinationNode(options, resolveOptions) {
|
|
81
|
-
return fetchExperience(
|
|
82
|
-
{ spaceId: this.spaceId, destinationId: options.destinationId, nodeId: options.nodeId },
|
|
83
|
-
{ client: this.#deliveryClient },
|
|
84
|
-
{ config: this.#resolverConfig, ...this.#mergeResolveOptions(resolveOptions) }
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
fetchByDestinationPath(options, resolveOptions) {
|
|
88
|
-
return fetchExperience(
|
|
89
|
-
{ spaceId: this.spaceId, destinationId: options.destinationId, path: options.path },
|
|
90
|
-
{ client: this.#deliveryClient },
|
|
91
|
-
{ config: this.#resolverConfig, ...this.#mergeResolveOptions(resolveOptions) }
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
#mergeResolveOptions(options) {
|
|
95
|
-
return {
|
|
96
|
-
metadata: { ...this.#resolveDefaults.metadata, ...options?.metadata },
|
|
97
|
-
debug: options?.debug ?? this.#resolveDefaults.debug
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
export {
|
|
102
|
-
ContentfulExperiences
|
|
103
|
-
};
|
|
104
|
-
//# sourceMappingURL=contentful-experiences.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 {\n createRuntimeDeliveryClient,\n type RuntimeDeliveryClientOptions,\n} from './create-delivery-client.js';\nimport {\n fetchExperience,\n type DestinationRedirectResult,\n type ExperienceRequestExtensions,\n type PersonalizationOptions,\n} from './fetch-experience.js';\nimport {\n createRuntimeOptimizationClient,\n type RuntimeOptimizationConfig,\n} from './create-optimization-client.js';\nimport { PREVIEW_HOST } from './hosts.js';\nimport { DEFAULT_EVENT_CONTEXT_LIBRARY } from './sdk-info.js';\nimport {\n createRuntimeEventMethods,\n type RuntimeEventBindings,\n type RuntimeEventDispatch,\n type RuntimeEventMethods,\n type RuntimeOptimizationApiClient,\n} from './runtime-event-methods.js';\n\nexport type RuntimeResolveOptions = {\n metadata?: Record<string, unknown>;\n debug?: boolean;\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 personalization?: PersonalizationOptions;\n extensions?: ExperienceRequestExtensions;\n preview?: 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 /** Configuration for the runtime-owned Content Delivery API client. */\n delivery: RuntimeDeliveryClientOptions;\n /** Optional configuration for the runtime-owned Content Preview API client. */\n preview?: RuntimeDeliveryClientOptions;\n /** Overrides for the runtime-owned Personalization and Analytics event transport. */\n optimization?: RuntimeOptimizationConfig;\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 eventBuilder: EventBuilder;\n\n readonly #locale: string | undefined;\n readonly #resolverConfig: ResolverConfig;\n readonly #deliveryClient: ContentfulViewDeliveryClient;\n readonly #previewClient: ContentfulViewDeliveryClient | undefined;\n protected readonly optimizationApi: RuntimeOptimizationApiClient;\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 = createRuntimeDeliveryClient(config.delivery);\n this.#previewClient =\n config.preview === undefined\n ? undefined\n : createRuntimeDeliveryClient(config.preview, PREVIEW_HOST);\n this.optimizationApi = createRuntimeOptimizationClient({\n spaceId: config.spaceId,\n environmentId: config.environmentId,\n ...config.optimization,\n });\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 get locale(): string | undefined {\n return this.#locale;\n }\n\n protected createEventMethods(\n bindings: RuntimeEventBindings,\n dispatch?: RuntimeEventDispatch\n ): RuntimeEventMethods {\n return createRuntimeEventMethods(this.optimizationApi, this.eventBuilder, bindings, dispatch);\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 personalization: options.personalization,\n extensions: options.extensions,\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 };\n }\n}\n"],"mappings":"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","names":[]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ExperienceApiClientConfig, InsightsApiClientConfig, ApiClientConfig } from '@contentful/optimization-api-client';
|
|
2
|
-
import { RuntimeOptimizationApiClient } from './runtime-event-methods.js';
|
|
3
|
-
import '@contentful/optimization-api-client/api-schemas';
|
|
4
|
-
import './event-builder.js';
|
|
5
|
-
import 'zod/mini';
|
|
6
|
-
|
|
7
|
-
/** Stable configuration for the runtime-owned Optimization API client. */
|
|
8
|
-
type RuntimeOptimizationConfig = {
|
|
9
|
-
personalizationBaseUrl?: ExperienceApiClientConfig['baseUrl'];
|
|
10
|
-
analyticsBaseUrl?: InsightsApiClientConfig['baseUrl'];
|
|
11
|
-
personalizationEnabledFeatures?: ExperienceApiClientConfig['enabledFeatures'];
|
|
12
|
-
fetchOptions?: ApiClientConfig['fetchOptions'];
|
|
13
|
-
};
|
|
14
|
-
type CreateRuntimeOptimizationClientOptions = RuntimeOptimizationConfig & {
|
|
15
|
-
spaceId: string;
|
|
16
|
-
environmentId: string;
|
|
17
|
-
};
|
|
18
|
-
declare function createRuntimeOptimizationClient({ spaceId, environmentId, personalizationBaseUrl, analyticsBaseUrl, personalizationEnabledFeatures, fetchOptions, }: CreateRuntimeOptimizationClientOptions): RuntimeOptimizationApiClient;
|
|
19
|
-
|
|
20
|
-
export { type RuntimeOptimizationConfig, createRuntimeOptimizationClient };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ApiClient as OptimizationApiClient
|
|
3
|
-
} from "@contentful/optimization-api-client";
|
|
4
|
-
function createRuntimeOptimizationClient({
|
|
5
|
-
spaceId,
|
|
6
|
-
environmentId,
|
|
7
|
-
personalizationBaseUrl,
|
|
8
|
-
analyticsBaseUrl,
|
|
9
|
-
personalizationEnabledFeatures,
|
|
10
|
-
fetchOptions
|
|
11
|
-
}) {
|
|
12
|
-
const client = new OptimizationApiClient({
|
|
13
|
-
spaceId,
|
|
14
|
-
environment: environmentId,
|
|
15
|
-
fetchOptions,
|
|
16
|
-
experience: {
|
|
17
|
-
baseUrl: personalizationBaseUrl,
|
|
18
|
-
enabledFeatures: personalizationEnabledFeatures
|
|
19
|
-
},
|
|
20
|
-
insights: { baseUrl: analyticsBaseUrl }
|
|
21
|
-
});
|
|
22
|
-
return {
|
|
23
|
-
personalization: client.experience,
|
|
24
|
-
analytics: client.insights
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export {
|
|
28
|
-
createRuntimeOptimizationClient
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=create-optimization-client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create-optimization-client.ts"],"sourcesContent":["import {\n ApiClient as OptimizationApiClient,\n type ApiClientConfig as OptimizationApiClientConfig,\n type ExperienceApiClientConfig as PersonalizationApiClientConfig,\n type InsightsApiClientConfig as AnalyticsApiClientConfig,\n} from '@contentful/optimization-api-client';\nimport type { RuntimeOptimizationApiClient } from './runtime-event-methods.js';\n\n/** Stable configuration for the runtime-owned Optimization API client. */\nexport type RuntimeOptimizationConfig = {\n personalizationBaseUrl?: PersonalizationApiClientConfig['baseUrl'];\n analyticsBaseUrl?: AnalyticsApiClientConfig['baseUrl'];\n personalizationEnabledFeatures?: PersonalizationApiClientConfig['enabledFeatures'];\n fetchOptions?: OptimizationApiClientConfig['fetchOptions'];\n};\n\ntype CreateRuntimeOptimizationClientOptions = RuntimeOptimizationConfig & {\n spaceId: string;\n environmentId: string;\n};\n\nexport function createRuntimeOptimizationClient({\n spaceId,\n environmentId,\n personalizationBaseUrl,\n analyticsBaseUrl,\n personalizationEnabledFeatures,\n fetchOptions,\n}: CreateRuntimeOptimizationClientOptions): RuntimeOptimizationApiClient {\n const client = new OptimizationApiClient({\n spaceId,\n environment: environmentId,\n fetchOptions,\n experience: {\n baseUrl: personalizationBaseUrl,\n enabledFeatures: personalizationEnabledFeatures,\n },\n insights: { baseUrl: analyticsBaseUrl },\n });\n\n return {\n personalization: client.experience,\n analytics: client.insights,\n };\n}\n"],"mappings":"AAAA;AAAA,EACE,aAAa;AAAA,OAIR;AAgBA,SAAS,gCAAgC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyE;AACvE,QAAM,SAAS,IAAI,sBAAsB;AAAA,IACvC;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA,YAAY;AAAA,MACV,SAAS;AAAA,MACT,iBAAiB;AAAA,IACnB;AAAA,IACA,UAAU,EAAE,SAAS,iBAAiB;AAAA,EACxC,CAAC;AAED,SAAO;AAAA,IACL,iBAAiB,OAAO;AAAA,IACxB,WAAW,OAAO;AAAA,EACpB;AACF;","names":[]}
|