Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@openfeature/core

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openfeature/core - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

126

dist/cjs/index.js

@@ -46,2 +46,3 @@ "use strict";

TypeMismatchError: () => TypeMismatchError,
instantiateErrorByErrorCode: () => instantiateErrorByErrorCode,
isObject: () => isObject,

@@ -55,11 +56,2 @@ isString: () => isString,

// src/errors/open-feature-error-abstract.ts
var OpenFeatureError = class _OpenFeatureError extends Error {
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _OpenFeatureError.prototype);
this.name = "OpenFeatureError";
}
};
// src/evaluation/evaluation.ts

@@ -118,10 +110,8 @@ var StandardResolutionReasons = {

// src/errors/general-error.ts
var GeneralError = class _GeneralError extends OpenFeatureError {
code;
// src/errors/open-feature-error-abstract.ts
var OpenFeatureError = class _OpenFeatureError extends Error {
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _GeneralError.prototype);
this.name = "GeneralError";
this.code = "GENERAL" /* GENERAL */;
Object.setPrototypeOf(this, _OpenFeatureError.prototype);
this.name = "OpenFeatureError";
}

@@ -141,43 +131,43 @@ };

// src/errors/parse-error.ts
var ParseError = class _ParseError extends OpenFeatureError {
// src/errors/general-error.ts
var GeneralError = class _GeneralError extends OpenFeatureError {
code;
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _ParseError.prototype);
this.name = "ParseError";
this.code = "PARSE_ERROR" /* PARSE_ERROR */;
Object.setPrototypeOf(this, _GeneralError.prototype);
this.name = "GeneralError";
this.code = "GENERAL" /* GENERAL */;
}
};
// src/errors/type-mismatch-error.ts
var TypeMismatchError = class _TypeMismatchError extends OpenFeatureError {
// src/errors/invalid-context-error.ts
var InvalidContextError = class _InvalidContextError extends OpenFeatureError {
code;
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _TypeMismatchError.prototype);
this.name = "TypeMismatchError";
this.code = "TYPE_MISMATCH" /* TYPE_MISMATCH */;
Object.setPrototypeOf(this, _InvalidContextError.prototype);
this.name = "InvalidContextError";
this.code = "INVALID_CONTEXT" /* INVALID_CONTEXT */;
}
};
// src/errors/targeting-key-missing-error.ts
var TargetingKeyMissingError = class _TargetingKeyMissingError extends OpenFeatureError {
// src/errors/parse-error.ts
var ParseError = class _ParseError extends OpenFeatureError {
code;
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _TargetingKeyMissingError.prototype);
this.name = "TargetingKeyMissingError";
this.code = "TARGETING_KEY_MISSING" /* TARGETING_KEY_MISSING */;
Object.setPrototypeOf(this, _ParseError.prototype);
this.name = "ParseError";
this.code = "PARSE_ERROR" /* PARSE_ERROR */;
}
};
// src/errors/invalid-context-error.ts
var InvalidContextError = class _InvalidContextError extends OpenFeatureError {
// src/errors/provider-fatal-error.ts
var ProviderFatalError = class _ProviderFatalError extends OpenFeatureError {
code;
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _InvalidContextError.prototype);
this.name = "InvalidContextError";
this.code = "INVALID_CONTEXT" /* INVALID_CONTEXT */;
Object.setPrototypeOf(this, _ProviderFatalError.prototype);
this.name = "ProviderFatalError";
this.code = "PROVIDER_FATAL" /* PROVIDER_FATAL */;
}

@@ -197,13 +187,46 @@ };

