@revturbine/sdk 0.2.68 → 0.2.69
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/dist/headless.js +1 -1
- package/dist/headless.js.map +1 -1
- package/dist/index.d.ts +30 -7
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/web-sdk/react/useCan.d.ts +24 -7
- package/dist/types/web-sdk/react/useCan.d.ts.map +1 -1
- package/dist/types/web-sdk/react/useEntitlement.d.ts +6 -0
- package/dist/types/web-sdk/react/useEntitlement.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -7,9 +7,13 @@ export interface UseCanResult {
|
|
|
7
7
|
/**
|
|
8
8
|
* `true` when the user may proceed. This is `allowed || limited` (equivalently,
|
|
9
9
|
* not `denied`): a `limited` entitlement still grants access — it just means the
|
|
10
|
-
* usage/credit balance is running low.
|
|
11
|
-
* `
|
|
12
|
-
*
|
|
10
|
+
* usage/credit balance is running low. Deny-until-ready, matching the SDK's
|
|
11
|
+
* fail-closed contract: `can` is `false` until the check resolves, and stays
|
|
12
|
+
* `false` if the check errors. Evaluation is local to the loaded Playbook (no
|
|
13
|
+
* per-check network call), so the unresolved window is one microtask once
|
|
14
|
+
* initialization completes; in hosted mode the first load spans the initial
|
|
15
|
+
* config fetch. Gate paywall UI on `!can && !isLoading` so entitled users never
|
|
16
|
+
* see an upsell flash; never gate on `!allowed` (that would also block
|
|
13
17
|
* `limited` users who are still entitled).
|
|
14
18
|
*/
|
|
15
19
|
can: boolean;
|
|
@@ -18,6 +22,14 @@ export interface UseCanResult {
|
|
|
18
22
|
* "running low" state). Surface a soft warning while still allowing the action.
|
|
19
23
|
*/
|
|
20
24
|
limited: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* `true` until the entitlement check first resolves (including while the SDK
|
|
27
|
+
* initializes), and again while a recheck is in flight. Settles to `false`
|
|
28
|
+
* once a result — or an error — has landed. Pair with `can`:
|
|
29
|
+
* `!can && isLoading` is "still deciding"; `!can && !isLoading` is a settled
|
|
30
|
+
* deny.
|
|
31
|
+
*/
|
|
32
|
+
isLoading: boolean;
|
|
21
33
|
/**
|
|
22
34
|
* The full entitlement result (`status`, `reason`, `current_tier`, `placement`,
|
|
23
35
|
* …), or `null` until the check resolves — the escape hatch for details beyond
|
|
@@ -29,16 +41,21 @@ export interface UseCanResult {
|
|
|
29
41
|
* Reactive counterpart to the imperative `rt.can(handle)` — the entitlement check
|
|
30
42
|
* as a `can` question. Takes the entitlement handle positionally (matching
|
|
31
43
|
* `rt.can('handle')`), plus the same options {@link useEntitlement} accepts, and
|
|
32
|
-
* returns a curated `{ can, limited, result }`.
|
|
44
|
+
* returns a curated `{ can, limited, isLoading, result }`.
|
|
45
|
+
*
|
|
46
|
+
* Deny-until-ready: `can` is `false` while the check is unresolved, flipping
|
|
47
|
+
* within one microtask in local mode once the Playbook is in memory. Use
|
|
48
|
+
* `isLoading` to distinguish "still deciding" from a settled deny.
|
|
33
49
|
*
|
|
34
|
-
* For the full reactive surface (`allowed` / `denied` / `
|
|
50
|
+
* For the full reactive surface (`allowed` / `denied` / `error` /
|
|
35
51
|
* `gatedPlacement` / `recheck`), use {@link useEntitlement} directly.
|
|
36
52
|
*
|
|
37
53
|
* @example
|
|
38
54
|
* ```tsx
|
|
39
55
|
* function BatchExport() {
|
|
40
|
-
* const { can, limited } = useCan('batch_export');
|
|
41
|
-
* if (!can) return
|
|
56
|
+
* const { can, limited, isLoading } = useCan('batch_export');
|
|
57
|
+
* if (!can && isLoading) return null; // still deciding — render nothing yet
|
|
58
|
+
* if (!can) return <UpgradePrompt />; // settled deny
|
|
42
59
|
* return <BatchExportButton warnLowBalance={limited} />;
|
|
43
60
|
* }
|
|
44
61
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCan.d.ts","sourceRoot":"","sources":["../../../../react/useCan.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEzG;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B
|
|
1
|
+
{"version":3,"file":"useCan.d.ts","sourceRoot":"","sources":["../../../../react/useCan.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEzG;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;;;OAWG;IACH,GAAG,EAAE,OAAO,CAAC;IACb;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,MAAM,CACpB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAC,GAC9C,YAAY,CASd"}
|
|
@@ -40,6 +40,12 @@ export interface UseEntitlementResult {
|
|
|
40
40
|
*
|
|
41
41
|
* Returns a reactive entitlement result that can drive access-gate UI.
|
|
42
42
|
*
|
|
43
|
+
* Until the first check resolves, `allowed` and `denied` are both `false` and
|
|
44
|
+
* `result` is `null` — the three-state model. Consumers decide from the triple
|
|
45
|
+
* (`isLoading` / `allowed` / `denied`), never from `denied` alone; the SDK is
|
|
46
|
+
* fail-closed, so "not yet allowed" is the default. Evaluation is local to the
|
|
47
|
+
* loaded Playbook — there is no per-check network call.
|
|
48
|
+
*
|
|
43
49
|
* @example
|
|
44
50
|
* ```tsx
|
|
45
51
|
* function BrandKitSection() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEntitlement.d.ts","sourceRoot":"","sources":["../../../../react/useEntitlement.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,4BAA4B,EAC5B,gCAAgC,EACjC,MAAM,kBAAkB,CAAC;AAM1B,MAAM,WAAW,qBAAqB;IACpC,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,OAAO,CAAC,EAAE,4BAA4B,CAAC;IACvC,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,IAAI,CAAC,gCAAgC,EAAE,mBAAmB,CAAC,CAAC;CACpF;AAED,MAAM,WAAW,oBAAoB;IACnC,oDAAoD;IACpD,SAAS,EAAE,OAAO,CAAC;IACnB,yCAAyC;IACzC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,kEAAkE;IAClE,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,2DAA2D;IAC3D,OAAO,EAAE,OAAO,CAAC;IACjB,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAC;IACjB,0DAA0D;IAC1D,MAAM,EAAE,OAAO,CAAC;IAChB,wEAAwE;IACxE,cAAc,EAAE,eAAe,GAAG,IAAI,CAAC;IACvC,oCAAoC;IACpC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAMD
|
|
1
|
+
{"version":3,"file":"useEntitlement.d.ts","sourceRoot":"","sources":["../../../../react/useEntitlement.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,4BAA4B,EAC5B,gCAAgC,EACjC,MAAM,kBAAkB,CAAC;AAM1B,MAAM,WAAW,qBAAqB;IACpC,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,OAAO,CAAC,EAAE,4BAA4B,CAAC;IACvC,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,IAAI,CAAC,gCAAgC,EAAE,mBAAmB,CAAC,CAAC;CACpF;AAED,MAAM,WAAW,oBAAoB;IACnC,oDAAoD;IACpD,SAAS,EAAE,OAAO,CAAC;IACnB,yCAAyC;IACzC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,kEAAkE;IAClE,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,2DAA2D;IAC3D,OAAO,EAAE,OAAO,CAAC;IACjB,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAC;IACjB,0DAA0D;IAC1D,MAAM,EAAE,OAAO,CAAC;IAChB,wEAAwE;IACxE,cAAc,EAAE,eAAe,GAAG,IAAI,CAAC;IACvC,oCAAoC;IACpC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,OAAO,EACP,SAAgB,EAChB,QAAgB,EAChB,oBAAoB,GACrB,EAAE,qBAAqB,GAAG,oBAAoB,CAqD9C"}
|
package/package.json
CHANGED