@openfeature/core
Advanced tools
Comparing version 0.0.18 to 0.0.19
@@ -356,3 +356,3 @@ type FlagValueType = 'boolean' | 'string' | 'number' | 'object'; | ||
interface Hook<T extends FlagValue = FlagValue> { | ||
interface BaseHook<T extends FlagValue = FlagValue, BeforeHookReturn = unknown, HooksReturn = unknown> { | ||
/** | ||
@@ -364,3 +364,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; | ||
/** | ||
@@ -372,3 +372,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; | ||
/** | ||
@@ -380,3 +380,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; | ||
/** | ||
@@ -388,3 +388,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; | ||
} | ||
@@ -400,11 +400,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[]; | ||
/** | ||
@@ -478,7 +478,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; | ||
@@ -491,4 +491,4 @@ protected _logger: Logger; | ||
constructor(category: Paradigm); | ||
addHooks(...hooks: Hook<FlagValue>[]): this; | ||
getHooks(): Hook<FlagValue>[]; | ||
addHooks(...hooks: H[]): this; | ||
getHooks(): H[]; | ||
clearHooks(): this; | ||
@@ -571,2 +571,2 @@ setLogger(logger: Logger): this; | ||
export { BeforeHookContext, ClientMetadata, CommonEventDetails, CommonProvider, ConfigChangeEvent, DefaultLogger, ErrorCode, ErrorEvent, EvaluationContext, EvaluationContextValue, EvaluationDetails, EvaluationLifeCycle, EventContext, EventDetails, EventHandler, EventMetadata, Eventing, FlagMetadata, FlagNotFoundError, FlagValue, FlagValueType, GeneralError, GenericEventEmitter, Hook, HookContext, HookHints, InvalidContextError, JsonArray, JsonObject, JsonValue, LOG_LEVELS, Logger, ManageContext, ManageLogger, Metadata, OpenFeatureCommonAPI, OpenFeatureError, Paradigm, ParseError, PrimitiveValue, ProviderEvents, ProviderMetadata, ProviderStatus, ReadyEvent, ResolutionDetails, ResolutionReason, SafeLogger, StaleEvent, StandardResolutionReasons, TargetingKeyMissingError, TypeMismatchError, isObject, isString, objectOrUndefined, statusMatchesEvent, stringOrUndefined }; | ||
export { BaseHook, BeforeHookContext, ClientMetadata, CommonEventDetails, CommonProvider, ConfigChangeEvent, DefaultLogger, ErrorCode, ErrorEvent, EvaluationContext, EvaluationContextValue, EvaluationDetails, EvaluationLifeCycle, EventContext, EventDetails, EventHandler, EventMetadata, Eventing, FlagMetadata, FlagNotFoundError, FlagValue, FlagValueType, GeneralError, GenericEventEmitter, HookContext, HookHints, InvalidContextError, JsonArray, JsonObject, JsonValue, LOG_LEVELS, Logger, ManageContext, ManageLogger, Metadata, OpenFeatureCommonAPI, OpenFeatureError, Paradigm, ParseError, PrimitiveValue, ProviderEvents, ProviderMetadata, ProviderStatus, ReadyEvent, ResolutionDetails, ResolutionReason, SafeLogger, StaleEvent, StandardResolutionReasons, TargetingKeyMissingError, TypeMismatchError, isObject, isString, objectOrUndefined, statusMatchesEvent, stringOrUndefined }; |
{ | ||
"name": "@openfeature/core", | ||
"version": "0.0.18", | ||
"version": "0.0.19", | ||
"description": "Shared OpenFeature JS components (server and web)", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
156696