@contentful/optimization-core 0.1.0-alpha8 → 0.1.0-alpha9

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.
Files changed (147) hide show
  1. package/README.md +221 -31
  2. package/dist/260.mjs +14 -0
  3. package/dist/260.mjs.map +1 -0
  4. package/dist/499.mjs +4 -0
  5. package/dist/632.mjs +5 -0
  6. package/dist/632.mjs.map +1 -0
  7. package/dist/808.mjs +2 -0
  8. package/dist/942.mjs +2 -0
  9. package/dist/api-client.cjs +60 -0
  10. package/dist/api-client.cjs.map +1 -0
  11. package/dist/api-client.d.cts +4 -0
  12. package/dist/api-client.d.mts +4 -0
  13. package/dist/api-client.d.ts +4 -0
  14. package/dist/api-client.mjs +2 -0
  15. package/dist/api-schemas.cjs +60 -0
  16. package/dist/api-schemas.cjs.map +1 -0
  17. package/dist/api-schemas.d.cts +4 -0
  18. package/dist/api-schemas.d.mts +4 -0
  19. package/dist/api-schemas.d.ts +4 -0
  20. package/dist/api-schemas.mjs +2 -0
  21. package/dist/constants.cjs +78 -0
  22. package/dist/constants.cjs.map +1 -0
  23. package/dist/{global-constants.d.ts → constants.d.cts} +88 -67
  24. package/dist/{global-constants.js → constants.d.mts} +88 -69
  25. package/dist/constants.d.ts +88 -0
  26. package/dist/constants.mjs +1 -0
  27. package/dist/index.cjs +1833 -1706
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +774 -341
  30. package/dist/index.d.mts +774 -341
  31. package/dist/index.d.ts +2432 -15
  32. package/dist/index.mjs +617 -341
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/logger.cjs +67 -0
  35. package/dist/logger.cjs.map +1 -0
  36. package/dist/logger.d.cts +8 -0
  37. package/dist/logger.d.mts +8 -0
  38. package/dist/logger.d.ts +8 -0
  39. package/dist/logger.mjs +2 -0
  40. package/dist/symbols.cjs +42 -0
  41. package/dist/symbols.cjs.map +1 -0
  42. package/dist/symbols.d.cts +10 -0
  43. package/dist/symbols.d.mts +10 -0
  44. package/dist/symbols.d.ts +10 -0
  45. package/dist/symbols.mjs +1 -0
  46. package/package.json +56 -8
  47. package/dist/Consent.d.ts +0 -44
  48. package/dist/Consent.d.ts.map +0 -1
  49. package/dist/Consent.js +0 -2
  50. package/dist/Consent.js.map +0 -1
  51. package/dist/CoreBase.d.ts +0 -161
  52. package/dist/CoreBase.d.ts.map +0 -1
  53. package/dist/CoreBase.js +0 -151
  54. package/dist/CoreBase.js.map +0 -1
  55. package/dist/CoreStateful.d.ts +0 -144
  56. package/dist/CoreStateful.d.ts.map +0 -1
  57. package/dist/CoreStateful.js +0 -141
  58. package/dist/CoreStateful.js.map +0 -1
  59. package/dist/CoreStateless.d.ts +0 -53
  60. package/dist/CoreStateless.d.ts.map +0 -1
  61. package/dist/CoreStateless.js +0 -43
  62. package/dist/CoreStateless.js.map +0 -1
  63. package/dist/ProductBase.d.ts +0 -83
  64. package/dist/ProductBase.d.ts.map +0 -1
  65. package/dist/ProductBase.js +0 -50
  66. package/dist/ProductBase.js.map +0 -1
  67. package/dist/analytics/AnalyticsBase.d.ts +0 -35
  68. package/dist/analytics/AnalyticsBase.d.ts.map +0 -1
  69. package/dist/analytics/AnalyticsBase.js +0 -13
  70. package/dist/analytics/AnalyticsBase.js.map +0 -1
  71. package/dist/analytics/AnalyticsStateful.d.ts +0 -138
  72. package/dist/analytics/AnalyticsStateful.d.ts.map +0 -1
  73. package/dist/analytics/AnalyticsStateful.js +0 -179
  74. package/dist/analytics/AnalyticsStateful.js.map +0 -1
  75. package/dist/analytics/AnalyticsStateless.d.ts +0 -48
  76. package/dist/analytics/AnalyticsStateless.d.ts.map +0 -1
  77. package/dist/analytics/AnalyticsStateless.js +0 -61
  78. package/dist/analytics/AnalyticsStateless.js.map +0 -1
  79. package/dist/analytics/index.d.ts +0 -5
  80. package/dist/analytics/index.d.ts.map +0 -1
  81. package/dist/analytics/index.js +0 -5
  82. package/dist/analytics/index.js.map +0 -1
  83. package/dist/global-constants.d.ts.map +0 -1
  84. package/dist/global-constants.js.map +0 -1
  85. package/dist/index.d.ts.map +0 -1
  86. package/dist/index.js +0 -15
  87. package/dist/index.js.map +0 -1
  88. package/dist/lib/decorators/guardedBy.d.ts +0 -113
  89. package/dist/lib/decorators/guardedBy.d.ts.map +0 -1
  90. package/dist/lib/decorators/guardedBy.js +0 -143
  91. package/dist/lib/decorators/guardedBy.js.map +0 -1
  92. package/dist/lib/decorators/index.d.ts +0 -2
  93. package/dist/lib/decorators/index.d.ts.map +0 -1
  94. package/dist/lib/decorators/index.js +0 -2
  95. package/dist/lib/decorators/index.js.map +0 -1
  96. package/dist/lib/interceptor/InterceptorManager.d.ts +0 -127
  97. package/dist/lib/interceptor/InterceptorManager.d.ts.map +0 -1
  98. package/dist/lib/interceptor/InterceptorManager.js +0 -125
  99. package/dist/lib/interceptor/InterceptorManager.js.map +0 -1
  100. package/dist/lib/interceptor/index.d.ts +0 -2
  101. package/dist/lib/interceptor/index.d.ts.map +0 -1
  102. package/dist/lib/interceptor/index.js +0 -2
  103. package/dist/lib/interceptor/index.js.map +0 -1
  104. package/dist/lib/value-presence/ValuePresence.d.ts +0 -123
  105. package/dist/lib/value-presence/ValuePresence.d.ts.map +0 -1
  106. package/dist/lib/value-presence/ValuePresence.js +0 -141
  107. package/dist/lib/value-presence/ValuePresence.js.map +0 -1
  108. package/dist/lib/value-presence/index.d.ts +0 -2
  109. package/dist/lib/value-presence/index.d.ts.map +0 -1
  110. package/dist/lib/value-presence/index.js +0 -2
  111. package/dist/lib/value-presence/index.js.map +0 -1
  112. package/dist/personalization/PersonalizationBase.d.ts +0 -184
  113. package/dist/personalization/PersonalizationBase.d.ts.map +0 -1
  114. package/dist/personalization/PersonalizationBase.js +0 -76
  115. package/dist/personalization/PersonalizationBase.js.map +0 -1
  116. package/dist/personalization/PersonalizationStateful.d.ts +0 -226
  117. package/dist/personalization/PersonalizationStateful.d.ts.map +0 -1
  118. package/dist/personalization/PersonalizationStateful.js +0 -297
  119. package/dist/personalization/PersonalizationStateful.js.map +0 -1
  120. package/dist/personalization/PersonalizationStateless.d.ts +0 -74
  121. package/dist/personalization/PersonalizationStateless.d.ts.map +0 -1
  122. package/dist/personalization/PersonalizationStateless.js +0 -98
  123. package/dist/personalization/PersonalizationStateless.js.map +0 -1
  124. package/dist/personalization/index.d.ts +0 -6
  125. package/dist/personalization/index.d.ts.map +0 -1
  126. package/dist/personalization/index.js +0 -6
  127. package/dist/personalization/index.js.map +0 -1
  128. package/dist/personalization/resolvers/FlagsResolver.d.ts +0 -35
  129. package/dist/personalization/resolvers/FlagsResolver.d.ts.map +0 -1
  130. package/dist/personalization/resolvers/FlagsResolver.js +0 -47
  131. package/dist/personalization/resolvers/FlagsResolver.js.map +0 -1
  132. package/dist/personalization/resolvers/MergeTagValueResolver.d.ts +0 -74
  133. package/dist/personalization/resolvers/MergeTagValueResolver.d.ts.map +0 -1
  134. package/dist/personalization/resolvers/MergeTagValueResolver.js +0 -109
  135. package/dist/personalization/resolvers/MergeTagValueResolver.js.map +0 -1
  136. package/dist/personalization/resolvers/PersonalizedEntryResolver.d.ts +0 -142
  137. package/dist/personalization/resolvers/PersonalizedEntryResolver.d.ts.map +0 -1
  138. package/dist/personalization/resolvers/PersonalizedEntryResolver.js +0 -196
  139. package/dist/personalization/resolvers/PersonalizedEntryResolver.js.map +0 -1
  140. package/dist/personalization/resolvers/index.d.ts +0 -7
  141. package/dist/personalization/resolvers/index.d.ts.map +0 -1
  142. package/dist/personalization/resolvers/index.js +0 -7
  143. package/dist/personalization/resolvers/index.js.map +0 -1
  144. package/dist/signals.d.ts +0 -42
  145. package/dist/signals.d.ts.map +0 -1
  146. package/dist/signals.js +0 -36
  147. package/dist/signals.js.map +0 -1
package/README.md CHANGED
@@ -11,13 +11,13 @@
11
11
  <div align="center">
12
12
 
13
13
  [Readme](./README.md) · [Reference](https://contentful.github.io/optimization) ·
14
- [Contributing](/CONTRIBUTING.md)
14
+ [Contributing](../../CONTRIBUTING.md)
15
15
 
16
16
  </div>
17
17
 
18
18
  > [!WARNING]
19
19
  >
20
- > The Optimization SDK Suite is currently ALPHA! Breaking changes may be published at any time.
20
+ > The Optimization SDK Suite is pre-release (alpha). Breaking changes may be published at any time.
21
21
 
22
22
  The Optimization Core SDK encapsulates all platform-agnostic functionality and business logic. All
23
23
  other SDKs descend from the Core SDK.
@@ -43,12 +43,17 @@ other SDKs descend from the Core SDK.
43
43
  - [Personalization and Analytics Event Methods](#personalization-and-analytics-event-methods)
44
44
  - [`identify`](#identify)
45
45
  - [`page`](#page)
46
+ - [`screen`](#screen)
46
47
  - [`track`](#track)
47
48
  - [`trackComponentView`](#trackcomponentview)
49
+ - [`trackComponentClick`](#trackcomponentclick)
48
50
  - [`trackFlagView`](#trackflagview)
49
51
  - [Stateful-only Core Methods](#stateful-only-core-methods)
50
52
  - [`consent`](#consent)
51
53
  - [`reset`](#reset)
54
+ - [`flush`](#flush)
55
+ - [`destroy`](#destroy)
56
+ - [`registerPreviewPanel` (preview tooling only)](#registerpreviewpanel-preview-tooling-only)
52
57
  - [Stateful-only Core Properties](#stateful-only-core-properties)
53
58
  - [Interceptors](#interceptors)
54
59
  - [Life-cycle Interceptors](#life-cycle-interceptors)
@@ -100,32 +105,38 @@ In stateful environments, Core maintains state internally for consent, an event
100
105
  profile-related data that is commonly obtained from requests to the Experience API. These states are
101
106
  exposed externally as read-only observables.
102
107
 
108
+ > [!IMPORTANT]
109
+ >
110
+ > `CoreStateful` uses module-global state by design. Initialize exactly one stateful instance per
111
+ > JavaScript runtime and reuse it.
112
+
103
113
  ## Configuration
104
114
 
105
115
  ### Top-level Configuration Options
106
116
 
107
- | Option | Required? | Default | Description |
108
- | ----------------- | --------- | ----------------------------- | --------------------------------------------------------------------- |
109
- | `analytics` | No | See "Analytics Options" | Configuration specific to the Analytics/Insights API |
110
- | `clientId` | Yes | N/A | The Ninetailed API Key which can be found in the Ninetailed Admin app |
111
- | `environment` | No | `'main'` | The Ninetailed environment configured in the Ninetailed Admin app |
112
- | `eventBuilder` | No | See "Event Builder Options" | Event builder configuration (channel/library metadata, etc.) |
113
- | `fetchOptions` | No | See "Fetch Options" | Configuration for Fetch timeout and retry functionality |
114
- | `logLevel` | No | `'error'` | Minimum log level for the default console sin |
115
- | `personalization` | No | See "Personalization Options" | Configuration specific to the Personalization/Experience API |
117
+ | Option | Required? | Default | Description |
118
+ | ----------------- | --------- | ----------------------------- | ------------------------------------------------------------ |
119
+ | `analytics` | No | See "Analytics Options" | Configuration specific to the Analytics/Insights API |
120
+ | `clientId` | Yes | N/A | The Optimization API key |
121
+ | `environment` | No | `'main'` | The environment identifier |
122
+ | `eventBuilder` | No | See "Event Builder Options" | Event builder configuration (channel/library metadata, etc.) |
123
+ | `fetchOptions` | No | See "Fetch Options" | Configuration for Fetch timeout and retry functionality |
124
+ | `logLevel` | No | `'error'` | Minimum log level for the default console sink |
125
+ | `personalization` | No | See "Personalization Options" | Configuration specific to the Personalization/Experience API |
116
126
 
117
127
  The following configuration options apply only in stateful environments:
118
128
 
119
- | Option | Required? | Default | Description |
120
- | -------------------------- | --------- | ---------------------- | ----------------------------------------------------------------- |
121
- | `allowedEventTypes` | No | `['identify', 'page']` | Allow-listed event types permitted when consent is not set |
122
- | `defaults` | No | `undefined` | Set of default state values applied on initialization |
123
- | `getAnonymousId` | No | `undefined` | Function used to obtain an anonymous user identifier |
124
- | `preventedComponentEvents` | No | `undefined` | Initial duplication prevention configuration for component events |
129
+ | Option | Required? | Default | Description |
130
+ | ------------------- | --------- | -------------------------------- | ---------------------------------------------------------- |
131
+ | `allowedEventTypes` | No | `['identify', 'page', 'screen']` | Allow-listed event types permitted when consent is not set |
132
+ | `defaults` | No | `undefined` | Set of default state values applied on initialization |
133
+ | `getAnonymousId` | No | `undefined` | Function used to obtain an anonymous user identifier |
134
+ | `onEventBlocked` | No | `undefined` | Callback invoked when an event call is blocked by guards |
125
135
 
126
136
  Configuration method signatures:
127
137
 
128
138
  - `getAnonymousId`: `() => string | undefined`
139
+ - `onEventBlocked`: `(event: BlockedEvent) => void`
129
140
 
130
141
  ### Analytics Options
131
142
 
@@ -135,13 +146,49 @@ Configuration method signatures:
135
146
 
136
147
  The following configuration options apply only in stateful environments:
137
148
 
138
- | Option | Required? | Default | Description |
139
- | --------------- | --------- | ----------- | ------------------------------------------------------------------------ |
140
- | `beaconHandler` | No | `undefined` | Handler used to enqueue events via the Beacon API or a similar mechanism |
149
+ | Option | Required? | Default | Description |
150
+ | --------------- | --------- | --------------------- | ------------------------------------------------------------------------ |
151
+ | `beaconHandler` | No | `undefined` | Handler used to enqueue events via the Beacon API or a similar mechanism |
152
+ | `queuePolicy` | No | See method signatures | Queue flush retry/backoff/circuit policy for stateful analytics |
141
153
 
142
154
  Configuration method signatures:
143
155
 
144
156
  - `beaconHandler`: `(url: string | URL, data: BatchInsightsEventArray) => boolean`
157
+ - `queuePolicy`:
158
+
159
+ ```ts
160
+ {
161
+ baseBackoffMs?: number,
162
+ maxBackoffMs?: number,
163
+ jitterRatio?: number,
164
+ maxConsecutiveFailures?: number,
165
+ circuitOpenMs?: number,
166
+ onFlushFailure?: (context: QueueFlushFailureContext) => void,
167
+ onCircuitOpen?: (context: QueueFlushFailureContext) => void,
168
+ onFlushRecovered?: (context: QueueFlushRecoveredContext) => void
169
+ }
170
+ ```
171
+
172
+ Supporting callback payloads:
173
+
174
+ ```ts
175
+ type QueueFlushFailureContext = {
176
+ consecutiveFailures: number
177
+ queuedBatches: number
178
+ queuedEvents: number
179
+ retryDelayMs: number
180
+ }
181
+
182
+ type QueueFlushRecoveredContext = {
183
+ consecutiveFailures: number
184
+ }
185
+ ```
186
+
187
+ Notes:
188
+ - Invalid numeric values fall back to defaults.
189
+ - `jitterRatio` is clamped to `[0, 1]`.
190
+ - `maxBackoffMs` is normalized to be at least `baseBackoffMs`.
191
+ - Failed flush attempts include both `false` responses and thrown send errors.
145
192
 
146
193
  ### Event Builder Options
147
194
 
@@ -207,6 +254,13 @@ Configuration method signatures:
207
254
  - `fetchMethod`: `(url: string | URL, init: RequestInit) => Promise<Response>`
208
255
  - `onFailedAttempt` and `onRequestTimeout`: `(options: FetchMethodCallbackOptions) => void`
209
256
 
257
+ > [!NOTE]
258
+ >
259
+ > Core inherits the API Client retry contract: default retries intentionally apply only to HTTP
260
+ > `503` responses (`Service Unavailable`). This is deliberate and aligned with current Experience
261
+ > and Insights API expectations; do not broaden retry status handling without an explicit API
262
+ > contract change.
263
+
210
264
  ### Personalization Options
211
265
 
212
266
  | Option | Required? | Default | Description |
@@ -218,6 +272,61 @@ Configuration method signatures:
218
272
  | `plainText` | No | `false` | Sends performance-critical endpoints in plain text |
219
273
  | `preflight` | No | `false` | Instructs the API to aggregate a new profile state but not store it |
220
274
 
275
+ The following configuration options apply only in stateful environments:
276
+
277
+ | Option | Required? | Default | Description |
278
+ | ------------- | --------- | --------------------- | --------------------------------------------------------------------------- |
279
+ | `queuePolicy` | No | See method signatures | Queue and flush-retry policy for stateful personalization offline buffering |
280
+
281
+ Configuration method signatures:
282
+
283
+ - `queuePolicy`:
284
+
285
+ ```ts
286
+ {
287
+ maxEvents?: number,
288
+ onDrop?: (context: PersonalizationOfflineQueueDropContext) => void,
289
+ flushPolicy?: {
290
+ baseBackoffMs?: number,
291
+ maxBackoffMs?: number,
292
+ jitterRatio?: number,
293
+ maxConsecutiveFailures?: number,
294
+ circuitOpenMs?: number,
295
+ onFlushFailure?: (context: QueueFlushFailureContext) => void,
296
+ onCircuitOpen?: (context: QueueFlushFailureContext) => void,
297
+ onFlushRecovered?: (context: QueueFlushRecoveredContext) => void
298
+ }
299
+ }
300
+ ```
301
+
302
+ Supporting callback payloads:
303
+
304
+ ```ts
305
+ type PersonalizationOfflineQueueDropContext = {
306
+ droppedCount: number
307
+ droppedEvents: ExperienceEventArray
308
+ maxEvents: number
309
+ queuedEvents: number
310
+ }
311
+
312
+ type QueueFlushFailureContext = {
313
+ consecutiveFailures: number
314
+ queuedBatches: number
315
+ queuedEvents: number
316
+ retryDelayMs: number
317
+ }
318
+
319
+ type QueueFlushRecoveredContext = {
320
+ consecutiveFailures: number
321
+ }
322
+ ```
323
+
324
+ Notes:
325
+ - Default `maxEvents` is `100`.
326
+ - If the queue is full while offline, oldest events are dropped first.
327
+ - `onDrop` is best-effort; callback errors are swallowed.
328
+ - `flushPolicy` uses the same normalization semantics as `analytics.queuePolicy`.
329
+
221
330
  ## Core Methods
222
331
 
223
332
  The methods in this section are available in both stateful and stateless Core classes. However, be
@@ -291,7 +400,16 @@ Arguments:
291
400
 
292
401
  ### Personalization and Analytics Event Methods
293
402
 
294
- Each method except `trackFlagView` may return an `OptimizationData` object containing:
403
+ Only the following methods may return an `OptimizationData` object:
404
+
405
+ - `identify`
406
+ - `page`
407
+ - `screen`
408
+ - `track`
409
+ - `trackComponentView` (when `payload.sticky` is `true`)
410
+
411
+ `trackComponentClick` and `trackFlagView` return no data. When returned, `OptimizationData`
412
+ contains:
295
413
 
296
414
  - `changes`: Currently used for Custom Flags
297
415
  - `personalizations`: Selected personalizations for the profile
@@ -315,6 +433,15 @@ Arguments:
315
433
  - `payload`\*: Page view event builder arguments object, including an optional `profile` property
316
434
  with a `PartialProfile` value that requires only an `id`
317
435
 
436
+ #### `screen`
437
+
438
+ Record a personalization screen view.
439
+
440
+ Arguments:
441
+
442
+ - `payload`\*: Screen view event builder arguments object, including an optional `profile` property
443
+ with a `PartialProfile` value that requires only an `id`
444
+
318
445
  #### `track`
319
446
 
320
447
  Record a personalization custom track event.
@@ -334,20 +461,31 @@ Arguments:
334
461
 
335
462
  - `payload`\*: Component view event builder arguments object, including an optional `profile`
336
463
  property with a `PartialProfile` value that requires only an `id`
337
- - `duplicationScope`: Arbitrary string that may be used to scope component view duplication; used in
338
- Stateful implementations
464
+
465
+ #### `trackComponentClick`
466
+
467
+ Record an analytics component click event.
468
+
469
+ Returns:
470
+
471
+ - `void`
472
+
473
+ Arguments:
474
+
475
+ - `payload`\*: Component click event builder arguments object
339
476
 
340
477
  #### `trackFlagView`
341
478
 
342
479
  Track a feature flag view via analytics. This is functionally the same as a non-sticky component
343
480
  view event.
344
481
 
482
+ Returns:
483
+
484
+ - `void`
485
+
345
486
  Arguments:
346
487
 
347
- - `payload`\*: Component view event builder arguments object, including an optional `profile`
348
- property with a `PartialProfile` value that requires only an `id`
349
- - `duplicationScope`: Arbitrary string that may be used to scope component view duplication; used in
350
- Stateful implementations
488
+ - `payload`\*: Component view event builder arguments object
351
489
 
352
490
  ## Stateful-only Core Methods
353
491
 
@@ -357,24 +495,76 @@ Updates the user consent state.
357
495
 
358
496
  Arguments:
359
497
 
360
- - `accept`: A boolean value specifying whether the user has accepted (`true`) or denied (`false`). A
361
- value of `undefined` implies that the user has not yet explicitly chosen whether to consent.
498
+ - `accept`: A boolean value specifying whether the user has accepted (`true`) or denied (`false`)
362
499
 
363
500
  ### `reset`
364
501
 
365
502
  Resets all internal state _except_ consent. This method expects no arguments and returns no value.
366
503
 
504
+ ### `flush`
505
+
506
+ Flushes queued analytics and personalization events. This method expects no arguments and returns a
507
+ `Promise<void>`.
508
+
509
+ ### `destroy`
510
+
511
+ Releases singleton ownership for stateful runtime usage. This is intended for explicit teardown
512
+ paths, such as tests or hot-reload workflows. This method expects no arguments and returns no value.
513
+
514
+ ### `registerPreviewPanel` (preview tooling only)
515
+
516
+ Registers a preview consumer object and exposes internal signal references used by first-party
517
+ preview tooling.
518
+
519
+ Arguments:
520
+
521
+ - `previewPanel`: Required object that receives symbol-keyed signal bridge values
522
+
523
+ Returns:
524
+
525
+ - `void`
526
+
527
+ Bridge symbols:
528
+
529
+ - `PREVIEW_PANEL_SIGNALS_SYMBOL`: key used to expose internal `signals`
530
+ - `PREVIEW_PANEL_SIGNAL_FNS_SYMBOL`: key used to expose internal `signalFns`
531
+
532
+ Example:
533
+
534
+ ```ts
535
+ import {
536
+ PREVIEW_PANEL_SIGNAL_FNS_SYMBOL,
537
+ PREVIEW_PANEL_SIGNALS_SYMBOL,
538
+ type PreviewPanelSignalObject,
539
+ } from '@contentful/optimization-core'
540
+
541
+ const previewBridge: PreviewPanelSignalObject = {}
542
+ optimization.registerPreviewPanel(previewBridge)
543
+
544
+ const signals = previewBridge[PREVIEW_PANEL_SIGNALS_SYMBOL]
545
+ const signalFns = previewBridge[PREVIEW_PANEL_SIGNAL_FNS_SYMBOL]
546
+ ```
547
+
548
+ > [!IMPORTANT]
549
+ >
550
+ > This method intentionally exposes mutable internal signals for preview tooling. The Web and React
551
+ > Native preview panels are tightly coupled by design and rely on this bridge (plus state
552
+ > interceptors) to apply immediate local overrides without network round-trips. This coupling is
553
+ > deliberate and necessary for preview functionality.
554
+
367
555
  ## Stateful-only Core Properties
368
556
 
369
557
  - `states`: Returns an object mapping of observables for all internal states
370
558
  - `consent`: The current state of user consent
559
+ - `blockedEventStream`: The latest blocked event payload
371
560
  - `eventStream`: The latest event to be queued
372
561
  - `flags`: All current resolved Custom Flags
373
562
  - `profile`: The current user profile
374
563
  - `personalizations`: The current collection of selected personalizations
375
564
 
376
- Each state except `consent` and `eventStream` is updated internally whenever a response from the
377
- Experience API contains a new or updated respective state.
565
+ The `blockedEventStream` state is updated whenever a call is blocked by consent guards. Each state
566
+ except `consent`, `eventStream`, and `blockedEventStream` is updated internally whenever a response
567
+ from the Experience API contains a new or updated respective state.
378
568
 
379
569
  Example `states` observable usage:
380
570
 
package/dist/260.mjs ADDED
@@ -0,0 +1,14 @@
1
+ const OPTIMIZATION_CORE_SDK_VERSION = "0.1.0-alpha9";
2
+ const OPTIMIZATION_CORE_SDK_NAME = "@contentful/optimization-core";
3
+ const ANONYMOUS_ID_COOKIE = 'ctfl-opt-aid';
4
+ const ANONYMOUS_ID_KEY = '__ctfl_opt_anonymous_id__';
5
+ const CONSENT_KEY = '__ctfl_opt_consent__';
6
+ const CHANGES_CACHE_KEY = '__ctfl_opt_changes__';
7
+ const DEBUG_FLAG_KEY = '__ctfl_opt_debug__';
8
+ const PROFILE_CACHE_KEY = '__ctfl_opt_profile__';
9
+ const PERSONALIZATIONS_CACHE_KEY = '__ctfl_opt_personalizations__';
10
+ const ANONYMOUS_ID_COOKIE_LEGACY = 'ntaid';
11
+ const ANONYMOUS_ID_KEY_LEGACY = '__nt_anonymous_id__';
12
+ export { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_COOKIE_LEGACY, ANONYMOUS_ID_KEY, ANONYMOUS_ID_KEY_LEGACY, CHANGES_CACHE_KEY, CONSENT_KEY, DEBUG_FLAG_KEY, OPTIMIZATION_CORE_SDK_NAME, OPTIMIZATION_CORE_SDK_VERSION, PERSONALIZATIONS_CACHE_KEY, PROFILE_CACHE_KEY };
13
+
14
+ //# sourceMappingURL=260.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"260.mjs","sources":["../src/constants.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_VERSION__: string | undefined\n// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_PACKAGE_NAME__: string | undefined\n\n/**\n * The current version of the Optimization Core SDK, injected at build time.\n *\n * @public\n */\nexport const OPTIMIZATION_CORE_SDK_VERSION =\n typeof __OPTIMIZATION_VERSION__ === 'string' ? __OPTIMIZATION_VERSION__ : '0.0.0'\n/**\n * The package name of the Optimization Core SDK, injected at build time.\n *\n * @public\n */\nexport const OPTIMIZATION_CORE_SDK_NAME =\n typeof __OPTIMIZATION_PACKAGE_NAME__ === 'string'\n ? __OPTIMIZATION_PACKAGE_NAME__\n : '@contentful/optimization-core'\n\n/**\n * Anonymous-ID cookie name used by the Optimization Core.\n *\n * @public\n * @remarks\n * This constant represents the cookie key used by the Optimization Framework\n * to persist an anonymous identifier for tracking personalization and analytics\n * events when no explicit profile is known.\n *\n * @example\n * ```ts\n * import { ANONYMOUS_ID_COOKIE } from '@contentful/optimization-core/constants'\n * const profileId = request.cookies[ANONYMOUS_ID_COOKIE]\n * ```\n */\nexport const ANONYMOUS_ID_COOKIE = 'ctfl-opt-aid'\n\n/**\n * Storage key for the anonymous identifier.\n *\n * @internal\n */\nexport const ANONYMOUS_ID_KEY = '__ctfl_opt_anonymous_id__'\n\n/**\n * Storage key for the persisted consent status.\n *\n * @internal\n */\nexport const CONSENT_KEY = '__ctfl_opt_consent__'\n\n/**\n * Storage key for cached Custom Flags.\n *\n * @internal\n */\nexport const CHANGES_CACHE_KEY = '__ctfl_opt_changes__'\n\n/**\n * Storage key for the debug flag toggle.\n *\n * @internal\n */\nexport const DEBUG_FLAG_KEY = '__ctfl_opt_debug__'\n\n/**\n * Storage key for cached profile data.\n *\n * @internal\n */\nexport const PROFILE_CACHE_KEY = '__ctfl_opt_profile__'\n\n/**\n * Storage key for cached selected personalizations.\n *\n * @internal\n */\nexport const PERSONALIZATIONS_CACHE_KEY = '__ctfl_opt_personalizations__'\n\n/**\n * Legacy anoynmous ID cookie key for migration from experience.js\n *\n * @internal\n */\nexport const ANONYMOUS_ID_COOKIE_LEGACY = 'ntaid'\n\n/**\n * Legacy anoynmous ID storage key for migration from experience.js\n *\n * @internal\n */\nexport const ANONYMOUS_ID_KEY_LEGACY = '__nt_anonymous_id__'\n"],"names":["OPTIMIZATION_CORE_SDK_VERSION","__OPTIMIZATION_VERSION__","OPTIMIZATION_CORE_SDK_NAME","__OPTIMIZATION_PACKAGE_NAME__","ANONYMOUS_ID_COOKIE","ANONYMOUS_ID_KEY","CONSENT_KEY","CHANGES_CACHE_KEY","DEBUG_FLAG_KEY","PROFILE_CACHE_KEY","PERSONALIZATIONS_CACHE_KEY","ANONYMOUS_ID_COOKIE_LEGACY","ANONYMOUS_ID_KEY_LEGACY"],"mappings":"AAUO,MAAMA,gCACoCC;AAM1C,MAAMC,6BAEPC;AAkBC,MAAMC,sBAAsB;AAO5B,MAAMC,mBAAmB;AAOzB,MAAMC,cAAc;AAOpB,MAAMC,oBAAoB;AAO1B,MAAMC,iBAAiB;AAOvB,MAAMC,oBAAoB;AAO1B,MAAMC,6BAA6B;AAOnC,MAAMC,6BAA6B;AAOnC,MAAMC,0BAA0B"}
package/dist/499.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import * as __rspack_external__contentful_optimization_api_client_logger_f0d05f82 from "@contentful/optimization-api-client/logger";
2
+ var default_0 = __rspack_external__contentful_optimization_api_client_logger_f0d05f82["default"];
3
+ export default default_0;
4
+ export { __rspack_external__contentful_optimization_api_client_logger_f0d05f82 };
package/dist/632.mjs ADDED
@@ -0,0 +1,5 @@
1
+ const PREVIEW_PANEL_SIGNALS_SYMBOL = Symbol.for('ctfl.optimization.preview.signals');
2
+ const PREVIEW_PANEL_SIGNAL_FNS_SYMBOL = Symbol.for('ctfl.optimization.preview.signalFns');
3
+ export { PREVIEW_PANEL_SIGNALS_SYMBOL, PREVIEW_PANEL_SIGNAL_FNS_SYMBOL };
4
+
5
+ //# sourceMappingURL=632.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"632.mjs","sources":["../src/symbols.ts"],"sourcesContent":["/**\n * Well-known symbols used by the preview panel bridge.\n *\n * @public\n */\nexport const PREVIEW_PANEL_SIGNALS_SYMBOL = Symbol.for('ctfl.optimization.preview.signals')\nexport const PREVIEW_PANEL_SIGNAL_FNS_SYMBOL = Symbol.for('ctfl.optimization.preview.signalFns')\n"],"names":["PREVIEW_PANEL_SIGNALS_SYMBOL","Symbol","PREVIEW_PANEL_SIGNAL_FNS_SYMBOL"],"mappings":"AAKO,MAAMA,+BAA+BC,OAAO,GAAG,CAAC;AAChD,MAAMC,kCAAkCD,OAAO,GAAG,CAAC"}
package/dist/808.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import * as __rspack_external__contentful_optimization_api_client_api_schemas_4192893e from "@contentful/optimization-api-client/api-schemas";
2
+ export { __rspack_external__contentful_optimization_api_client_api_schemas_4192893e };
package/dist/942.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import * as __rspack_external__contentful_optimization_api_client_cba5a7ee from "@contentful/optimization-api-client";
2
+ export { __rspack_external__contentful_optimization_api_client_cba5a7ee };
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __webpack_modules__ = {
3
+ "@contentful/optimization-api-client" (module) {
4
+ module.exports = require("@contentful/optimization-api-client");
5
+ }
6
+ };
7
+ var __webpack_module_cache__ = {};
8
+ function __webpack_require__(moduleId) {
9
+ var cachedModule = __webpack_module_cache__[moduleId];
10
+ if (void 0 !== cachedModule) return cachedModule.exports;
11
+ var module = __webpack_module_cache__[moduleId] = {
12
+ exports: {}
13
+ };
14
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
+ return module.exports;
16
+ }
17
+ (()=>{
18
+ __webpack_require__.n = (module)=>{
19
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
20
+ __webpack_require__.d(getter, {
21
+ a: getter
22
+ });
23
+ return getter;
24
+ };
25
+ })();
26
+ (()=>{
27
+ __webpack_require__.d = (exports1, definition)=>{
28
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
+ enumerable: true,
30
+ get: definition[key]
31
+ });
32
+ };
33
+ })();
34
+ (()=>{
35
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
36
+ })();
37
+ (()=>{
38
+ __webpack_require__.r = (exports1)=>{
39
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
40
+ value: 'Module'
41
+ });
42
+ Object.defineProperty(exports1, '__esModule', {
43
+ value: true
44
+ });
45
+ };
46
+ })();
47
+ var __webpack_exports__ = {};
48
+ (()=>{
49
+ __webpack_require__.r(__webpack_exports__);
50
+ var _contentful_optimization_api_client__rspack_import_0 = __webpack_require__("@contentful/optimization-api-client");
51
+ var __rspack_reexport = {};
52
+ for(const __rspack_import_key in _contentful_optimization_api_client__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_contentful_optimization_api_client__rspack_import_0[__rspack_import_key];
53
+ __webpack_require__.d(__webpack_exports__, __rspack_reexport);
54
+ })();
55
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
56
+ Object.defineProperty(exports, '__esModule', {
57
+ value: true
58
+ });
59
+
60
+ //# sourceMappingURL=api-client.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client.cjs","sources":["webpack/runtime/compat_get_default_export","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol"],"mappings":";;;;;;;;;;;;;;;;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFP,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOQ,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D"}
@@ -0,0 +1,4 @@
1
+
2
+ export * from "@contentful/optimization-api-client";
3
+
4
+ export { }
@@ -0,0 +1,4 @@
1
+
2
+ export * from "@contentful/optimization-api-client";
3
+
4
+ export { }
@@ -0,0 +1,4 @@
1
+
2
+ export * from "@contentful/optimization-api-client";
3
+
4
+ export { }
@@ -0,0 +1,2 @@
1
+ import "./942.mjs";
2
+ export * from "@contentful/optimization-api-client";
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __webpack_modules__ = {
3
+ "@contentful/optimization-api-client/api-schemas" (module) {
4
+ module.exports = require("@contentful/optimization-api-client/api-schemas");
5
+ }
6
+ };
7
+ var __webpack_module_cache__ = {};
8
+ function __webpack_require__(moduleId) {
9
+ var cachedModule = __webpack_module_cache__[moduleId];
10
+ if (void 0 !== cachedModule) return cachedModule.exports;
11
+ var module = __webpack_module_cache__[moduleId] = {
12
+ exports: {}
13
+ };
14
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
+ return module.exports;
16
+ }
17
+ (()=>{
18
+ __webpack_require__.n = (module)=>{
19
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
20
+ __webpack_require__.d(getter, {
21
+ a: getter
22
+ });
23
+ return getter;
24
+ };
25
+ })();
26
+ (()=>{
27
+ __webpack_require__.d = (exports1, definition)=>{
28
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
+ enumerable: true,
30
+ get: definition[key]
31
+ });
32
+ };
33
+ })();
34
+ (()=>{
35
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
36
+ })();
37
+ (()=>{
38
+ __webpack_require__.r = (exports1)=>{
39
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
40
+ value: 'Module'
41
+ });
42
+ Object.defineProperty(exports1, '__esModule', {
43
+ value: true
44
+ });
45
+ };
46
+ })();
47
+ var __webpack_exports__ = {};
48
+ (()=>{
49
+ __webpack_require__.r(__webpack_exports__);
50
+ var _contentful_optimization_api_client_api_schemas__rspack_import_0 = __webpack_require__("@contentful/optimization-api-client/api-schemas");
51
+ var __rspack_reexport = {};
52
+ for(const __rspack_import_key in _contentful_optimization_api_client_api_schemas__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_contentful_optimization_api_client_api_schemas__rspack_import_0[__rspack_import_key];
53
+ __webpack_require__.d(__webpack_exports__, __rspack_reexport);
54
+ })();
55
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
56
+ Object.defineProperty(exports, '__esModule', {
57
+ value: true
58
+ });
59
+
60
+ //# sourceMappingURL=api-schemas.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-schemas.cjs","sources":["webpack/runtime/compat_get_default_export","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol"],"mappings":";;;;;;;;;;;;;;;;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFP,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOQ,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D"}
@@ -0,0 +1,4 @@
1
+
2
+ export * from "@contentful/optimization-api-client/api-schemas";
3
+
4
+ export { }
@@ -0,0 +1,4 @@
1
+
2
+ export * from "@contentful/optimization-api-client/api-schemas";
3
+
4
+ export { }
@@ -0,0 +1,4 @@
1
+
2
+ export * from "@contentful/optimization-api-client/api-schemas";
3
+
4
+ export { }
@@ -0,0 +1,2 @@
1
+ import "./808.mjs";
2
+ export * from "@contentful/optimization-api-client/api-schemas";