2.0.2 • Published 6 years ago
calculate-conditions v2.0.2
calculate-conditions
Return configuration nodes with 'isActive' node where value is true or false in function conditions properties
Install
npm install calculate-conditions
Example
const calculateConditions = require('calculate-conditions');
// User example
const user = {
// UserAgent properties
// Example appUserAgent:
// F8C3150BDFF86F3B1A092761;Android;samsung;SM-G920F;1440x2560;Android;6.0.1;Android;6.0.1;appName;7.5;xxxhdpi
uid : "F8C3150BDFF86F3B1A092761",
platform : "Android",
brand : "samsung",
model : "SM-G920F,
resolution : "1440x2560",
os : "Android",
osVersion : "6.0.1",
app : "appName",
appVersion : "7.5",
screenDensity : "xxxhdpi",
webviewVersion : "Chrome/58.0.3029.83"
// Session and apps properties
id = 000000001R;
isEmployee = true;
// Env properties
// Example referer:
// https://www.aaaaaa.com/qa/feature-DB-727-example/apps/appName1/index.html
referer = {
domain : "www.aaaaaa.com",
env : "qa",
branch : "feature-DB-727-example",
path : "apps",
app : "appName1"
};
lang = "spa";
};
// Conditions example
const "conditions": [
{"isEnvironment": "lh,ei,au,qa,qt", "minAppVersion": "6.6.0"}
]
const "conditions": [
{"isEnvironment": "ei", "value": "initialMessageTitleEI"},
{"isEnvironment": "qa", "value": "initialMessageTitleQA"},
{"isEnvironment": "pr", "value": "initialMessageTitlePR"}
]
const "conditions": [
{"isPlatform":"Android", "minOsVersion":"5.0", "minAppVersion": "4.9.0"},
{"isPlatform":"iPhone", "minOsVersion":"9.0", "minAppVersion": "4.9.0"}
]
//every condition node:
const evalCond = calculateConditions.calculateConditions(user, conditions);
//RESULT: {"isActive": true/false}
Conditions:
Conditions functions are configurable in conditions.js
Actual conditions:
- minAppVersion
- maxAppVersion
- minOsVersion
- maxOsVersion
- isPlatform
- isNotPlatform
- isApp
- app
- isEnvironment
- isEmployee
- isLang
- isModel
- beginDateTime
- endDateTime
- isUpdatableWebView,
- isResolution,
- isScreenDensity
License
Smart Assistants
2.0.2
6 years ago
2.0.1
6 years ago
2.0.0
6 years ago
1.0.2-3.1
6 years ago
1.0.25
6 years ago
1.1.0
6 years ago
1.0.23
6 years ago
1.0.24
6 years ago
1.0.22
7 years ago
1.0.21
7 years ago
1.0.20
7 years ago
1.0.19
7 years ago
1.0.18
7 years ago
1.0.17
7 years ago
1.0.16
7 years ago
1.0.15
7 years ago
1.0.14
7 years ago
1.0.13
7 years ago
1.0.1-2.1
7 years ago
1.0.12
7 years ago
1.0.11
7 years ago
1.0.10
7 years ago
1.0.9
7 years ago
1.0.8
7 years ago
1.0.7
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago