@revturbine/sdk 0.2.83 → 0.2.85

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.
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @module @revt-eng/web-sdk/views
3
+ *
4
+ * The decision shapes a caller reads, independent of *how* the decision was
5
+ * obtained (plan 186 TASK-1).
6
+ *
7
+ * A React hook resolves a decision over time, so its result carries lifecycle
8
+ * fields — `isLoading`, `error`, a re-run callback. A server-rendered caller
9
+ * awaits the decision, so it has none of those: by the time it holds a value,
10
+ * the value is final. What both share is the decision itself, and that shared
11
+ * part lives here.
12
+ *
13
+ * This module deliberately contains **types only and no runtime imports**, and
14
+ * deliberately sits outside `react/`. Every module under `react/` opens with
15
+ * `'use client'`, so a React Server Component importing one receives an opaque
16
+ * client reference rather than a usable value — the server binding could not
17
+ * reuse these shapes if they stayed there.
18
+ *
19
+ * Plan: docs/dev-lifecycle/inprogress/186-server-rendering-sdk-and-api-token-management.md
20
+ */
21
+ import type { EntitlementResult, PlacementOutput, RevTurbinePlacementContent, RevTurbinePlacementDecision } from './customer-side';
22
+ /**
23
+ * A resolved entitlement decision.
24
+ *
25
+ * The three booleans are conveniences over {@link EntitlementView.result} and
26
+ * are mutually exclusive once resolved. Note that `allowed` and `limited` are
27
+ * not opposites: a `limited` result still grants access when the evaluator
28
+ * permits it, so gate paywall UI on `denied`, never on `!allowed`.
29
+ *
30
+ * Callers that need to distinguish "denied" from "not yet decided" want the
31
+ * client-side {@link UseEntitlementResult}, whose `isLoading` carries that
32
+ * distinction. On the server the question does not arise — the value is awaited,
33
+ * so it is always decided.
34
+ */
35
+ export interface EntitlementView {
36
+ /** The full entitlement result from the evaluator. `null` until resolved. */
37
+ result: EntitlementResult | null;
38
+ /** `true` when the entitlement is allowed outright. */
39
+ allowed: boolean;
40
+ /** `true` when access is granted but the balance is approaching its limit. */
41
+ limited: boolean;
42
+ /** `true` when the entitlement is denied. */
43
+ denied: boolean;
44
+ /** The upgrade surface to render on denial, when one was resolved. */
45
+ gatedPlacement: PlacementOutput | null;
46
+ }
47
+ /**
48
+ * A resolved placement decision.
49
+ *
50
+ * Carries what to render and whether to render it — not how to interact with
51
+ * it. Interaction callbacks (`dismiss`, `ctaClick`, …) and viewport-exposure
52
+ * wiring are inherently client-side and live on
53
+ * {@link UsePlacementResult} instead.
54
+ */
55
+ export interface PlacementView {
56
+ /** The resolved placement identifier. */
57
+ placementId: string;
58
+ /** Whether the placement should be rendered. */
59
+ visible: boolean;
60
+ /** The full decision from the engine. `null` until resolved. */
61
+ decision: RevTurbinePlacementDecision | null;
62
+ /** Resolved content with personalization tokens expanded. `null` until resolved. */
63
+ content: RevTurbinePlacementContent['content'] | null;
64
+ }
65
+ //# sourceMappingURL=views.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.d.ts","sourceRoot":"","sources":["../../../views.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,uDAAuD;IACvD,OAAO,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,OAAO,EAAE,OAAO,CAAC;IACjB,6CAA6C;IAC7C,MAAM,EAAE,OAAO,CAAC;IAChB,sEAAsE;IACtE,cAAc,EAAE,eAAe,GAAG,IAAI,CAAC;CACxC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,gEAAgE;IAChE,QAAQ,EAAE,2BAA2B,GAAG,IAAI,CAAC;IAC7C,oFAAoF;IACpF,OAAO,EAAE,0BAA0B,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;CACvD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revturbine/sdk",
3
- "version": "0.2.83",
3
+ "version": "0.2.85",
4
4
  "description": "RevTurbine customer-facing SDK — placement decisioning, entitlement checks, and usage tracking.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.12.0",
@@ -16,6 +16,10 @@
16
16
  "import": "./dist/headless.js",
17
17
  "types": "./dist/headless.d.ts"
18
18
  },
19
+ "./server": {
20
+ "import": "./dist/server.js",
21
+ "types": "./dist/server.d.ts"
22
+ },
19
23
  "./source": "./index.ts",
20
24
  "./source/headless": "./headless.ts"
21
25
  },