unleash-client
Advanced tools
Comparing version 3.9.1 to 3.10.0
# Changelog | ||
# 3.10.0 | ||
- feat: Add support to provide namePrefix and tags for filtering (#237) | ||
- fix: cleanup tag interface | ||
- fix: Changed the priority of the strategy block (#235) | ||
- fix: bump eslint-config-prettier to 8.3.0 | ||
- fix: upgrade sinon to 11.1.2 | ||
- fix: run tests all node.js > 12 | ||
- fix: upgrade husky to 7.0.1 | ||
- fix: bump lint staged to 11.1.2 | ||
- fix: bump @types/node to 14.17.9 | ||
- fix: upgrade @ava/babel to 2.0.0 | ||
- fix: failing test | ||
- fix: update yarn.lock | ||
- fix: bump make-fetch-happen to version 9.0.4 | ||
# 3.9.0 | ||
@@ -4,0 +20,0 @@ |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import * as express from 'express'; | ||
@@ -2,0 +3,0 @@ import { Unleash, Strategy } from '../lib/unleash'; |
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -12,0 +14,0 @@ function __() { this.constructor = d; } |
@@ -1,1 +0,1 @@ | ||
{ "name": "unleash-client-node", "version": "3.9.0", "sdkVersion": "unleash-client-node:3.9.0" } | ||
{ "name": "unleash-client-node", "version": "3.10.0", "sdkVersion": "unleash-client-node:3.10.0" } |
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -12,0 +14,0 @@ function __() { this.constructor = d; } |
@@ -7,2 +7,3 @@ /// <reference types="node" /> | ||
import { HttpOptions } from './http-options'; | ||
import { TagFilter } from './tags'; | ||
export declare type StorageImpl = typeof Storage; | ||
@@ -26,2 +27,4 @@ export interface RepositoryInterface extends EventEmitter { | ||
httpOptions?: HttpOptions; | ||
namePrefix?: string; | ||
tags?: Array<TagFilter>; | ||
} | ||
@@ -42,6 +45,9 @@ export default class Repository extends EventEmitter implements EventEmitter { | ||
private httpOptions?; | ||
constructor({ backupPath, url, appName, instanceId, projectName, refreshInterval, StorageImpl, timeout, headers, customHeadersFunction, httpOptions, }: RepositoryOptions); | ||
private readonly namePrefix?; | ||
private readonly tags?; | ||
constructor({ backupPath, url, appName, instanceId, projectName, refreshInterval, StorageImpl, timeout, headers, customHeadersFunction, httpOptions, namePrefix, tags, }: RepositoryOptions); | ||
timedFetch(): void; | ||
validateFeature(feature: FeatureInterface): void; | ||
fetch(): Promise<void>; | ||
mergeTagsToStringArray(tags: Array<TagFilter>): Array<string>; | ||
stop(): void; | ||
@@ -48,0 +54,0 @@ getToggle(name: string): FeatureInterface; |
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -71,3 +73,3 @@ function __() { this.constructor = d; } | ||
function Repository(_a) { | ||
var backupPath = _a.backupPath, url = _a.url, appName = _a.appName, instanceId = _a.instanceId, projectName = _a.projectName, refreshInterval = _a.refreshInterval, _b = _a.StorageImpl, StorageImpl = _b === void 0 ? storage_1.Storage : _b, timeout = _a.timeout, headers = _a.headers, customHeadersFunction = _a.customHeadersFunction, httpOptions = _a.httpOptions; | ||
var backupPath = _a.backupPath, url = _a.url, appName = _a.appName, instanceId = _a.instanceId, projectName = _a.projectName, refreshInterval = _a.refreshInterval, _b = _a.StorageImpl, StorageImpl = _b === void 0 ? storage_1.Storage : _b, timeout = _a.timeout, headers = _a.headers, customHeadersFunction = _a.customHeadersFunction, httpOptions = _a.httpOptions, namePrefix = _a.namePrefix, tags = _a.tags; | ||
var _this = _super.call(this) || this; | ||
@@ -84,2 +86,4 @@ _this.stopped = false; | ||
_this.httpOptions = httpOptions; | ||
_this.namePrefix = namePrefix; | ||
_this.tags = tags; | ||
_this.storage = new StorageImpl({ backupPath: backupPath, appName: appName }); | ||
@@ -118,3 +122,3 @@ _this.storage.on('error', function (err) { return _this.emit('error', err); }); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url, headers, _a, res, data, obj, err_1, err_2; | ||
var mergedTags, url, headers, _a, res, data, obj, err_1, err_2; | ||
var _this = this; | ||
@@ -130,3 +134,7 @@ return __generator(this, function (_b) { | ||
_b.trys.push([1, 11, 12, 13]); | ||
url = url_utils_1.default(this.url, this.projectName); | ||
mergedTags = void 0; | ||
if (this.tags) { | ||
mergedTags = this.mergeTagsToStringArray(this.tags); | ||
} | ||
url = url_utils_1.default(this.url, this.projectName, this.namePrefix, mergedTags); | ||
if (!this.customHeadersFunction) return [3 /*break*/, 3]; | ||
@@ -198,2 +206,5 @@ return [4 /*yield*/, this.customHeadersFunction()]; | ||
}; | ||
Repository.prototype.mergeTagsToStringArray = function (tags) { | ||
return tags.map(function (tag) { return tag.name + ":" + tag.value; }); | ||
}; | ||
Repository.prototype.stop = function () { | ||
@@ -200,0 +211,0 @@ this.stopped = true; |
@@ -61,2 +61,3 @@ "use strict"; | ||
retries: 2, | ||
maxTimeout: timeout || 10000, | ||
}, | ||
@@ -63,0 +64,0 @@ strictSSL: httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.rejectUnauthorized, |
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -12,0 +14,0 @@ function __() { this.constructor = d; } |
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -12,0 +14,0 @@ function __() { this.constructor = d; } |
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -12,0 +14,0 @@ function __() { this.constructor = d; } |
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -12,0 +14,0 @@ function __() { this.constructor = d; } |
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -12,0 +14,0 @@ function __() { this.constructor = d; } |
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -12,0 +14,0 @@ function __() { this.constructor = d; } |
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -12,0 +14,0 @@ function __() { this.constructor = d; } |
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -12,0 +14,0 @@ function __() { this.constructor = d; } |
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -12,0 +14,0 @@ function __() { this.constructor = d; } |
@@ -11,2 +11,3 @@ /// <reference types="node" /> | ||
import { HttpOptions } from './http-options'; | ||
import { TagFilter } from './tags'; | ||
export { Strategy }; | ||
@@ -21,2 +22,3 @@ export interface UnleashConfig { | ||
metricsInterval?: number; | ||
namePrefix?: string; | ||
disableMetrics?: boolean; | ||
@@ -30,2 +32,3 @@ backupPath?: string; | ||
httpOptions?: HttpOptions; | ||
tags?: Array<TagFilter>; | ||
} | ||
@@ -42,3 +45,3 @@ export interface StaticContext { | ||
private synchronized; | ||
constructor({ appName, environment, projectName, instanceId, url, refreshInterval, metricsInterval, disableMetrics, backupPath, strategies, repository, customHeaders, customHeadersFunction, timeout, httpOptions, }: UnleashConfig); | ||
constructor({ appName, environment, projectName, instanceId, url, refreshInterval, metricsInterval, disableMetrics, backupPath, strategies, repository, namePrefix, customHeaders, customHeadersFunction, timeout, httpOptions, tags, }: UnleashConfig); | ||
destroy(): void; | ||
@@ -45,0 +48,0 @@ isEnabled(name: string, context?: Context, fallbackFunction?: FallbackFunction): boolean; |
@@ -10,2 +10,4 @@ "use strict"; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -42,3 +44,3 @@ function __() { this.constructor = d; } | ||
function Unleash(_a) { | ||
var appName = _a.appName, _b = _a.environment, environment = _b === void 0 ? 'default' : _b, projectName = _a.projectName, instanceId = _a.instanceId, url = _a.url, _c = _a.refreshInterval, refreshInterval = _c === void 0 ? 15 * 1000 : _c, _d = _a.metricsInterval, metricsInterval = _d === void 0 ? 60 * 1000 : _d, _e = _a.disableMetrics, disableMetrics = _e === void 0 ? false : _e, _f = _a.backupPath, backupPath = _f === void 0 ? BACKUP_PATH : _f, _g = _a.strategies, strategies = _g === void 0 ? [] : _g, repository = _a.repository, customHeaders = _a.customHeaders, customHeadersFunction = _a.customHeadersFunction, timeout = _a.timeout, httpOptions = _a.httpOptions; | ||
var appName = _a.appName, _b = _a.environment, environment = _b === void 0 ? 'default' : _b, projectName = _a.projectName, instanceId = _a.instanceId, url = _a.url, _c = _a.refreshInterval, refreshInterval = _c === void 0 ? 15 * 1000 : _c, _d = _a.metricsInterval, metricsInterval = _d === void 0 ? 60 * 1000 : _d, _e = _a.disableMetrics, disableMetrics = _e === void 0 ? false : _e, _f = _a.backupPath, backupPath = _f === void 0 ? BACKUP_PATH : _f, _g = _a.strategies, strategies = _g === void 0 ? [] : _g, repository = _a.repository, namePrefix = _a.namePrefix, customHeaders = _a.customHeaders, customHeadersFunction = _a.customHeadersFunction, timeout = _a.timeout, httpOptions = _a.httpOptions, tags = _a.tags; | ||
var _this = _super.call(this) || this; | ||
@@ -91,4 +93,6 @@ _this.synchronized = false; | ||
httpOptions: httpOptions, | ||
namePrefix: namePrefix, | ||
tags: tags, | ||
}); | ||
var strats = strategy_1.defaultStrategies.concat(strategies); | ||
var strats = strategies.concat(strategy_1.defaultStrategies); | ||
_this.repository.on('ready', function () { | ||
@@ -95,0 +99,0 @@ _this.client = new client_1.default(_this.repository, strats); |
@@ -1,4 +0,4 @@ | ||
declare const getUrl: (base: string, projectName?: string | undefined) => string; | ||
declare const getUrl: (base: string, projectName?: string | undefined, namePrefix?: string | undefined, tags?: string[] | undefined) => string; | ||
export declare const suffixSlash: (url: string) => string; | ||
export default getUrl; | ||
//# sourceMappingURL=url-utils.d.ts.map |
@@ -5,7 +5,18 @@ "use strict"; | ||
var url_1 = require("url"); | ||
var getUrl = function (base, projectName) { | ||
var getUrl = function (base, projectName, namePrefix, tags) { | ||
var url = url_1.resolve(base, './client/features'); | ||
var params = new URLSearchParams(); | ||
if (projectName) { | ||
return url_1.resolve(base, "./client/features?project=" + projectName); | ||
params.append('project', projectName); | ||
} | ||
return url_1.resolve(base, './client/features'); | ||
if (namePrefix) { | ||
params.append('namePrefix', namePrefix); | ||
} | ||
if (tags) { | ||
tags.forEach(function (tag) { return params.append('tag', tag); }); | ||
} | ||
if (params.toString().length > 0) { | ||
return url + "?" + params.toString(); | ||
} | ||
return url; | ||
}; | ||
@@ -12,0 +23,0 @@ var suffixSlash = function (url) { return (url.endsWith('/') ? url : url + "/"); }; |
{ | ||
"name": "unleash-client", | ||
"version": "3.9.1", | ||
"version": "3.10.0", | ||
"description": "Unleash Client for Node", | ||
@@ -32,3 +32,3 @@ "license": "Apache-2.0", | ||
"ip": "^1.1.5", | ||
"make-fetch-happen": "^8.0.14", | ||
"make-fetch-happen": "^9.0.4", | ||
"murmurhash3js": "^3.0.1" | ||
@@ -45,7 +45,7 @@ }, | ||
"devDependencies": { | ||
"@ava/babel": "^1.0.1", | ||
"@ava/babel": "^2.0.0", | ||
"@types/ip": "^1.1.0", | ||
"@types/make-fetch-happen": "8.0.1", | ||
"@types/make-fetch-happen": "^9.0.0", | ||
"@types/murmurhash3js": "^3.0.2", | ||
"@types/node": "^14.0.1", | ||
"@types/node": "^14.17.9", | ||
"@typescript-eslint/eslint-plugin": "^4.14.2", | ||
@@ -59,8 +59,8 @@ "@unleash/client-specification": "^4.0.0", | ||
"eslint-config-airbnb-typescript": "^12.3.1", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"esm": "^3.2.25", | ||
"husky": "^4.3.8", | ||
"lint-staged": "^10.5.4", | ||
"husky": "^7.0.1", | ||
"lint-staged": "^11.1.2", | ||
"mkdirp": "^1.0.4", | ||
@@ -70,3 +70,3 @@ "nock": "^13.0.7", | ||
"prettier": "^2.2.1", | ||
"sinon": "^9.2.4", | ||
"sinon": "^11.1.2", | ||
"typescript": "^4.1.3" | ||
@@ -73,0 +73,0 @@ }, |
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
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
180204
119
2206
+ Addedmake-fetch-happen@9.1.0(transitive)
+ Addednegotiator@0.6.4(transitive)
+ Addedsocks-proxy-agent@6.2.1(transitive)
- Removedmake-fetch-happen@8.0.14(transitive)
- Removedsocks-proxy-agent@5.0.1(transitive)
Updatedmake-fetch-happen@^9.0.4