featureflow-node-sdk 0.6.9-alpha → 0.6.10

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.
@@ -0,0 +1,14 @@
1
+ export default class Featureflow extends EventEmitter {
2
+ constructor(config: any, callback?: (_err: any, self: any) => void);
3
+ failoverVariants: {};
4
+ isReady: boolean;
5
+ config: any;
6
+ eventsClient: EventsClient;
7
+ close: PollingClient;
8
+ ready(callback?: () => void): Featureflow | undefined;
9
+ evaluateAll(): any;
10
+ evaluate(key: any): any;
11
+ }
12
+ import EventEmitter = require("events");
13
+ import EventsClient from "./EventsClient";
14
+ import PollingClient from "./PollingClient";
package/dist/Client.js CHANGED
@@ -44,7 +44,7 @@ var Featureflow = function (_EventEmitter) {
44
44
  _inherits(Featureflow, _EventEmitter);
45
45
 
46
46
  function Featureflow(config) {
47
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
47
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (_err, self) {};
48
48
 
49
49
  _classCallCheck(this, Featureflow);
50
50
 
@@ -105,17 +105,6 @@ var Featureflow = function (_EventEmitter) {
105
105
  });
106
106
  }
107
107
  }
108
- }, {
109
- key: 'waitForReady',
110
- value: function waitForReady() {
111
- var _this3 = this;
112
-
113
- return new Promise(function (resolve) {
114
- _this3.ready(function () {
115
- return resolve();
116
- });
117
- });
118
- }
119
108
  }, {
120
109
  key: 'evaluateAll',
121
110
  value: function (_evaluateAll) {
@@ -0,0 +1 @@
1
+ export function test(op: any, a: any, b: any): any;
@@ -0,0 +1,11 @@
1
+ export default class Evaluate {
2
+ constructor(featureKey: any, evaluatedVariant: any, user: any, eventsClient: any);
3
+ featureKey: any;
4
+ evaluatedVariant: any;
5
+ user: any;
6
+ eventsClient: any;
7
+ is(value: any): boolean;
8
+ isOn(): boolean;
9
+ isOff(): boolean;
10
+ value(): any;
11
+ }
@@ -0,0 +1,5 @@
1
+ export function featureEvaluation(feature: any, user: any): any;
2
+ export function ruleMatches(rule: any, user: any): boolean;
3
+ export function getVariantSplitKey(variantSplits: any, variantValue: any): any;
4
+ export function calculateHash(salt: any, feature: any, id: any): any;
5
+ export function getVariantValue(hash: any): number;
@@ -0,0 +1,19 @@
1
+ export default class EventsClient {
2
+ constructor(apiKey: any, eventsUrl?: string, disabled?: boolean);
3
+ SEND_INTERVAL: number;
4
+ QUEUE_SIZE: number;
5
+ clientVersion: string;
6
+ queue: any[];
7
+ overLimit: boolean;
8
+ apiKey: any;
9
+ eventsUrl: string;
10
+ disabled: boolean;
11
+ sendInterval: number;
12
+ interval: NodeJS.Timer;
13
+ registerFeaturesEvent(features: any): void;
14
+ evaluateEvent(featureKey: any, evaluatedVariant: any, expectedVariant: any, user: any): void;
15
+ queueEvaluateEvent(event: any): void;
16
+ sendQueue(): void;
17
+ sendEvent(eventType: any, method: any, url: any, json: any): void;
18
+ close(): void;
19
+ }
@@ -0,0 +1 @@
1
+ export default function _default(options: any): (req: any, res: any, next: any) => void;
@@ -0,0 +1,12 @@
1
+ export default class Feature {
2
+ constructor(key: any, failoverVariant?: string);
3
+ variants: any[];
4
+ key: any;
5
+ failoverVariant: string;
6
+ addVariant(key: any, value: any): Feature;
7
+ build(): {
8
+ key: any;
9
+ failoverVariant: string;
10
+ variants: any[];
11
+ };
12
+ }
@@ -0,0 +1,8 @@
1
+ export class InMemoryFeatureStore {
2
+ constructor(features?: {});
3
+ features: {};
4
+ get(key: any): any;
5
+ set(key: any, feature: any): void;
6
+ setAll(features: any): void;
7
+ getAll(): {};
8
+ }
@@ -0,0 +1,13 @@
1
+ export default class PollingClient {
2
+ constructor(url: any, config: any, callback: any);
3
+ DEFAULT_TIMEOUT: number;
4
+ DEFAULT_INTERVAL: number;
5
+ clientVersion: string;
6
+ url: any;
7
+ apiKey: any;
8
+ featureStore: any;
9
+ interval: number;
10
+ timeout: number;
11
+ etag: string;
12
+ getFeatures(callback?: () => void): void;
13
+ }
@@ -23,8 +23,8 @@ var PollingClient = function () {
23
23
  _classCallCheck(this, PollingClient);
24
24
 
25
25
  this.DEFAULT_TIMEOUT = 5 * 1000;
26
- this.DEFAULT_INTERVAL = 10 * 1000;
27
- this.clientVersion = 'NodeJsClient/0.6.6';
26
+ this.DEFAULT_INTERVAL = 30 * 1000;
27
+ this.clientVersion = 'NodeJsClient/0.6.10';
28
28
 
29
29
  this.url = url;
30
30
  this.apiKey = config.apiKey;
@@ -35,7 +35,10 @@ var PollingClient = function () {
35
35
  }
36
36
  this.timeout = this.DEFAULT_TIMEOUT;
37
37
  this.etag = "";
38
-
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
+ }
39
42
  this.getFeatures(callback);
40
43
  if (this.interval > 0) {
41
44
  var interval = setInterval(this.getFeatures.bind(this), this.interval);
@@ -0,0 +1 @@
1
+ declare function PollingProcessor(config: any): void;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ function PollingProcessor(config) {}
package/dist/User.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export class UserBuilder {
2
+ constructor(id: any);
3
+ id: any;
4
+ attributes: {
5
+ 'featureflow.user.id': any[];
6
+ 'featureflow.date': string[];
7
+ };
8
+ withAttribute(key: any, value: any): UserBuilder;
9
+ withAttributes(key: any, values: any): UserBuilder;
10
+ build(): User;
11
+ }
12
+ declare class User {
13
+ constructor(id: any, attributes: any);
14
+ id: any;
15
+ attributes: any;
16
+ getId(): any;
17
+ getAttributesForKey(key: any): any;
18
+ addAttribute(key: any, value: any): void;
19
+ }
20
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const _exports: any;
2
+ export = _exports;
@@ -0,0 +1,11 @@
1
+ declare namespace _default {
2
+ export { Client };
3
+ export { UserBuilder };
4
+ export { Feature };
5
+ export { ExpressClient };
6
+ }
7
+ export default _default;
8
+ import Client from "./Client";
9
+ import { UserBuilder } from "./User";
10
+ import Feature from "./Feature";
11
+ import ExpressClient from "./ExpressMiddleware";
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "featureflow-node-sdk",
3
- "version": "0.6.9-alpha",
3
+ "version": "0.6.10",
4
4
  "description": "Featureflow sdk for Node",
5
5
  "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
6
7
  "engines": {
7
8
  "node": ">4.0.0"
8
9
  },
@@ -10,7 +11,7 @@
10
11
  "dist"
11
12
  ],
12
13
  "scripts": {
13
- "build": "babel src -d dist",
14
+ "build": "babel src -d dist && tsc",
14
15
  "watch": "babel --watch src -d dist",
15
16
  "prepublish": "npm run build",
16
17
  "test": "cucumber.js --compiler js:babel-core/register --tags \"not @ignore and not @integration\"",
@@ -34,6 +35,7 @@
34
35
  "sha1-hex": "^1.0.0"
35
36
  },
36
37
  "devDependencies": {
38
+ "@jest/globals": "^29.5.0",
37
39
  "babel-cli": "^6.26.0",
38
40
  "babel-core": "^6.26.0",
39
41
  "babel-plugin-transform-flow-strip-types": "^6.22.0",
@@ -41,7 +43,12 @@
41
43
  "babel-preset-es2015": "^6.24.0",
42
44
  "babel-preset-stage-2": "^6.22.0",
43
45
  "chai": "^3.5.0",
46
+ "cookie-parser": "~1.4.3",
44
47
  "cucumber": "^2.3.1",
45
- "moment": "^2.18.1"
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
53
  }
47
54
  }