@bluealba/pae-ui-react-core 4.0.1-feature-feature-flags-1243 → 4.0.1-feature-feature-flags-1245

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.
@@ -23,11 +23,6 @@ export interface FeatureFlagGuardProps {
23
23
  * @default false
24
24
  */
25
25
  invert?: boolean;
26
- /**
27
- * Base URL for the gateway API
28
- * @default ''
29
- */
30
- gatewayUrl?: string;
31
26
  }
32
27
  /**
33
28
  * Component for conditional rendering based on feature flags
@@ -0,0 +1,39 @@
1
+ import { ServiceInvoker } from '../hooks/useServiceInvoker';
2
+ import { UnifiedEvaluationResponse, FeatureFlagsResponse } from './types';
3
+
4
+ /**
5
+ * API client for feature flag operations
6
+ */
7
+ export declare class FeatureFlagsApiClient {
8
+ /**
9
+ * Evaluate a single feature flag using the unified endpoint
10
+ *
11
+ * This endpoint returns the flag's value which can be:
12
+ * - For boolean flags: true or false
13
+ * - For variant flags: variant name (string), null, or undefined
14
+ *
15
+ * Note: This endpoint does NOT return payload data for variants.
16
+ * To get payloads, use evaluateFlags() with the bulk endpoint.
17
+ *
18
+ * @param invoker - ServiceInvoker for the gateway service
19
+ * @param flagName - Name of the feature flag to evaluate
20
+ * @returns Unified evaluation response
21
+ * @throws Error if the API request fails
22
+ */
23
+ static evaluateFlag(invoker: ServiceInvoker, flagName: string): Promise<UnifiedEvaluationResponse>;
24
+ /**
25
+ * Evaluate multiple feature flags using the bulk evaluation endpoint
26
+ *
27
+ * This endpoint returns full flag evaluation results including:
28
+ * - Boolean enabled state
29
+ * - Variant information with payload data
30
+ * - Evaluation timestamp
31
+ *
32
+ * @param invoker - ServiceInvoker for the gateway service
33
+ * @param flagNames - Array of flag names to evaluate
34
+ * @param customProperties - Optional custom properties for evaluation context
35
+ * @returns Feature flags response with array of evaluation results
36
+ * @throws Error if the API request fails
37
+ */
38
+ static evaluateFlags(invoker: ServiceInvoker, flagNames: string[], customProperties?: Record<string, any>): Promise<FeatureFlagsResponse>;
39
+ }
@@ -49,11 +49,6 @@ export interface FeatureFlagsContextValue {
49
49
  * Props for the FeatureFlagsProvider component
50
50
  */
51
51
  export interface FeatureFlagsProviderProps {
52
- /**
53
- * Base URL for the gateway API
54
- * @default ''
55
- */
56
- gatewayUrl?: string;
57
52
  /**
58
53
  * Array of flag names to prefetch on mount and refresh
59
54
  * These flags will be eagerly loaded and cached
@@ -3,7 +3,12 @@
3
3
  *
4
4
  * This module provides React hooks and components for working with feature flags
5
5
  * in the Blue Alba Platform. All utilities are compatible with the gateway's
6
- * feature flags API (/_/feature-flags).
6
+ * feature flags API (/_/feature-flags) and use the platform's service discovery pattern.
7
+ *
8
+ * Key Features:
9
+ * - Automatic service discovery via useServiceInvoker
10
+ * - No need to manually configure gateway URLs
11
+ * - Centralized API client for feature flag operations
7
12
  *
8
13
  * @example
9
14
  * ```tsx
@@ -11,13 +16,12 @@
11
16
  * FeatureFlagsProvider,
12
17
  * useFeatureFlag,
13
18
  * useFeatureFlags,
14
- * useVariant,
19
+ * useFeatureFlagVariant,
15
20
  * FeatureFlagGuard
16
21
  * } from '@bluealba/pae-ui-react-core';
17
22
  *
18
23
  * // Wrap your app with the provider
19
24
  * <FeatureFlagsProvider
20
- * gatewayUrl="/api"
21
25
  * prefetchFlags={['new-ui', 'beta-feature']}
22
26
  * refreshInterval={60000}
23
27
  * >
@@ -31,9 +35,10 @@
31
35
  * }
32
36
  * ```
33
37
  */
38
+ export { FeatureFlagsApiClient } from './FeatureFlagsApiClient';
34
39
  export type { FlagEvaluationResult, FeatureFlagVariant, FeatureFlagsResponse, SingleFlagResponse, VariantResponse, UnifiedEvaluationResponse, } from './types';
35
40
  export { FeatureFlagsProvider, FeatureFlagsContext, type FeatureFlagsProviderProps, type FeatureFlagsContextValue, } from './FeatureFlagsProvider';
36
41
  export { useFeatureFlag } from './useFeatureFlag';
37
42
  export { useFeatureFlags } from './useFeatureFlags';
38
- export { useVariant, type UseVariantResult } from './useVariant';
43
+ export { useFeatureFlagVariant, type UseFeatureFlagVariantResult } from './useFeatureFlagVariant';
39
44
  export { FeatureFlagGuard, type FeatureFlagGuardProps } from './FeatureFlagGuard';
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * A React hook for evaluating a single boolean feature flag.
5
5
  * This hook first checks if the flag is in the prefetched cache (from FeatureFlagsProvider).
6
- * If not found in cache, it fetches the flag individually from the API.
6
+ * If not found in cache, it fetches the flag individually from the API using service discovery.
7
7
  *
8
8
  * @example
9
9
  * ```tsx
@@ -19,7 +19,6 @@
19
19
  *
20
20
  * @param flagName - Name of the feature flag to evaluate
21
21
  * @param defaultValue - Default value to use if flag cannot be evaluated (default: false)
22
- * @param gatewayUrl - Base URL for the gateway API (default: '')
23
22
  * @returns Boolean indicating whether the flag is enabled
24
23
  */
25
- export declare function useFeatureFlag(flagName: string, defaultValue?: boolean, gatewayUrl?: string): boolean;
24
+ export declare function useFeatureFlag(flagName: string, defaultValue?: boolean): boolean;
@@ -1,9 +1,9 @@
1
1
  /**
2
- * useVariant Hook
2
+ * useFeatureFlagVariant Hook
3
3
  *
4
4
  * A React hook for getting the variant value of a multivariant feature flag.
5
5
  * This hook first checks if the variant is in the prefetched cache (from FeatureFlagsProvider).
6
- * If not found in cache, it fetches the variant individually from the unified API.
6
+ * If not found in cache, it fetches the variant individually from the unified API using service discovery.
7
7
  *
8
8
  * IMPORTANT: The unified individual API endpoint does NOT return the payload.
9
9
  * To get payload data, you should either:
@@ -13,7 +13,7 @@
13
13
  * @example
14
14
  * ```tsx
15
15
  * function MyComponent() {
16
- * const { variant, payload, isLoading } = useVariant('checkout-flow');
16
+ * const { variant, payload, isLoading } = useFeatureFlagVariant('checkout-flow');
17
17
  *
18
18
  * if (isLoading) return <Spinner />;
19
19
  *
@@ -26,9 +26,9 @@
26
26
  * ```
27
27
  */
28
28
  /**
29
- * Return type for the useVariant hook
29
+ * Return type for the useFeatureFlagVariant hook
30
30
  */
31
- export interface UseVariantResult {
31
+ export interface UseFeatureFlagVariantResult {
32
32
  /**
33
33
  * The selected variant name, or null if no variant is selected
34
34
  */
@@ -48,7 +48,6 @@ export interface UseVariantResult {
48
48
  * Hook for getting the variant value of a multivariant feature flag
49
49
  *
50
50
  * @param flagName - Name of the feature flag
51
- * @param gatewayUrl - Base URL for the gateway API (default: '')
52
51
  * @returns Object containing variant, payload, and loading state
53
52
  */
54
- export declare function useVariant(flagName: string, gatewayUrl?: string): UseVariantResult;
53
+ export declare function useFeatureFlagVariant(flagName: string): UseFeatureFlagVariantResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluealba/pae-ui-react-core",
3
- "version": "4.0.1-feature-feature-flags-1243",
3
+ "version": "4.0.1-feature-feature-flags-1245",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",