@xenia-martech/sdk-js 1.2.0-dev.7 → 1.2.0-dev.9

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 (96) hide show
  1. package/README.md +70 -6
  2. package/dist/{actions-35V37IT0.d.cts → actions--1_9Z8ig.d.cts} +13 -2
  3. package/dist/{actions-35V37IT0.d.ts → actions--1_9Z8ig.d.ts} +13 -2
  4. package/dist/{api-0IycTYJR.d.cts → api-DbUxT38T.d.ts} +1 -1
  5. package/dist/{api-COXWLL5L.d.ts → api-DgzJ5s-k.d.cts} +1 -1
  6. package/dist/chunk-DPXINHQR.cjs +34 -0
  7. package/dist/chunk-DPXINHQR.cjs.map +1 -0
  8. package/dist/chunk-FSJMHXS6.js +432 -0
  9. package/dist/chunk-FSJMHXS6.js.map +1 -0
  10. package/dist/chunk-GXJLU3RE.cjs +448 -0
  11. package/dist/chunk-GXJLU3RE.cjs.map +1 -0
  12. package/dist/{chunk-2DR5AVPX.cjs → chunk-I5EHLRSR.cjs} +11 -10
  13. package/dist/chunk-I5EHLRSR.cjs.map +1 -0
  14. package/dist/{chunk-LW5AEJ6K.js → chunk-MEULT5X6.js} +4 -241
  15. package/dist/chunk-MEULT5X6.js.map +1 -0
  16. package/dist/{chunk-GWRDZIVA.js → chunk-NDRRSRTU.js} +4 -3
  17. package/dist/chunk-NDRRSRTU.js.map +1 -0
  18. package/dist/chunk-RC46KXDM.js +32 -0
  19. package/dist/chunk-RC46KXDM.js.map +1 -0
  20. package/dist/{chunk-RWE2OCQL.cjs → chunk-SU25SELD.cjs} +4 -244
  21. package/dist/chunk-SU25SELD.cjs.map +1 -0
  22. package/dist/{chunk-WHGK55JP.cjs → chunk-UUIKUU5W.cjs} +5 -5
  23. package/dist/{chunk-WHGK55JP.cjs.map → chunk-UUIKUU5W.cjs.map} +1 -1
  24. package/dist/{chunk-QEYONKWY.js → chunk-UVTFGQR6.js} +3 -3
  25. package/dist/{chunk-QEYONKWY.js.map → chunk-UVTFGQR6.js.map} +1 -1
  26. package/dist/{chunk-OMMIRSPK.js → chunk-V4EGU3PM.js} +48 -11
  27. package/dist/chunk-V4EGU3PM.js.map +1 -0
  28. package/dist/{chunk-YLMMTKQL.cjs → chunk-WMGCQPHY.cjs} +52 -13
  29. package/dist/chunk-WMGCQPHY.cjs.map +1 -0
  30. package/dist/client/index.cjs +26 -10
  31. package/dist/client/index.cjs.map +1 -1
  32. package/dist/client/index.d.cts +2 -2
  33. package/dist/client/index.d.ts +2 -2
  34. package/dist/client/index.js +26 -10
  35. package/dist/client/index.js.map +1 -1
  36. package/dist/client/react/index.cjs +73 -15
  37. package/dist/client/react/index.cjs.map +1 -1
  38. package/dist/client/react/index.d.cts +9 -3
  39. package/dist/client/react/index.d.ts +9 -3
  40. package/dist/client/react/index.js +73 -15
  41. package/dist/client/react/index.js.map +1 -1
  42. package/dist/cms/contentful.cjs +7 -24
  43. package/dist/cms/contentful.cjs.map +1 -1
  44. package/dist/cms/contentful.d.cts +5 -4
  45. package/dist/cms/contentful.d.ts +5 -4
  46. package/dist/cms/contentful.js +4 -23
  47. package/dist/cms/contentful.js.map +1 -1
  48. package/dist/cms/contentstack.cjs +120 -0
  49. package/dist/cms/contentstack.cjs.map +1 -0
  50. package/dist/cms/contentstack.d.cts +41 -0
  51. package/dist/cms/contentstack.d.ts +41 -0
  52. package/dist/cms/contentstack.js +117 -0
  53. package/dist/cms/contentstack.js.map +1 -0
  54. package/dist/{consent-DRCV0N0d.d.ts → consent-Dtiqzz2B.d.cts} +71 -11
  55. package/dist/{consent-BgAETCkL.d.cts → consent-byYiDMFr.d.ts} +71 -11
  56. package/dist/{cookie-names-DU3MtcNG.d.ts → cookie-names-B4hda2rX.d.cts} +1 -1
  57. package/dist/{cookie-names-DFItnSLK.d.cts → cookie-names-DioZXuV0.d.ts} +1 -1
  58. package/dist/edge/index.cjs +122 -29
  59. package/dist/edge/index.cjs.map +1 -1
  60. package/dist/edge/index.d.cts +42 -6
  61. package/dist/edge/index.d.ts +42 -6
  62. package/dist/edge/index.js +92 -9
  63. package/dist/edge/index.js.map +1 -1
  64. package/dist/index.cjs +31 -31
  65. package/dist/index.d.cts +4 -5
  66. package/dist/index.d.ts +4 -5
  67. package/dist/index.js +2 -2
  68. package/dist/next/index.cjs +39 -34
  69. package/dist/next/index.cjs.map +1 -1
  70. package/dist/next/index.d.cts +2 -3
  71. package/dist/next/index.d.ts +2 -3
  72. package/dist/next/index.js +13 -8
  73. package/dist/next/index.js.map +1 -1
  74. package/dist/{types-DgVHS4Qw.d.ts → personalize-content-D6xeBI7-.d.cts} +150 -1
  75. package/dist/{types-DgVHS4Qw.d.cts → personalize-content-D6xeBI7-.d.ts} +150 -1
  76. package/dist/server/index.cjs +30 -30
  77. package/dist/server/index.d.cts +5 -6
  78. package/dist/server/index.d.ts +5 -6
  79. package/dist/server/index.js +5 -5
  80. package/dist/xenia-sdk.iife.js +3 -3
  81. package/dist/xenia-sdk.iife.js.map +1 -1
  82. package/dist/{xenia-server-Cf24mL0c.d.ts → xenia-server-BcgeUHX4.d.ts} +2 -3
  83. package/dist/{xenia-server-D-bx14lw.d.cts → xenia-server-lv6LtJZP.d.cts} +2 -3
  84. package/package.json +14 -1
  85. package/dist/chunk-2DR5AVPX.cjs.map +0 -1
  86. package/dist/chunk-BQ5PJCZ7.js +0 -179
  87. package/dist/chunk-BQ5PJCZ7.js.map +0 -1
  88. package/dist/chunk-GWRDZIVA.js.map +0 -1
  89. package/dist/chunk-LW5AEJ6K.js.map +0 -1
  90. package/dist/chunk-N5M4PI7C.cjs +0 -192
  91. package/dist/chunk-N5M4PI7C.cjs.map +0 -1
  92. package/dist/chunk-OMMIRSPK.js.map +0 -1
  93. package/dist/chunk-RWE2OCQL.cjs.map +0 -1
  94. package/dist/chunk-YLMMTKQL.cjs.map +0 -1
  95. package/dist/personalize-content-Cwc2AomC.d.ts +0 -141
  96. package/dist/personalize-content-CxSdplMV.d.cts +0 -141
