@kelviq/react-sdk 0.0.1-beta → 2.0.0-beta

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/README.md CHANGED
@@ -1,377 +1,31 @@
1
+ # @kelviq/react-sdk
1
2
 
2
- The `@kelviq/react-sdk` provides a seamless way to integrate Kelviq entitlement management into your React applications.
3
+ React SDK for integrating Kelviq entitlement management into your applications. Provides a context provider, hooks, and conditional rendering components to control feature access based on customer entitlements.
3
4
 
4
- ## Overview
5
+ ## Installation
5
6
 
6
- - A **React Context Provider** (`KelviqProvider`) to initialize and configure the SDK.
7
- - **Hooks** to easily access entitlement status and data within your components.
8
- - **Conditional rendering components** to show or hide UI elements based on feature access.
9
- - Automatic and manual **data fetching** and caching mechanisms.
10
-
11
- The SDK fetches all entitlements for a given organization and customer, caches them, and makes them available throughout your application via React Context and custom hooks.
12
-
13
- ## **2. Installation**
14
-
15
- Install the SDK using npm or yarn:
16
-
17
- ``` bash
7
+ ```bash
18
8
  npm install @kelviq/react-sdk
19
- # or
20
- yarn add @kelviq/react-sdk
21
-
22
9
  ```
23
10
 
24
- You will also need `react` as a peer dependency.
25
-
26
- ## **3. Setup & Configuration**
27
-
28
- ### `KelviqProvider`
29
-
30
- The core of the SDK is the `KelviqProvider`. You need to wrap your application (or the relevant part of it) with this provider. It initializes the SDK and makes entitlement data available to its children components via context.
31
-
32
- ``` tsx
33
- // In your App.tsx or main application entry point
34
- import React from 'react';
35
- import { KelviqProvider, PDPaywall } from '@kelviq/react-sdk';
36
-
37
- const App = () => {
38
- return (
39
- <KelviqProvider
40
- customerId="your-customer-id"
41
- accessToken="your-access-token"
42
- >
43
- <MyAppContent />
44
- </KelviqProvider>
45
- );
46
- };
47
-
48
- const MyAppContent = () => {
49
-
50
- return (
51
- <PDPaywall offeringId="your-offering-id">
52
- <div>My Application</div>
53
- </PDPaywall>
54
- );
55
-
56
- };
11
+ ## Quick Start
57
12
 
58
- export default App;
13
+ ```tsx
14
+ import { KelviqProvider, ShowWhenBooleanEntitled } from '@kelviq/react-sdk';
59
15
 
16
+ const App = () => (
17
+ <KelviqProvider customerId="your-customer-id" accessToken="your-access-token">
18
+ <ShowWhenBooleanEntitled featureKey="premium-feature">
19
+ <PremiumContent />
20
+ </ShowWhenBooleanEntitled>
21
+ </KelviqProvider>
22
+ );
60
23
  ```
61
24
 