// src/errors/provider-fatal-error.ts
var ProviderFatalError = class _ProviderFatalError extends OpenFeatureError {
// src/errors/targeting-key-missing-error.ts
var TargetingKeyMissingError = class _TargetingKeyMissingError extends OpenFeatureError {
code;
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _ProviderFatalError.prototype);
this.name = "ProviderFatalError";
this.code = "PROVIDER_FATAL" /* PROVIDER_FATAL */;
Object.setPrototypeOf(this, _TargetingKeyMissingError.prototype);
this.name = "TargetingKeyMissingError";
this.code = "TARGETING_KEY_MISSING" /* TARGETING_KEY_MISSING */;
}
};
// src/errors/type-mismatch-error.ts
var TypeMismatchError = class _TypeMismatchError extends OpenFeatureError {
code;
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _TypeMismatchError.prototype);
this.name = "TypeMismatchError";
this.code = "TYPE_MISMATCH" /* TYPE_MISMATCH */;
}
};
// src/errors/index.ts
var instantiateErrorByErrorCode = (errorCode, message) => {
switch (errorCode) {
case "FLAG_NOT_FOUND" /* FLAG_NOT_FOUND */:
return new FlagNotFoundError(message);
case "PARSE_ERROR" /* PARSE_ERROR */:
return new ParseError(message);
case "TYPE_MISMATCH" /* TYPE_MISMATCH */:
return new TypeMismatchError(message);
case "TARGETING_KEY_MISSING" /* TARGETING_KEY_MISSING */:
return new TargetingKeyMissingError(message);
case "INVALID_CONTEXT" /* INVALID_CONTEXT */:
return new InvalidContextError(message);
case "PROVIDER_NOT_READY" /* PROVIDER_NOT_READY */:
return new ProviderNotReadyError(message);
case "PROVIDER_FATAL" /* PROVIDER_FATAL */:
return new ProviderFatalError(message);
default:
return new GeneralError(message);
}
};
// src/provider/provider.ts

@@ -519,13 +542,2 @@ var ServerProviderStatus = /* @__PURE__ */ ((ServerProviderStatus3) => {

}
async setProviderAndWait(domainOrProvider, providerOrUndefined) {
await this.setAwaitableProvider(domainOrProvider, providerOrUndefined);
}
setProvider(domainOrProvider, providerOrUndefined) {
const maybePromise = this.setAwaitableProvider(domainOrProvider, providerOrUndefined);
if (maybePromise) {
maybePromise.catch(() => {
});
}
return this;
}
setAwaitableProvider(domainOrProvider, providerOrUndefined) {

@@ -551,3 +563,7 @@ const domain = stringOrUndefined(domainOrProvider);

let initializationPromise = void 0;
const wrappedProvider = new ProviderWrapper(provider, this._statusEnumType.NOT_READY, this._statusEnumType);
const wrappedProvider = new ProviderWrapper(
provider,
this._statusEnumType.NOT_READY,
this._statusEnumType
);
if (typeof provider.initialize === "function" && !this.allProviders.includes(provider)) {

@@ -685,3 +701,7 @@ initializationPromise = provider.initialize?.(domain ? this._domainScopedContext.get(domain) ?? this._context : this._context)?.then(() => {

this._domainScopedProviders.clear();
this._defaultProvider = new ProviderWrapper(defaultProvider, this._statusEnumType.NOT_READY, this._statusEnumType);
this._defaultProvider = new ProviderWrapper(
defaultProvider,
this._statusEnumType.NOT_READY,
this._statusEnumType
);
}

@@ -688,0 +708,0 @@ }

@@ -1,10 +0,1 @@

// src/errors/open-feature-error-abstract.ts
var OpenFeatureError = class _OpenFeatureError extends Error {
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _OpenFeatureError.prototype);
this.name = "OpenFeatureError";
}
};
// src/evaluation/evaluation.ts

@@ -63,10 +54,8 @@ var StandardResolutionReasons = {

// src/errors/general-error.ts
var GeneralError = class _GeneralError extends OpenFeatureError {
code;
// src/errors/open-feature-error-abstract.ts
var OpenFeatureError = class _OpenFeatureError extends Error {
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _GeneralError.prototype);
this.name = "GeneralError";
this.code = "GENERAL" /* GENERAL */;
Object.setPrototypeOf(this, _OpenFeatureError.prototype);
this.name = "OpenFeatureError";
}

@@ -86,43 +75,43 @@ };

// src/errors/parse-error.ts
var ParseError = class _ParseError extends OpenFeatureError {
// src/errors/general-error.ts
var GeneralError = class _GeneralError extends OpenFeatureError {
code;
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _ParseError.prototype);
this.name = "ParseError";
this.code = "PARSE_ERROR" /* PARSE_ERROR */;
Object.setPrototypeOf(this, _GeneralError.prototype);
this.name = "GeneralError";
this.code = "GENERAL" /* GENERAL */;
}
};
// src/errors/type-mismatch-error.ts
var TypeMismatchError = class _TypeMismatchError extends OpenFeatureError {
// src/errors/invalid-context-error.ts
var InvalidContextError = class _InvalidContextError extends OpenFeatureError {
code;
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _TypeMismatchError.prototype);
this.name = "TypeMismatchError";
this.code = "TYPE_MISMATCH" /* TYPE_MISMATCH */;
Object.setPrototypeOf(this, _InvalidContextError.prototype);
this.name = "InvalidContextError";
this.code = "INVALID_CONTEXT" /* INVALID_CONTEXT */;
}
};
// src/errors/targeting-key-missing-error.ts
var TargetingKeyMissingError = class _TargetingKeyMissingError extends OpenFeatureError {
// src/errors/parse-error.ts
var ParseError = class _ParseError extends OpenFeatureError {
code;
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _TargetingKeyMissingError.prototype);
this.name = "TargetingKeyMissingError";
this.code = "TARGETING_KEY_MISSING" /* TARGETING_KEY_MISSING */;
Object.setPrototypeOf(this, _ParseError.prototype);
this.name = "ParseError";
this.code = "PARSE_ERROR" /* PARSE_ERROR */;
}
};
// src/errors/invalid-context-error.ts
var InvalidContextError = class _InvalidContextError extends OpenFeatureError {
// src/errors/provider-fatal-error.ts
var ProviderFatalError = class _ProviderFatalError extends OpenFeatureError {
code;
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _InvalidContextError.prototype);
this.name = "InvalidContextError";
this.code = "INVALID_CONTEXT" /* INVALID_CONTEXT */;
Object.setPrototypeOf(this, _ProviderFatalError.prototype);
this.name = "ProviderFatalError";
this.code = "PROVIDER_FATAL" /* PROVIDER_FATAL */;
}