@@ -1,141 +0,0 @@
1
- import { h as EntrySwapOp, g as EntryQuery, e as EntryDecision, p as ResolveOptions } from './types-DgVHS4Qw.js';
2
-
3
- /**
4
- * CMS page personalization — walk a fetched CMS page breadth-first, swap the
5
- * entries Xenia marked as personalized, and do it in as few round trips as
6
- * the page's nesting allows.
7
- *
8
- * Rules (see the "Rounds" section of the feature plan):
9
- * - **Static** targets carry their replacement in the payload (`xeniaVariants`)
10
- * and are swapped inline — no network at all.
11
- * - **Runtime** targets are a barrier: their id is collected, their subtree is
12
- * NOT walked (it may be replaced). One `resolve-entries` call decides every
13
- * target found in a round, one parallel CMS fetch loads every replacement,
14
- * and the next round walks whatever now sits at each position.
15
- * - Never throws: on error or when `timeoutMs` runs out, whatever is not yet
16
- * decided keeps its base content.
17
- *
18
- * CMS specifics live behind {@link CmsAdapter}; built-in adapters ship as
19
- * `@xenia-martech/sdk-js/cms/contentful` (and later `/cms/contentstack`). Any
20
- * other CMS works by implementing the interface.
21
- */
22
-
23
- /** Any value inside a CMS payload — the walker is shape-agnostic; adapters give it meaning. */
24
- type Node = any;
25
- /** The parsed `xenia` marker field of a personalized entry. */
26
- interface XeniaMarker {
27
- kind: "static" | "runtime";
28
- op?: EntrySwapOp;
29
- /** Array field replaced by `op: "items"`. */
30
- field?: string;
31
- limit?: number;
32
- /**
33
- * The content keys (Personalization Resolve identifiers) that personalize this entry. A page only
34
- * acts on markers that list its `contentKey`; a marker without keys is ignored.
35
- */
36
- keys?: string[];
37
- }
38
- /** What the page resolver needs to know about a CMS's entries. `N` is the entry shape. */
39
- interface CmsAdapter<N extends object = Node> {
40
- /** The entry id when `value` is a CMS entry (not a link stub, asset or plain object). */
41
- entryId(value: unknown): string | undefined;
42
- /** The entry's Xenia marker, or null when it is not personalized. */
43
- marker(entry: N): XeniaMarker | null;
44
- /** Static replacements pinned on the entry (its resolved `xeniaVariants`). */
45
- staticVariants(entry: N): N[];
46
- getField(entry: N, field: string): unknown;
47
- setField(entry: N, field: string, value: unknown): void;
48
- /** Legacy `items` without a field: copy the replacement's array fields onto the entry. */
49
- mergeItems?(entry: N, replacement: N): void;
50
- /**
51
- * Remove the marker from an entry that has been dealt with (kept base, or had its items replaced),
52
- * so personalizing the output again — e.g. the browser continuing a server render — never decides
53
- * it twice. Optional; without it a re-run re-asks Xenia about those entries.
54
- */
55
- clearMarker?(entry: N): void;
56
- /** Normalize a fetched payload before walking (e.g. resolve links). Defaults to identity. */
57
- prepare?(payload: unknown): unknown;
58
- /** Load entries by id in ONE call; order does not matter. */
59
- fetchEntries(ids: string[], locale?: string): Promise<N[]>;
60
- /** Run a content-type query in ONE call, in the query's order. */
61
- queryEntries(query: EntryQuery, locale?: string): Promise<N[]>;
62
- /**
63
- * Load one page with its whole tree (links resolved), or null when there is none. Optional; it
64
- * is what lets `personalizePage(ref)` do the fetch, so apps never fetch the page themselves.
65
- */
66
- fetchPage?(ref: PageRef, locale?: string): Promise<N | null>;
67
- }
68
- /** Identifies a page in the CMS: its entry id, or a content type plus exact field values (a slug). */
69
- type PageRef = string | {
70
- contentType: string;
71
- fields: Record<string, string | number | boolean>;
72
- };
73
- /** Resolves a round's runtime targets — `XeniaApi.resolveEntries` bound to the visitor. */
74
- type EntryResolver = (entryIds: string[]) => Promise<EntryDecision[]>;
75
- /** Reported for every swap actually applied (for impressions / analytics). */
76
- interface AppliedSwap {
77
- target: string;
78
- kind: "static" | "runtime";
79
- op: EntrySwapOp;
80
- /** Ids of the entries now at the target's position (or in its field). */
81
- entryIds: string[];
82
- contentKey?: string;
83
- bucket?: string;
84
- round: number;
85
- }
86
- interface PersonalizeContentOptions {
87
- cms: CmsAdapter;
88
- /** Decides runtime targets. Omit to apply static swaps only (zero network). */
89
- resolve?: EntryResolver;
90
- locale?: string;
91
- /**
92
- * The page's Personalization Resolve identifier (required). Only that journey personalizes the
93
- * page: a marker that doesn't list this key is plain content, and the backend decides for this key
94
- * alone — another journey targeting the same section is neither consulted nor run.
95
- */
96
- contentKey: string;
97
- /** Max network rounds (nesting depth of runtime targets). Default 3. */
98
- maxRounds?: number;
99
- /** Total budget for all rounds, in ms. Undecided targets keep their base. Default 300. */
100
- timeoutMs?: number;
101
- /** Mutate the payload in place instead of personalizing a copy. Default false. */
102
- inPlace?: boolean;
103
- onApplied?(swap: AppliedSwap): void;
104
- /**
105
- * Called when a round starts waiting on the network (`pending` = targets being decided) and when
106
- * it has been applied (`pending` empty). `content` is the live, partially personalized tree —
107
- * lets a UI render level by level instead of waiting for every round.
108
- */
109
- onProgress?(progress: {
110
- content: unknown;
111
- round: number;
112
- pending: string[];
113
- }): void;
114
- }
115
- /** `personalizeContent` options as taken by `XeniaClient` / `XeniaServer`, which supply `resolve`. */
116
- type PagePersonalizeOptions = Omit<PersonalizeContentOptions, "resolve"> & Pick<ResolveOptions, "data" | "identity" | "context">;
117
- interface PersonalizeContentResult<T> {
118
- content: T;
119
- applied: AppliedSwap[];
120
- /** False when the budget ran out, a call failed, or `maxRounds` was hit with targets left. */
121
- complete: boolean;
122
- error?: unknown;
123
- }
124
- declare function personalizeContent<T>(payload: T, options: PersonalizeContentOptions): Promise<PersonalizeContentResult<T>>;
125
- /**
126
- * The entries Xenia still has to decide on this page — runtime targets reachable without crossing
127
- * another undecided one. Synchronous and network-free (it reads the `xenia` markers), so a page can
128
- * render a skeleton in exactly those places from the first frame instead of flashing base content.
129
- * Nested targets inside a pending one are found once it is decided.
130
- */
131
- declare function pendingTargets(payload: unknown, adapter: CmsAdapter, contentKey: string): string[];
132
- /**
133
- * Fetch a page through `options.cms` and personalize it — {@link personalizeContent} without the
134
- * fetch in app code. Never throws: a failed fetch comes back as `content: null` with `error`; a page
135
- * that does not exist as `content: null`, `complete: true`. The page fetch is not counted against
136
- * `timeoutMs` — that budget is for personalization only.
137
- */
138
- declare function personalizePage<T>(ref: PageRef, options: PersonalizeContentOptions): Promise<PersonalizeContentResult<T | null>>;
139
-
140
- export { personalizeContent as d, personalizePage as e, pendingTargets as p };
141
- export type { AppliedSwap as A, CmsAdapter as C, EntryResolver as E, PagePersonalizeOptions as P, XeniaMarker as X, PageRef as a, PersonalizeContentOptions as b, PersonalizeContentResult as c };
@@ -1,141 +0,0 @@
1
- import { h as EntrySwapOp, g as EntryQuery, e as EntryDecision, p as ResolveOptions } from './types-DgVHS4Qw.cjs';
2
-
3
- /**
4
- * CMS page personalization — walk a fetched CMS page breadth-first, swap the
5
- * entries Xenia marked as personalized, and do it in as few round trips as
6
- * the page's nesting allows.
7
- *
8
- * Rules (see the "Rounds" section of the feature plan):
9
- * - **Static** targets carry their replacement in the payload (`xeniaVariants`)
10
- * and are swapped inline — no network at all.
11
- * - **Runtime** targets are a barrier: their id is collected, their subtree is
12
- * NOT walked (it may be replaced). One `resolve-entries` call decides every
13
- * target found in a round, one parallel CMS fetch loads every replacement,
14
- * and the next round walks whatever now sits at each position.
15
- * - Never throws: on error or when `timeoutMs` runs out, whatever is not yet
16
- * decided keeps its base content.
17
- *
18
- * CMS specifics live behind {@link CmsAdapter}; built-in adapters ship as
19
- * `@xenia-martech/sdk-js/cms/contentful` (and later `/cms/contentstack`). Any
20
- * other CMS works by implementing the interface.
21
- */
22
-
23
- /** Any value inside a CMS payload — the walker is shape-agnostic; adapters give it meaning. */
24
- type Node = any;
25
- /** The parsed `xenia` marker field of a personalized entry. */
26
- interface XeniaMarker {
27
- kind: "static" | "runtime";
28
- op?: EntrySwapOp;
29
- /** Array field replaced by `op: "items"`. */
30
- field?: string;
31
- limit?: number;
32
- /**
33
- * The content keys (Personalization Resolve identifiers) that personalize this entry. A page only
34
- * acts on markers that list its `contentKey`; a marker without keys is ignored.
35
- */
36
- keys?: string[];
37
- }
38
- /** What the page resolver needs to know about a CMS's entries. `N` is the entry shape. */
39
- interface CmsAdapter<N extends object = Node> {
40
- /** The entry id when `value` is a CMS entry (not a link stub, asset or plain object). */
41
- entryId(value: unknown): string | undefined;
42
- /** The entry's Xenia marker, or null when it is not personalized. */
43
- marker(entry: N): XeniaMarker | null;
44
- /** Static replacements pinned on the entry (its resolved `xeniaVariants`). */
45
- staticVariants(entry: N): N[];
46
- getField(entry: N, field: string): unknown;
47
- setField(entry: N, field: string, value: unknown): void;
48
- /** Legacy `items` without a field: copy the replacement's array fields onto the entry. */
49
- mergeItems?(entry: N, replacement: N): void;
50
- /**
51
- * Remove the marker from an entry that has been dealt with (kept base, or had its items replaced),
52
- * so personalizing the output again — e.g. the browser continuing a server render — never decides
53
- * it twice. Optional; without it a re-run re-asks Xenia about those entries.
54
- */
55
- clearMarker?(entry: N): void;
56
- /** Normalize a fetched payload before walking (e.g. resolve links). Defaults to identity. */
57
- prepare?(payload: unknown): unknown;
58
- /** Load entries by id in ONE call; order does not matter. */
59
- fetchEntries(ids: string[], locale?: string): Promise<N[]>;
60
- /** Run a content-type query in ONE call, in the query's order. */
61
- queryEntries(query: EntryQuery, locale?: string): Promise<N[]>;
62
- /**
63
- * Load one page with its whole tree (links resolved), or null when there is none. Optional; it
64
- * is what lets `personalizePage(ref)` do the fetch, so apps never fetch the page themselves.
65
- */
66
- fetchPage?(ref: PageRef, locale?: string): Promise<N | null>;
67
- }
68
- /** Identifies a page in the CMS: its entry id, or a content type plus exact field values (a slug). */
69
- type PageRef = string | {
70
- contentType: string;
71
- fields: Record<string, string | number | boolean>;
72
- };
73
- /** Resolves a round's runtime targets — `XeniaApi.resolveEntries` bound to the visitor. */
74
- type EntryResolver = (entryIds: string[]) => Promise<EntryDecision[]>;
75
- /** Reported for every swap actually applied (for impressions / analytics). */
76
- interface AppliedSwap {
77
- target: string;
78
- kind: "static" | "runtime";
79
- op: EntrySwapOp;
80
- /** Ids of the entries now at the target's position (or in its field). */
81
- entryIds: string[];
82
- contentKey?: string;
83
- bucket?: string;
84
- round: number;
85
- }
86
- interface PersonalizeContentOptions {
87
- cms: CmsAdapter;
88
- /** Decides runtime targets. Omit to apply static swaps only (zero network). */
89
- resolve?: EntryResolver;
90
- locale?: string;
91
- /**
92
- * The page's Personalization Resolve identifier (required). Only that journey personalizes the
93
- * page: a marker that doesn't list this key is plain content, and the backend decides for this key
94
- * alone — another journey targeting the same section is neither consulted nor run.
95
- */
96
- contentKey: string;
97
- /** Max network rounds (nesting depth of runtime targets). Default 3. */
98
- maxRounds?: number;
99
- /** Total budget for all rounds, in ms. Undecided targets keep their base. Default 300. */
100
- timeoutMs?: number;
101
- /** Mutate the payload in place instead of personalizing a copy. Default false. */
102
- inPlace?: boolean;
103
- onApplied?(swap: AppliedSwap): void;
104
- /**
105
- * Called when a round starts waiting on the network (`pending` = targets being decided) and when
106
- * it has been applied (`pending` empty). `content` is the live, partially personalized tree —
107
- * lets a UI render level by level instead of waiting for every round.
108
- */
109
- onProgress?(progress: {
110
- content: unknown;
111
- round: number;
112
- pending: string[];
113
- }): void;
114
- }
115
- /** `personalizeContent` options as taken by `XeniaClient` / `XeniaServer`, which supply `resolve`. */
116
- type PagePersonalizeOptions = Omit<PersonalizeContentOptions, "resolve"> & Pick<ResolveOptions, "data" | "identity" | "context">;
117
- interface PersonalizeContentResult<T> {
118
- content: T;
119
- applied: AppliedSwap[];
120
- /** False when the budget ran out, a call failed, or `maxRounds` was hit with targets left. */
121
- complete: boolean;
122
- error?: unknown;
123
- }
124
- declare function personalizeContent<T>(payload: T, options: PersonalizeContentOptions): Promise<PersonalizeContentResult<T>>;
125
- /**
126
- * The entries Xenia still has to decide on this page — runtime targets reachable without crossing
127
- * another undecided one. Synchronous and network-free (it reads the `xenia` markers), so a page can
128
- * render a skeleton in exactly those places from the first frame instead of flashing base content.
129
- * Nested targets inside a pending one are found once it is decided.
130
- */
131
- declare function pendingTargets(payload: unknown, adapter: CmsAdapter, contentKey: string): string[];
132
- /**
133
- * Fetch a page through `options.cms` and personalize it — {@link personalizeContent} without the
134
- * fetch in app code. Never throws: a failed fetch comes back as `content: null` with `error`; a page
135
- * that does not exist as `content: null`, `complete: true`. The page fetch is not counted against
136
- * `timeoutMs` — that budget is for personalization only.
137
- */
138
- declare function personalizePage<T>(ref: PageRef, options: PersonalizeContentOptions): Promise<PersonalizeContentResult<T | null>>;
139
-
140
- export { personalizeContent as d, personalizePage as e, pendingTargets as p };
141
- export type { AppliedSwap as A, CmsAdapter as C, EntryResolver as E, PagePersonalizeOptions as P, XeniaMarker as X, PageRef as a, PersonalizeContentOptions as b, PersonalizeContentResult as c };