62
- ### Required Props for `KelviqProvider`
63
-
64
- - `customerId: string`
65
- - The ID of the customer for whom entitlements are being fetched. This will be sent as a query parameter (`customer_id`).
66
- - `accessToken: string | null`
67
- - Your static API token or Bearer token for authenticating requests to the Kelviq API. If provided, it will be included in the `Authorization: Bearer <accessToken>` header.
68
-
69
- ### Optional Props for `KelviqProvider`
70
-
71
-
72
- - `apiUrl: string`
73
- - The base URL for your Kelviq API. For example, `https://edge.api.kelviq.com/api/v1`.
74
- - `entitlementsPath: string`
75
- - The specific path for the endpoint that returns all entitlements for a customer. This path will be appended to `apiUrl`. For example, `entitlement-check` or `user-entitlements`.
76
- - `config?: KelviqApiBehaviorOptions`
77
- - An optional object to configure more advanced behaviors of the SDK.
78
-
79
- ### **Configuration Object (**`config: KelviqApiBehaviorOptions`**)**
80
-
81
- This optional object can contain the following properties:
82
-
83
- - `onError?: (error: Error) => void`
84
- - A callback function that will be invoked if an error occurs during the API request for entitlements.
85
- - `maxRetries?: number`
86
- - The maximum number of times to retry a failed API request. Defaults to the value set in your `apiRequest` service (typically 3).
87
- - `timeout?: number`
88
- - Timeout for API requests in milliseconds. Defaults to the value set in your `apiRequest` service (typically 5000ms).
89
- - `backoffBaseDelay?: number`
90
- - Base delay (in milliseconds) for the exponential backoff strategy used in retries. Defaults to the value set in your `apiRequest` service (typically 1000ms).
91
- - `fetchEntitlementsOnMount?: boolean`
92
- - Defaults to `true`. If true, entitlements are fetched automatically when the `KelviqProvider` mounts.
93
- - Set to `false` if you want to control the initial fetch manually using the `refreshAllEntitlements` function from the `useKelviq` hook.
94
-
95
-
96
- ## **4. Fetching Entitlements**
97
-
98
- ### **Automatic Fetching on Mount**
99
-
100
- By default (`fetchEntitlementsOnMount: true` in the `config` prop, or if `config` or this specific option is omitted), the SDK will attempt to fetch all entitlements for the specified `customerId` as soon as the `KelviqProvider` is mounted.
101
-
102
- The `isLoading` state from `useKelviq()` will be `true` during this initial fetch.
103
-
104
- ### **Manual Fetching**
105
-
106
- If `fetchEntitlementsOnMount` is set to `false`, or if you need to re-fetch entitlements at any point (e.g., after a user action that might change their entitlements), you can use the `refreshAllEntitlements` function.
107
-
108
-
109
- ``` tsx
110
- import { useKelviq } from '@kelviq/react-sdk';
111
-
112
- function MyComponent() {
113
- const { refreshAllEntitlements, isLoading, error } = useKelviq();
114
-
115
- const handleRefresh = async () => {
116
- try {
117
- await refreshAllEntitlements();
118
- console.log("Entitlements refreshed!");
119
- } catch (e) {
120
- console.error("Failed to refresh entitlements:", e);
121
- }
122
- };
123
-
124
- return (
125
- <div>
126
- <button onClick={handleRefresh} disabled={isLoading}>
127
- {isLoading ? 'Refreshing...' : 'Refresh Entitlements'}
128
- </button>
129
- {error && <p style={{ color: 'red' }}>Error: {error.message}</p>}
130
- {/* ... rest of your component ... */}
131
- </div>
132
- );
133
- }
134
-
135
- ```
136
-
137
- ## **5. Accessing Entitlement Data (Hooks)**
138
-
139
- The SDK provides several hooks to access entitlement data and SDK state.
140
-
141
- ### `useKelviq()`
142
-
143
- This is the primary hook to access the SDK's context.
144
-
145
- - **Returns:** `KelviqContextValue` object containing:
146
- - `allEntitlements: AsyncState<EntitlementMap | null>`: The state object for all fetched entitlements.
147
- - `data`: An `EntitlementMap` (a `Record<string, AnyEntitlement>`) where keys are `featureKey`s, or `null` if not loaded or error.
148
- - `isLoading`: Boolean indicating if the `allEntitlements` data is currently being fetched/refreshed.
149
- - `error`: An `Error` object if the last fetch failed, otherwise `null`.
150
- - `refreshAllEntitlements: () => Promise<void>`: Function to manually trigger a re-fetch of all entitlements.
151
- - `getEntitlement: <T extends AnyEntitlement>(featureKey: string, type: T['type']) => AsyncState<T | null>`: Function to get a specific entitlement's state from the cache.
152
- - `hasAccess: (featureKey: string) => boolean | undefined`: A utility function to quickly check access for a feature. Returns `true` if access is granted, `false` if denied or feature not found, and `undefined` if data is loading or an error occurred.
153
- - `isLoading: boolean`: A global loading state indicating if the SDK is performing its initial configured fetch or a refresh operation.
154
- - `error: Error | null`: A global error state reflecting any error from the last fetch operation initiated by the provider.
155
- - `customerId: string`: The customer ID passed to the provider.
156
- - `apiUrl: string`: The base API URL passed to the provider.
157
- - `entitlementsPath: string`: The entitlements path passed to the provider.
158
-
159
- ### `useAllEntitlements()`
160
-
161
- A convenience hook that directly returns the `allEntitlements` state object.
162
-
163
- - **Returns:** `AsyncState<EntitlementMap | null>`
164
-
165
- ``` tsx
166
- import { useAllEntitlements } from '@kelviq/react-sdk';
167
-
168
- function EntitlementsList() {
169
- const { data: entitlementsMap, isLoading, error } = useAllEntitlements();
170
-
171
- if (isLoading) return <p>Loading all entitlements...</p>;
172
- if (error) return <p>Error loading entitlements: {error.message}</p>;
173
- if (!entitlementsMap) return <p>No entitlements data.</p>;
174
-
175
- return (
176
- <ul>
177
- {Object.values(entitlementsMap).map(ent => (
178
- <li key={ent.featureKey}>
179
- {ent.featureKey}: {ent.hasAccess ? 'Enabled' : 'Disabled'} ({ent.type})
180
- </li>
181
- ))}
182
- </ul>
183
- );
184
- }
185
-
186
- ```
187
-
188
- ### `useBooleanEntitlement(featureKey: string)`
189
-
190
- Fetches the state for a specific boolean entitlement from the cache.
191
-
192
- - **Arguments:**
193
- - `featureKey: string`: The key of the boolean feature.
194
- - **Returns:** `AsyncState<BooleanEntitlement | null>`
195
-
196
- ### `useConfigEntitlement(featureKey: string)`
197
-
198
- Fetches the state for a specific configuration entitlement from the cache.
199
-
200
- - **Arguments:**
201
- - `featureKey: string`: The key of the configuration feature.
202
- - **Returns:** `AsyncState<ConfigEntitlement | null>` (where `ConfigEntitlement` has a `configuration: number | null` property).
203
-
204
- ### `useMeteredEntitlement(featureKey: string)`
205
-
206
- Fetches the state for a specific metered entitlement from the cache.
207
-
208
- - **Arguments:**
209
- - `featureKey: string`: The key of the metered feature.
210
- - **Returns:** `AsyncState<MeteredEntitlement | null>`
211
-
212
- **Example using a specific entitlement hook:**
213
-
214
- ``` tsx
215
- import { useBooleanEntitlement } from '@kelviq/react-sdk';
216
-
217
- function FeatureSpecificComponent({ featureKey }: { featureKey: string }) {
218
- const { data: entitlement, isLoading, error } = useBooleanEntitlement(featureKey);
219
-
220
- if (isLoading) return <p>Loading feature {featureKey}...</p>;
221
- if (error) return <p>Error loading feature {featureKey}: {error.message}</p>;
222
-
223
- if (entitlement && entitlement.hasAccess) {
224
- return <p>You have access to {featureKey}!</p>;
225
- } else {
226
- return <p>You do not have access to {featureKey}.</p>;
227
- }
228
- }
229
-
230
- ```
231
-
232
- ## **6. Conditional Rendering Components**
233
-
234
- These components provide a declarative way to render UI based on entitlement status. They internally use the respective hooks.
235
-
236
- **Common Props:**
237
-
238
- - `featureKey: string`: The unique key of the feature to check.
239
- - `children: ReactNode | ((data: E) => ReactNode)`:
240
- - If a `ReactNode`, it's rendered when the user is entitled and conditions are met.
241
- - If a function (render prop), it's called with the entitlement data (`BooleanEntitlement`, `ConfigEntitlement`, or `MeteredEntitlement`) and its return value is rendered.
242
- - `fallback?: ReactNode`: Content to render if the user is not entitled, or if data is loading (and no `loadingComponent` is provided), or if an error occurs. Defaults to `null`.
243
- - `loadingComponent?: ReactNode`: Specific content to render while the entitlement data is loading. Overrides `fallback` during loading.
244
-
245
- ### `ShowWhenBooleanEntitled`
246
-
247
- Renders children if the boolean feature is enabled (`hasAccess: true`).
248
-
249
- ``` tsx
250
- import { ShowWhenBooleanEntitled } from '@kelviq/react-sdk';
251
-
252
- <ShowWhenBooleanEntitled
253
- featureKey="enable-dark-mode"
254
- loadingComponent={<p>Checking theme settings...</p>}
255
- fallback={<p>Dark mode is not available.</p>}
256
- >
257
- <button>Toggle Dark Mode</button>
258
- </ShowWhenBooleanEntitled>
259
-
260
- <ShowWhenBooleanEntitled featureKey="show-advanced-settings">
261
- {(entitlementData) => (
262
- <div>Advanced settings for {entitlementData.featureKey} are visible!</div>
263
- )}
264
- </ShowWhenBooleanEntitled>
265
-
266
- ```
267
-
268
- ### `ShowWhenConfigEntitled`
269
-
270
- Renders children if the config feature is enabled and provides the numeric configuration value to the children render prop.
271
-
272
- - **Children Prop:** `(config: number) => ReactNode` (Required to be a function for this component).
273
-
274
- ``` tsx
275
- import { ShowWhenConfigEntitled } from '@kelviq/react-sdk';
276
-
277
- <ShowWhenConfigEntitled
278
- featureKey="max-items-per-page"
279
- loadingComponent={<p>Loading display settings...</p>}
280
- fallback={<p>Default item limit applies.</p>}
281
- >
282
- {(maxItems) => <p>You can display up to {maxItems} items per page.</p>}
283
- </ShowWhenConfigEntitled>
284
-
285
- ```
286
-
287
- ### `ShowWhenMeteredEntitled`
288
-
289
- Renders children if the metered feature is enabled and, by default, if `remaining` usage is greater than 0 or unlimited (`limit` is `null`).
290
-
291
- - **Optional Prop:**
292
- - `condition?: (data: MeteredEntitlement) => boolean`: A custom function to further determine if children should render based on the metered entitlement data.
293
- - **Children Prop:** Can be `ReactNode` or `(data: MeteredEntitlement) => ReactNode`.
294
-
295
- ``` tsx
296
- import { ShowWhenMeteredEntitled } from '@kelviq/react-sdk';
297
-
298
- <ShowWhenMeteredEntitled
299
- featureKey="api-calls-quota"
300
- loadingComponent={<p>Loading API quota...</p>}
301
- fallback={<p>API call limit reached or feature not available.</p>}
302
- >
303
- {(meterData) => (
304
- <div>
305
- <p>API Calls Used: {meterData.used} / {meterData.limit === null ? 'Unlimited' : meterData.limit}</p>
306
- <p>Remaining: {meterData.remaining === null ? 'Unlimited' : meterData.remaining}</p>
307
- </div>
308
- )}
309
- </ShowWhenMeteredEntitled>
310
-
311
- ```
312
-
313
- ## **7. Key Types**
314
-
315
- The SDK exports several types for better integration with TypeScript. Some key ones include:
316
-
317
- - `KelviqProviderOptions`: Configuration for the provider.
318
- - `KelviqContextValue`: The shape of the object returned by `useKelviq()`.
319
- - `AsyncState<T>`: Generic type for asynchronous data states.
320
- - `EntitlementMap`: The structure of the cached entitlements (`Record<string, AnyEntitlement>`).
321
- - `Entitlement`, `BooleanEntitlement`, `ConfigEntitlement`, `MeteredEntitlement`: Processed entitlement types.
322
- - `ApiRequestConfig`, `ApiResponse`: Interfaces related to the underlying `apiRequest` service.
323
- - `RawEntitlementsApiResponse` and related `Raw...` types: Represent the structure of the direct API response.
324
-
325
- You can import these types from `@kelviq/react-sdk/types` (assuming your `src/types/index.ts` re-exports them) or directly from the main SDK entry if configured.
326
-
327
- ## **8. Error Handling**
328
-
329
- - **Provider Level:** The `onError` callback in `KelviqProviderOptions` can be used to globally handle errors that occur during the entitlement fetching process initiated by the provider.
330
- - **Hook Level:** Each hook (`useAllEntitlements`, `useBooleanEntitlement`, etc.) returns an `AsyncState` object which includes an `error: Error | null` property. You can check this to handle errors specific to that data slice.
331
- - **Context Level:** `useKelviq()` also returns a global `error: Error | null` state, reflecting errors from the provider's most recent fetch operation.
332
-
333
- ## **9. Example Usage**
334
-
335
- A comprehensive example is provided within the comments of the SDK code, demonstrating provider setup and component usage. The core setup involves:
336
-
337
- 1. Wrapping your application with `KelviqProvider` and providing the required props (`customerId`, `accessToken`)
338
- 2. Using hooks like `useBooleanEntitlement` or conditional components like `ShowWhenBooleanEntitled` in your components to control UI and behavior based on entitlements.
339
-
340
- ## **10. API Request Service**
341
-
342
- The SDK relies on an `apiRequest` function for making HTTP requests. The SDK's `KelviqProvider` passes configuration like `timeout`, `maxRetries`, `backoffBaseDelay`, and `accessToken` to this function.
343
-
344
- - **Your Responsibility:** You need to ensure that your project includes an implementation of this `apiRequest` service (e.g., in `src/services/makeRequest.service.ts`) that matches the `ApiRequestConfig` and `ApiResponse` interfaces used by the SDK. This service should handle actual HTTP communication, including appending query parameters passed via `ApiRequestConfig.queryParams` and using the `accessToken` to set the `Authorization` header.
345
- - The placeholder `apiRequest` function included in the SDK's source code is for demonstration and type-checking purposes only and will not make real API calls.
346
-
347
- ## **11. Project Structure (for contributors/reference)**
25
+ ## Documentation
348
26
 
