expf-sigma-node.js 3.2.0 → 3.2.2
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/package.json +1 -1
- package/public/sigma.js +71 -55
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expf-sigma-node.js",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"description": "expf-sigma-node.js lets you manage features flags and remote config across web, server side applications. Deliver true Continuous Integration. Get builds out faster. Control who has access to new features.",
|
|
5
5
|
"main": "public/sigma.js",
|
|
6
6
|
"keywords": [
|
package/public/sigma.js
CHANGED
|
@@ -902,6 +902,70 @@ function compareVersions(versionA, versionB, strict = true) {
|
|
|
902
902
|
}
|
|
903
903
|
}
|
|
904
904
|
|
|
905
|
+
// src/helpers/conditionOperation.js
|
|
906
|
+
function conditionOperation(userValue, conditionValues, operation) {
|
|
907
|
+
!operation ? operation = "=" : operation;
|
|
908
|
+
if (userValue === null || typeof userValue === "undefined" || !conditionValues)
|
|
909
|
+
return false;
|
|
910
|
+
userValue = String(userValue);
|
|
911
|
+
if (!Array.isArray(conditionValues))
|
|
912
|
+
conditionValues = String(conditionValues);
|
|
913
|
+
switch (operation.trim()) {
|
|
914
|
+
case "equal":
|
|
915
|
+
return userValue.toLowerCase().trim() == conditionValues.toLowerCase().trim();
|
|
916
|
+
case "not equal":
|
|
917
|
+
return userValue.toLowerCase().trim() != conditionValues.toLowerCase().trim();
|
|
918
|
+
case "greater":
|
|
919
|
+
return compareVersions(userValue.trim(), conditionValues.trim());
|
|
920
|
+
case "less":
|
|
921
|
+
return compareVersions(conditionValues.trim(), userValue.trim());
|
|
922
|
+
case "greater equal":
|
|
923
|
+
return compareVersions(userValue.trim(), conditionValues.trim(), false);
|
|
924
|
+
case "less equal":
|
|
925
|
+
return compareVersions(conditionValues.trim(), userValue.trim(), false);
|
|
926
|
+
case "any of":
|
|
927
|
+
return conditionValues.includes(userValue);
|
|
928
|
+
case "none of":
|
|
929
|
+
return !conditionValues.includes(userValue);
|
|
930
|
+
case "contains any of":
|
|
931
|
+
for (let i = 0; i < conditionValues.length; i++) {
|
|
932
|
+
if (userValue.includes(conditionValues[i])) {
|
|
933
|
+
return true;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
return false;
|
|
937
|
+
case "contains none of":
|
|
938
|
+
for (let i = 0; i < conditionValues.length; i++) {
|
|
939
|
+
if (userValue.includes(conditionValues[i])) {
|
|
940
|
+
return false;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
return true;
|
|
944
|
+
case "on date":
|
|
945
|
+
return Math.floor(
|
|
946
|
+
new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60 * 24)
|
|
947
|
+
) == this.sigmaUserData.user.date;
|
|
948
|
+
case "after time":
|
|
949
|
+
return new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60) < this.sigmaUserData.user.time;
|
|
950
|
+
case "before time":
|
|
951
|
+
return new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60) > this.sigmaUserData.user.time;
|
|
952
|
+
case "starts with":
|
|
953
|
+
return userValue.startsWith(conditionValues);
|
|
954
|
+
case "not starts with":
|
|
955
|
+
return !userValue.startsWith(conditionValues);
|
|
956
|
+
case "ends with":
|
|
957
|
+
return userValue.endsWith(conditionValues);
|
|
958
|
+
case "not ends with":
|
|
959
|
+
return !userValue.endsWith(conditionValues);
|
|
960
|
+
case "contains":
|
|
961
|
+
return userValue.includes(conditionValues);
|
|
962
|
+
case "not contains":
|
|
963
|
+
return !userValue.includes(conditionValues);
|
|
964
|
+
default:
|
|
965
|
+
return false;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
|
|
905
969
|
// src/helpers/delay.js
|
|
906
970
|
function delay(ms) {
|
|
907
971
|
return new Promise((resolve) => setTimeout(() => resolve(void 0), ms));
|
|
@@ -966,8 +1030,10 @@ function filterByPlatform(config, platformName) {
|
|
|
966
1030
|
return config;
|
|
967
1031
|
let filteredConfig = { ...config };
|
|
968
1032
|
const { feature_flags, experiments } = filteredConfig;
|
|
969
|
-
filteredConfig.feature_flags
|
|
970
|
-
|
|
1033
|
+
if (filteredConfig.feature_flags)
|
|
1034
|
+
filteredConfig.feature_flags = generateFilteredList(feature_flags, platformName);
|
|
1035
|
+
if (filteredConfig.experiments)
|
|
1036
|
+
filteredConfig.experiments = generateFilteredList(experiments, platformName);
|
|
971
1037
|
return filteredConfig;
|
|
972
1038
|
}
|
|
973
1039
|
function generateFilteredList(array, name) {
|
|
@@ -983,7 +1049,7 @@ function generateFilteredList(array, name) {
|
|
|
983
1049
|
return array;
|
|
984
1050
|
array = array.filter((item) => {
|
|
985
1051
|
for (let index in listName) {
|
|
986
|
-
if (!item.platform)
|
|
1052
|
+
if (!item.platform || item.platform === "all")
|
|
987
1053
|
return item;
|
|
988
1054
|
if (item.platform === listName[index])
|
|
989
1055
|
return item;
|
|
@@ -1242,56 +1308,6 @@ var Sigma = class {
|
|
|
1242
1308
|
}
|
|
1243
1309
|
return flagValue;
|
|
1244
1310
|
}
|
|
1245
|
-
conditionOperation(userValue, conditionValues, operation) {
|
|
1246
|
-
!operation ? operation = "=" : operation;
|
|
1247
|
-
if (userValue === null || typeof userValue === "undefined" || !conditionValues)
|
|
1248
|
-
return false;
|
|
1249
|
-
userValue = String(userValue);
|
|
1250
|
-
if (!Array.isArray(conditionValues))
|
|
1251
|
-
conditionValues = String(conditionValues);
|
|
1252
|
-
switch (operation.trim()) {
|
|
1253
|
-
case "equal":
|
|
1254
|
-
return userValue.toLowerCase().trim() == conditionValues.toLowerCase().trim();
|
|
1255
|
-
case "not equal":
|
|
1256
|
-
return userValue.toLowerCase().trim() != conditionValues.toLowerCase().trim();
|
|
1257
|
-
case "greater":
|
|
1258
|
-
return compareVersions(userValue.trim(), conditionValues.trim());
|
|
1259
|
-
case "less":
|
|
1260
|
-
return compareVersions(conditionValues.trim(), userValue.trim());
|
|
1261
|
-
case "greater equal":
|
|
1262
|
-
return compareVersions(userValue.trim(), conditionValues.trim(), false);
|
|
1263
|
-
case "less equal":
|
|
1264
|
-
return compareVersions(conditionValues.trim(), userValue.trim(), false);
|
|
1265
|
-
case "any of":
|
|
1266
|
-
return conditionValues.includes(userValue);
|
|
1267
|
-
case "none of":
|
|
1268
|
-
return !conditionValues.includes(userValue);
|
|
1269
|
-
case "contains any of":
|
|
1270
|
-
for (let i = 0; i < conditionValues.length; i++) {
|
|
1271
|
-
if (userValue.includes(conditionValues[i])) {
|
|
1272
|
-
return true;
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
return false;
|
|
1276
|
-
case "contains none of":
|
|
1277
|
-
for (let i = 0; i < conditionValues.length; i++) {
|
|
1278
|
-
if (userValue.includes(conditionValues[i])) {
|
|
1279
|
-
return false;
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
return true;
|
|
1283
|
-
case "on date":
|
|
1284
|
-
return Math.floor(
|
|
1285
|
-
new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60 * 24)
|
|
1286
|
-
) == this.sigmaUserData.user.date;
|
|
1287
|
-
case "after time":
|
|
1288
|
-
return new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60) < this.sigmaUserData.user.time;
|
|
1289
|
-
case "before time":
|
|
1290
|
-
return new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60) > this.sigmaUserData.user.time;
|
|
1291
|
-
default:
|
|
1292
|
-
return false;
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
1311
|
getUserParamValue(paramKey, privateFlag = null, isConditionSignForHash = false) {
|
|
1296
1312
|
if (!paramKey)
|
|
1297
1313
|
return false;
|
|
@@ -1385,7 +1401,7 @@ var Sigma = class {
|
|
|
1385
1401
|
this.checkConditionSignForHash(targets.conditions[index].condition_sign)
|
|
1386
1402
|
);
|
|
1387
1403
|
results.push(
|
|
1388
|
-
|
|
1404
|
+
conditionOperation(
|
|
1389
1405
|
userValue,
|
|
1390
1406
|
targets.conditions[index].value,
|
|
1391
1407
|
targets.conditions[index].condition_sign
|
|
@@ -1597,7 +1613,7 @@ var Sigma = class {
|
|
|
1597
1613
|
this.checkConditionSignForHash(conditions[i].condition_sign)
|
|
1598
1614
|
);
|
|
1599
1615
|
results.push(
|
|
1600
|
-
|
|
1616
|
+
conditionOperation(
|
|
1601
1617
|
userValue,
|
|
1602
1618
|
conditions[i].value,
|
|
1603
1619
|
conditions[i].condition_sign
|