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

@openfeature/server-sdk

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openfeature/server-sdk - npm Package Compare versions

Comparing version 1.15.1 to 1.16.0

44

dist/cjs/index.js

@@ -203,6 +203,9 @@ "use strict";

var OpenFeatureClient = class {
constructor(providerAccessor, providerStatusAccessor, emitterAccessor, globalLogger, options, context = {}) {
constructor(providerAccessor, providerStatusAccessor, emitterAccessor, apiContextAccessor, apiHooksAccessor, transactionContextAccessor, globalLogger, options, context = {}) {
this.providerAccessor = providerAccessor;
this.providerStatusAccessor = providerStatusAccessor;
this.emitterAccessor = emitterAccessor;
this.apiContextAccessor = apiContextAccessor;
this.apiHooksAccessor = apiHooksAccessor;
this.transactionContextAccessor = transactionContextAccessor;
this.globalLogger = globalLogger;

@@ -325,2 +328,16 @@ this.options = options;

}
track(occurrenceKey, context, occurrenceDetails) {
var _a, _b;
try {
this.shortCircuitIfNotReady();
if (typeof this._provider.track === "function") {
const frozenContext = Object.freeze(this.mergeContexts(context));
return (_b = (_a = this._provider).track) == null ? void 0 : _b.call(_a, occurrenceKey, frozenContext, occurrenceDetails);
} else {
this._logger.debug("Provider does not support the track function; will no-op.");
}
} catch (err) {
this._logger.debug("Error recording tracking event.", err);
}
}
evaluate(_0, _1, _2, _3) {

@@ -330,3 +347,3 @@ return __async(this, arguments, function* (flagKey, resolver, defaultValue, flagType, invocationContext = {}, options = {}) {

const allHooks = [
...OpenFeature.getHooks(),
...this.apiHooksAccessor(),
...this.getHooks(),

@@ -337,3 +354,3 @@ ...options.hooks || [],

const allHooksReversed = [...allHooks].reverse();
const mergedContext = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, OpenFeature.getContext()), OpenFeature.getTransactionContext()), this._context), invocationContext);
const mergedContext = this.mergeContexts(invocationContext);
const hookContext = {

@@ -350,7 +367,3 @@ flagKey,

const frozenContext = yield this.beforeHooks(allHooks, hookContext, options);
if (this.providerStatus === import_core.ServerProviderStatus.NOT_READY) {
throw new import_core4.ProviderNotReadyError("provider has not yet initialized");
} else if (this.providerStatus === import_core.ServerProviderStatus.FATAL) {
throw new import_core4.ProviderFatalError("provider is in an irrecoverable error state");
}
this.shortCircuitIfNotReady();
const resolution = yield resolver.call(this._provider, flagKey, defaultValue, frozenContext, this._logger);

@@ -442,2 +455,12 @@ const evaluationDetails = __spreadProps(__spreadValues({}, resolution), {

}
mergeContexts(invocationContext) {
return __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, this.apiContextAccessor()), this.transactionContextAccessor()), this._context), invocationContext);
}
shortCircuitIfNotReady() {
if (this.providerStatus === import_core.ServerProviderStatus.NOT_READY) {
throw new import_core4.ProviderNotReadyError("provider has not yet initialized");
} else if (this.providerStatus === import_core.ServerProviderStatus.FATAL) {
throw new import_core4.ProviderFatalError("provider is in an irrecoverable error state");
}
}
};

@@ -447,3 +470,3 @@