@@ -142,13 +131,46 @@ };

// src/errors/provider-fatal-error.ts
var ProviderFatalError = class _ProviderFatalError extends OpenFeatureError {
// src/errors/targeting-key-missing-error.ts
var TargetingKeyMissingError = class _TargetingKeyMissingError extends OpenFeatureError {
code;
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _ProviderFatalError.prototype);
this.name = "ProviderFatalError";
this.code = "PROVIDER_FATAL" /* PROVIDER_FATAL */;
Object.setPrototypeOf(this, _TargetingKeyMissingError.prototype);
this.name = "TargetingKeyMissingError";
this.code = "TARGETING_KEY_MISSING" /* TARGETING_KEY_MISSING */;
}
};
// src/errors/type-mismatch-error.ts
var TypeMismatchError = class _TypeMismatchError extends OpenFeatureError {
code;
constructor(message, options) {
super(message, options);
Object.setPrototypeOf(this, _TypeMismatchError.prototype);
this.name = "TypeMismatchError";
this.code = "TYPE_MISMATCH" /* TYPE_MISMATCH */;
}
};
// src/errors/index.ts
var instantiateErrorByErrorCode = (errorCode, message) => {
switch (errorCode) {
case "FLAG_NOT_FOUND" /* FLAG_NOT_FOUND */:
return new FlagNotFoundError(message);
case "PARSE_ERROR" /* PARSE_ERROR */:
return new ParseError(message);
case "TYPE_MISMATCH" /* TYPE_MISMATCH */:
return new TypeMismatchError(message);
case "TARGETING_KEY_MISSING" /* TARGETING_KEY_MISSING */:
return new TargetingKeyMissingError(message);
case "INVALID_CONTEXT" /* INVALID_CONTEXT */:
return new InvalidContextError(message);
case "PROVIDER_NOT_READY" /* PROVIDER_NOT_READY */:
return new ProviderNotReadyError(message);
case "PROVIDER_FATAL" /* PROVIDER_FATAL */:
return new ProviderFatalError(message);
default:
return new GeneralError(message);
}
};
// src/provider/provider.ts

