rivia 0.0.57 → 0.0.59
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/index.js +96 -9
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -82,9 +82,9 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
82
82
|
user_var1 = "User_" + Math.random().toString(36).substring(2, 8);
|
|
83
83
|
sessionStorage.setItem(user_var, user_var1);
|
|
84
84
|
}
|
|
85
|
-
const backendUrl = `
|
|
85
|
+
const backendUrl = `http://localhost:5000/clients/${checklist_id}/${user_var1}`;
|
|
86
86
|
async function getUserProgress22() {
|
|
87
|
-
const backendUrl2 = `
|
|
87
|
+
const backendUrl2 = `http://localhost:5000/clients/${checklist_id}/${user_var1}`;
|
|
88
88
|
try {
|
|
89
89
|
const res = await fetch(backendUrl2, { credentials: "include" });
|
|
90
90
|
if (!res.ok) console.warn(`GET failed: ${res.status}`);
|
|
@@ -122,7 +122,7 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
122
122
|
}
|
|
123
123
|
storedVisited2 = sessionStorage.getItem("onboardingVisited");
|
|
124
124
|
async function getUserProgress22() {
|
|
125
|
-
const backendUrl2 = `
|
|
125
|
+
const backendUrl2 = `http://localhost:5000/clients/${checklist_id}/${user_var1}`;
|
|
126
126
|
try {
|
|
127
127
|
const res = await fetch(backendUrl2, { credentials: "include" });
|
|
128
128
|
if (!res.ok) console.warn(`GET failed: ${res.status}`);
|
|
@@ -862,7 +862,7 @@ transform: translateY(-20%);
|
|
|
862
862
|
function uploadVisitedPagesInBackground(completed2, touched = false) {
|
|
863
863
|
let activeStepId2 = sessionStorage.getItem("activeStepId") || null;
|
|
864
864
|
let user_var22 = user_var;
|
|
865
|
-
const backendUrl22 = `
|
|
865
|
+
const backendUrl22 = `http://localhost:5000/clients/${checklist_id}`;
|
|
866
866
|
try {
|
|
867
867
|
const payload = {
|
|
868
868
|
name: user_var22,
|
|
@@ -893,7 +893,7 @@ transform: translateY(-20%);
|
|
|
893
893
|
storedVisited2 = sessionStorage.getItem("onboardingVisited");
|
|
894
894
|
if (!storedVisited2 || storedVisited2 == "[]") {
|
|
895
895
|
async function getUserProgress22() {
|
|
896
|
-
const backendUrl2 = `
|
|
896
|
+
const backendUrl2 = `http://localhost:5000/clients/${checklist_id}/${user_var}`;
|
|
897
897
|
try {
|
|
898
898
|
const res = await fetch(backendUrl2, { credentials: "include" });
|
|
899
899
|
if (!res.ok) console.warn(`GET failed: ${res.status}`);
|
|
@@ -1209,9 +1209,78 @@ transform: translateY(-20%);
|
|
|
1209
1209
|
if (label.style.display !== "none") positionCloseBtn();
|
|
1210
1210
|
});
|
|
1211
1211
|
}
|
|
1212
|
-
|
|
1212
|
+
function evaluateRule(rule, context) {
|
|
1213
|
+
const leftValue = context[rule.name];
|
|
1214
|
+
const operator = rule.operator;
|
|
1215
|
+
const rightValue = rule.values;
|
|
1216
|
+
console.log("leftValue", leftValue);
|
|
1217
|
+
console.log("operator", operator);
|
|
1218
|
+
console.log("rightValue", rightValue);
|
|
1219
|
+
if (leftValue === void 0) return false;
|
|
1220
|
+
switch (operator) {
|
|
1221
|
+
case "in":
|
|
1222
|
+
return Array.isArray(rightValue) && rightValue.includes(leftValue);
|
|
1223
|
+
case "not_in":
|
|
1224
|
+
return Array.isArray(rightValue) && !rightValue.includes(leftValue);
|
|
1225
|
+
case "equals":
|
|
1226
|
+
if (rightValue == "sign_up_at")
|
|
1227
|
+
return new Date(leftValue).getTime() === new Date(rightValue).getTime();
|
|
1228
|
+
else
|
|
1229
|
+
return leftValue === rightValue;
|
|
1230
|
+
case "not_equals":
|
|
1231
|
+
return leftValue != rightValue;
|
|
1232
|
+
case "greater_than":
|
|
1233
|
+
if (rightValue == "sign_up_at")
|
|
1234
|
+
return new Date(leftValue).getTime() > new Date(rightValue).getTime();
|
|
1235
|
+
else
|
|
1236
|
+
return leftValue > rightValue;
|
|
1237
|
+
case "less_than":
|
|
1238
|
+
if (rightValue == "sign_up_at")
|
|
1239
|
+
return new Date(leftValue).getTime() < new Date(rightValue).getTime();
|
|
1240
|
+
else
|
|
1241
|
+
return leftValue < rightValue;
|
|
1242
|
+
case "greater_or_equals":
|
|
1243
|
+
if (rightValue == "sign_up_at")
|
|
1244
|
+
return new Date(leftValue).getTime() >= new Date(rightValue).getTime();
|
|
1245
|
+
else
|
|
1246
|
+
return leftValue >= rightValue;
|
|
1247
|
+
case "less_or_equals":
|
|
1248
|
+
if (rightValue == "sign_up_at")
|
|
1249
|
+
return new Date(leftValue).getTime() <= new Date(rightValue).getTime();
|
|
1250
|
+
else
|
|
1251
|
+
return leftValue <= rightValue;
|
|
1252
|
+
default:
|
|
1253
|
+
return false;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
function evaluateRules(rules, context) {
|
|
1257
|
+
if (!Array.isArray(rules) || rules.length === 0) return true;
|
|
1258
|
+
let finalResult = evaluateRule(rules[0], context);
|
|
1259
|
+
for (let i = 1; i < rules.length; i++) {
|
|
1260
|
+
console.log(finalResult);
|
|
1261
|
+
const previousRule = rules[i - 1];
|
|
1262
|
+
const currentResult = evaluateRule(rules[i], context);
|
|
1263
|
+
switch (previousRule.next) {
|
|
1264
|
+
case "and":
|
|
1265
|
+
finalResult = finalResult && currentResult;
|
|
1266
|
+
break;
|
|
1267
|
+
case "or":
|
|
1268
|
+
finalResult = finalResult || currentResult;
|
|
1269
|
+
break;
|
|
1270
|
+
default:
|
|
1271
|
+
finalResult = currentResult;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
return finalResult;
|
|
1275
|
+
}
|
|
1276
|
+
async function Checklist(workspace_id, obj) {
|
|
1213
1277
|
window.workspace_id = workspace_id;
|
|
1214
|
-
window.
|
|
1278
|
+
window.userid = obj.userid;
|
|
1279
|
+
let user_var = obj.userid;
|
|
1280
|
+
window.sign_up_at = obj.sign_up_at;
|
|
1281
|
+
window.role = obj.role;
|
|
1282
|
+
window.email = obj.email;
|
|
1283
|
+
console.log("");
|
|
1215
1284
|
try {
|
|
1216
1285
|
let doesRouteMatch2 = function(routes) {
|
|
1217
1286
|
if (!Array.isArray(routes)) return false;
|
|
@@ -1230,10 +1299,19 @@ async function Checklist(workspace_id, user_var) {
|
|
|
1230
1299
|
});
|
|
1231
1300
|
}, escapeRegex2 = function(str) {
|
|
1232
1301
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1302
|
+
}, buildContext2 = function(obj2) {
|
|
1303
|
+
return {
|
|
1304
|
+
userid: obj2.userid,
|
|
1305
|
+
role: obj2.role,
|
|
1306
|
+
sign_up_at: obj2.sign_up_at,
|
|
1307
|
+
email: obj2.email,
|
|
1308
|
+
first_name: obj2.first_name,
|
|
1309
|
+
last_name: obj2.last_name
|
|
1310
|
+
};
|
|
1233
1311
|
};
|
|
1234
|
-
var doesRouteMatch = doesRouteMatch2, escapeRegex = escapeRegex2;
|
|
1312
|
+
var doesRouteMatch = doesRouteMatch2, escapeRegex = escapeRegex2, buildContext = buildContext2;
|
|
1235
1313
|
const res = await fetch(
|
|
1236
|
-
`
|
|
1314
|
+
`http://localhost:5000/checklist_by_workspace2/${workspace_id}`,
|
|
1237
1315
|
{
|
|
1238
1316
|
method: "GET",
|
|
1239
1317
|
headers: { "Content-Type": "application/json" }
|
|
@@ -1260,6 +1338,15 @@ async function Checklist(workspace_id, user_var) {
|
|
|
1260
1338
|
console.log("No checklist applicable for this route");
|
|
1261
1339
|
return;
|
|
1262
1340
|
}
|
|
1341
|
+
console.log("userid", obj.userid);
|
|
1342
|
+
console.log("matched ch", matchedChecklist);
|
|
1343
|
+
const rules = matchedChecklist?.targeting_data?.custom_rules || [];
|
|
1344
|
+
console.log("rules", rules);
|
|
1345
|
+
const context = buildContext2(obj);
|
|
1346
|
+
const shouldShow = evaluateRules(rules, context);
|
|
1347
|
+
if (!shouldShow) {
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1263
1350
|
const {
|
|
1264
1351
|
checklist_id,
|
|
1265
1352
|
title = "Untitled Checklist",
|
package/index.d.ts
CHANGED