var import_core5 = require("@openfeature/core");
var import_node_events = require("events");
var import_node_events = require("node:events");
var OpenFeatureEventEmitter = class extends import_core5.GenericEventEmitter {

@@ -559,2 +582,5 @@ constructor() {

() => this.buildAndCacheEventEmitterForClient(domain),
() => this.getContext(),
() => this.getHooks(),
() => this.getTransactionContext(),
() => this._logger,

@@ -561,0 +587,0 @@ { domain, version },

@@ -42,3 +42,5 @@ var __defProp = Object.defineProperty;

// src/provider/provider.ts
import { ServerProviderStatus } from "@openfeature/core";
import {
ServerProviderStatus
} from "@openfeature/core";

@@ -191,6 +193,9 @@ // src/provider/no-op-provider.ts

var OpenFeatureClient = class {
constructor(providerAccessor, providerStatusAccessor, emitterAccessor, globalLogger, options, context = {}) {
constructor(providerAccessor, providerStatusAccessor, emitterAccessor, apiContextAccessor, apiHooksAccessor, transactionContextAccessor, globalLogger, options, context = {}) {
this.providerAccessor = providerAccessor;
this.providerStatusAccessor = providerStatusAccessor;
this.emitterAccessor = emitterAccessor;
this.apiContextAccessor = apiContextAccessor;
this.apiHooksAccessor = apiHooksAccessor;
this.transactionContextAccessor = transactionContextAccessor;
this.globalLogger = globalLogger;

@@ -313,2 +318,16 @@ this.options = options;

}
track(occurrenceKey, context, occurrenceDetails) {
var _a, _b;
try {
this.shortCircuitIfNotReady();
if (typeof this._provider.track === "function") {
const frozenContext = Object.freeze(this.mergeContexts(context));
return (_b = (_a = this._provider).track) == null ? void 0 : _b.call(_a, occurrenceKey, frozenContext, occurrenceDetails);
} else {
this._logger.debug("Provider does not support the track function; will no-op.");
}
} catch (err) {
this._logger.debug("Error recording tracking event.", err);
}
}
evaluate(_0, _1, _2, _3) {

@@ -318,3 +337,3 @@ return __async(this, arguments, function* (flagKey, resolver, defaultValue, flagType, invocationContext = {}, options = {}) {

const allHooks = [
...OpenFeature.getHooks(),
...this.apiHooksAccessor(),
...this.getHooks(),

@@ -325,3 +344,3 @@ ...options.hooks || [],

const allHooksReversed = [...allHooks].reverse();
const mergedContext = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, OpenFeature.getContext()), OpenFeature.getTransactionContext()), this._context), invocationContext);
const mergedContext = this.mergeContexts(invocationContext);
const hookContext = {

@@ -338,7 +357,3 @@ flagKey,

const frozenContext = yield this.beforeHooks(allHooks, hookContext, options);
if (this.providerStatus === ServerProviderStatus.NOT_READY) {
throw new ProviderNotReadyError("provider has not yet initialized");
} else if (this.providerStatus === ServerProviderStatus.FATAL) {
throw new ProviderFatalError("provider is in an irrecoverable error state");
}
this.shortCircuitIfNotReady();
const resolution = yield resolver.call(this._provider, flagKey, defaultValue, frozenContext, this._logger);

@@ -430,2 +445,12 @@ const evaluationDetails = __spreadProps(__spreadValues({}, resolution), {

}
mergeContexts(invocationContext) {
return __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, this.apiContextAccessor()), this.transactionContextAccessor()), this._context), invocationContext);
}
shortCircuitIfNotReady() {
if (this.providerStatus === ServerProviderStatus.NOT_READY) {
throw new ProviderNotReadyError("provider has not yet initialized");
} else if (this.providerStatus === ServerProviderStatus.FATAL) {
throw new ProviderFatalError("provider is in an irrecoverable error state");
}
}
};

@@ -435,3 +460,3 @@

import { GenericEventEmitter } from "@openfeature/core";
import { EventEmitter } from "events";
import { EventEmitter } from "node:events";
var OpenFeatureEventEmitter = class extends GenericEventEmitter {

@@ -547,2 +572,5 @@ constructor() {

() => this.buildAndCacheEventEmitterForClient(domain),
() => this.getContext(),
() => this.getHooks(),
() => this.getTransactionContext(),
() => this._logger,

@@ -549,0 +577,0 @@ { domain, version },

@@ -1,2 +0,2 @@

import { BaseHook, FlagValue, EvaluationContext, HookHints, EvaluationDetails, JsonValue, CommonProvider, ServerProviderStatus, Logger, ResolutionDetails, GenericEventEmitter, ServerProviderEvents, EvaluationLifeCycle, ManageContext, ManageLogger, Eventing, ClientMetadata, OpenFeatureCommonAPI, ProviderWrapper } from '@openfeature/core';
import { BaseHook, FlagValue, EvaluationContext, HookHints, EvaluationDetails, JsonValue, CommonProvider, ServerProviderStatus, Logger, ResolutionDetails, GenericEventEmitter, ServerProviderEvents, TrackingEventDetails, EvaluationLifeCycle, ManageContext, ManageLogger, Eventing, ClientMetadata, OpenFeatureCommonAPI, ProviderWrapper } from '@openfeature/core';
export * from '@openfeature/core';

@@ -216,3 +216,13 @@ export { ServerProviderEvents as ProviderEvents, ServerProviderStatus as ProviderStatus } from '@openfeature/core';

interface Client extends EvaluationLifeCycle<Client>, Features, ManageContext<Client>, ManageLogger<Client>, Eventing<ServerProviderEvents> {
interface Tracking {
/**
* Track a user action or application state, usually representing a business objective or outcome.
* @param trackingEventName an identifier for the event
* @param context the evaluation context
* @param trackingEventDetails the details of the tracking event
*/
track(trackingEventName: string, context?: EvaluationContext, trackingEventDetails?: TrackingEventDetails): void;
}
interface Client extends EvaluationLifeCycle<Client>, Features, ManageContext<Client>, ManageLogger<Client>, Tracking, Eventing<ServerProviderEvents> {
readonly metadata: ClientMetadata;

@@ -394,2 +404,2 @@ /**

export { AsyncLocalStorageTransactionContextPropagator, Client, Features, FlagEvaluationOptions, Hook, InMemoryProvider, ManageTransactionContextPropagator, NOOP_PROVIDER, NOOP_TRANSACTION_CONTEXT_PROPAGATOR, OpenFeature, OpenFeatureAPI, OpenFeatureEventEmitter, Provider, TransactionContext, TransactionContextPropagator };
export { AsyncLocalStorageTransactionContextPropagator, type Client, type Features, type FlagEvaluationOptions, type Hook, InMemoryProvider, type ManageTransactionContextPropagator, NOOP_PROVIDER, NOOP_TRANSACTION_CONTEXT_PROPAGATOR, OpenFeature, OpenFeatureAPI, OpenFeatureEventEmitter, type Provider, type Tracking, type TransactionContext, type TransactionContextPropagator };
{
"name": "@openfeature/server-sdk",
"version": "1.15.1",
"version": "1.16.0",
"description": "OpenFeature SDK for JavaScript",

@@ -19,2 +19,3 @@ "main": "./dist/cjs/index.js",

"lint": "eslint ./",
"lint:fix": "eslint ./ --fix",
"clean": "shx rm -rf ./dist",

@@ -52,7 +53,7 @@ "build:esm": "esbuild src/index.ts --bundle --external:@openfeature/core --sourcemap --target=es2015 --platform=node --format=esm --outfile=./dist/esm/index.js --analyze",

"peerDependencies": {
"@openfeature/core": "1.4.0"
"@openfeature/core": "1.5.0"
},
"devDependencies": {
"@openfeature/core": "1.4.0"
"@openfeature/core": "1.5.0"
}
}

@@ -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.15.1">
<img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v1.15.1&color=blue&style=for-the-badge" />
<a href="https://github.com/open-feature/js-sdk/releases/tag/server-sdk-v1.16.0">
<img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v1.16.0&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

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