@shiva004/surveys 0.12.1 → 0.12.2
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/elements.js +5582 -6061
- package/dist/flags/client/client.d.ts +34 -0
- package/dist/flags/client/context.d.ts +19 -0
- package/dist/flags/client/events.d.ts +18 -0
- package/dist/flags/client/index.d.ts +4 -0
- package/dist/flags/client/status.d.ts +17 -0
- package/dist/flags/client/types.d.ts +77 -0
- package/dist/{openfeature → flags}/context/use-context-mutator.d.ts +6 -6
- package/dist/flags/declarative/FeatureFlag.d.ts +52 -0
- package/dist/flags/evaluation/use-feature-flag.d.ts +43 -0
- package/dist/{openfeature → flags}/internal/context.d.ts +3 -3
- package/dist/flags/internal/hook-flag-query.d.ts +16 -0
- package/dist/flags/internal/suspense.d.ts +18 -0
- package/dist/{openfeature → flags}/internal/use.d.ts +1 -2
- package/dist/{openfeature → flags}/options.d.ts +6 -9
- package/dist/flags/provider/index.d.ts +5 -0
- package/dist/{openfeature → flags}/provider/provider.d.ts +7 -7
- package/dist/flags/provider/use-flags-backend.d.ts +8 -0
- package/dist/flags/provider/use-flags-client-status.d.ts +7 -0
- package/dist/flags/provider/use-flags-client.d.ts +7 -0
- package/dist/flags/provider/use-when-flags-ready.d.ts +13 -0
- package/dist/{openfeature → flags}/query/query.d.ts +7 -10
- package/dist/{openfeature/index.d.ts → flags/sdk.d.ts} +1 -1
- package/dist/{openfeature → flags}/tracking/use-track.d.ts +4 -3
- package/dist/index.d.ts +1 -4
- package/dist/index.js +5212 -5691
- package/package.json +8 -5
- package/dist/flags/OpenFeatureFlags.d.ts +0 -21
- package/dist/flags/openfeature.d.ts +0 -36
- package/dist/openfeature/declarative/FeatureFlag.d.ts +0 -68
- package/dist/openfeature/evaluation/use-feature-flag.d.ts +0 -113
- package/dist/openfeature/internal/hook-flag-query.d.ts +0 -16
- package/dist/openfeature/internal/suspense.d.ts +0 -18
- package/dist/openfeature/provider/index.d.ts +0 -5
- package/dist/openfeature/provider/test-provider.d.ts +0 -35
- package/dist/openfeature/provider/use-open-feature-client-status.d.ts +0 -7
- package/dist/openfeature/provider/use-open-feature-client.d.ts +0 -7
- package/dist/openfeature/provider/use-open-feature-provider.d.ts +0 -8
- package/dist/openfeature/provider/use-when-provider-ready.d.ts +0 -14
- package/dist/openfeature/sdk/api.d.ts +0 -43
- package/dist/openfeature/sdk/client.d.ts +0 -46
- package/dist/openfeature/sdk/errors.d.ts +0 -38
- package/dist/openfeature/sdk/events.d.ts +0 -10
- package/dist/openfeature/sdk/index.d.ts +0 -8
- package/dist/openfeature/sdk/providers.d.ts +0 -46
- package/dist/openfeature/sdk/types.d.ts +0 -168
- /package/dist/{openfeature → flags}/context/index.d.ts +0 -0
- /package/dist/{openfeature → flags}/declarative/index.d.ts +0 -0
- /package/dist/{openfeature → flags}/evaluation/index.d.ts +0 -0
- /package/dist/{openfeature → flags}/internal/errors.d.ts +0 -0
- /package/dist/{openfeature → flags}/internal/index.d.ts +0 -0
- /package/dist/{openfeature → flags}/internal/is-equal.d.ts +0 -0
- /package/dist/{openfeature → flags}/internal/options.d.ts +0 -0
- /package/dist/{openfeature → flags}/query/index.d.ts +0 -0
- /package/dist/{openfeature → flags}/tracking/index.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shiva004/surveys",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "Logs, Live Events, Feedback, Heatmap, Feature Management, Queues, Sessions, Error Tracking, Releases, Notifications, Mock API and User Journey for React, Angular (web components), Vue and plain HTML",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"@types/react": "^18.3.3",
|
|
39
39
|
"@types/react-dom": "^18.3.0",
|
|
40
40
|
"@vitejs/plugin-react": "^4.3.1",
|
|
41
|
+
"lucide-react": "^1.72.0",
|
|
41
42
|
"react": "^18.3.1",
|
|
42
43
|
"react-dom": "^18.3.1",
|
|
44
|
+
"react-router-dom": "^7.18.5",
|
|
45
|
+
"rrweb": "^1.1.3",
|
|
43
46
|
"typescript": "^5.5.4",
|
|
44
47
|
"vite": "^5.4.2",
|
|
45
|
-
"vite-plugin-css-injected-by-js": "^3.5.2"
|
|
46
|
-
"lucide-react": "^1.72.0",
|
|
47
|
-
"react-router-dom": "^7.18.5",
|
|
48
|
-
"rrweb": "^1.1.3"
|
|
48
|
+
"vite-plugin-css-injected-by-js": "^3.5.2"
|
|
49
49
|
},
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"keywords": [
|
|
@@ -73,5 +73,8 @@
|
|
|
73
73
|
"react-dom": {
|
|
74
74
|
"optional": true
|
|
75
75
|
}
|
|
76
|
+
},
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"@shiva004/surveys": "^0.12.1"
|
|
76
79
|
}
|
|
77
80
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import type { EvaluationContext } from '../openfeature/sdk';
|
|
3
|
-
export interface FlagsOpenFeatureProviderProps {
|
|
4
|
-
children?: ReactNode;
|
|
5
|
-
/** Starting evaluation context, e.g. { targetingKey: user.id, country: 'IN', plan: 'pro' }. Default: the Live Events user id. */
|
|
6
|
-
context?: EvaluationContext;
|
|
7
|
-
/** Shown until the provider is ready (a few ms). Default: nothing, so flags never flash their default. */
|
|
8
|
-
fallback?: ReactNode;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Put this once above the components that read flags:
|
|
12
|
-
*
|
|
13
|
-
* <FlagsOpenFeatureProvider context={{ targetingKey: user.id, country: 'IN' }}>
|
|
14
|
-
* <App />
|
|
15
|
-
* </FlagsOpenFeatureProvider>
|
|
16
|
-
*
|
|
17
|
-
* then anywhere below: const on = useBooleanFlagValue('new_checkout_flow', false);
|
|
18
|
-
* The component re-renders by itself when that flag is toggled, its rollout or rules change,
|
|
19
|
-
* a remote sync brings new flags, or the user context changes (identifyFlagUser).
|
|
20
|
-
*/
|
|
21
|
-
export declare function FlagsOpenFeatureProvider({ children, context, fallback }: FlagsOpenFeatureProviderProps): import("react").JSX.Element;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type EvaluationContext, type Provider, type ResolutionDetails, type JsonValue } from '../openfeature/sdk';
|
|
2
|
-
import { type Env } from './data';
|
|
3
|
-
/** The OpenFeature domain this bridge is registered under. */
|
|
4
|
-
export declare const FLAGS_DOMAIN = "flags";
|
|
5
|
-
/** OpenFeature provider backed by the in-browser flag store (flags/data.ts). Flags are boolean. */
|
|
6
|
-
export declare class FlagsProvider implements Provider {
|
|
7
|
-
readonly metadata: {
|
|
8
|
-
readonly name: "flag-store";
|
|
9
|
-
};
|
|
10
|
-
readonly runsOn: "client";
|
|
11
|
-
readonly events: import("..").EventEmitter;
|
|
12
|
-
private last;
|
|
13
|
-
private unsubscribe?;
|
|
14
|
-
/**
|
|
15
|
-
* Start watching the store: every change becomes a ConfigurationChanged event (this is what re-renders the hooks).
|
|
16
|
-
* Must return a Promise: the SDK only marks the provider READY when the promise resolves.
|
|
17
|
-
*/
|
|
18
|
-
initialize(): Promise<void>;
|
|
19
|
-
onClose(): Promise<void>;
|
|
20
|
-
resolveBooleanEvaluation(flagKey: string, defaultValue: boolean, context?: EvaluationContext): ResolutionDetails<boolean>;
|
|
21
|
-
resolveStringEvaluation(flagKey: string): ResolutionDetails<string>;
|
|
22
|
-
resolveNumberEvaluation(flagKey: string): ResolutionDetails<number>;
|
|
23
|
-
resolveObjectEvaluation<T extends JsonValue>(flagKey: string): ResolutionDetails<T>;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Register the store with OpenFeature (once). Safe to call many times.
|
|
27
|
-
* `context` is the starting evaluation context, e.g. { targetingKey: 'u1', country: 'IN', env: 'staging' }.
|
|
28
|
-
*/
|
|
29
|
-
export declare const registerFlagsProvider: (context?: EvaluationContext) => Promise<void>;
|
|
30
|
-
/** Tear down (tests / hot reload): closes the provider and forgets the registration. */
|
|
31
|
-
export declare const unregisterFlagsProvider: () => Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* Change who the flags are evaluated for. Every mounted flag hook re-evaluates (ContextChanged event).
|
|
34
|
-
* identifyFlagUser('u42', { country: 'IN', plan: 'pro' })
|
|
35
|
-
*/
|
|
36
|
-
export declare const identifyFlagUser: (userId: string, attributes?: Record<string, string | number | boolean>, env?: Env) => Promise<void>;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { FlagQuery } from '../query';
|
|
3
|
-
import type { FlagValue, EvaluationDetails, ConstrainedFlagKey } from '../sdk';
|
|
4
|
-
import type { ReactFlagEvaluationOptions } from '../options';
|
|
5
|
-
/**
|
|
6
|
-
* Props for the FeatureFlag component that conditionally renders content based on feature flag state.
|
|
7
|
-
* @interface FeatureFlagProps
|
|
8
|
-
*/
|
|
9
|
-
interface FeatureFlagProps<T extends FlagValue = FlagValue> {
|
|
10
|
-
/**
|
|
11
|
-
* The key of the feature flag to evaluate.
|
|
12
|
-
*/
|
|
13
|
-
flagKey: ConstrainedFlagKey<T>;
|
|
14
|
-
/**
|
|
15
|
-
* Optional predicate function for custom matching logic.
|
|
16
|
-
* If provided, this function will be used instead of the default equality check.
|
|
17
|
-
* @param matchValue The value to match (matchValue prop)
|
|
18
|
-
* @param details The evaluation details
|
|
19
|
-
* @returns true if the condition is met, false otherwise
|
|
20
|
-
*/
|
|
21
|
-
predicate?: (matchValue: T | undefined, details: EvaluationDetails<T>) => boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Content to render when the feature flag condition is met.
|
|
24
|
-
* Can be a React node or a function that receives flag query details and returns a React node.
|
|
25
|
-
*/
|
|
26
|
-
children: React.ReactNode | ((details: FlagQuery<T>) => React.ReactNode);
|
|
27
|
-
/**
|
|
28
|
-
* Optional content to render when the feature flag condition is not met.
|
|
29
|
-
* Can be a React node or a function that receives evaluation details and returns a React node.
|
|
30
|
-
*/
|
|
31
|
-
fallback?: React.ReactNode | ((details: EvaluationDetails<T>) => React.ReactNode);
|
|
32
|
-
/**
|
|
33
|
-
* Flag evaluation options that will be passed to useFlag hook.
|
|
34
|
-
*/
|
|
35
|
-
evaluationOptions?: ReactFlagEvaluationOptions;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Configuration for matching flag values.
|
|
39
|
-
* For boolean flags, `match` is optional (defaults to checking truthiness).
|
|
40
|
-
* For non-boolean flags (string, number, object), `match` is required to determine when to render.
|
|
41
|
-
*/
|
|
42
|
-
type FeatureFlagMatchConfig<T extends FlagValue> = {
|
|
43
|
-
/**
|
|
44
|
-
* Default value to use when the feature flag is not found.
|
|
45
|
-
*/
|
|
46
|
-
defaultValue: T;
|
|
47
|
-
} & (T extends boolean ? {
|
|
48
|
-
/**
|
|
49
|
-
* Optional value to match against the feature flag value.
|
|
50
|
-
*/
|
|
51
|
-
matchValue?: T | undefined;
|
|
52
|
-
} : {
|
|
53
|
-
/**
|
|
54
|
-
* Value to match against the feature flag value.
|
|
55
|
-
* Required for non-boolean flags to determine when children should render.
|
|
56
|
-
* By default, strict equality is used for comparison.
|
|
57
|
-
*/
|
|
58
|
-
matchValue: T;
|
|
59
|
-
});
|
|
60
|
-
type FeatureFlagComponentProps<T extends FlagValue> = FeatureFlagProps<T> & FeatureFlagMatchConfig<T>;
|
|
61
|
-
/**
|
|
62
|
-
* @experimental This API is experimental, and is subject to change.
|
|
63
|
-
* FeatureFlag component that conditionally renders its children based on the evaluation of a feature flag.
|
|
64
|
-
* @param {FeatureFlagComponentProps} props The properties for the FeatureFlag component.
|
|
65
|
-
* @returns {React.ReactElement | null} The rendered component or null if the feature is not enabled.
|
|
66
|
-
*/
|
|
67
|
-
export declare function FeatureFlag<T extends FlagValue = FlagValue>({ flagKey, matchValue, predicate, defaultValue, children, evaluationOptions, fallback, }: FeatureFlagComponentProps<T>): React.ReactElement | null;
|
|
68
|
-
export {};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import type { BooleanFlagKey, ConstrainedFlagKey, EvaluationDetails, FlagValue, JsonValue, NumberFlagKey, ObjectFlagKey, StringFlagKey } from '../sdk';
|
|
2
|
-
import type { ReactFlagEvaluationNoSuspenseOptions, ReactFlagEvaluationOptions } from '../options';
|
|
3
|
-
import type { FlagQuery } from '../query';
|
|
4
|
-
/**
|
|
5
|
-
* Evaluates a feature flag generically, returning an react-flavored queryable object.
|
|
6
|
-
* The resolver method to use is based on the type of the defaultValue.
|
|
7
|
-
* For type-specific hooks, use {@link useBooleanFlagValue}, {@link useBooleanFlagDetails} and equivalents.
|
|
8
|
-
* By default, components will re-render when the flag value changes.
|
|
9
|
-
* @param {ConstrainedFlagKey<T>} flagKey the flag identifier
|
|
10
|
-
* @template {FlagValue} T A optional generic argument constraining the default.
|
|
11
|
-
* @param {T} defaultValue the default value; used to determine what resolved type should be used.
|
|
12
|
-
* @param {ReactFlagEvaluationOptions} options for this evaluation
|
|
13
|
-
* @returns { FlagQuery } a queryable object containing useful information about the flag.
|
|
14
|
-
*/
|
|
15
|
-
export declare function useFlag<T extends FlagValue = FlagValue>(flagKey: ConstrainedFlagKey<T>, defaultValue: T, options?: ReactFlagEvaluationOptions): FlagQuery<T extends boolean ? boolean : T extends number ? number : T extends string ? string : T extends JsonValue ? T : JsonValue>;
|
|
16
|
-
type UseFlagReturn<T extends FlagValue> = ReturnType<typeof useFlag<T>>;
|
|
17
|
-
/**
|
|
18
|
-
* Equivalent to {@link useFlag} with `options: { suspend: true }`
|
|
19
|
-
* @experimental Suspense is an experimental feature subject to change in future versions.
|
|
20
|
-
* @param {ConstrainedFlagKey<T>} flagKey the flag identifier
|
|
21
|
-
* @template {FlagValue} T A optional generic argument constraining the default.
|
|
22
|
-
* @param {T} defaultValue the default value; used to determine what resolved type should be used.
|
|
23
|
-
* @param {ReactFlagEvaluationNoSuspenseOptions} options for this evaluation
|
|
24
|
-
* @returns { UseFlagReturn<T> } a queryable object containing useful information about the flag.
|
|
25
|
-
*/
|
|
26
|
-
export declare function useSuspenseFlag<T extends FlagValue = FlagValue>(flagKey: ConstrainedFlagKey<T>, defaultValue: T, options?: ReactFlagEvaluationNoSuspenseOptions): UseFlagReturn<T>;
|
|
27
|
-
/**
|
|
28
|
-
* Evaluates a feature flag, returning a boolean.
|
|
29
|
-
* By default, components will re-render when the flag value changes.
|
|
30
|
-
* For a generic hook returning a queryable interface, see {@link useFlag}.
|
|
31
|
-
* @param {BooleanFlagKey} flagKey the flag identifier
|
|
32
|
-
* @param {boolean} defaultValue the default value
|
|
33
|
-
* @param {ReactFlagEvaluationOptions} options options for this evaluation
|
|
34
|
-
* @returns { boolean} a EvaluationDetails object for this evaluation
|
|
35
|
-
*/
|
|
36
|
-
export declare function useBooleanFlagValue(flagKey: BooleanFlagKey, defaultValue: boolean, options?: ReactFlagEvaluationOptions): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Evaluates a feature flag, returning evaluation details.
|
|
39
|
-
* By default, components will re-render when the flag value changes.
|
|
40
|
-
* For a generic hook returning a queryable interface, see {@link useFlag}.
|
|
41
|
-
* @param {BooleanFlagKey} flagKey the flag identifier
|
|
42
|
-
* @param {boolean} defaultValue the default value
|
|
43
|
-
* @param {ReactFlagEvaluationOptions} options options for this evaluation
|
|
44
|
-
* @returns { EvaluationDetails<boolean>} a EvaluationDetails object for this evaluation
|
|
45
|
-
*/
|
|
46
|
-
export declare function useBooleanFlagDetails(flagKey: BooleanFlagKey, defaultValue: boolean, options?: ReactFlagEvaluationOptions): EvaluationDetails<boolean>;
|
|
47
|
-
/**
|
|
48
|
-
* Evaluates a feature flag, returning a string.
|
|
49
|
-
* By default, components will re-render when the flag value changes.
|
|
50
|
-
* For a generic hook returning a queryable interface, see {@link useFlag}.
|
|
51
|
-
* @param {StringFlagKey} flagKey the flag identifier
|
|
52
|
-
* @template {string} [T=string] A optional generic argument constraining the string
|
|
53
|
-
* @param {T} defaultValue the default value
|
|
54
|
-
* @param {ReactFlagEvaluationOptions} options options for this evaluation
|
|
55
|
-
* @returns { boolean} a EvaluationDetails object for this evaluation
|
|
56
|
-
*/
|
|
57
|
-
export declare function useStringFlagValue<T extends string = string>(flagKey: StringFlagKey, defaultValue: T, options?: ReactFlagEvaluationOptions): string;
|
|
58
|
-
/**
|
|
59
|
-
* Evaluates a feature flag, returning evaluation details.
|
|
60
|
-
* By default, components will re-render when the flag value changes.
|
|
61
|
-
* For a generic hook returning a queryable interface, see {@link useFlag}.
|
|
62
|
-
* @param {StringFlagKey} flagKey the flag identifier
|
|
63
|
-
* @template {string} [T=string] A optional generic argument constraining the string
|
|
64
|
-
* @param {T} defaultValue the default value
|
|
65
|
-
* @param {ReactFlagEvaluationOptions} options options for this evaluation
|
|
66
|
-
* @returns { EvaluationDetails<string>} a EvaluationDetails object for this evaluation
|
|
67
|
-
*/
|
|
68
|
-
export declare function useStringFlagDetails<T extends string = string>(flagKey: StringFlagKey, defaultValue: T, options?: ReactFlagEvaluationOptions): EvaluationDetails<string>;
|
|
69
|
-
/**
|
|
70
|
-
* Evaluates a feature flag, returning a number.
|
|
71
|
-
* By default, components will re-render when the flag value changes.
|
|
72
|
-
* For a generic hook returning a queryable interface, see {@link useFlag}.
|
|
73
|
-
* @param {NumberFlagKey} flagKey the flag identifier
|
|
74
|
-
* @template {number} [T=number] A optional generic argument constraining the number
|
|
75
|
-
* @param {T} defaultValue the default value
|
|
76
|
-
* @param {ReactFlagEvaluationOptions} options options for this evaluation
|
|
77
|
-
* @returns { boolean} a EvaluationDetails object for this evaluation
|
|
78
|
-
*/
|
|
79
|
-
export declare function useNumberFlagValue<T extends number = number>(flagKey: NumberFlagKey, defaultValue: T, options?: ReactFlagEvaluationOptions): number;
|
|
80
|
-
/**
|
|
81
|
-
* Evaluates a feature flag, returning evaluation details.
|
|
82
|
-
* By default, components will re-render when the flag value changes.
|
|
83
|
-
* For a generic hook returning a queryable interface, see {@link useFlag}.
|
|
84
|
-
* @param {NumberFlagKey} flagKey the flag identifier
|
|
85
|
-
* @template {number} [T=number] A optional generic argument constraining the number
|
|
86
|
-
* @param {T} defaultValue the default value
|
|
87
|
-
* @param {ReactFlagEvaluationOptions} options options for this evaluation
|
|
88
|
-
* @returns { EvaluationDetails<number>} a EvaluationDetails object for this evaluation
|
|
89
|
-
*/
|
|
90
|
-
export declare function useNumberFlagDetails<T extends number = number>(flagKey: NumberFlagKey, defaultValue: T, options?: ReactFlagEvaluationOptions): EvaluationDetails<number>;
|
|
91
|
-
/**
|
|
92
|
-
* Evaluates a feature flag, returning an object.
|
|
93
|
-
* By default, components will re-render when the flag value changes.
|
|
94
|
-
* For a generic hook returning a queryable interface, see {@link useFlag}.
|
|
95
|
-
* @param {ObjectFlagKey} flagKey the flag identifier
|
|
96
|
-
* @template {JsonValue} [T=JsonValue] A optional generic argument describing the structure
|
|
97
|
-
* @param {T} defaultValue the default value
|
|
98
|
-
* @param {ReactFlagEvaluationOptions} options options for this evaluation
|
|
99
|
-
* @returns { boolean} a EvaluationDetails object for this evaluation
|
|
100
|
-
*/
|
|
101
|
-
export declare function useObjectFlagValue<T extends JsonValue = JsonValue>(flagKey: ObjectFlagKey, defaultValue: T, options?: ReactFlagEvaluationOptions): T;
|
|
102
|
-
/**
|
|
103
|
-
* Evaluates a feature flag, returning evaluation details.
|
|
104
|
-
* By default, components will re-render when the flag value changes.
|
|
105
|
-
* For a generic hook returning a queryable interface, see {@link useFlag}.
|
|
106
|
-
* @param {ObjectFlagKey} flagKey the flag identifier
|
|
107
|
-
* @param {T} defaultValue the default value
|
|
108
|
-
* @template {JsonValue} [T=JsonValue] A optional generic argument describing the structure
|
|
109
|
-
* @param {ReactFlagEvaluationOptions} options options for this evaluation
|
|
110
|
-
* @returns { EvaluationDetails<T>} a EvaluationDetails object for this evaluation
|
|
111
|
-
*/
|
|
112
|
-
export declare function useObjectFlagDetails<T extends JsonValue = JsonValue>(flagKey: ObjectFlagKey, defaultValue: T, options?: ReactFlagEvaluationOptions): EvaluationDetails<T>;
|
|
113
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { EvaluationDetails, FlagValue } from '../sdk';
|
|
2
|
-
import type { FlagQuery } from '../query';
|
|
3
|
-
export declare class HookFlagQuery<T extends FlagValue = FlagValue> implements FlagQuery {
|
|
4
|
-
private _details;
|
|
5
|
-
constructor(_details: EvaluationDetails<T>);
|
|
6
|
-
get details(): EvaluationDetails<T>;
|
|
7
|
-
get value(): T;
|
|
8
|
-
get variant(): string | undefined;
|
|
9
|
-
get flagMetadata(): Readonly<import("..").FlagMetadata> & import("..").FlagMetadata;
|
|
10
|
-
get reason(): import("..").ResolutionReason | undefined;
|
|
11
|
-
get isError(): boolean;
|
|
12
|
-
get errorCode(): import("..").ErrorCode | undefined;
|
|
13
|
-
get errorMessage(): string | undefined;
|
|
14
|
-
get isAuthoritative(): boolean;
|
|
15
|
-
get type(): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
16
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Client, Provider } from '../sdk';
|
|
2
|
-
/**
|
|
3
|
-
* Suspends until the client is ready to evaluate feature flags.
|
|
4
|
-
*
|
|
5
|
-
* **DO NOT EXPORT PUBLICLY**
|
|
6
|
-
* @internal
|
|
7
|
-
* @param {Provider} provider the provider to suspend for
|
|
8
|
-
* @param {Client} client the client to check for readiness
|
|
9
|
-
*/
|
|
10
|
-
export declare function suspendUntilInitialized(provider: Provider, client: Client): void;
|
|
11
|
-
/**
|
|
12
|
-
* Suspends until the provider has finished reconciling.
|
|
13
|
-
*
|
|
14
|
-
* **DO NOT EXPORT PUBLICLY**
|
|
15
|
-
* @internal
|
|
16
|
-
* @param {Client} client the client to check for readiness
|
|
17
|
-
*/
|
|
18
|
-
export declare function suspendUntilReconciled(client: Client): void;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { JsonValue, Provider } from '../sdk';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { OpenFeatureProvider } from './provider';
|
|
4
|
-
type FlagValueMap = {
|
|
5
|
-
[flagKey: string]: JsonValue;
|
|
6
|
-
};
|
|
7
|
-
type TestProviderProps = Omit<React.ComponentProps<typeof OpenFeatureProvider>, 'client'> & ({
|
|
8
|
-
provider?: never;
|
|
9
|
-
/**
|
|
10
|
-
* Optional map of flagKeys to flagValues for this OpenFeatureTestProvider context.
|
|
11
|
-
* If not supplied, all flag evaluations will default.
|
|
12
|
-
*/
|
|
13
|
-
flagValueMap?: FlagValueMap;
|
|
14
|
-
/**
|
|
15
|
-
* Optional delay for the underlying test provider's readiness and reconciliation.
|
|
16
|
-
* Defaults to 0.
|
|
17
|
-
*/
|
|
18
|
-
delayMs?: number;
|
|
19
|
-
} | {
|
|
20
|
-
/**
|
|
21
|
-
* An optional partial provider to pass for full control over the flag resolution for this OpenFeatureTestProvider context.
|
|
22
|
-
* Any un-implemented methods or properties will no-op.
|
|
23
|
-
*/
|
|
24
|
-
provider?: Partial<Provider>;
|
|
25
|
-
flagValueMap?: never;
|
|
26
|
-
delayMs?: never;
|
|
27
|
-
});
|
|
28
|
-
/**
|
|
29
|
-
* A React Context provider based on the {@link TypedInMemoryProvider}, specifically built for testing.
|
|
30
|
-
* Use this for testing components that use flag evaluation hooks.
|
|
31
|
-
* @param {TestProviderProps} testProviderOptions options for the OpenFeatureTestProvider
|
|
32
|
-
* @returns {OpenFeatureProvider} OpenFeatureTestProvider
|
|
33
|
-
*/
|
|
34
|
-
export declare function OpenFeatureTestProvider(testProviderOptions: TestProviderProps): React.JSX.Element;
|
|
35
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ProviderStatus } from '../sdk';
|
|
2
|
-
/**
|
|
3
|
-
* Get the {@link ProviderStatus} for the OpenFeatureClient.
|
|
4
|
-
* Reacts to changes in provider status.
|
|
5
|
-
* @returns {ProviderStatus} status of the client for this scope
|
|
6
|
-
*/
|
|
7
|
-
export declare function useOpenFeatureClientStatus(): ProviderStatus;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type Client } from '../sdk';
|
|
2
|
-
/**
|
|
3
|
-
* Get the {@link Client} instance for this OpenFeatureProvider context.
|
|
4
|
-
* Note that the provider to which this is bound is determined by the OpenFeatureProvider's domain.
|
|
5
|
-
* @returns {Client} client for this scope
|
|
6
|
-
*/
|
|
7
|
-
export declare function useOpenFeatureClient(): Client;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Provider } from '../sdk';
|
|
2
|
-
/**
|
|
3
|
-
* Get the {@link Provider} bound to the domain specified in the OpenFeatureProvider context.
|
|
4
|
-
* Note that it isn't recommended to interact with the provider directly, but rather through
|
|
5
|
-
* an OpenFeature client.
|
|
6
|
-
* @returns {Provider} provider for this scope
|
|
7
|
-
*/
|
|
8
|
-
export declare function useOpenFeatureProvider(): Provider;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ReactFlagEvaluationOptions } from '../options';
|
|
2
|
-
type Options = Pick<ReactFlagEvaluationOptions, 'suspendUntilReady'>;
|
|
3
|
-
/**
|
|
4
|
-
* Utility hook that triggers suspense until the provider is {@link ProviderStatus.READY}, without evaluating any flags.
|
|
5
|
-
* Especially useful for React v16/17 "Legacy Suspense", in which siblings to suspending components are
|
|
6
|
-
* initially mounted and then hidden (see: https://github.com/reactwg/react-18/discussions/7).
|
|
7
|
-
*
|
|
8
|
-
* NOTE: This hook returns true only when the provider status is {@link ProviderStatus.READY}.
|
|
9
|
-
* For other statuses (ERROR, STALE, FATAL, RECONCILING), use {@link useOpenFeatureClientStatus}.
|
|
10
|
-
* @param {Options} options options for suspense
|
|
11
|
-
* @returns {boolean} boolean indicating if provider is {@link ProviderStatus.READY}, useful if suspense is disabled and you want to handle loaders on your own
|
|
12
|
-
*/
|
|
13
|
-
export declare function useWhenProviderReady(options?: Options): boolean;
|
|
14
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ProviderStatus, type Client, type EvaluationContext, type Hook, type Provider } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* The OpenFeature singleton. One provider + one evaluation context per **domain**;
|
|
4
|
-
* the default provider / context serve every domain that has none of its own.
|
|
5
|
-
*/
|
|
6
|
-
export declare class OpenFeatureAPI {
|
|
7
|
-
private _defaultProvider;
|
|
8
|
-
private _domainProviders;
|
|
9
|
-
private _context;
|
|
10
|
-
private _domainContext;
|
|
11
|
-
private _emitters;
|
|
12
|
-
private _hooks;
|
|
13
|
-
static getInstance(): OpenFeatureAPI;
|
|
14
|
-
/** Sync version: errors during init are logged, status tells the rest. */
|
|
15
|
-
setProvider(provider: Provider): this;
|
|
16
|
-
setProvider(provider: Provider, context: EvaluationContext): this;
|
|
17
|
-
setProvider(domain: string, provider: Provider): this;
|
|
18
|
-
setProvider(domain: string, provider: Provider, context: EvaluationContext): this;
|
|
19
|
-
/** Resolves when the provider is READY (rejects if its initialize() fails). */
|
|
20
|
-
setProviderAndWait(provider: Provider): Promise<void>;
|
|
21
|
-
setProviderAndWait(provider: Provider, context: EvaluationContext): Promise<void>;
|
|
22
|
-
setProviderAndWait(domain: string, provider: Provider): Promise<void>;
|
|
23
|
-
setProviderAndWait(domain: string, provider: Provider, context: EvaluationContext): Promise<void>;
|
|
24
|
-
private set;
|
|
25
|
-
getProvider(domain?: string): Provider;
|
|
26
|
-
getProviderStatus(domain?: string): ProviderStatus;
|
|
27
|
-
private wrapperFor;
|
|
28
|
-
clearProviders(): Promise<void>;
|
|
29
|
-
getContext(domain?: string): EvaluationContext;
|
|
30
|
-
/** Set the global context (domain omitted) or one domain's context. Providers get `onContextChange`; clients get `ContextChanged`. */
|
|
31
|
-
setContext(context: EvaluationContext): Promise<void>;
|
|
32
|
-
setContext(domain: string, context: EvaluationContext): Promise<void>;
|
|
33
|
-
clearContext(domain?: string): Promise<void>;
|
|
34
|
-
private contextChanged;
|
|
35
|
-
getClient(domain?: string, version?: string): Client;
|
|
36
|
-
addHooks(...hooks: Hook[]): this;
|
|
37
|
-
clearHooks(): this;
|
|
38
|
-
getHooks(): Hook[];
|
|
39
|
-
private emitterOf;
|
|
40
|
-
/** Events of the default provider also reach domains that have no provider of their own. */
|
|
41
|
-
private emit;
|
|
42
|
-
}
|
|
43
|
-
export declare const OpenFeature: OpenFeatureAPI;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { EventEmitter } from './events';
|
|
2
|
-
import { ProviderStatus, type Client, type ClientMetadata, type EvaluationContext, type EvaluationDetails, type EventHandler, type EventOptions, type FlagEvaluationOptions, type Hook, type JsonValue, type Logger, type Provider, type ProviderEvents, type TrackingEventDetails } from './types';
|
|
3
|
-
export type ClientAccessors = {
|
|
4
|
-
provider: () => Provider;
|
|
5
|
-
status: () => ProviderStatus;
|
|
6
|
-
emitter: () => EventEmitter;
|
|
7
|
-
context: (domain?: string) => EvaluationContext;
|
|
8
|
-
apiHooks: () => Hook[];
|
|
9
|
-
logger: () => Logger;
|
|
10
|
-
};
|
|
11
|
-
export declare const registerStatusEvents: (m: Partial<Record<ProviderStatus, ProviderEvents>>) => Partial<Record<ProviderStatus, ProviderEvents>>;
|
|
12
|
-
/**
|
|
13
|
-
* Client bound to a domain. Everything it needs is read through accessors, so it always sees the
|
|
14
|
-
* current provider / status / context even if they are replaced after the client was created.
|
|
15
|
-
*/
|
|
16
|
-
export declare class OpenFeatureClient implements Client {
|
|
17
|
-
private readonly a;
|
|
18
|
-
private readonly options;
|
|
19
|
-
private _hooks;
|
|
20
|
-
constructor(a: ClientAccessors, options: {
|
|
21
|
-
domain?: string;
|
|
22
|
-
version?: string;
|
|
23
|
-
});
|
|
24
|
-
get metadata(): ClientMetadata;
|
|
25
|
-
get providerStatus(): ProviderStatus;
|
|
26
|
-
addHandler<E extends ProviderEvents>(eventType: E, handler: EventHandler<E>, options?: EventOptions): void;
|
|
27
|
-
removeHandler<E extends ProviderEvents>(eventType: E, handler: EventHandler<E>): void;
|
|
28
|
-
addHooks(...hooks: Hook[]): this;
|
|
29
|
-
getHooks(): Hook[];
|
|
30
|
-
clearHooks(): this;
|
|
31
|
-
getBooleanValue(k: string, d: boolean, o?: FlagEvaluationOptions): boolean;
|
|
32
|
-
getBooleanDetails(k: string, d: boolean, o?: FlagEvaluationOptions): EvaluationDetails<boolean>;
|
|
33
|
-
getStringValue<T extends string = string>(k: string, d: T, o?: FlagEvaluationOptions): T;
|
|
34
|
-
getStringDetails<T extends string = string>(k: string, d: T, o?: FlagEvaluationOptions): EvaluationDetails<T>;
|
|
35
|
-
getNumberValue<T extends number = number>(k: string, d: T, o?: FlagEvaluationOptions): T;
|
|
36
|
-
getNumberDetails<T extends number = number>(k: string, d: T, o?: FlagEvaluationOptions): EvaluationDetails<T>;
|
|
37
|
-
getObjectValue<T extends JsonValue = JsonValue>(k: string, d: T, o?: FlagEvaluationOptions): T;
|
|
38
|
-
getObjectDetails<T extends JsonValue = JsonValue>(k: string, d: T, o?: FlagEvaluationOptions): EvaluationDetails<T>;
|
|
39
|
-
track(name: string, details?: TrackingEventDetails): void;
|
|
40
|
-
/** The heart of a flag read: hooks -> provider -> hooks, never throws. */
|
|
41
|
-
private evaluate;
|
|
42
|
-
private runAll;
|
|
43
|
-
private get provider();
|
|
44
|
-
private shortCircuitIfNotReady;
|
|
45
|
-
private errorDetails;
|
|
46
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ErrorCode } from './types';
|
|
2
|
-
export declare abstract class OpenFeatureError extends Error {
|
|
3
|
-
abstract code: ErrorCode;
|
|
4
|
-
constructor(message?: string);
|
|
5
|
-
}
|
|
6
|
-
export declare class GeneralError extends OpenFeatureError {
|
|
7
|
-
code: ErrorCode;
|
|
8
|
-
constructor(m?: string);
|
|
9
|
-
}
|
|
10
|
-
export declare class FlagNotFoundError extends OpenFeatureError {
|
|
11
|
-
code: ErrorCode;
|
|
12
|
-
constructor(m?: string);
|
|
13
|
-
}
|
|
14
|
-
export declare class ParseError extends OpenFeatureError {
|
|
15
|
-
code: ErrorCode;
|
|
16
|
-
constructor(m?: string);
|
|
17
|
-
}
|
|
18
|
-
export declare class TypeMismatchError extends OpenFeatureError {
|
|
19
|
-
code: ErrorCode;
|
|
20
|
-
constructor(m?: string);
|
|
21
|
-
}
|
|
22
|
-
export declare class TargetingKeyMissingError extends OpenFeatureError {
|
|
23
|
-
code: ErrorCode;
|
|
24
|
-
constructor(m?: string);
|
|
25
|
-
}
|
|
26
|
-
export declare class InvalidContextError extends OpenFeatureError {
|
|
27
|
-
code: ErrorCode;
|
|
28
|
-
constructor(m?: string);
|
|
29
|
-
}
|
|
30
|
-
export declare class ProviderNotReadyError extends OpenFeatureError {
|
|
31
|
-
code: ErrorCode;
|
|
32
|
-
constructor(m?: string);
|
|
33
|
-
}
|
|
34
|
-
export declare class ProviderFatalError extends OpenFeatureError {
|
|
35
|
-
code: ErrorCode;
|
|
36
|
-
constructor(m?: string);
|
|
37
|
-
}
|
|
38
|
-
export declare const instantiateErrorByErrorCode: (code: ErrorCode, message?: string) => OpenFeatureError;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ConfigChangeDetails, EventHandler, ProviderEventEmitter, ProviderEvents } from './types';
|
|
2
|
-
/** Tiny event emitter: used by providers (`provider.events`) and by the API (one per domain). */
|
|
3
|
-
export declare class EventEmitter implements ProviderEventEmitter {
|
|
4
|
-
private handlers;
|
|
5
|
-
addHandler(event: ProviderEvents, handler: EventHandler): void;
|
|
6
|
-
removeHandler(event: ProviderEvents, handler: EventHandler): void;
|
|
7
|
-
getHandlers(event: ProviderEvents): EventHandler[];
|
|
8
|
-
emit(event: ProviderEvents, details?: ConfigChangeDetails): void;
|
|
9
|
-
}
|
|
10
|
-
export declare const OpenFeatureEventEmitter: typeof EventEmitter;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Local OpenFeature client SDK (what the React layer needs from @openfeature/web-sdk + @openfeature/core). */
|
|
2
|
-
export * from './types';
|
|
3
|
-
export * from './errors';
|
|
4
|
-
export * from './events';
|
|
5
|
-
export { OpenFeature, OpenFeatureAPI } from './api';
|
|
6
|
-
export { OpenFeatureClient } from './client';
|
|
7
|
-
export { NOOP_PROVIDER, TypedInMemoryProvider, InMemoryProvider, withFrameworkMetadata } from './providers';
|
|
8
|
-
export type { InMemoryFlagConfiguration, InMemoryFlag, FlagVariants } from './providers';
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from './events';
|
|
2
|
-
import { type EvaluationContext, type JsonValue, type Logger, type Provider, type ResolutionDetails } from './types';
|
|
3
|
-
/** Default provider: always answers with the default value. */
|
|
4
|
-
declare class NoopFeatureProvider implements Provider {
|
|
5
|
-
readonly metadata: {
|
|
6
|
-
readonly name: "No-op Provider";
|
|
7
|
-
};
|
|
8
|
-
resolveBooleanEvaluation(_: string, d: boolean): ResolutionDetails<boolean>;
|
|
9
|
-
resolveStringEvaluation(_: string, d: string): ResolutionDetails<string>;
|
|
10
|
-
resolveNumberEvaluation(_: string, d: number): ResolutionDetails<number>;
|
|
11
|
-
resolveObjectEvaluation<T extends JsonValue>(_: string, d: T): ResolutionDetails<T>;
|
|
12
|
-
private noOp;
|
|
13
|
-
}
|
|
14
|
-
export declare const NOOP_PROVIDER: NoopFeatureProvider;
|
|
15
|
-
export type FlagVariants<V extends string = string> = {
|
|
16
|
-
variants: Record<V, JsonValue>;
|
|
17
|
-
defaultVariant: V;
|
|
18
|
-
};
|
|
19
|
-
export type InMemoryFlag = FlagVariants & {
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
contextEvaluator?: (ctx: EvaluationContext) => string;
|
|
22
|
-
};
|
|
23
|
-
export type InMemoryFlagConfiguration = Record<string, InMemoryFlag>;
|
|
24
|
-
export declare class TypedInMemoryProvider implements Provider {
|
|
25
|
-
readonly events: EventEmitter;
|
|
26
|
-
readonly runsOn: "client";
|
|
27
|
-
readonly metadata: {
|
|
28
|
-
readonly name: "in-memory";
|
|
29
|
-
};
|
|
30
|
-
/** Optional: assigned by subclasses that want a delayed start. */
|
|
31
|
-
initialize?: Provider['initialize'];
|
|
32
|
-
private config;
|
|
33
|
-
constructor(config?: InMemoryFlagConfiguration);
|
|
34
|
-
putConfiguration(config: InMemoryFlagConfiguration): Promise<void>;
|
|
35
|
-
resolveBooleanEvaluation(k: string, d: boolean, c?: EvaluationContext, l?: Logger): ResolutionDetails<boolean>;
|
|
36
|
-
resolveStringEvaluation(k: string, d: string, c?: EvaluationContext, l?: Logger): ResolutionDetails<string>;
|
|
37
|
-
resolveNumberEvaluation(k: string, d: number, c?: EvaluationContext, l?: Logger): ResolutionDetails<number>;
|
|
38
|
-
resolveObjectEvaluation<T extends JsonValue>(k: string, d: T, c?: EvaluationContext, l?: Logger): ResolutionDetails<T>;
|
|
39
|
-
private resolve;
|
|
40
|
-
}
|
|
41
|
-
export declare const InMemoryProvider: typeof TypedInMemoryProvider;
|
|
42
|
-
/** Wraps a client so `metadata.framework` is set (the React layer passes 'react'). */
|
|
43
|
-
export declare function withFrameworkMetadata<T extends {
|
|
44
|
-
metadata: object;
|
|
45
|
-
}>(client: T, framework: string): T;
|
|
46
|
-
export {};
|