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

unleash-client

Package Overview
Dependencies
Maintainers
3
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unleash-client - npm Package Compare versions

Comparing version 3.14.1 to 3.15.0

47

CHANGELOG.md
# Changelog
# 3.15.0
- feat: add impression events (#336)
- fix: string operator needs to guard against non-string values (#343)
- fix(deps): update dependency make-fetch-happen to v10 (#300)
- fix: NOT_IN operator for missing contextField should return true. (#340)
- fix: Use fallback value if not initialised (#339)
- chore(deps): update dependency @types/node to v14.18.21 (#341)
- chore(deps): update dependency @typescript-eslint/eslint-plugin to v5.29.0 (#294)
- chore(deps): update dependency eslint-plugin-import to v2.26.0 (#322)
- chore(deps): update dependency @types/semver to v7.3.10 (#342)
- chore(deps): update dependency eslint to v8.18.0 (#298)
- chore(deps): update dependency prettier to v2.7.1 (#323)
- chore(deps): update dependency typescript to v4.7.4 (#324)
- chore(deps): update actions/checkout action to v3 (#325)
- chore(deps): update actions/setup-node action to v3 (#326)
# 3.14.1
- feat: pass spec header so global segments can be toggled (#335)
- chore: Update build-details
- chore: Update build-details
# 3.14.0
- feat: Added agent to the HttpOptions (#332)
- feat: Add support for handling global segments (#329)
- fix: force semver operators to resolve to false against non strict semver (#333)
- fix: Type is missing from FeatureInterface used by getFeatureDefinitions and more (#328)
- docs: fix example usage in readme (#330)
- meta: add external PRs to project board
- meta: add 'new items to project board' workflow
- chore: upgrade unleash client spec to 4.2.0
- chore: Update build-details
# 3.13.4
- fix: Cannot read property 'split' of undefined in UserWithIdStrategy (#311)
- fix: Use string[] instead of String[] for Override values (#320)
- docs: Add remaining change requests from #318 (#319)
- docs: Clearer client alternative usage and highlight the require use of error handling (#318)
- chore(deps): update dependency @types/node to v14.18.16 (#321)
- chore(deps): update dependency sinon to v13 (#299)
- chore(deps): update dependency lint-staged to v12.4.1 (#295)
- chore(deps): update dependency nock to v13.2.4 (#301)
- chore(deps): update dependency @types/make-fetch-happen to v9.0.2 (#312)
- chore(deps): update dependency eslint-config-prettier to v8.5.0 (#317)
- chore(deps): pin dependencies (#306)
- chore(deps): update dependency redis to v4.0.6 (#314)
- chore: correct changelog
- chore: Update build-details
# 3.13.3

@@ -4,0 +51,0 @@ - fix: getVariant should also count usage

25

lib/client.js

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

var variant_1 = require("./variant");
var events_2 = require("./events");
var UnleashClient = /** @class */ (function (_super) {

@@ -83,3 +84,3 @@ __extends(UnleashClient, _super);

this.warned[missingStrategy + name] = true;
this.emit('warn', "Missing strategy \"".concat(missingStrategy, "\" for toggle \"").concat(name, "\". Ensure that \"").concat(strategies
this.emit(events_2.UnleashEvents.Warn, "Missing strategy \"".concat(missingStrategy, "\" for toggle \"").concat(name, "\". Ensure that \"").concat(strategies
.map(function (_a) {

@@ -94,3 +95,10 @@ var n = _a.name;

var feature = this.repository.getToggle(name);
return this.isFeatureEnabled(feature, context, fallback);
var enabled = this.isFeatureEnabled(feature, context, fallback);
this.emit(events_2.UnleashEvents.Impression, (0, events_2.createImpressionEvent)({
featureName: name,
context: context,
enabled: enabled,
eventType: 'isEnabled'
}));
return enabled;
};

@@ -106,3 +114,4 @@ UnleashClient.prototype.isFeatureEnabled = function (feature, context, fallback) {

if (!Array.isArray(feature.strategies)) {
this.emit('error', new Error("Malformed feature, strategies not an array, is a ".concat(typeof feature.strategies)));
var msg = "Malformed feature, strategies not an array, is a ".concat(typeof feature.strategies);
this.emit(events_2.UnleashEvents.Error, new Error(msg));
return false;

@@ -211,3 +220,11 @@ }

UnleashClient.prototype.getVariant = function (name, context, fallbackVariant) {
return this.resolveVariant(name, context, true, fallbackVariant);
var variant = this.resolveVariant(name, context, true, fallbackVariant);
this.emit(events_2.UnleashEvents.Impression, (0, events_2.createImpressionEvent)({
featureName: name,
context: context,
enabled: variant.enabled,
eventType: 'getVariant',
variant: variant.name,
}));
return variant;
};

@@ -214,0 +231,0 @@ // This function is intended to close an issue in the proxy where feature enabled

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

import { Context } from './context';
export declare enum UnleashEvents {

@@ -11,4 +12,13 @@ Ready = "ready",

Sent = "sent",
Registered = "registered"
Registered = "registered",
Impression = "impression"
}
export interface ImpressionEvent {
eventType: 'isEnabled' | 'getVariant';
context: Context;
enabled: boolean;
featureName: string;
variant?: string;
}
export declare function createImpressionEvent(evt: ImpressionEvent): ImpressionEvent;
//# sourceMappingURL=events.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnleashEvents = void 0;
exports.createImpressionEvent = exports.UnleashEvents = void 0;
// eslint-disable-next-line import/prefer-default-export

@@ -17,3 +17,9 @@ var UnleashEvents;

UnleashEvents["Registered"] = "registered";
UnleashEvents["Impression"] = "impression";
})(UnleashEvents = exports.UnleashEvents || (exports.UnleashEvents = {}));
// Wrapper to provide type checking.
function createImpressionEvent(evt) {
return evt;
}
exports.createImpressionEvent = createImpressionEvent;
//# sourceMappingURL=events.js.map
/// <reference types="node" />
/// <reference types="node" />
import type { URL } from 'url';

@@ -3,0 +4,0 @@ import type { Agent } from 'http';

2

lib/index.d.ts

@@ -14,3 +14,3 @@ import { Unleash, UnleashConfig } from './unleash';

export declare function isEnabled(name: string, context?: Context, fallbackValue?: boolean): boolean;
export declare function destroy(): void | undefined;
export declare function destroy(): void;
export declare function getFeatureToggleDefinition(toggleName: string): import("./feature").FeatureInterface | undefined;

@@ -17,0 +17,0 @@ export declare function getFeatureToggleDefinitions(): import("./feature").FeatureInterface[] | undefined;

@@ -79,7 +79,10 @@ "use strict";

if (context === void 0) { context = {}; }
return !!instance && instance.isEnabled(name, context, fallbackValue);
return instance ? instance.isEnabled(name, context, fallbackValue) : !!fallbackValue;
}
exports.isEnabled = isEnabled;
function destroy() {
return instance && instance.destroy();
if (instance) {
instance.destroy();
}
instance = undefined;
}

@@ -86,0 +89,0 @@ exports.destroy = destroy;

@@ -47,3 +47,3 @@ "use strict";

if (!backupPath) {
throw new Error("backup Path is required");
throw new Error('backup Path is required');
}

@@ -50,0 +50,0 @@ this.backupPath = backupPath;

@@ -28,5 +28,5 @@ /// <reference types="node" />

export declare const getDefaultAgent: (url: URL) => http.Agent;
export declare const buildHeaders: (appName?: string | undefined, instanceId?: string | undefined, etag?: string | undefined, contentType?: string | undefined, custom?: CustomHeaders | undefined, specVersionSupported?: string | undefined) => Record<string, string>;
export declare const buildHeaders: (appName?: string, instanceId?: string, etag?: string, contentType?: string, custom?: CustomHeaders, specVersionSupported?: string) => Record<string, string>;
export declare const post: ({ url, appName, timeout, instanceId, headers, json, httpOptions, }: PostRequestOptions) => Promise<import("node-fetch").Response>;
export declare const get: ({ url, etag, appName, timeout, instanceId, headers, httpOptions, supportedSpecVersion, }: GetRequestOptions) => Promise<import("node-fetch").Response>;
//# sourceMappingURL=request.d.ts.map

@@ -41,5 +41,2 @@ "use strict";

var contextValue = (0, helpers_1.resolveContextValue)(context, field);
if (!contextValue) {
return false;
}
var isIn = values.some(function (val) { return val === contextValue; });

@@ -56,2 +53,5 @@ return constraint.operator === Operator.IN ? isIn : !isIn;

}
if (typeof contextValue !== 'string') {
return false;
}
if (operator === Operator.STR_STARTS_WITH) {

@@ -58,0 +58,0 @@ return values.some(function (val) { return contextValue === null || contextValue === void 0 ? void 0 : contextValue.startsWith(val); });

@@ -139,3 +139,5 @@ "use strict";

_this.client.on(events_2.UnleashEvents.Error, function (err) { return _this.emit(events_2.UnleashEvents.Error, err); });
_this.client.on(events_2.UnleashEvents.Warn, function (msg) { return _this.emit(events_2.UnleashEvents.Warn, msg); });
_this.client.on(events_2.UnleashEvents.Impression, function (e) {
return _this.emit(events_2.UnleashEvents.Impression, e);
});
_this.metrics = new metrics_1.default({

@@ -142,0 +144,0 @@ disableMetrics: disableMetrics,

@@ -1,4 +0,4 @@

declare const getUrl: (base: string, projectName?: string | undefined, namePrefix?: string | undefined, tags?: string[] | undefined) => string;
declare const getUrl: (base: string, projectName?: string, namePrefix?: string, tags?: Array<string>) => string;
export declare const suffixSlash: (url: string) => string;
export default getUrl;
//# sourceMappingURL=url-utils.d.ts.map
{
"name": "unleash-client",
"version": "3.14.1",
"version": "3.15.0",
"description": "Unleash Client for Node",

@@ -33,3 +33,3 @@ "license": "Apache-2.0",

"ip": "^1.1.5",
"make-fetch-happen": "^9.0.4",
"make-fetch-happen": "^10.0.0",
"murmurhash3js": "^3.0.1",

@@ -51,6 +51,6 @@ "semver": "^7.3.5"

"@types/murmurhash3js": "3.0.2",
"@types/node": "14.18.16",
"@types/semver": "7.3.9",
"@typescript-eslint/eslint-plugin": "5.10.0",
"@unleash/client-specification": "4.2.0",
"@types/node": "14.18.21",
"@types/semver": "7.3.10",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@unleash/client-specification": "4.2.1",
"ava": "3.15.0",

@@ -60,7 +60,7 @@ "coveralls": "3.1.1",

"del-cli": "4.0.1",
"eslint": "8.7.0",
"eslint": "8.18.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "12.3.1",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-prettier": "4.0.0",

@@ -73,6 +73,6 @@ "esm": "3.2.25",

"nyc": "15.1.0",
"prettier": "2.5.1",
"prettier": "2.7.1",
"redis": "4.0.6",
"sinon": "13.0.2",
"typescript": "4.5.5"
"typescript": "4.7.4"
},

@@ -79,0 +79,0 @@ "resolutions": {

@@ -196,3 +196,3 @@ # Unleash Client SDK for Node.js

| ready | - | is emitted once the fs-cache is ready. if no cache file exists it will still be emitted. The client is ready to use, but might not have synchronized with the Unleash API yet. This means the SDK still can operate on stale configurations. |
| synchronized | - | is emitted when the SDK has successfully synchronized with the Unleash API, or when it has been bootstrapped, and has all the latest feature toggle configuration available. |
| synchronized | - | is emitted when the SDK has successfully synchronized with the Unleash API, or when it has been bootstrapped, and has all the latest feature toggle configuration available. |
| registered | - | is emitted after the app has been registered at the api server |

@@ -205,3 +205,3 @@ | sent | `object` data | key/value pair of delivered metrics |

| changed | `object` data | is emitted each time the client gets new toggle state from server and changes has been made |
| |
| impression | `object` data | is emitted for every user impression (isEnabled / getVariant) |

@@ -208,0 +208,0 @@ Example usage:

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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