drapcode-utility 1.9.0 → 1.9.1
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/build/utils/util.js +15 -0
- package/package.json +1 -1
package/build/utils/util.js
CHANGED
|
@@ -298,28 +298,34 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
298
298
|
var _a;
|
|
299
299
|
var contentList = (_a = expression
|
|
300
300
|
.match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
|
|
301
|
+
console.log("1 replaceDataValueIntoExpression");
|
|
301
302
|
contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
|
|
302
303
|
var needle = "{{".concat(prop, "}}");
|
|
304
|
+
console.log("needle :>> ", needle);
|
|
303
305
|
var dataOfItem = "";
|
|
304
306
|
if (prop.includes("current_user")) {
|
|
307
|
+
console.log("Current User");
|
|
305
308
|
prop = prop.replace("current_user.", "");
|
|
306
309
|
if (Object.keys(user).length > 0) {
|
|
307
310
|
dataOfItem = (0, exports.parseValueFromData)(user, prop);
|
|
308
311
|
}
|
|
309
312
|
}
|
|
310
313
|
else if (prop.includes("current_tenant")) {
|
|
314
|
+
console.log("Current Tenant");
|
|
311
315
|
prop = prop.replace("current_tenant.", "");
|
|
312
316
|
if (Object.keys(tenant).length > 0) {
|
|
313
317
|
dataOfItem = (0, exports.parseValueFromData)(tenant, prop);
|
|
314
318
|
}
|
|
315
319
|
}
|
|
316
320
|
else if (prop.includes("current_settings")) {
|
|
321
|
+
console.log("Current Setting");
|
|
317
322
|
prop = prop.replace("current_settings.", "");
|
|
318
323
|
if (Object.keys(userSetting).length > 0) {
|
|
319
324
|
dataOfItem = (0, exports.parseValueFromData)(userSetting, prop);
|
|
320
325
|
}
|
|
321
326
|
}
|
|
322
327
|
else if (prop.includes("current_session")) {
|
|
328
|
+
console.log("Current Session");
|
|
323
329
|
prop = prop.replace("current_session.", "");
|
|
324
330
|
if (Object.keys(sessionValue).length > 0) {
|
|
325
331
|
//Session will contain multi level data
|
|
@@ -327,6 +333,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
327
333
|
}
|
|
328
334
|
}
|
|
329
335
|
else if (prop.includes("form_data_session")) {
|
|
336
|
+
console.log("Form Data Session");
|
|
330
337
|
prop = prop.replace("form_data_session.", "");
|
|
331
338
|
if (Object.keys(sessionFormValue).length > 0) {
|
|
332
339
|
//Form Session will contain multi level data
|
|
@@ -334,6 +341,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
334
341
|
}
|
|
335
342
|
}
|
|
336
343
|
else if (prop.includes("SESSION_STORAGE")) {
|
|
344
|
+
console.log("Session Storage");
|
|
337
345
|
prop = prop.replace("SESSION_STORAGE.", "");
|
|
338
346
|
if (Object.keys(sessionValue).length > 0) {
|
|
339
347
|
//Session will contain multi level data
|
|
@@ -341,6 +349,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
341
349
|
}
|
|
342
350
|
}
|
|
343
351
|
else if (prop.includes("LOCAL_STORAGE")) {
|
|
352
|
+
console.log("Local Storage");
|
|
344
353
|
prop = prop.replace("LOCAL_STORAGE.", "");
|
|
345
354
|
if (Object.keys(localStorageValue).length > 0) {
|
|
346
355
|
//Session will contain multi level data
|
|
@@ -348,6 +357,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
348
357
|
}
|
|
349
358
|
}
|
|
350
359
|
else if (prop.includes("COOKIES")) {
|
|
360
|
+
console.log("Cookies");
|
|
351
361
|
prop = prop.replace("COOKIES.", "");
|
|
352
362
|
if (Object.keys(cookiesValue).length > 0) {
|
|
353
363
|
//Session will contain multi level data
|
|
@@ -355,6 +365,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
355
365
|
}
|
|
356
366
|
}
|
|
357
367
|
else if (prop.includes("environment_variable")) {
|
|
368
|
+
console.log("Environment Variable");
|
|
358
369
|
prop = prop.replace("environment_variable.", "");
|
|
359
370
|
if (Object.keys(envConstants).length > 0) {
|
|
360
371
|
var selectedConstant = envConstants.find(function (constant) { return constant.name === prop; });
|
|
@@ -362,13 +373,16 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
362
373
|
}
|
|
363
374
|
}
|
|
364
375
|
else {
|
|
376
|
+
console.log("Nothing Matches");
|
|
365
377
|
if (Object.keys(data).length > 0) {
|
|
366
378
|
dataOfItem = (0, exports.parseValueFromData)(data, prop);
|
|
367
379
|
//TODO: Need better way
|
|
368
380
|
delete data[prop];
|
|
369
381
|
}
|
|
370
382
|
}
|
|
383
|
+
console.log("dataOfItem :>> ", dataOfItem);
|
|
371
384
|
expression = replaceValueInExpression(needle, dataOfItem, expression);
|
|
385
|
+
console.log("expression :>> ", expression);
|
|
372
386
|
});
|
|
373
387
|
return expression;
|
|
374
388
|
};
|
|
@@ -427,6 +441,7 @@ var parseValueFromData = function (data, fieldName) {
|
|
|
427
441
|
else {
|
|
428
442
|
value = data ? data[fieldName] : "";
|
|
429
443
|
}
|
|
444
|
+
console.log("value :>> ", value);
|
|
430
445
|
if (value && Array.isArray(value) && typeof value[0] === "string") {
|
|
431
446
|
return value.join(", ");
|
|
432
447
|
}
|