@@ -464,13 +486,2 @@ var ServerProviderStatus = /* @__PURE__ */ ((ServerProviderStatus3) => {

}
async setProviderAndWait(domainOrProvider, providerOrUndefined) {
await this.setAwaitableProvider(domainOrProvider, providerOrUndefined);
}
setProvider(domainOrProvider, providerOrUndefined) {
const maybePromise = this.setAwaitableProvider(domainOrProvider, providerOrUndefined);
if (maybePromise) {
maybePromise.catch(() => {
});
}
return this;
}
setAwaitableProvider(domainOrProvider, providerOrUndefined) {

@@ -496,3 +507,7 @@ const domain = stringOrUndefined(domainOrProvider);

let initializationPromise = void 0;
const wrappedProvider = new ProviderWrapper(provider, this._statusEnumType.NOT_READY, this._statusEnumType);
const wrappedProvider = new ProviderWrapper(
provider,
this._statusEnumType.NOT_READY,
this._statusEnumType
);
if (typeof provider.initialize === "function" && !this.allProviders.includes(provider)) {

@@ -630,3 +645,7 @@ initializationPromise = provider.initialize?.(domain ? this._domainScopedContext.get(domain) ?? this._context : this._context)?.then(() => {

this._domainScopedProviders.clear();
this._defaultProvider = new ProviderWrapper(defaultProvider, this._statusEnumType.NOT_READY, this._statusEnumType);
this._defaultProvider = new ProviderWrapper(
defaultProvider,
this._statusEnumType.NOT_READY,
this._statusEnumType
);
}

@@ -669,2 +688,3 @@ }

TypeMismatchError,
instantiateErrorByErrorCode,
isObject,

@@ -671,0 +691,0 @@ isString,

@@ -238,12 +238,12 @@ type FlagValueType = 'boolean' | 'string' | 'number' | 'object';

type CommonEventDetails = {
providerName: string;
readonly providerName: string;
/**
* @deprecated alias of "domain", use domain instead
*/
clientName?: string;
readonly clientName?: string;
readonly domain?: string;
};
type CommonEventProps = {
message?: string;
metadata?: EventMetadata;
readonly message?: string;
readonly metadata?: EventMetadata;
};

@@ -254,6 +254,6 @@ type ReadyEvent = CommonEventProps;

type ReconcilingEvent = CommonEventProps & {
errorCode: ErrorCode;
readonly errorCode: ErrorCode;
};
type ConfigChangeEvent = CommonEventProps & {
flagsChanged?: string[];
readonly flagsChanged?: string[];
};

@@ -553,3 +553,3 @@ type ServerEventMap = {

declare class GeneralError extends OpenFeatureError {
declare class FlagNotFoundError extends OpenFeatureError {
code: ErrorCode;

@@ -559,3 +559,3 @@ constructor(message?: string, options?: ErrorOptions);

declare class FlagNotFoundError extends OpenFeatureError {
declare class GeneralError extends OpenFeatureError {
code: ErrorCode;

@@ -565,3 +565,3 @@ constructor(message?: string, options?: ErrorOptions);

declare class ParseError extends OpenFeatureError {
declare class InvalidContextError extends OpenFeatureError {
code: ErrorCode;

@@ -571,3 +571,3 @@ constructor(message?: string, options?: ErrorOptions);

declare class TypeMismatchError extends OpenFeatureError {
declare class ParseError extends OpenFeatureError {
code: ErrorCode;

@@ -577,3 +577,3 @@ constructor(message?: string, options?: ErrorOptions);

declare class TargetingKeyMissingError extends OpenFeatureError {
declare class ProviderFatalError extends OpenFeatureError {
code: ErrorCode;

@@ -583,3 +583,3 @@ constructor(message?: string, options?: ErrorOptions);

declare class InvalidContextError extends OpenFeatureError {
declare class ProviderNotReadyError extends OpenFeatureError {
code: ErrorCode;

@@ -589,3 +589,3 @@ constructor(message?: string, options?: ErrorOptions);

declare class ProviderNotReadyError extends OpenFeatureError {
declare class TargetingKeyMissingError extends OpenFeatureError {
code: ErrorCode;

@@ -595,3 +595,3 @@ constructor(message?: string, options?: ErrorOptions);

declare class ProviderFatalError extends OpenFeatureError {
declare class TypeMismatchError extends OpenFeatureError {
code: ErrorCode;

@@ -601,2 +601,4 @@ constructor(message?: string, options?: ErrorOptions);

declare const instantiateErrorByErrorCode: (errorCode: ErrorCode, message?: string) => OpenFeatureError;
/**

@@ -699,42 +701,5 @@ * Checks whether the parameter is a string.

getHandlers<T extends AnyProviderEvent>(eventType: T): EventHandler[];
/**
* Sets the default provider for flag evaluations and returns a promise that resolves when the provider is ready.
* The default provider will be used by domainless clients and clients associated with domains to which no provider is bound.
* Setting a provider supersedes the current provider used in new and existing unbound clients.
* @template P
* @param {P} provider The provider responsible for flag evaluations.
* @returns {Promise<void>}
* @throws Uncaught exceptions thrown by the provider during initialization.
*/
setProviderAndWait(provider: P): Promise<void>;
/**
* Sets the provider that OpenFeature will use for flag evaluations on clients bound to the same domain.
* A promise is returned that resolves when the provider is ready.
* Setting a provider supersedes the current provider used in new and existing clients in the same domain.
* @template P
* @param {string} domain An identifier which logically binds clients with providers
* @param {P} provider The provider responsible for flag evaluations.
* @returns {Promise<void>}
* @throws Uncaught exceptions thrown by the provider during initialization.
*/
setProviderAndWait(domain: string, provider: P): Promise<void>;
/**
* Sets the default provider for flag evaluations.
* The default provider will be used by domainless clients and clients associated with domains to which no provider is bound.
* Setting a provider supersedes the current provider used in new and existing unbound clients.
* @template P
* @param {P} provider The provider responsible for flag evaluations.
* @returns {this} OpenFeature API
*/
setProvider(provider: P): this;
/**
* Sets the provider that OpenFeature will use for flag evaluations on clients bound to the same domain.
* Setting a provider supersedes the current provider used in new and existing clients in the same domain.
* @template P
* @param {string} domain An identifier which logically binds clients with providers
* @param {P} provider The provider responsible for flag evaluations.
* @returns {this} OpenFeature API
*/
setProvider(domain: string, provider: P): this;
private setAwaitableProvider;
abstract setProviderAndWait(clientOrProvider?: string | P, providerContextOrUndefined?: P | EvaluationContext, contextOrUndefined?: EvaluationContext): Promise<void>;
abstract setProvider(clientOrProvider?: string | P, providerContextOrUndefined?: P | EvaluationContext, contextOrUndefined?: EvaluationContext): this;
protected setAwaitableProvider(domainOrProvider?: string | P, providerOrUndefined?: P): Promise<void> | void;
protected getProviderForClient(domain?: string): P;

@@ -751,2 +716,2 @@ protected buildAndCacheEventEmitterForClient(domain?: string): GenericEventEmitter<AnyProviderEvent>;

export { ClientProviderEvents as AllProviderEvents, ClientProviderStatus as AllProviderStatus, AnyProviderEvent, BaseHook, BeforeHookContext, ClientMetadata, ClientProviderEvents, ClientProviderStatus, 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, NotChangeEvents, OpenFeatureCommonAPI, OpenFeatureError, Paradigm, ParseError, PrimitiveValue, ProviderEventEmitter, ProviderFatalError, ProviderMetadata, ProviderNotReadyError, ProviderWrapper, ReadyEvent, ReconcilingEvent, ResolutionDetails, ResolutionReason, SafeLogger, ServerProviderEvents, ServerProviderStatus, StaleEvent, StandardResolutionReasons, TargetingKeyMissingError, TypeMismatchError, isObject, isString, objectOrUndefined, statusMatchesEvent, stringOrUndefined };
export { ClientProviderEvents as AllProviderEvents, ClientProviderStatus as AllProviderStatus, AnyProviderEvent, BaseHook, BeforeHookContext, ClientMetadata, ClientProviderEvents, ClientProviderStatus, 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, NotChangeEvents, OpenFeatureCommonAPI, OpenFeatureError, Paradigm, ParseError, PrimitiveValue, ProviderEventEmitter, ProviderFatalError, ProviderMetadata, ProviderNotReadyError, ProviderWrapper, ReadyEvent, ReconcilingEvent, ResolutionDetails, ResolutionReason, SafeLogger, ServerProviderEvents, ServerProviderStatus, StaleEvent, StandardResolutionReasons, TargetingKeyMissingError, TypeMismatchError, instantiateErrorByErrorCode, isObject, isString, objectOrUndefined, statusMatchesEvent, stringOrUndefined };
{
"name": "@openfeature/core",
"version": "1.1.0",
"version": "1.2.0",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc