@contentful/optimization-core 0.1.0-alpha → 0.1.0-alpha11

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 (149) hide show
  1. package/README.md +329 -93
  2. package/dist/160.mjs +3 -0
  3. package/dist/260.mjs +14 -0
  4. package/dist/260.mjs.map +1 -0
  5. package/dist/499.mjs +4 -0
  6. package/dist/632.mjs +5 -0
  7. package/dist/632.mjs.map +1 -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 +63 -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/constants.d.cts +88 -0
  24. package/dist/constants.d.mts +88 -0
  25. package/dist/constants.d.ts +88 -0
  26. package/dist/constants.mjs +1 -0
  27. package/dist/index.cjs +1509 -1715
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +2523 -0
  30. package/dist/index.d.mts +2523 -0
  31. package/dist/index.d.ts +2523 -15
  32. package/dist/index.mjs +1215 -1362
  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 +78 -12
  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 -142
  56. package/dist/CoreStateful.d.ts.map +0 -1
  57. package/dist/CoreStateful.js +0 -137
  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 +0 -18
  84. package/dist/global-constants.d.ts.map +0 -1
  85. package/dist/global-constants.js +0 -18
  86. package/dist/global-constants.js.map +0 -1
  87. package/dist/index.d.ts.map +0 -1
  88. package/dist/index.js +0 -15
  89. package/dist/index.js.map +0 -1
  90. package/dist/lib/decorators/guardedBy.d.ts +0 -113
  91. package/dist/lib/decorators/guardedBy.d.ts.map +0 -1
  92. package/dist/lib/decorators/guardedBy.js +0 -143
  93. package/dist/lib/decorators/guardedBy.js.map +0 -1
  94. package/dist/lib/decorators/index.d.ts +0 -2
  95. package/dist/lib/decorators/index.d.ts.map +0 -1
  96. package/dist/lib/decorators/index.js +0 -2
  97. package/dist/lib/decorators/index.js.map +0 -1
  98. package/dist/lib/interceptor/InterceptorManager.d.ts +0 -127
  99. package/dist/lib/interceptor/InterceptorManager.d.ts.map +0 -1
  100. package/dist/lib/interceptor/InterceptorManager.js +0 -125
  101. package/dist/lib/interceptor/InterceptorManager.js.map +0 -1
  102. package/dist/lib/interceptor/index.d.ts +0 -2
  103. package/dist/lib/interceptor/index.d.ts.map +0 -1
  104. package/dist/lib/interceptor/index.js +0 -2
  105. package/dist/lib/interceptor/index.js.map +0 -1
  106. package/dist/lib/value-presence/ValuePresence.d.ts +0 -123
  107. package/dist/lib/value-presence/ValuePresence.d.ts.map +0 -1
  108. package/dist/lib/value-presence/ValuePresence.js +0 -141
  109. package/dist/lib/value-presence/ValuePresence.js.map +0 -1
  110. package/dist/lib/value-presence/index.d.ts +0 -2
  111. package/dist/lib/value-presence/index.d.ts.map +0 -1
  112. package/dist/lib/value-presence/index.js +0 -2
  113. package/dist/lib/value-presence/index.js.map +0 -1
  114. package/dist/personalization/PersonalizationBase.d.ts +0 -184
  115. package/dist/personalization/PersonalizationBase.d.ts.map +0 -1
  116. package/dist/personalization/PersonalizationBase.js +0 -76
  117. package/dist/personalization/PersonalizationBase.js.map +0 -1
  118. package/dist/personalization/PersonalizationStateful.d.ts +0 -226
  119. package/dist/personalization/PersonalizationStateful.d.ts.map +0 -1
  120. package/dist/personalization/PersonalizationStateful.js +0 -297
  121. package/dist/personalization/PersonalizationStateful.js.map +0 -1
  122. package/dist/personalization/PersonalizationStateless.d.ts +0 -74
  123. package/dist/personalization/PersonalizationStateless.d.ts.map +0 -1
  124. package/dist/personalization/PersonalizationStateless.js +0 -98
  125. package/dist/personalization/PersonalizationStateless.js.map +0 -1
  126. package/dist/personalization/index.d.ts +0 -6
  127. package/dist/personalization/index.d.ts.map +0 -1
  128. package/dist/personalization/index.js +0 -6
  129. package/dist/personalization/index.js.map +0 -1
  130. package/dist/personalization/resolvers/FlagsResolver.d.ts +0 -35
  131. package/dist/personalization/resolvers/FlagsResolver.d.ts.map +0 -1
  132. package/dist/personalization/resolvers/FlagsResolver.js +0 -47
  133. package/dist/personalization/resolvers/FlagsResolver.js.map +0 -1
  134. package/dist/personalization/resolvers/MergeTagValueResolver.d.ts +0 -74
  135. package/dist/personalization/resolvers/MergeTagValueResolver.d.ts.map +0 -1
  136. package/dist/personalization/resolvers/MergeTagValueResolver.js +0 -109
  137. package/dist/personalization/resolvers/MergeTagValueResolver.js.map +0 -1
  138. package/dist/personalization/resolvers/PersonalizedEntryResolver.d.ts +0 -142
  139. package/dist/personalization/resolvers/PersonalizedEntryResolver.d.ts.map +0 -1
  140. package/dist/personalization/resolvers/PersonalizedEntryResolver.js +0 -196
  141. package/dist/personalization/resolvers/PersonalizedEntryResolver.js.map +0 -1
  142. package/dist/personalization/resolvers/index.d.ts +0 -7
  143. package/dist/personalization/resolvers/index.d.ts.map +0 -1
  144. package/dist/personalization/resolvers/index.js +0 -7
  145. package/dist/personalization/resolvers/index.js.map +0 -1
  146. package/dist/signals.d.ts +0 -35
  147. package/dist/signals.d.ts.map +0 -1
  148. package/dist/signals.js +0 -30
  149. package/dist/signals.js.map +0 -1
@@ -1,123 +0,0 @@
1
- /**
2
- * A scope identifier for grouping values.
3
- *
4
- * @remarks
5
- * Use a non-empty string for a named scope. Use `undefined` for the
6
- * "global/default" scope. An empty string (`""`) passed to the constructor
7
- * initializer is normalized to `undefined`.
8
- *
9
- * @public
10
- */
11
- type ValuePresenceScope = string | undefined;
12
- /**
13
- * Tracks whether a given value is present within one or more logical scopes.
14
- *
15
- * @remarks
16
- * - Scope names are case-sensitive.
17
- * - Presence is based on `Set.has` reference equality for objects and
18
- * value equality for primitives.
19
- *
20
- * @example
21
- * ```ts
22
- * const presence = new ValuePresence({ default: ['a', 'b'] })
23
- * presence.isPresent('default', 'a') // true
24
- * presence.addValue('default', 'c')
25
- * presence.removeValue('default', 'b')
26
- * presence.reset('default')
27
- * ```
28
- *
29
- * @see {@link ValuePresenceScope}
30
- * @public
31
- */
32
- declare class ValuePresence {
33
- #private;
34
- /**
35
- * Create a new {@link ValuePresence}.
36
- *
37
- * @param defaultMap - Optional initial data. Keys are scope names; values are arrays of items to seed.
38
- * Empty-string keys are normalized to the default scope (`undefined`).
39
- *
40
- * @remarks
41
- * - If `defaultMap` contains duplicate items for a scope, duplicates are collapsed by the `Set`.
42
- */
43
- constructor(defaultMap?: Record<string, unknown[]>);
44
- /**
45
- * Check whether a value is present within a given scope.
46
- *
47
- * @param scope - The scope to check. Use `undefined` for the default scope.
48
- * @param value - The value to test for presence.
49
- * @returns `true` if the value is present in the specified scope; otherwise `false`.
50
- *
51
- * @remarks
52
- * Presence testing uses `Set.prototype.has` semantics.
53
- *
54
- * @example
55
- * ```ts
56
- * presence.isPresent(undefined, 42) // e.g., true or false
57
- * ```
58
- *
59
- * @public
60
- */
61
- isPresent(scope: ValuePresenceScope, value: unknown): boolean;
62
- /**
63
- * Add a value to a scope, creating the scope if it does not exist.
64
- *
65
- * @param scope - Scope to add the value to. Use `undefined` for the default scope.
66
- * @param value - The value to add.
67
- * @returns void
68
- *
69
- * @remarks
70
- * - No-op if the value is already present (due to `Set` semantics).
71
- *
72
- * @example
73
- * ```ts
74
- * presence.addValue('users', userId)
75
- * ```
76
- *
77
- * @public
78
- */
79
- addValue(scope: ValuePresenceScope, value: unknown): void;
80
- /**
81
- * Remove a value from a scope.
82
- *
83
- * @param scope - Scope to remove from. Use `undefined` for the default scope.
84
- * @param value - The value to remove.
85
- * @returns void
86
- *
87
- * @remarks
88
- * If the scope does not exist or the value is not present, this is a no-op.
89
- *
90
- * @example
91
- * ```ts
92
- * presence.removeValue('users', userId)
93
- * ```
94
- *
95
- * @public
96
- */
97
- removeValue(scope: ValuePresenceScope, value: unknown): void;
98
- /**
99
- * Clear values from a single scope, or from all scopes.
100
- *
101
- * @param scope - If provided, clears only that scope. If omitted, clears all scopes.
102
- * @returns void
103
- *
104
- * @remarks
105
- * - When called with a specific scope that does not exist, this is a no-op.
106
- * - When called with no arguments, all scopes and values are removed.
107
- * - Clearing a non-existent scope will not create the scope.
108
- *
109
- * @example
110
- * ```ts
111
- * // Clear one scope
112
- * presence.reset('users')
113
- *
114
- * // Clear all scopes
115
- * presence.reset()
116
- * ```
117
- *
118
- * @public
119
- */
120
- reset(scope?: ValuePresenceScope): void;
121
- }
122
- export default ValuePresence;
123
- //# sourceMappingURL=ValuePresence.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ValuePresence.d.ts","sourceRoot":"","sources":["../../../src/lib/value-presence/ValuePresence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,KAAK,kBAAkB,GAAG,MAAM,GAAG,SAAS,CAAA;AAE5C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,cAAM,aAAa;;IAQjB;;;;;;;;OAQG;gBACS,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;IAWlD;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO;IAI7D;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAUzD;;;;;;;;;;;;;;;;OAgBG;IACH,WAAW,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAI5D;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,KAAK,CAAC,EAAE,kBAAkB,GAAG,IAAI;CAOxC;AAED,eAAe,aAAa,CAAA"}
@@ -1,141 +0,0 @@
1
- /**
2
- * Tracks whether a given value is present within one or more logical scopes.
3
- *
4
- * @remarks
5
- * - Scope names are case-sensitive.
6
- * - Presence is based on `Set.has` reference equality for objects and
7
- * value equality for primitives.
8
- *
9
- * @example
10
- * ```ts
11
- * const presence = new ValuePresence({ default: ['a', 'b'] })
12
- * presence.isPresent('default', 'a') // true
13
- * presence.addValue('default', 'c')
14
- * presence.removeValue('default', 'b')
15
- * presence.reset('default')
16
- * ```
17
- *
18
- * @see {@link ValuePresenceScope}
19
- * @public
20
- */
21
- class ValuePresence {
22
- /**
23
- * Internal map of scope -> set of values present in that scope.
24
- *
25
- * @internal
26
- */
27
- #map;
28
- /**
29
- * Create a new {@link ValuePresence}.
30
- *
31
- * @param defaultMap - Optional initial data. Keys are scope names; values are arrays of items to seed.
32
- * Empty-string keys are normalized to the default scope (`undefined`).
33
- *
34
- * @remarks
35
- * - If `defaultMap` contains duplicate items for a scope, duplicates are collapsed by the `Set`.
36
- */
37
- constructor(defaultMap) {
38
- const map = new Map();
39
- if (defaultMap)
40
- Object.entries(defaultMap).map(([scope, values]) => map.set(scope.length ? scope : undefined, new Set(values)));
41
- this.#map = map;
42
- }
43
- /**
44
- * Check whether a value is present within a given scope.
45
- *
46
- * @param scope - The scope to check. Use `undefined` for the default scope.
47
- * @param value - The value to test for presence.
48
- * @returns `true` if the value is present in the specified scope; otherwise `false`.
49
- *
50
- * @remarks
51
- * Presence testing uses `Set.prototype.has` semantics.
52
- *
53
- * @example
54
- * ```ts
55
- * presence.isPresent(undefined, 42) // e.g., true or false
56
- * ```
57
- *
58
- * @public
59
- */
60
- isPresent(scope, value) {
61
- return this.#map.get(scope)?.has(value) ?? false;
62
- }
63
- /**
64
- * Add a value to a scope, creating the scope if it does not exist.
65
- *
66
- * @param scope - Scope to add the value to. Use `undefined` for the default scope.
67
- * @param value - The value to add.
68
- * @returns void
69
- *
70
- * @remarks
71
- * - No-op if the value is already present (due to `Set` semantics).
72
- *
73
- * @example
74
- * ```ts
75
- * presence.addValue('users', userId)
76
- * ```
77
- *
78
- * @public
79
- */
80
- addValue(scope, value) {
81
- const values = this.#map.get(scope);
82
- if (!values) {
83
- this.#map.set(scope, new Set([value]));
84
- }
85
- else {
86
- values.add(value);
87
- }
88
- }
89
- /**
90
- * Remove a value from a scope.
91
- *
92
- * @param scope - Scope to remove from. Use `undefined` for the default scope.
93
- * @param value - The value to remove.
94
- * @returns void
95
- *
96
- * @remarks
97
- * If the scope does not exist or the value is not present, this is a no-op.
98
- *
99
- * @example
100
- * ```ts
101
- * presence.removeValue('users', userId)
102
- * ```
103
- *
104
- * @public
105
- */
106
- removeValue(scope, value) {
107
- this.#map.get(scope)?.delete(value);
108
- }
109
- /**
110
- * Clear values from a single scope, or from all scopes.
111
- *
112
- * @param scope - If provided, clears only that scope. If omitted, clears all scopes.
113
- * @returns void
114
- *
115
- * @remarks
116
- * - When called with a specific scope that does not exist, this is a no-op.
117
- * - When called with no arguments, all scopes and values are removed.
118
- * - Clearing a non-existent scope will not create the scope.
119
- *
120
- * @example
121
- * ```ts
122
- * // Clear one scope
123
- * presence.reset('users')
124
- *
125
- * // Clear all scopes
126
- * presence.reset()
127
- * ```
128
- *
129
- * @public
130
- */
131
- reset(scope) {
132
- if (scope !== undefined) {
133
- this.#map.get(scope)?.clear();
134
- }
135
- else {
136
- this.#map.clear();
137
- }
138
- }
139
- }
140
- export default ValuePresence;
141
- //# sourceMappingURL=ValuePresence.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ValuePresence.js","sourceRoot":"","sources":["../../../src/lib/value-presence/ValuePresence.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,aAAa;IAC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H,KAAK,CAAC,KAA0B;QAC9B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAA;QAC/B,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;QACnB,CAAC;IACH,CAAC;CACF;AAED,eAAe,aAAa,CAAA"}
@@ -1,2 +0,0 @@
1
- export { default as ValuePresence } from './ValuePresence';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/value-presence/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA"}
@@ -1,2 +0,0 @@
1
- export { default as ValuePresence } from './ValuePresence';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/value-presence/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA"}
@@ -1,184 +0,0 @@
1
- import type { ChangeArray, ComponentViewBuilderArgs, IdentifyBuilderArgs, Json, MergeTagEntry, OptimizationData, PageViewBuilderArgs, Profile, ScreenViewBuilderArgs, SelectedPersonalizationArray, TrackBuilderArgs } from '@contentful/optimization-api-client';
2
- import type { ChainModifiers, Entry, EntrySkeletonType, LocaleCode } from 'contentful';
3
- import ProductBase from '../ProductBase';
4
- import { type ResolvedData } from './resolvers';
5
- /**
6
- * These methods assist in resolving values via Resolvers
7
- *
8
- * @internal
9
- * @privateRemarks
10
- * This interface exists to document that the included methods should not be
11
- * considered static.
12
- */
13
- interface ResolverMethods {
14
- /**
15
- * Get the specified Custom Flag's value from the supplied changes.
16
- * @param name - The name or key of the Custom Flag.
17
- * @param changes - Optional changes array.
18
- * @returns The current value of the Custom Flag if found.
19
- * @remarks
20
- * The changes array can be sourced from the data returned when emitting any
21
- * personalization event.
22
- * */
23
- getCustomFlag: (name: string, changes?: ChangeArray) => Json;
24
- /**
25
- * Resolve a Contentful entry to a personalized variant using the current
26
- * or provided selected personalizations.
27
- *
28
- * @typeParam S - Entry skeleton type.
29
- * @typeParam M - Chain modifiers.
30
- * @typeParam L - Locale code.
31
- * @param entry - The entry to personalize.
32
- * @param personalizations - Optional selections.
33
- * @returns The resolved entry data.
34
- * @remarks
35
- * Selected personalizations can be sourced from the data returned when emitting any
36
- * personalization event.
37
- */
38
- personalizeEntry: <S extends EntrySkeletonType, M extends ChainModifiers, L extends LocaleCode>(entry: Entry<S, M, L>, personalizations?: SelectedPersonalizationArray) => ResolvedData<S, M, L>;
39
- /**
40
- * Resolve a merge tag to a value based on the current (or provided) profile.
41
- *
42
- * @param embeddedEntryNodeTarget - The merge‑tag entry node to resolve.
43
- * @param profile - Optional profile.
44
- * @returns The resolved value (type depends on the tag).
45
- * @remarks
46
- * Merge tags are references to profile data that can be substituted into content. The
47
- * profile can be sourced from the data returned when emitting any personalization event.
48
- */
49
- getMergeTagValue: (embeddedEntryNodeTarget: MergeTagEntry, profile?: Profile) => unknown;
50
- }
51
- /**
52
- * Internal base for personalization products.
53
- *
54
- * @internal
55
- * @remarks
56
- * Concrete implementations should extend this class to expose public methods for
57
- * identify, page, and track events. This base wires in shared singleton
58
- * resolvers used to fetch/resolve personalized data.
59
- */
60
- declare abstract class PersonalizationBase extends ProductBase implements ResolverMethods {
61
- /**
62
- * Static {@link FlagsResolver | resolver} for evaluating personalized
63
- * custom flags.
64
- */
65
- readonly flagsResolver: {
66
- resolve(changes?: ChangeArray): import("@contentful/optimization-api-schemas").Flags;
67
- };
68
- /**
69
- * Static {@link MergeTagValueResolver | resolver} that returns values
70
- * sourced from a user profile based on a Contentful Merge Tag entry.
71
- */
72
- readonly mergeTagValueResolver: {
73
- isMergeTagEntry(embeddedEntryNodeTarget: unknown): embeddedEntryNodeTarget is MergeTagEntry;
74
- normalizeSelectors(id: string): string[];
75
- getValueFromProfile(id: string, profile?: Profile): string | undefined;
76
- resolve(mergeTagEntry: MergeTagEntry | undefined, profile?: Profile): string | undefined;
77
- };
78
- /**
79
- * Static {@link PersonalizedEntryResolver | resolver } for personalized
80
- * Contentful entries (e.g., entry variants targeted to a profile audience).
81
- *
82
- * @remarks
83
- * Used by higher-level personalization flows to materialize entry content
84
- * prior to event emission.
85
- */
86
- readonly personalizedEntryResolver: {
87
- getPersonalizationEntry({ personalizedEntry, selectedPersonalizations, }: {
88
- personalizedEntry: import("@contentful/optimization-api-schemas").PersonalizedEntry;
89
- selectedPersonalizations: SelectedPersonalizationArray;
90
- }, skipValidation?: boolean): import("@contentful/optimization-api-schemas").PersonalizationEntry | undefined;
91
- getSelectedPersonalization({ personalizationEntry, selectedPersonalizations, }: {
92
- personalizationEntry: import("@contentful/optimization-api-schemas").PersonalizationEntry;
93
- selectedPersonalizations: SelectedPersonalizationArray;
94
- }, skipValidation?: boolean): import("@contentful/optimization-api-schemas").SelectedPersonalization | undefined;
95
- getSelectedVariant({ personalizedEntry, personalizationEntry, selectedVariantIndex, }: {
96
- personalizedEntry: import("@contentful/optimization-api-schemas").PersonalizedEntry;
97
- personalizationEntry: import("@contentful/optimization-api-schemas").PersonalizationEntry;
98
- selectedVariantIndex: number;
99
- }, skipValidation?: boolean): import("@contentful/optimization-api-schemas").EntryReplacementVariant | undefined;
100
- getSelectedVariantEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = string>({ personalizationEntry, selectedVariant, }: {
101
- personalizationEntry: import("@contentful/optimization-api-schemas").PersonalizationEntry;
102
- selectedVariant: import("@contentful/optimization-api-schemas").EntryReplacementVariant;
103
- }, skipValidation?: boolean): Entry<S, M, L> | undefined;
104
- resolve<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = string>(entry: Entry<S, M, L>, selectedPersonalizations?: SelectedPersonalizationArray): ResolvedData<S, M, L>;
105
- };
106
- /**
107
- * Get the specified Custom Flag's value from the supplied changes.
108
- * @param name - The name/key of the Custom Flag.
109
- * @param changes - Optional changes array.
110
- * @returns The current value of the Custom Flag if found.
111
- * @remarks
112
- * The changes array can be sourced from the data returned when emitting any
113
- * personalization event.
114
- * */
115
- getCustomFlag(name: string, changes?: ChangeArray): Json;
116
- /**
117
- * Resolve a Contentful entry to a personalized variant using the current
118
- * or provided selected personalizations.
119
- *
120
- * @typeParam S - Entry skeleton type.
121
- * @typeParam M - Chain modifiers.
122
- * @typeParam L - Locale code.
123
- * @param entry - The entry to personalize.
124
- * @param personalizations - Optional selected personalizations.
125
- * @returns The resolved entry data.
126
- * @remarks
127
- * Selected personalizations can be sourced from the data returned when emitting any
128
- * personalization event.
129
- */
130
- personalizeEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = LocaleCode>(entry: Entry<S, M, L>, personalizations?: SelectedPersonalizationArray): ResolvedData<S, M, L>;
131
- /**
132
- * Resolve a merge tag to a value based on the current (or provided) profile.
133
- *
134
- * @param embeddedEntryNodeTarget - The merge tag entry node to resolve.
135
- * @param profile - Optional profile.
136
- * @returns The resolved value (type depends on the tag).
137
- * @remarks
138
- * Merge tags are references to profile data that can be substituted into content. The
139
- * profile can be sourced from the data returned when emitting any personalization event.
140
- */
141
- getMergeTagValue(embeddedEntryNodeTarget: MergeTagEntry, profile?: Profile): unknown;
142
- /**
143
- * Identify the current profile/visitor to associate traits with a profile.
144
- *
145
- * @param payload - Identify builder payload.
146
- * @returns The resulting {@link OptimizationData} for the identified user if the device is online.
147
- */
148
- abstract identify(payload: IdentifyBuilderArgs): Promise<OptimizationData | undefined>;
149
- /**
150
- * Record a page view.
151
- *
152
- * @param payload - Page view builder payload.
153
- * @returns The evaluated {@link OptimizationData} for this page view if the device is online.
154
- */
155
- abstract page(payload: PageViewBuilderArgs): Promise<OptimizationData | undefined>;
156
- /**
157
- * Record a screen view.
158
- *
159
- * @param payload - Screen view builder payload.
160
- * @returns The evaluated {@link OptimizationData} for this screen view if the device is online.
161
- */
162
- abstract screen(payload: ScreenViewBuilderArgs): Promise<OptimizationData | undefined>;
163
- /**
164
- * Record a custom track event.
165
- *
166
- * @param payload - Track builder payload.
167
- * @returns The evaluated {@link OptimizationData} for this event if the device is online.
168
- */
169
- abstract track(payload: TrackBuilderArgs): Promise<OptimizationData | undefined>;
170
- /**
171
- * Record a "sticky" component view.
172
- *
173
- * @param payload - "Sticky" component view builder payload.
174
- * @returns The evaluated {@link OptimizationData} for this component view if the device is online.
175
- * @remarks
176
- * This method is intended to be called only when a component is considered
177
- * "sticky".
178
- * @privateRemarks
179
- * Duplication prevention should be handled in Stateful implementations.
180
- */
181
- abstract trackComponentView(payload: ComponentViewBuilderArgs, duplicationScope?: string): Promise<OptimizationData | undefined>;
182
- }
183
- export default PersonalizationBase;
184
- //# sourceMappingURL=PersonalizationBase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PersonalizationBase.d.ts","sourceRoot":"","sources":["../../src/personalization/PersonalizationBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EACxB,mBAAmB,EACnB,IAAI,EACJ,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,qBAAqB,EACrB,4BAA4B,EAC5B,gBAAgB,EACjB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACtF,OAAO,WAAW,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,aAAa,CAAA;AAEpB;;;;;;;GAOG;AACH,UAAU,eAAe;IACvB;;;;;;;;SAQK;IACL,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,IAAI,CAAA;IAE5D;;;;;;;;;;;;;OA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AAC;IAEtF;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAElF;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAEtF;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAEhF;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,kBAAkB,CACzB,OAAO,EAAE,wBAAwB,EACjC,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;CACzC;AAED,eAAe,mBAAmB,CAAA"}
@@ -1,76 +0,0 @@
1
- import ProductBase from '../ProductBase';
2
- import { FlagsResolver, MergeTagValueResolver, PersonalizedEntryResolver, } from './resolvers';
3
- /**
4
- * Internal base for personalization products.
5
- *
6
- * @internal
7
- * @remarks
8
- * Concrete implementations should extend this class to expose public methods for
9
- * identify, page, and track events. This base wires in shared singleton
10
- * resolvers used to fetch/resolve personalized data.
11
- */
12
- class PersonalizationBase extends ProductBase {
13
- /**
14
- * Static {@link FlagsResolver | resolver} for evaluating personalized
15
- * custom flags.
16
- */
17
- flagsResolver = FlagsResolver;
18
- /**
19
- * Static {@link MergeTagValueResolver | resolver} that returns values
20
- * sourced from a user profile based on a Contentful Merge Tag entry.
21
- */
22
- mergeTagValueResolver = MergeTagValueResolver;
23
- /**
24
- * Static {@link PersonalizedEntryResolver | resolver } for personalized
25
- * Contentful entries (e.g., entry variants targeted to a profile audience).
26
- *
27
- * @remarks
28
- * Used by higher-level personalization flows to materialize entry content
29
- * prior to event emission.
30
- */
31
- personalizedEntryResolver = PersonalizedEntryResolver;
32
- /**
33
- * Get the specified Custom Flag's value from the supplied changes.
34
- * @param name - The name/key of the Custom Flag.
35
- * @param changes - Optional changes array.
36
- * @returns The current value of the Custom Flag if found.
37
- * @remarks
38
- * The changes array can be sourced from the data returned when emitting any
39
- * personalization event.
40
- * */
41
- getCustomFlag(name, changes) {
42
- return FlagsResolver.resolve(changes)[name];
43
- }
44
- /**
45
- * Resolve a Contentful entry to a personalized variant using the current
46
- * or provided selected personalizations.
47
- *
48
- * @typeParam S - Entry skeleton type.
49
- * @typeParam M - Chain modifiers.
50
- * @typeParam L - Locale code.
51
- * @param entry - The entry to personalize.
52
- * @param personalizations - Optional selected personalizations.
53
- * @returns The resolved entry data.
54
- * @remarks
55
- * Selected personalizations can be sourced from the data returned when emitting any
56
- * personalization event.
57
- */
58
- personalizeEntry(entry, personalizations) {
59
- return PersonalizedEntryResolver.resolve(entry, personalizations);
60
- }
61
- /**
62
- * Resolve a merge tag to a value based on the current (or provided) profile.
63
- *
64
- * @param embeddedEntryNodeTarget - The merge tag entry node to resolve.
65
- * @param profile - Optional profile.
66
- * @returns The resolved value (type depends on the tag).
67
- * @remarks
68
- * Merge tags are references to profile data that can be substituted into content. The
69
- * profile can be sourced from the data returned when emitting any personalization event.
70
- */
71
- getMergeTagValue(embeddedEntryNodeTarget, profile) {
72
- return MergeTagValueResolver.resolve(embeddedEntryNodeTarget, profile);
73
- }
74
- }
75
- export default PersonalizationBase;
76
- //# sourceMappingURL=PersonalizationBase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PersonalizationBase.js","sourceRoot":"","sources":["../../src/personalization/PersonalizationBase.ts"],"names":[],"mappings":"AAcA,OAAO,WAAW,MAAM,gBAAgB,CAAA;AACxC,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,yBAAyB,GAE1B,MAAM,aAAa,CAAA;AAsDpB;;;;;;;;GAQG;AACH,MAAe,mBAAoB,SAAQ,WAAW;IACpD;;;OAGG;IACM,aAAa,GAAG,aAAa,CAAA;IAEtC;;;OAGG;IACM,qBAAqB,GAAG,qBAAqB,CAAA;IAEtD;;;;;;;OAOG;IACM,yBAAyB,GAAG,yBAAyB,CAAA;IAE9D;;;;;;;;SAQK;IACL,aAAa,CAAC,IAAY,EAAE,OAAqB;QAC/C,OAAO,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAA;IAC7C,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAId,KAAqB,EAAE,gBAA+C;QACtE,OAAO,yBAAyB,CAAC,OAAO,CAAU,KAAK,EAAE,gBAAgB,CAAC,CAAA;IAC5E,CAAC;IAED;;;;;;;;;OASG;IACH,gBAAgB,CAAC,uBAAsC,EAAE,OAAiB;QACxE,OAAO,qBAAqB,CAAC,OAAO,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAA;IACxE,CAAC;CAiDF;AAED,eAAe,mBAAmB,CAAA"}