@sentientui/react 0.41.1 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/react",
3
- "version": "0.41.1",
3
+ "version": "0.42.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -78,7 +78,7 @@
78
78
  "llms.txt"
79
79
  ],
80
80
  "dependencies": {
81
- "@sentientui/core": "0.40.1",
81
+ "@sentientui/core": "0.40.2",
82
82
  "@sentientui/policy": "0.16.0"
83
83
  },
84
84
  "peerDependencies": {
package/dist/server.d.cts DELETED
@@ -1,116 +0,0 @@
1
- import * as _sentientui_core from '@sentientui/core';
2
- import * as _sentientui_core_server from '@sentientui/core/server';
3
- import { ServerAssignments } from '@sentientui/core/server';
4
- export { DecideResult, ServerAssignConfig, ServerAssignments, SlotDeclInput, SlotResult, preloadAssignments, preloadDecisions, readSessionCookie, signUserId, trackServerGoal } from '@sentientui/core/server';
5
-
6
- /** Return value of `loadAdaptiveAssignments` — includes the session ID used for SSR. */
7
- type LoadAdaptiveAssignmentsResult = {
8
- assignments: ServerAssignments;
9
- /** The session ID used for SSR assignment. Pass as `ssrSessionId` to `<AdaptiveProvider>`. */
10
- sessionId: string;
11
- /** Components the operator moved onto the shared track: not in
12
- * `assignments`. Pass as `initialUnified` to `<AdaptiveProvider>`. */
13
- unified: string[];
14
- };
15
- type LoadAdaptiveAssignmentsOptions = {
16
- /** Next.js `cookies()` return value, or any object with `get(name)`. */
17
- cookies: {
18
- get(name: string): {
19
- value: string;
20
- } | undefined;
21
- };
22
- apiKey: string;
23
- baseUrl: string;
24
- /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */
25
- createSessionId?: () => string;
26
- /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */
27
- origin?: string;
28
- /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */
29
- userAgent?: string;
30
- /** From Next.js `headers().get('referer')`. */
31
- referer?: string;
32
- /**
33
- * `utm_*` params from the landing URL. The Referer header never carries the
34
- * page's OWN query string, so without this the SSR-minted session has no
35
- * campaign attribution until the client SDK hydrates and re-upserts.
36
- * Derive with `extractTrackedParams(searchParams)` from `@sentientui/core/server`.
37
- */
38
- utmParams?: Record<string, string>;
39
- /** Ad-platform click IDs (gclid, fbclid, ttclid, …) from the landing URL — same derivation as `utmParams`. */
40
- clickIds?: Record<string, string>;
41
- /** The landing page's path (no query string) — recognises a paid click to a product page or a `/discount/` link on the first decision. */
42
- landingPath?: string;
43
- /** Set true when the request carries `DNT: 1` or `Sec-GPC: 1` — skips the SSR session upsert + assignment so no session is minted for an opted-out visitor (audit P4). `AdaptiveRoot` sets this automatically from the request headers. */
44
- doNotTrack?: boolean;
45
- /** Milliseconds to wait for the API before returning default variants. Defaults to 1000 (typical decide is well under 150 ms; the full budget is only reached on a cold start or a distant API). */
46
- timeoutMs?: number;
47
- /**
48
- * Declared persona — the role your app already knows for this visitor (e.g.
49
- * from your auth context: 'admin', 'evaluator'). Must be a key in the
50
- * project's persona vocabulary; unrecognized values are ignored server-side.
51
- * Never a user id or email.
52
- */
53
- persona?: string;
54
- };
55
- /**
56
- * Fetches bandit assignments on the server for SEO-safe HTML.
57
- * Pass `assignments` as `initialAssignments` and `sessionId` as `ssrSessionId`
58
- * on `<AdaptiveProvider>` so the client adopts the same session on first visit.
59
- */
60
- declare function loadAdaptiveAssignments(components: Array<{
61
- id: string;
62
- variantIds: string[];
63
- }>, options: LoadAdaptiveAssignmentsOptions): Promise<LoadAdaptiveAssignmentsResult>;
64
-
65
- /** Return value of `loadAdaptiveDecision` — includes the session ID used for SSR. */
66
- type LoadAdaptiveDecisionResult = _sentientui_core_server.DecideResult & {
67
- sessionId: string;
68
- };
69
- type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {
70
- /**
71
- * Section IDs in default order. Passed to /v1/decide as the candidate
72
- * layout. Optional since 0.13.0 — slot-only pages may omit it (at least
73
- * one of `sections`/`components`/`slots` must be non-empty).
74
- */
75
- sections?: string[];
76
- /** Components to assign in the same decide call. */
77
- components?: Array<{
78
- id: string;
79
- variantIds?: string[];
80
- }>;
81
- /** Adaptive-slot declarations (useAdaptiveTokens / AdaptiveGroup) to decide server-side. */
82
- slots?: _sentientui_core_server.SlotDeclInput[];
83
- /** 'registry' serves the project's published slot definitions (`<Adaptive id>`)
84
- * and is the only way `slotConfig`/`palette` come back. Default 'request'.
85
- * Requires `registrySlotIds`. */
86
- slotsFrom?: 'request' | 'registry';
87
- /**
88
- * Registry mode: the `<Adaptive id>`s THIS page renders — the decide is
89
- * scoped to exactly these. Required with `slotsFrom: 'registry'`; without it
90
- * the call downgrades to request mode (with a console.error) instead of
91
- * recording a close-out trial for every published slot on every page.
92
- */
93
- registrySlotIds?: string[];
94
- /**
95
- * Registry mode: what each slot on this page can render, keyed by slot id
96
- * (see `preloadDecisions`). Ids without an entry get core's default caps.
97
- * A hybrid `<Adaptive variants>{children}</Adaptive>` needs its entry: the
98
- * server draws `authored.<key>` only for keys the page declares here.
99
- */
100
- renderCaps?: Record<string, Omit<_sentientui_core.RenderCaps, 'fp'>>;
101
- };
102
- /**
103
- * SSR helper for pages with a declared section layout and/or adaptive slots.
104
- * Calls `/v1/decide` instead of multiple `/v1/assign` round trips.
105
- * Pass `sessionId` as `ssrSessionId` on `<AdaptiveProvider>` so the client
106
- * adopts the same session on first visit.
107
- *
108
- * Keyless: with no valid `pk_` key this never fetches (no timeout burn).
109
- * Under the `development` export condition the decision is computed by the
110
- * deterministic local engine with the same sessionId the client will adopt —
111
- * server and client agree by construction. In production the engine resolves
112
- * to a stub and defaults are returned with one console.error.
113
- */
114
- declare function loadAdaptiveDecision(options: LoadAdaptiveDecisionOptions): Promise<LoadAdaptiveDecisionResult>;
115
-
116
- export { type LoadAdaptiveAssignmentsOptions, type LoadAdaptiveAssignmentsResult, type LoadAdaptiveDecisionOptions, type LoadAdaptiveDecisionResult, loadAdaptiveAssignments, loadAdaptiveDecision };
package/dist/server.d.ts DELETED
@@ -1,116 +0,0 @@
1
- import * as _sentientui_core from '@sentientui/core';
2
- import * as _sentientui_core_server from '@sentientui/core/server';
3
- import { ServerAssignments } from '@sentientui/core/server';
4
- export { DecideResult, ServerAssignConfig, ServerAssignments, SlotDeclInput, SlotResult, preloadAssignments, preloadDecisions, readSessionCookie, signUserId, trackServerGoal } from '@sentientui/core/server';
5
-
6
- /** Return value of `loadAdaptiveAssignments` — includes the session ID used for SSR. */
7
- type LoadAdaptiveAssignmentsResult = {
8
- assignments: ServerAssignments;
9
- /** The session ID used for SSR assignment. Pass as `ssrSessionId` to `<AdaptiveProvider>`. */
10
- sessionId: string;
11
- /** Components the operator moved onto the shared track: not in
12
- * `assignments`. Pass as `initialUnified` to `<AdaptiveProvider>`. */
13
- unified: string[];
14
- };
15
- type LoadAdaptiveAssignmentsOptions = {
16
- /** Next.js `cookies()` return value, or any object with `get(name)`. */
17
- cookies: {
18
- get(name: string): {
19
- value: string;
20
- } | undefined;
21
- };
22
- apiKey: string;
23
- baseUrl: string;
24
- /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */
25
- createSessionId?: () => string;
26
- /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */
27
- origin?: string;
28
- /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */
29
- userAgent?: string;
30
- /** From Next.js `headers().get('referer')`. */
31
- referer?: string;
32
- /**
33
- * `utm_*` params from the landing URL. The Referer header never carries the
34
- * page's OWN query string, so without this the SSR-minted session has no
35
- * campaign attribution until the client SDK hydrates and re-upserts.
36
- * Derive with `extractTrackedParams(searchParams)` from `@sentientui/core/server`.
37
- */
38
- utmParams?: Record<string, string>;
39
- /** Ad-platform click IDs (gclid, fbclid, ttclid, …) from the landing URL — same derivation as `utmParams`. */
40
- clickIds?: Record<string, string>;
41
- /** The landing page's path (no query string) — recognises a paid click to a product page or a `/discount/` link on the first decision. */
42
- landingPath?: string;
43
- /** Set true when the request carries `DNT: 1` or `Sec-GPC: 1` — skips the SSR session upsert + assignment so no session is minted for an opted-out visitor (audit P4). `AdaptiveRoot` sets this automatically from the request headers. */
44
- doNotTrack?: boolean;
45
- /** Milliseconds to wait for the API before returning default variants. Defaults to 1000 (typical decide is well under 150 ms; the full budget is only reached on a cold start or a distant API). */
46
- timeoutMs?: number;
47
- /**
48
- * Declared persona — the role your app already knows for this visitor (e.g.
49
- * from your auth context: 'admin', 'evaluator'). Must be a key in the
50
- * project's persona vocabulary; unrecognized values are ignored server-side.
51
- * Never a user id or email.
52
- */
53
- persona?: string;
54
- };
55
- /**
56
- * Fetches bandit assignments on the server for SEO-safe HTML.
57
- * Pass `assignments` as `initialAssignments` and `sessionId` as `ssrSessionId`
58
- * on `<AdaptiveProvider>` so the client adopts the same session on first visit.
59
- */
60
- declare function loadAdaptiveAssignments(components: Array<{
61
- id: string;
62
- variantIds: string[];
63
- }>, options: LoadAdaptiveAssignmentsOptions): Promise<LoadAdaptiveAssignmentsResult>;
64
-
65
- /** Return value of `loadAdaptiveDecision` — includes the session ID used for SSR. */
66
- type LoadAdaptiveDecisionResult = _sentientui_core_server.DecideResult & {
67
- sessionId: string;
68
- };
69
- type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {
70
- /**
71
- * Section IDs in default order. Passed to /v1/decide as the candidate
72
- * layout. Optional since 0.13.0 — slot-only pages may omit it (at least
73
- * one of `sections`/`components`/`slots` must be non-empty).
74
- */
75
- sections?: string[];
76
- /** Components to assign in the same decide call. */
77
- components?: Array<{
78
- id: string;
79
- variantIds?: string[];
80
- }>;
81
- /** Adaptive-slot declarations (useAdaptiveTokens / AdaptiveGroup) to decide server-side. */
82
- slots?: _sentientui_core_server.SlotDeclInput[];
83
- /** 'registry' serves the project's published slot definitions (`<Adaptive id>`)
84
- * and is the only way `slotConfig`/`palette` come back. Default 'request'.
85
- * Requires `registrySlotIds`. */
86
- slotsFrom?: 'request' | 'registry';
87
- /**
88
- * Registry mode: the `<Adaptive id>`s THIS page renders — the decide is
89
- * scoped to exactly these. Required with `slotsFrom: 'registry'`; without it
90
- * the call downgrades to request mode (with a console.error) instead of
91
- * recording a close-out trial for every published slot on every page.
92
- */
93
- registrySlotIds?: string[];
94
- /**
95
- * Registry mode: what each slot on this page can render, keyed by slot id
96
- * (see `preloadDecisions`). Ids without an entry get core's default caps.
97
- * A hybrid `<Adaptive variants>{children}</Adaptive>` needs its entry: the
98
- * server draws `authored.<key>` only for keys the page declares here.
99
- */
100
- renderCaps?: Record<string, Omit<_sentientui_core.RenderCaps, 'fp'>>;
101
- };
102
- /**
103
- * SSR helper for pages with a declared section layout and/or adaptive slots.
104
- * Calls `/v1/decide` instead of multiple `/v1/assign` round trips.
105
- * Pass `sessionId` as `ssrSessionId` on `<AdaptiveProvider>` so the client
106
- * adopts the same session on first visit.
107
- *
108
- * Keyless: with no valid `pk_` key this never fetches (no timeout burn).
109
- * Under the `development` export condition the decision is computed by the
110
- * deterministic local engine with the same sessionId the client will adopt —
111
- * server and client agree by construction. In production the engine resolves
112
- * to a stub and defaults are returned with one console.error.
113
- */
114
- declare function loadAdaptiveDecision(options: LoadAdaptiveDecisionOptions): Promise<LoadAdaptiveDecisionResult>;
115
-
116
- export { type LoadAdaptiveAssignmentsOptions, type LoadAdaptiveAssignmentsResult, type LoadAdaptiveDecisionOptions, type LoadAdaptiveDecisionResult, loadAdaptiveAssignments, loadAdaptiveDecision };