349
- The SDK source code (`src/`) is organized as follows:
27
+ For full documentation, guides, and API reference, visit **[docs.kelviq.com/frontend-integration/react-sdk](https://docs.kelviq.com/frontend-integration/react-sdk)**.
350
28
 
351
- - `components/`: Contains conditional rendering React components.
352
- - `ShowWhenBooleanEntitled.tsx`
353
- - `ShowWhenConfigEntitled.tsx`
354
- - `ShowWhenMeteredEntitled.tsx`
355
- - `ShowWhenEntitledInternal.tsx` (Internal helper, not typically exported)
356
- - `index.ts` (Exports public components)
357
- - `context/`: Defines the React Context.
358
- - `KelviqContext.ts`
359
- - `hooks/`: Contains all custom React Hooks.
360
- - `useKelviq.ts`
361
- - `useAllEntitlements.ts`
362
- - `useBooleanEntitlement.ts`
363
- - `useConfigEntitlement.ts`
364
- - `useMeteredEntitlement.ts`
365
- - `index.ts` (Exports all hooks)
366
- - `provider/`: Contains the main `KelviqProvider`.
367
- - `KelviqProvider.tsx`
368
- - `types/`: Contains all TypeScript definitions.
369
- - `api.types.ts` (Raw types from API)
370
- - `sdk.types.ts` (Processed types for SDK and public use)
371
- - `index.ts` (Re-exports all types)
372
- - `utils/`: Contains utility functions.
373
- - `transformations.ts` (For `transformApiEntitlements`)
374
- - `index.ts` (Exports utilities)
375
- - `index.ts`: The main entry point of the SDK, re-exporting all public APIs (provider, hooks, components, types).
29
+ ## License
376
30
 
377
- This documentation should provide a good starting point for developers using your `@kelviq/react-sdk`. Remember to replace placeholder URLs and token examples with relevant information for your users.
31
+ MIT
@@ -1,3 +1,2 @@
1
- import { BooleanEntitlement } from '../types/sdk.types';
2
1
  import { ShowWhenEntitledProps } from './ShowWhenEntitledInternal';
3
- export declare const ShowWhenBooleanEntitled: React.FC<Omit<ShowWhenEntitledProps<BooleanEntitlement>, 'condition' | 'type'>>;
2
+ export declare const ShowWhenBooleanEntitled: React.FC<Omit<ShowWhenEntitledProps, 'condition'>>;
@@ -0,0 +1,9 @@
1
+ import { ShowWhenEntitledProps } from './ShowWhenEntitledInternal';
2
+ /**
3
+ * Conditionally renders children based on a customizable entitlement.
4
+ * @param featureId The feature identifier.
5
+ * @param children Content to render if entitled. Can be a ReactNode or a render function receiving the entitlement data.
6
+ * @param fallback Content to render if not entitled, loading, or error.
7
+ * @param loadingComponent Specific content to render while the entitlement is loading.
8
+ */
9
+ export declare const ShowWhenCustomizableEntitled: React.FC<Omit<ShowWhenEntitledProps, 'condition'>>;
@@ -1,12 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
- import { AnyEntitlement } from '../types/sdk.types';
3
- export interface ShowWhenEntitledProps<E extends AnyEntitlement> {
4
- featureKey: string;
5
- children: ReactNode | ((data: E) => ReactNode);
2
+ import { Entitlement } from '../types/sdk.types';
3
+ export interface ShowWhenEntitledProps {
4
+ featureId: string;
5
+ children: ReactNode | ((data: Entitlement) => ReactNode);
6
6
  fallback?: ReactNode;
7
7
  loadingComponent?: ReactNode;
8
- condition?: (data: E) => boolean;
8
+ condition?: (data: Entitlement) => boolean;
9
9
  }
10
- export declare const ShowWhenEntitledInternal: <E extends AnyEntitlement>({ featureKey, type, children, fallback, loadingComponent, condition, }: ShowWhenEntitledProps<E> & {
11
- type: E["type"];
12
- }) => JSX.Element;
10
+ export declare const ShowWhenEntitledInternal: React.FC<ShowWhenEntitledProps>;
@@ -1,13 +1,12 @@
1
- import { MeteredEntitlement } from '../types/sdk.types';
2
1
  import { ShowWhenEntitledProps } from './ShowWhenEntitledInternal';
3
2
  /**
4
3
  * Conditionally renders children based on a metered entitlement.
5
4
  * By default, children are rendered if hasAccess is true and remaining usage is greater than 0 or unlimited.
6
5
  * A custom `condition` function can be provided.
7
- * @param featureKey The key of the metered feature.
6
+ * @param featureId The feature identifier.
8
7
  * @param children Content to render if entitled and condition is met. Can be a ReactNode or a render function receiving the entitlement data.
9
- * @param fallback Content to render if not entitled, loading (and no loadingComponent), error, or condition not met.
8
+ * @param fallback Content to render if not entitled, loading, error, or condition not met.
10
9
  * @param loadingComponent Specific content to render while the entitlement is loading.
11
- * @param condition Optional function to further refine when children are rendered based on metered data.
10
+ * @param condition Optional function to further refine when children are rendered.
12
11
  */
13
- export declare const ShowWhenMeteredEntitled: React.FC<Omit<ShowWhenEntitledProps<MeteredEntitlement>, 'type'>>;
12
+ export declare const ShowWhenMeteredEntitled: React.FC<ShowWhenEntitledProps>;
@@ -1,11 +1,19 @@
1
- import { EntitlementMap, AnyEntitlement } from '../types/sdk.types';
1
+ import { Entitlement, EntitlementMap, EntitlementsResponse } from '../types/sdk.types';
2
2
  import { AsyncState } from '../types';
3
3
  /** Defines the shape of the context value provided by KelviqProvider. */
4
4
  export interface KelviqContextValue {
5
5
  allEntitlements: AsyncState<EntitlementMap | null>;
6
6
  refreshAllEntitlements: () => Promise<void>;
7
- getEntitlement: <T extends AnyEntitlement>(featureKey: string, type: T['type']) => AsyncState<T | null>;
8
- hasAccess: (featureKey: string) => boolean | undefined;
7
+ /** Returns all aggregated entitlements as a map keyed by featureId. */
8
+ getEntitlements: () => EntitlementMap;
9
+ /** Returns a single aggregated entitlement by featureId, or null. */
10
+ getEntitlement: (featureId: string) => Entitlement | null;
11
+ /** Returns the raw API response (customerId + un-aggregated entitlements). */
12
+ getRawEntitlements: () => EntitlementsResponse | null;
13
+ /** Returns the raw API response filtered to a specific featureId. */
14
+ getRawEntitlement: (featureId: string) => EntitlementsResponse | null;
15
+ hasAccess: (featureId: string) => boolean;
16
+ updateEntitlement: (featureId: string, data: Partial<Omit<Entitlement, 'featureId' | 'featureType' | 'items'>>) => void;
9
17
  isLoading: boolean;
10
18
  error: Error | null;
11
19
  customerId: string;
@@ -1,5 +1,5 @@
1
1
  export * from './useKelviq';
2
2
  export * from './useAllEntitlements';
3
3
  export * from './useBooleanEntitlement';
4
- export * from './useConfigEntitlement';
4
+ export * from './useCustomizableEntitlement';
5
5
  export * from './useMeteredEntitlement';
@@ -1,8 +1,7 @@
1
- import { AsyncState } from '../types';
2
- import { BooleanEntitlement } from '../types/sdk.types';
1
+ import { Entitlement } from '../types/sdk.types';
3
2
  /**
4
- * Hook to get a specific boolean entitlement's state.
5
- * @param featureKey The key of the boolean feature.
6
- * @returns AsyncState containing the BooleanEntitlement or null if not found/error.
3
+ * Hook to get a specific boolean entitlement.
4
+ * @param featureId The feature identifier.
5
+ * @returns The aggregated Entitlement object or null if not found/loading.
7
6
  */
8
- export declare const useBooleanEntitlement: (featureKey: string) => AsyncState<BooleanEntitlement | null>;
7
+ export declare const useBooleanEntitlement: (featureId: string) => Entitlement | null;
@@ -0,0 +1,7 @@
1
+ import { Entitlement } from '../types/sdk.types';
2
+ /**
3
+ * Hook to get a specific customizable entitlement.
4
+ * @param featureId The feature identifier.
5
+ * @returns The aggregated Entitlement object or null if not found/loading.
6
+ */
7
+ export declare const useCustomizableEntitlement: (featureId: string) => Entitlement | null;
@@ -1,8 +1,7 @@
1
- import { AsyncState } from '../types';
2
- import { MeteredEntitlement } from '../types/sdk.types';
1
+ import { Entitlement } from '../types/sdk.types';
3
2
  /**
4
- * Hook to get a specific metered entitlement's state.
5
- * @param featureKey The key of the metered feature.
6
- * @returns AsyncState containing the MeteredEntitlement or null.
3
+ * Hook to get a specific metered entitlement.
4
+ * @param featureId The feature identifier.
5
+ * @returns The aggregated Entitlement object or null if not found/loading.
7
6
  */
8
- export declare const useMeteredEntitlement: (featureKey: string) => AsyncState<MeteredEntitlement | null>;
7
+ export declare const useMeteredEntitlement: (featureId: string) => Entitlement | null;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export * from './contexts/KelviqProvider';
2
2
  export type * from './types';
3
- export * from './components/ShowWhenConfigEntitled';
3
+ export * from './components/ShowWhenCustomizableEntitled';
4
4
  export * from './components/ShowWhenMeteredEntitled';
5
5
  export * from './components/ShowWhenBooleanEntitled';
6
6
  export * from './contexts/KelviqContext';
7
7
  export * from './hooks/useKelviq';
8
8
  export * from './hooks/useAllEntitlements';
9
9
  export * from './hooks/useBooleanEntitlement';
10
- export * from './hooks/useConfigEntitlement';
10
+ export * from './hooks/useCustomizableEntitlement';
11
11
  export * from './hooks/useMeteredEntitlement';