@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
package/dist/index.d.ts
CHANGED
|
@@ -22465,6 +22465,12 @@ interface UseEntitlementResult {
|
|
|
22465
22465
|
*
|
|
22466
22466
|
* Returns a reactive entitlement result that can drive access-gate UI.
|
|
22467
22467
|
*
|
|
22468
|
+
* Until the first check resolves, `allowed` and `denied` are both `false` and
|
|
22469
|
+
* `result` is `null` — the three-state model. Consumers decide from the triple
|
|
22470
|
+
* (`isLoading` / `allowed` / `denied`), never from `denied` alone; the SDK is
|
|
22471
|
+
* fail-closed, so "not yet allowed" is the default. Evaluation is local to the
|
|
22472
|
+
* loaded Playbook — there is no per-check network call.
|
|
22473
|
+
*
|
|
22468
22474
|
* @example
|
|
22469
22475
|
* ```tsx
|
|
22470
22476
|
* function BrandKitSection() {
|
|
@@ -22716,9 +22722,13 @@ interface UseCanResult {
|
|
|
22716
22722
|
/**
|
|
22717
22723
|
* `true` when the user may proceed. This is `allowed || limited` (equivalently,
|
|
22718
22724
|
* not `denied`): a `limited` entitlement still grants access — it just means the
|
|
22719
|
-
* usage/credit balance is running low.
|
|
22720
|
-
* `
|
|
22721
|
-
*
|
|
22725
|
+
* usage/credit balance is running low. Deny-until-ready, matching the SDK's
|
|
22726
|
+
* fail-closed contract: `can` is `false` until the check resolves, and stays
|
|
22727
|
+
* `false` if the check errors. Evaluation is local to the loaded Playbook (no
|
|
22728
|
+
* per-check network call), so the unresolved window is one microtask once
|
|
22729
|
+
* initialization completes; in hosted mode the first load spans the initial
|
|
22730
|
+
* config fetch. Gate paywall UI on `!can && !isLoading` so entitled users never
|
|
22731
|
+
* see an upsell flash; never gate on `!allowed` (that would also block
|
|
22722
22732
|
* `limited` users who are still entitled).
|
|
22723
22733
|
*/
|
|
22724
22734
|
can: boolean;
|
|
@@ -22727,6 +22737,14 @@ interface UseCanResult {
|
|
|
22727
22737
|
* "running low" state). Surface a soft warning while still allowing the action.
|
|
22728
22738
|
*/
|
|
22729
22739
|
limited: boolean;
|
|
22740
|
+
/**
|
|
22741
|
+
* `true` until the entitlement check first resolves (including while the SDK
|
|
22742
|
+
* initializes), and again while a recheck is in flight. Settles to `false`
|
|
22743
|
+
* once a result — or an error — has landed. Pair with `can`:
|
|
22744
|
+
* `!can && isLoading` is "still deciding"; `!can && !isLoading` is a settled
|
|
22745
|
+
* deny.
|
|
22746
|
+
*/
|
|
22747
|
+
isLoading: boolean;
|
|
22730
22748
|
/**
|
|
22731
22749
|
* The full entitlement result (`status`, `reason`, `current_tier`, `placement`,
|
|
22732
22750
|
* …), or `null` until the check resolves — the escape hatch for details beyond
|
|
@@ -22738,16 +22756,21 @@ interface UseCanResult {
|
|
|
22738
22756
|
* Reactive counterpart to the imperative `rt.can(handle)` — the entitlement check
|
|
22739
22757
|
* as a `can` question. Takes the entitlement handle positionally (matching
|
|
22740
22758
|
* `rt.can('handle')`), plus the same options {@link useEntitlement} accepts, and
|
|
22741
|
-
* returns a curated `{ can, limited, result }`.
|
|
22759
|
+
* returns a curated `{ can, limited, isLoading, result }`.
|
|
22760
|
+
*
|
|
22761
|
+
* Deny-until-ready: `can` is `false` while the check is unresolved, flipping
|
|
22762
|
+
* within one microtask in local mode once the Playbook is in memory. Use
|
|
22763
|
+
* `isLoading` to distinguish "still deciding" from a settled deny.
|
|
22742
22764
|
*
|
|
22743
|
-
* For the full reactive surface (`allowed` / `denied` / `
|
|
22765
|
+
* For the full reactive surface (`allowed` / `denied` / `error` /
|
|
22744
22766
|
* `gatedPlacement` / `recheck`), use {@link useEntitlement} directly.
|
|
22745
22767
|
*
|
|
22746
22768
|
* @example
|
|
22747
22769
|
* ```tsx
|
|
22748
22770
|
* function BatchExport() {
|
|
22749
|
-
* const { can, limited } = useCan('batch_export');
|
|
22750
|
-
* if (!can) return
|
|
22771
|
+
* const { can, limited, isLoading } = useCan('batch_export');
|
|
22772
|
+
* if (!can && isLoading) return null; // still deciding — render nothing yet
|
|
22773
|
+
* if (!can) return <UpgradePrompt />; // settled deny
|
|
22751
22774
|
* return <BatchExportButton warnLowBalance={limited} />;
|
|
22752
22775
|
* }
|
|
22753
22776
|
* ```
|