flagsmith-nodejs 3.0.1 → 3.1.0
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.
|
@@ -83,10 +83,7 @@ var FeatureStateModel = /** @class */ (function () {
|
|
|
83
83
|
};
|
|
84
84
|
FeatureStateModel.prototype.getMultivariateValue = function (identityID) {
|
|
85
85
|
var e_1, _a;
|
|
86
|
-
var percentageValue
|
|
87
|
-
this.djangoID || this.featurestateUUID,
|
|
88
|
-
identityID
|
|
89
|
-
]);
|
|
86
|
+
var percentageValue;
|
|
90
87
|
var startPercentage = 0;
|
|
91
88
|
var sortedF = this.multivariateFeatureStateValues.sort(function (a, b) {
|
|
92
89
|
return a.id - b.id;
|
|
@@ -94,6 +91,19 @@ var FeatureStateModel = /** @class */ (function () {
|
|
|
94
91
|
try {
|
|
95
92
|
for (var sortedF_1 = __values(sortedF), sortedF_1_1 = sortedF_1.next(); !sortedF_1_1.done; sortedF_1_1 = sortedF_1.next()) {
|
|
96
93
|
var myValue = sortedF_1_1.value;
|
|
94
|
+
switch (myValue.percentageAllocation) {
|
|
95
|
+
case 0:
|
|
96
|
+
continue;
|
|
97
|
+
case 100:
|
|
98
|
+
return myValue.multivariateFeatureOption.value;
|
|
99
|
+
default:
|
|
100
|
+
if (percentageValue === undefined) {
|
|
101
|
+
percentageValue = (0, hashing_1.getHashedPercentateForObjIds)([
|
|
102
|
+
this.djangoID || this.featurestateUUID,
|
|
103
|
+
identityID
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
97
107
|
var limit = myValue.percentageAllocation + startPercentage;
|
|
98
108
|
if (startPercentage <= percentageValue && percentageValue < limit) {
|
|
99
109
|
return myValue.multivariateFeatureOption.value;
|
package/build/sdk/index.js
CHANGED
|
@@ -123,6 +123,7 @@ var Flagsmith = /** @class */ (function () {
|
|
|
123
123
|
*/
|
|
124
124
|
function Flagsmith(data) {
|
|
125
125
|
this.apiUrl = DEFAULT_API_URL;
|
|
126
|
+
this.requestTimeoutSeconds = 10;
|
|
126
127
|
this.enableLocalEvaluation = false;
|
|
127
128
|
this.environmentRefreshIntervalSeconds = 60;
|
|
128
129
|
this.enableAnalytics = false;
|
package/build/sdk/utils.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ export declare function generateIdentitiesData(identifier: string, traits: {
|
|
|
9
9
|
}[];
|
|
10
10
|
};
|
|
11
11
|
export declare const delay: (ms: number) => Promise<unknown>;
|
|
12
|
-
export declare const retryFetch: (url: string, fetchOptions: RequestInit, retries?: number, timeout?: number
|
|
12
|
+
export declare const retryFetch: (url: string, fetchOptions: RequestInit, retries?: number, timeout?: number) => Promise<Response>;
|
package/build/sdk/utils.js
CHANGED
|
@@ -62,6 +62,7 @@ exports.delay = delay;
|
|
|
62
62
|
var retryFetch = function (url, fetchOptions, retries, timeout // set an overall timeout for this function
|
|
63
63
|
) {
|
|
64
64
|
if (retries === void 0) { retries = 3; }
|
|
65
|
+
if (timeout === void 0) { timeout = 10; }
|
|
65
66
|
return new Promise(function (resolve, reject) {
|
|
66
67
|
var retryWrapper = function (n) {
|
|
67
68
|
requestWrapper()
|
|
@@ -96,18 +96,27 @@ export class FeatureStateModel {
|
|
|
96
96
|
}
|
|
97
97
|
return this.featureSegment.priority < other.featureSegment.priority;
|
|
98
98
|
}
|
|
99
|
-
|
|
100
|
-
getMultivariateValue(identityID: number | string) {
|
|
101
|
-
const percentageValue = getHashedPercentateForObjIds([
|
|
102
|
-
this.djangoID || this.featurestateUUID,
|
|
103
|
-
identityID
|
|
104
|
-
]);
|
|
105
99
|
|
|
100
|
+
getMultivariateValue(identityID: number | string) {
|
|
101
|
+
let percentageValue: number | undefined;
|
|
106
102
|
let startPercentage = 0;
|
|
107
|
-
const sortedF = this.multivariateFeatureStateValues.sort((a, b) =>{
|
|
103
|
+
const sortedF = this.multivariateFeatureStateValues.sort((a, b) => {
|
|
108
104
|
return a.id - b.id;
|
|
109
105
|
});
|
|
110
106
|
for (const myValue of sortedF) {
|
|
107
|
+
switch (myValue.percentageAllocation) {
|
|
108
|
+
case 0:
|
|
109
|
+
continue;
|
|
110
|
+
case 100:
|
|
111
|
+
return myValue.multivariateFeatureOption.value;
|
|
112
|
+
default:
|
|
113
|
+
if (percentageValue === undefined) {
|
|
114
|
+
percentageValue = getHashedPercentateForObjIds([
|
|
115
|
+
this.djangoID || this.featurestateUUID,
|
|
116
|
+
identityID
|
|
117
|
+
]);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
111
120
|
const limit = myValue.percentageAllocation + startPercentage;
|
|
112
121
|
if (startPercentage <= percentageValue && percentageValue < limit) {
|
|
113
122
|
return myValue.multivariateFeatureOption.value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flagsmith-nodejs",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Flagsmith lets you manage features flags and remote config across web, mobile and server side applications. Deliver true Continuous Integration. Get builds out faster. Control who has access to new features.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"repository": {
|
package/sdk/index.ts
CHANGED
|
@@ -30,7 +30,7 @@ export class Flagsmith {
|
|
|
30
30
|
environmentKey?: string;
|
|
31
31
|
apiUrl: string = DEFAULT_API_URL;
|
|
32
32
|
customHeaders?: { [key: string]: any };
|
|
33
|
-
requestTimeoutSeconds?: number;
|
|
33
|
+
requestTimeoutSeconds?: number = 10;
|
|
34
34
|
agent: RequestInit['agent'];
|
|
35
35
|
requestTimeoutMs?: number;
|
|
36
36
|
enableLocalEvaluation?: boolean = false;
|
package/sdk/utils.ts
CHANGED
|
@@ -19,8 +19,8 @@ export const delay = (ms: number) =>
|
|
|
19
19
|
export const retryFetch = (
|
|
20
20
|
url: string,
|
|
21
21
|
fetchOptions: RequestInit,
|
|
22
|
-
retries = 3,
|
|
23
|
-
timeout
|
|
22
|
+
retries: number = 3,
|
|
23
|
+
timeout: number = 10// set an overall timeout for this function
|
|
24
24
|
): Promise<Response> => {
|
|
25
25
|
return new Promise((resolve, reject) => {
|
|
26
26
|
const retryWrapper = (n: number) => {
|