mirror of https://github.com/open-feature/cli.git
235 lines
10 KiB
Plaintext
235 lines
10 KiB
Plaintext
// AUTOMATICALLY GENERATED BY OPENFEATURE CLI, DO NOT EDIT.
|
|
import {
|
|
OpenFeature,
|
|
stringOrUndefined,
|
|
objectOrUndefined,
|
|
JsonValue,
|
|
} from "@openfeature/server-sdk";
|
|
import type {
|
|
EvaluationContext,
|
|
EvaluationDetails,
|
|
FlagEvaluationOptions,
|
|
} from "@openfeature/server-sdk";
|
|
|
|
export interface GeneratedClient {
|
|
/**
|
|
* Discount percentage applied to purchases.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `discountPercentage`
|
|
* - default value: `0.15`
|
|
* - type: `number`
|
|
*
|
|
* Performs a flag evaluation that returns a number.
|
|
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
|
|
* @param {FlagEvaluationOptions} options Additional flag evaluation options
|
|
* @returns {Promise<number>} Flag evaluation response
|
|
*/
|
|
discountPercentage(context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<number>;
|
|
|
|
/**
|
|
* Discount percentage applied to purchases.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `discountPercentage`
|
|
* - default value: `0.15`
|
|
* - type: `number`
|
|
*
|
|
* Performs a flag evaluation that a returns an evaluation details object.
|
|
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
|
|
* @param {FlagEvaluationOptions} options Additional flag evaluation options
|
|
* @returns {Promise<EvaluationDetails<number>>} Flag evaluation details response
|
|
*/
|
|
discountPercentageDetails(context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<EvaluationDetails<number>>;
|
|
|
|
/**
|
|
* Controls whether Feature A is enabled.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `enableFeatureA`
|
|
* - default value: `false`
|
|
* - type: `boolean`
|
|
*
|
|
* Performs a flag evaluation that returns a boolean.
|
|
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
|
|
* @param {FlagEvaluationOptions} options Additional flag evaluation options
|
|
* @returns {Promise<boolean>} Flag evaluation response
|
|
*/
|
|
enableFeatureA(context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<boolean>;
|
|
|
|
/**
|
|
* Controls whether Feature A is enabled.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `enableFeatureA`
|
|
* - default value: `false`
|
|
* - type: `boolean`
|
|
*
|
|
* Performs a flag evaluation that a returns an evaluation details object.
|
|
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
|
|
* @param {FlagEvaluationOptions} options Additional flag evaluation options
|
|
* @returns {Promise<EvaluationDetails<boolean>>} Flag evaluation details response
|
|
*/
|
|
enableFeatureADetails(context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<EvaluationDetails<boolean>>;
|
|
|
|
/**
|
|
* The message to use for greeting users.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `greetingMessage`
|
|
* - default value: `Hello there!`
|
|
* - type: `string`
|
|
*
|
|
* Performs a flag evaluation that returns a string.
|
|
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
|
|
* @param {FlagEvaluationOptions} options Additional flag evaluation options
|
|
* @returns {Promise<string>} Flag evaluation response
|
|
*/
|
|
greetingMessage(context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<string>;
|
|
|
|
/**
|
|
* The message to use for greeting users.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `greetingMessage`
|
|
* - default value: `Hello there!`
|
|
* - type: `string`
|
|
*
|
|
* Performs a flag evaluation that a returns an evaluation details object.
|
|
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
|
|
* @param {FlagEvaluationOptions} options Additional flag evaluation options
|
|
* @returns {Promise<EvaluationDetails<string>>} Flag evaluation details response
|
|
*/
|
|
greetingMessageDetails(context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<EvaluationDetails<string>>;
|
|
|
|
/**
|
|
* Allows customization of theme colors.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `themeCustomization`
|
|
* - default value: `{"primaryColor":"#007bff","secondaryColor":"#6c757d"}`
|
|
* - type: `JsonValue`
|
|
*
|
|
* Performs a flag evaluation that returns a object.
|
|
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
|
|
* @param {FlagEvaluationOptions} options Additional flag evaluation options
|
|
* @returns {Promise<JsonValue>} Flag evaluation response
|
|
*/
|
|
themeCustomization(context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<JsonValue>;
|
|
|
|
/**
|
|
* Allows customization of theme colors.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `themeCustomization`
|
|
* - default value: `{"primaryColor":"#007bff","secondaryColor":"#6c757d"}`
|
|
* - type: `JsonValue`
|
|
*
|
|
* Performs a flag evaluation that a returns an evaluation details object.
|
|
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
|
|
* @param {FlagEvaluationOptions} options Additional flag evaluation options
|
|
* @returns {Promise<EvaluationDetails<JsonValue>>} Flag evaluation details response
|
|
*/
|
|
themeCustomizationDetails(context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<EvaluationDetails<JsonValue>>;
|
|
|
|
/**
|
|
* Maximum allowed length for usernames.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `usernameMaxLength`
|
|
* - default value: `50`
|
|
* - type: `number`
|
|
*
|
|
* Performs a flag evaluation that returns a number.
|
|
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
|
|
* @param {FlagEvaluationOptions} options Additional flag evaluation options
|
|
* @returns {Promise<number>} Flag evaluation response
|
|
*/
|
|
usernameMaxLength(context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<number>;
|
|
|
|
/**
|
|
* Maximum allowed length for usernames.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `usernameMaxLength`
|
|
* - default value: `50`
|
|
* - type: `number`
|
|
*
|
|
* Performs a flag evaluation that a returns an evaluation details object.
|
|
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
|
|
* @param {FlagEvaluationOptions} options Additional flag evaluation options
|
|
* @returns {Promise<EvaluationDetails<number>>} Flag evaluation details response
|
|
*/
|
|
usernameMaxLengthDetails(context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<EvaluationDetails<number>>;
|
|
}
|
|
|
|
/**
|
|
* A factory function that returns a generated client that not bound to a domain.
|
|
* It was generated using the OpenFeature CLI and is compatible with `@openfeature/server-sdk`.
|
|
*
|
|
* All domainless or unbound clients use the default provider set via {@link OpenFeature.setProvider}.
|
|
* @param {EvaluationContext} context Evaluation context that should be set on the client to used during flag evaluations
|
|
* @returns {GeneratedClient} Generated OpenFeature Client
|
|
*/
|
|
export function getGeneratedClient(context?: EvaluationContext): GeneratedClient
|
|
/**
|
|
* A factory function that returns a domain-bound generated client that was
|
|
* created using the OpenFeature CLI and is compatible with the `@openfeature/server-sdk`.
|
|
*
|
|
* If there is already a provider bound to this domain via {@link OpenFeature.setProvider}, this provider will be used.
|
|
* Otherwise, the default provider is used until a provider is assigned to that domain.
|
|
* @param {string} domain An identifier which logically binds clients with providers
|
|
* @param {EvaluationContext} context Evaluation context that should be set on the client to used during flag evaluations
|
|
* @returns {GeneratedClient} Generated OpenFeature Client
|
|
*/
|
|
export function getGeneratedClient(domain: string, context?: EvaluationContext): GeneratedClient
|
|
export function getGeneratedClient(domainOrContext?: string | EvaluationContext, contextOrUndefined?: EvaluationContext): GeneratedClient {
|
|
const domain = stringOrUndefined(domainOrContext);
|
|
const context =
|
|
objectOrUndefined<EvaluationContext>(domainOrContext) ??
|
|
objectOrUndefined<EvaluationContext>(contextOrUndefined);
|
|
|
|
const client = domain ? OpenFeature.getClient(domain, context) : OpenFeature.getClient(context)
|
|
|
|
return {
|
|
discountPercentage: (context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<number> => {
|
|
return client.getNumberValue("discountPercentage", 0.15, context, options);
|
|
},
|
|
|
|
discountPercentageDetails: (context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<EvaluationDetails<number>> => {
|
|
return client.getNumberDetails("discountPercentage", 0.15, context, options);
|
|
},
|
|
|
|
enableFeatureA: (context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<boolean> => {
|
|
return client.getBooleanValue("enableFeatureA", false, context, options);
|
|
},
|
|
|
|
enableFeatureADetails: (context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<EvaluationDetails<boolean>> => {
|
|
return client.getBooleanDetails("enableFeatureA", false, context, options);
|
|
},
|
|
|
|
greetingMessage: (context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<string> => {
|
|
return client.getStringValue("greetingMessage", "Hello there!", context, options);
|
|
},
|
|
|
|
greetingMessageDetails: (context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<EvaluationDetails<string>> => {
|
|
return client.getStringDetails("greetingMessage", "Hello there!", context, options);
|
|
},
|
|
|
|
themeCustomization: (context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<JsonValue> => {
|
|
return client.getObjectValue("themeCustomization", {"primaryColor":"#007bff","secondaryColor":"#6c757d"}, context, options);
|
|
},
|
|
|
|
themeCustomizationDetails: (context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<EvaluationDetails<JsonValue>> => {
|
|
return client.getObjectDetails("themeCustomization", {"primaryColor":"#007bff","secondaryColor":"#6c757d"}, context, options);
|
|
},
|
|
|
|
usernameMaxLength: (context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<number> => {
|
|
return client.getNumberValue("usernameMaxLength", 50, context, options);
|
|
},
|
|
|
|
usernameMaxLengthDetails: (context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<EvaluationDetails<number>> => {
|
|
return client.getNumberDetails("usernameMaxLength", 50, context, options);
|
|
},
|
|
}
|
|
} |