@openfeature/server-sdk
Advanced tools
Comparing version 1.7.2 to 1.7.3
@@ -358,3 +358,3 @@ import EventEmitter from 'events'; | ||
interface Hook<T extends FlagValue = FlagValue> { | ||
interface BaseHook<T extends FlagValue = FlagValue, BeforeHookReturn = unknown, HooksReturn = unknown> { | ||
/** | ||
@@ -366,3 +366,3 @@ * Runs before flag values are resolved from the provider. | ||
*/ | ||
before?(hookContext: BeforeHookContext, hookHints?: HookHints): Promise<EvaluationContext | void> | EvaluationContext | void; | ||
before?(hookContext: BeforeHookContext, hookHints?: HookHints): BeforeHookReturn; | ||
/** | ||
@@ -374,3 +374,3 @@ * Runs after flag values are successfully resolved from the provider. | ||
*/ | ||
after?(hookContext: Readonly<HookContext<T>>, evaluationDetails: EvaluationDetails<T>, hookHints?: HookHints): Promise<void> | void; | ||
after?(hookContext: Readonly<HookContext<T>>, evaluationDetails: EvaluationDetails<T>, hookHints?: HookHints): HooksReturn; | ||
/** | ||
@@ -382,3 +382,3 @@ * Runs in the event of an unhandled error or promise rejection during flag resolution, or any attached hooks. | ||
*/ | ||
error?(hookContext: Readonly<HookContext<T>>, error: unknown, hookHints?: HookHints): Promise<void> | void; | ||
error?(hookContext: Readonly<HookContext<T>>, error: unknown, hookHints?: HookHints): HooksReturn; | ||
/** | ||
@@ -390,3 +390,3 @@ * Runs after all other hook stages, regardless of success or error. | ||
*/ | ||
finally?(hookContext: Readonly<HookContext<T>>, hookHints?: HookHints): Promise<void> | void; | ||
finally?(hookContext: Readonly<HookContext<T>>, hookHints?: HookHints): HooksReturn; | ||
} | ||
@@ -402,11 +402,11 @@ | ||
* @template T The type of the receiver | ||
* @param {Hook<FlagValue>[]} hooks A list of hooks that should always run | ||
* @param {BaseHook[]} hooks A list of hooks that should always run | ||
* @returns {T} The receiver (this object) | ||
*/ | ||
addHooks(...hooks: Hook<FlagValue>[]): T; | ||
addHooks(...hooks: BaseHook[]): T; | ||
/** | ||
* Access all the hooks that are registered on this receiver. | ||
* @returns {Hook<FlagValue>[]} A list of the client hooks | ||
* @returns {BaseHook<FlagValue>[]} A list of the client hooks | ||
*/ | ||
getHooks(): Hook<FlagValue>[]; | ||
getHooks(): BaseHook[]; | ||
/** | ||
@@ -480,7 +480,7 @@ * Clears all the hooks that are registered on this receiver. | ||
declare abstract class OpenFeatureCommonAPI<P extends CommonProvider = CommonProvider> implements Eventing, EvaluationLifeCycle<OpenFeatureCommonAPI<P>>, ManageLogger<OpenFeatureCommonAPI<P>> { | ||
declare abstract class OpenFeatureCommonAPI<P extends CommonProvider = CommonProvider, H extends BaseHook = BaseHook> implements Eventing, EvaluationLifeCycle<OpenFeatureCommonAPI<P>>, ManageLogger<OpenFeatureCommonAPI<P>> { | ||
protected abstract _createEventEmitter(): GenericEventEmitter; | ||
protected abstract _defaultProvider: P; | ||
protected abstract readonly _events: GenericEventEmitter; | ||
protected _hooks: Hook[]; | ||
protected _hooks: H[]; | ||
protected _context: EvaluationContext; | ||
@@ -493,4 +493,4 @@ protected _logger: Logger; | ||
constructor(category: Paradigm); | ||
addHooks(...hooks: Hook<FlagValue>[]): this; | ||
getHooks(): Hook<FlagValue>[]; | ||
addHooks(...hooks: H[]): this; | ||
getHooks(): H[]; | ||
clearHooks(): this; | ||
@@ -573,2 +573,4 @@ setLogger(logger: Logger): this; | ||
type Hook = BaseHook<FlagValue, Promise<EvaluationContext | Promise<void>> | EvaluationContext | void, Promise<void> | void>; | ||
interface FlagEvaluationOptions { | ||
@@ -803,4 +805,4 @@ hooks?: Hook[]; | ||
getContext(): EvaluationContext; | ||
addHooks(...hooks: Hook<FlagValue>[]): OpenFeatureClient; | ||
getHooks(): Hook<FlagValue>[]; | ||
addHooks(...hooks: Hook[]): OpenFeatureClient; | ||
getHooks(): Hook[]; | ||
clearHooks(): OpenFeatureClient; | ||
@@ -888,3 +890,3 @@ getBooleanValue(flagKey: string, defaultValue: boolean, context?: EvaluationContext, options?: FlagEvaluationOptions): Promise<boolean>; | ||
declare class OpenFeatureAPI extends OpenFeatureCommonAPI<Provider> implements ManageContext<OpenFeatureAPI>, ManageTransactionContextPropagator<OpenFeatureCommonAPI<Provider>> { | ||
declare class OpenFeatureAPI extends OpenFeatureCommonAPI<Provider, Hook> implements ManageContext<OpenFeatureAPI>, ManageTransactionContextPropagator<OpenFeatureCommonAPI<Provider>> { | ||
protected _events: OpenFeatureEventEmitter; | ||
@@ -953,2 +955,2 @@ protected _defaultProvider: Provider; | ||
export { BeforeHookContext, Client, ClientMetadata, CommonEventDetails, CommonProvider, ConfigChangeEvent, DefaultLogger, ErrorCode, ErrorEvent, EvaluationContext, EvaluationContextValue, EvaluationDetails, EvaluationLifeCycle, EventContext, EventDetails, EventHandler, EventMetadata, Eventing, Features, FlagEvaluationOptions, FlagMetadata, FlagNotFoundError, FlagValue, FlagValueType, GeneralError, GenericEventEmitter, Hook, HookContext, HookHints, InMemoryProvider, InvalidContextError, JsonArray, JsonObject, JsonValue, LOG_LEVELS, Logger, ManageContext, ManageLogger, ManageTransactionContextPropagator, Metadata, NOOP_PROVIDER, NOOP_TRANSACTION_CONTEXT_PROPAGATOR, OpenFeature, OpenFeatureAPI, OpenFeatureClient, OpenFeatureCommonAPI, OpenFeatureError, OpenFeatureEventEmitter, Paradigm, ParseError, PrimitiveValue, Provider, ProviderEvents, ProviderMetadata, ProviderStatus, ReadyEvent, ResolutionDetails, ResolutionReason, SafeLogger, StaleEvent, StandardResolutionReasons, TargetingKeyMissingError, TransactionContext, TransactionContextPropagator, TypeMismatchError, isObject, isString, objectOrUndefined, statusMatchesEvent, stringOrUndefined }; | ||
export { BaseHook, BeforeHookContext, Client, ClientMetadata, CommonEventDetails, CommonProvider, ConfigChangeEvent, DefaultLogger, ErrorCode, ErrorEvent, EvaluationContext, EvaluationContextValue, EvaluationDetails, EvaluationLifeCycle, EventContext, EventDetails, EventHandler, EventMetadata, Eventing, Features, FlagEvaluationOptions, FlagMetadata, FlagNotFoundError, FlagValue, FlagValueType, GeneralError, GenericEventEmitter, Hook, HookContext, HookHints, InMemoryProvider, InvalidContextError, JsonArray, JsonObject, JsonValue, LOG_LEVELS, Logger, ManageContext, ManageLogger, ManageTransactionContextPropagator, Metadata, NOOP_PROVIDER, NOOP_TRANSACTION_CONTEXT_PROPAGATOR, OpenFeature, OpenFeatureAPI, OpenFeatureClient, OpenFeatureCommonAPI, OpenFeatureError, OpenFeatureEventEmitter, Paradigm, ParseError, PrimitiveValue, Provider, ProviderEvents, ProviderMetadata, ProviderStatus, ReadyEvent, ResolutionDetails, ResolutionReason, SafeLogger, StaleEvent, StandardResolutionReasons, TargetingKeyMissingError, TransactionContext, TransactionContextPropagator, TypeMismatchError, isObject, isString, objectOrUndefined, statusMatchesEvent, stringOrUndefined }; |
{ | ||
"name": "@openfeature/server-sdk", | ||
"version": "1.7.2", | ||
"version": "1.7.3", | ||
"description": "OpenFeature SDK for JavaScript", | ||
@@ -51,7 +51,7 @@ "main": "./dist/cjs/index.js", | ||
"peerDependencies": { | ||
"@openfeature/core": "0.0.18" | ||
"@openfeature/core": "0.0.19" | ||
}, | ||
"devDependencies": { | ||
"@openfeature/core": "0.0.18" | ||
"@openfeature/core": "0.0.19" | ||
} | ||
} |
@@ -19,4 +19,4 @@ <!-- markdownlint-disable MD033 --> | ||
<!-- x-release-please-start-version --> | ||
<a href="https://github.com/open-feature/js-sdk/releases/tag/server-sdk-v1.7.2"> | ||
<img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v1.7.2&color=blue&style=for-the-badge" /> | ||
<a href="https://github.com/open-feature/js-sdk/releases/tag/server-sdk-v1.7.3"> | ||
<img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v1.7.3&color=blue&style=for-the-badge" /> | ||
</a> | ||
@@ -23,0 +23,0 @@ <!-- x-release-please-end --> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
178508
1948