@revturbine/sdk 0.2.22 → 0.2.23
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.
|
@@ -1,22 +1,47 @@
|
|
|
1
1
|
import { type UseEntitlementOptions, type UseEntitlementResult } from './useEntitlement';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Result of {@link useCan} — the entitlement check reduced to the shape a `can`
|
|
4
|
+
* question actually needs.
|
|
5
|
+
*/
|
|
6
|
+
export interface UseCanResult {
|
|
7
|
+
/**
|
|
8
|
+
* `true` when the user may proceed. This is `allowed || limited` (equivalently,
|
|
9
|
+
* not `denied`): a `limited` entitlement still grants access — it just means the
|
|
10
|
+
* usage/credit balance is running low. Fail-open, matching the SDK: `can` is also
|
|
11
|
+
* `true` before the check resolves and if the entitlement service is unreachable.
|
|
12
|
+
* Gate on `!can` to block; never gate on `!allowed` (that would also block
|
|
13
|
+
* `limited` users who are still entitled).
|
|
14
|
+
*/
|
|
15
|
+
can: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* `true` when access is granted but the balance is approaching its limit (the
|
|
18
|
+
* "running low" state). Surface a soft warning while still allowing the action.
|
|
19
|
+
*/
|
|
20
|
+
limited: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The full entitlement result (`status`, `reason`, `current_tier`, `placement`,
|
|
23
|
+
* …), or `null` until the check resolves — the escape hatch for details beyond
|
|
24
|
+
* `can` / `limited`.
|
|
25
|
+
*/
|
|
26
|
+
result: UseEntitlementResult['result'];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Reactive counterpart to the imperative `rt.can(handle)` — the entitlement check
|
|
30
|
+
* as a `can` question. Takes the entitlement handle positionally (matching
|
|
5
31
|
* `rt.can('handle')`), plus the same options {@link useEntitlement} accepts, and
|
|
6
|
-
* returns
|
|
7
|
-
* `result` / `recheck` / …).
|
|
32
|
+
* returns a curated `{ can, limited, result }`.
|
|
8
33
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
34
|
+
* For the full reactive surface (`allowed` / `denied` / `isLoading` / `error` /
|
|
35
|
+
* `gatedPlacement` / `recheck`), use {@link useEntitlement} directly.
|
|
11
36
|
*
|
|
12
37
|
* @example
|
|
13
38
|
* ```tsx
|
|
14
|
-
* function
|
|
15
|
-
* const {
|
|
16
|
-
* if (
|
|
17
|
-
* return <
|
|
39
|
+
* function BatchExport() {
|
|
40
|
+
* const { can, limited } = useCan('batch_export');
|
|
41
|
+
* if (!can) return <UpgradePrompt />;
|
|
42
|
+
* return <BatchExportButton warnLowBalance={limited} />;
|
|
18
43
|
* }
|
|
19
44
|
* ```
|
|
20
45
|
*/
|
|
21
|
-
export declare function useCan(handle: string, options?: Omit<UseEntitlementOptions, 'handle'>):
|
|
46
|
+
export declare function useCan(handle: string, options?: Omit<UseEntitlementOptions, 'handle'>): UseCanResult;
|
|
22
47
|
//# sourceMappingURL=useCan.d.ts.map
|
|
@@ -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
|
|
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;;;;;;;OAOG;IACH,GAAG,EAAE,OAAO,CAAC;IACb;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CACpB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAC,GAC9C,YAAY,CAGd"}
|