featureflow-node-sdk 0.6.10 → 0.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Client.d.ts +4 -4
- package/dist/Client.js +7 -1
- package/dist/EventsClient.d.ts +1 -1
- package/dist/EventsClient.js +1 -2
- package/dist/PollingClient.d.ts +3 -1
- package/dist/PollingClient.js +62 -61
- package/package.json +7 -12
- package/dist/PollingProcessor.d.ts +0 -1
- package/dist/PollingProcessor.js +0 -3
package/dist/Client.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export default class Featureflow
|
|
1
|
+
export default class Featureflow {
|
|
2
2
|
constructor(config: any, callback?: (_err: any, self: any) => void);
|
|
3
3
|
failoverVariants: {};
|
|
4
4
|
isReady: boolean;
|
|
5
5
|
config: any;
|
|
6
6
|
eventsClient: EventsClient;
|
|
7
|
-
|
|
8
|
-
ready(callback?: () => void):
|
|
7
|
+
pollingClient: PollingClient;
|
|
8
|
+
ready(callback?: () => void): any;
|
|
9
9
|
evaluateAll(): any;
|
|
10
10
|
evaluate(key: any): any;
|
|
11
|
+
close(): void;
|
|
11
12
|
}
|
|
12
|
-
import EventEmitter = require("events");
|
|
13
13
|
import EventsClient from "./EventsClient";
|
|
14
14
|
import PollingClient from "./PollingClient";
|
package/dist/Client.js
CHANGED
|
@@ -81,7 +81,7 @@ var Featureflow = function (_EventEmitter) {
|
|
|
81
81
|
_this.eventsClient.registerFeaturesEvent(_this.config.withFeatures);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
_this.
|
|
84
|
+
_this.pollingClient = new _PollingClient2.default(_this.config.baseUrl + '/api/sdk/v1/features', _this.config, function () {
|
|
85
85
|
(0, _debug2.default)("client initialized");
|
|
86
86
|
_this.isReady = true;
|
|
87
87
|
_this.emit('ready');
|
|
@@ -168,6 +168,12 @@ var Featureflow = function (_EventEmitter) {
|
|
|
168
168
|
|
|
169
169
|
return new _Evaluate2.default(key, evaluatedVariant, user, this.eventsClient);
|
|
170
170
|
}
|
|
171
|
+
}, {
|
|
172
|
+
key: 'close',
|
|
173
|
+
value: function close() {
|
|
174
|
+
this.pollingClient.close();
|
|
175
|
+
this.eventsClient.close();
|
|
176
|
+
}
|
|
171
177
|
}]);
|
|
172
178
|
|
|
173
179
|
return Featureflow;
|
package/dist/EventsClient.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export default class EventsClient {
|
|
|
9
9
|
eventsUrl: string;
|
|
10
10
|
disabled: boolean;
|
|
11
11
|
sendInterval: number;
|
|
12
|
-
interval:
|
|
12
|
+
interval: number;
|
|
13
13
|
registerFeaturesEvent(features: any): void;
|
|
14
14
|
evaluateEvent(featureKey: any, evaluatedVariant: any, expectedVariant: any, user: any): void;
|
|
15
15
|
queueEvaluateEvent(event: any): void;
|
package/dist/EventsClient.js
CHANGED
|
@@ -29,7 +29,7 @@ var EventsClient = function () {
|
|
|
29
29
|
|
|
30
30
|
this.SEND_INTERVAL = 5;
|
|
31
31
|
this.QUEUE_SIZE = 10000;
|
|
32
|
-
this.clientVersion = 'NodeJsClient/0.6.
|
|
32
|
+
this.clientVersion = 'NodeJsClient/0.6.11';
|
|
33
33
|
this.queue = [];
|
|
34
34
|
this.overLimit = false;
|
|
35
35
|
|
|
@@ -80,7 +80,6 @@ var EventsClient = function () {
|
|
|
80
80
|
}, {
|
|
81
81
|
key: 'sendEvent',
|
|
82
82
|
value: function sendEvent(eventType, method, url, json) {
|
|
83
|
-
|
|
84
83
|
if (this.disabled) {
|
|
85
84
|
return;
|
|
86
85
|
}
|
package/dist/PollingClient.d.ts
CHANGED
|
@@ -6,8 +6,10 @@ export default class PollingClient {
|
|
|
6
6
|
url: any;
|
|
7
7
|
apiKey: any;
|
|
8
8
|
featureStore: any;
|
|
9
|
-
|
|
9
|
+
pollingInterval: number;
|
|
10
10
|
timeout: number;
|
|
11
11
|
etag: string;
|
|
12
|
+
interval: number | undefined;
|
|
12
13
|
getFeatures(callback?: () => void): void;
|
|
14
|
+
close(): void;
|
|
13
15
|
}
|
package/dist/PollingClient.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -19,71 +19,72 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
19
19
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
20
20
|
|
|
21
21
|
var PollingClient = function () {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
this.timeout = this.DEFAULT_TIMEOUT;
|
|
37
|
-
this.etag = "";
|
|
38
|
-
if (this.apiKey.length < 8) {
|
|
39
|
-
(0, _debug2.default)("Api Key is not valid. Please set your environment api key. Not calling featureflow");
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
this.getFeatures(callback);
|
|
43
|
-
if (this.interval > 0) {
|
|
44
|
-
var interval = setInterval(this.getFeatures.bind(this), this.interval);
|
|
45
|
-
return clearInterval.bind(this, interval);
|
|
46
|
-
} else {
|
|
47
|
-
(0, _debug2.default)("Polling interval set to 0. Featureflow will NOT poll for feature changes.");
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
_createClass(PollingClient, [{
|
|
52
|
-
key: 'getFeatures',
|
|
53
|
-
value: function getFeatures() {
|
|
54
|
-
var _this = this;
|
|
55
|
-
|
|
56
|
-
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
|
|
57
|
-
|
|
58
|
-
(0, _request2.default)({
|
|
59
|
-
method: 'get',
|
|
60
|
-
uri: this.url,
|
|
61
|
-
timeout: this.timeout,
|
|
62
|
-
headers: {
|
|
63
|
-
'Authorization': 'Bearer ' + this.apiKey,
|
|
64
|
-
'If-None-Match': this.etag,
|
|
65
|
-
'X-Featureflow-Client': this.clientVersion
|
|
22
|
+
function PollingClient(url, config, callback) {
|
|
23
|
+
_classCallCheck(this, PollingClient);
|
|
24
|
+
|
|
25
|
+
this.DEFAULT_TIMEOUT = 5 * 1000;
|
|
26
|
+
this.DEFAULT_INTERVAL = 10 * 1000;
|
|
27
|
+
this.clientVersion = 'NodeJsClient/0.6.11';
|
|
28
|
+
|
|
29
|
+
this.url = url;
|
|
30
|
+
this.apiKey = config.apiKey;
|
|
31
|
+
this.featureStore = config.featureStore;
|
|
32
|
+
this.pollingInterval = this.DEFAULT_INTERVAL;
|
|
33
|
+
if (config.interval && config.interval > 5 || config.interval == 0) {
|
|
34
|
+
this.pollingInterval = config.interval * 1000;
|
|
66
35
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} else if (response.statusCode >= 400 || error) {
|
|
74
|
-
(0, _debug2.default)("request for features failed with response status %d", response.statusCode);
|
|
75
|
-
}
|
|
76
|
-
callback();
|
|
36
|
+
this.timeout = this.DEFAULT_TIMEOUT;
|
|
37
|
+
this.etag = "";
|
|
38
|
+
|
|
39
|
+
this.getFeatures(callback);
|
|
40
|
+
if (this.pollingInterval > 0) {
|
|
41
|
+
this.interval = setInterval(this.getFeatures.bind(this), this.pollingInterval);
|
|
77
42
|
} else {
|
|
78
|
-
|
|
79
|
-
(0, _debug2.default)(error.code);
|
|
80
|
-
}
|
|
43
|
+
(0, _debug2.default)("Polling interval set to 0. Featureflow will NOT poll for feature changes.");
|
|
81
44
|
}
|
|
82
|
-
});
|
|
83
45
|
}
|
|
84
|
-
}]);
|
|
85
46
|
|
|
86
|
-
|
|
47
|
+
_createClass(PollingClient, [{
|
|
48
|
+
key: 'getFeatures',
|
|
49
|
+
value: function getFeatures() {
|
|
50
|
+
var _this = this;
|
|
51
|
+
|
|
52
|
+
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
|
|
53
|
+
|
|
54
|
+
(0, _request2.default)({
|
|
55
|
+
method: 'get',
|
|
56
|
+
uri: this.url,
|
|
57
|
+
timeout: this.timeout,
|
|
58
|
+
headers: {
|
|
59
|
+
'Authorization': 'Bearer ' + this.apiKey,
|
|
60
|
+
'If-None-Match': this.etag,
|
|
61
|
+
'X-Featureflow-Client': this.clientVersion
|
|
62
|
+
}
|
|
63
|
+
}, function (error, response, body) {
|
|
64
|
+
if (response) {
|
|
65
|
+
if (response.statusCode === 200) {
|
|
66
|
+
_this.etag = response.headers['etag'];
|
|
67
|
+
(0, _debug2.default)("updating features");
|
|
68
|
+
_this.featureStore.setAll(JSON.parse(body));
|
|
69
|
+
} else if (response.statusCode >= 400 || error) {
|
|
70
|
+
(0, _debug2.default)("request for features failed with response status %d", response.statusCode);
|
|
71
|
+
}
|
|
72
|
+
callback();
|
|
73
|
+
} else {
|
|
74
|
+
if (error.code != null) {
|
|
75
|
+
(0, _debug2.default)(error.code);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: 'close',
|
|
82
|
+
value: function close() {
|
|
83
|
+
clearInterval(this.interval);
|
|
84
|
+
}
|
|
85
|
+
}]);
|
|
86
|
+
|
|
87
|
+
return PollingClient;
|
|
87
88
|
}();
|
|
88
89
|
|
|
89
90
|
exports.default = PollingClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "featureflow-node-sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.11",
|
|
4
4
|
"description": "Featureflow sdk for Node",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"build": "babel src -d dist && tsc",
|
|
15
15
|
"watch": "babel --watch src -d dist",
|
|
16
16
|
"prepublish": "npm run build",
|
|
17
|
-
"test": "cucumber
|
|
18
|
-
"ci-test": "cucumber
|
|
17
|
+
"test": "node_modules/.bin/cucumber-js --compiler js:babel-core/register --format=json | node_modules/.bin/cucumber-junit > output_JUnit.xml --tags \"not @ignore and not @integration\"",
|
|
18
|
+
"ci-test": "node_modules/.bin/cucumber-js --compiler js:babel-core/register --format=json | node_modules/.bin/cucumber-junit > ~/junit.xml --tags \"not @ignore and not @integration\"",
|
|
19
19
|
"test:integration": "cucumber.js --compiler js:babel-core/register --tags \"@integration\""
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"big-integer": "^1.6.17",
|
|
33
33
|
"debug": "^2.6.2",
|
|
34
34
|
"request": "^2.88.0",
|
|
35
|
-
"sha1-hex": "^1.0.0"
|
|
35
|
+
"sha1-hex": "^1.0.0",
|
|
36
|
+
"typescript": "^4.8.2"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@jest/globals": "^29.5.0",
|
|
39
39
|
"babel-cli": "^6.26.0",
|
|
40
40
|
"babel-core": "^6.26.0",
|
|
41
41
|
"babel-plugin-transform-flow-strip-types": "^6.22.0",
|
|
@@ -43,12 +43,7 @@
|
|
|
43
43
|
"babel-preset-es2015": "^6.24.0",
|
|
44
44
|
"babel-preset-stage-2": "^6.22.0",
|
|
45
45
|
"chai": "^3.5.0",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"express": "~4.17.1",
|
|
49
|
-
"jest": "^27.0.4",
|
|
50
|
-
"morgan": "~1.7.0",
|
|
51
|
-
"moment": "^2.18.1",
|
|
52
|
-
"typescript": "^4.8.2"
|
|
46
|
+
"cucumber-junit": "^1.7.1",
|
|
47
|
+
"moment": "^2.18.1"
|
|
53
48
|
}
|
|
54
49
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare function PollingProcessor(config: any): void;
|
package/dist/PollingProcessor.js
DELETED