New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@rh-support/utils

Package Overview
Dependencies
Maintainers
4
Versions
339
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rh-support/utils - npm Package Compare versions

Comparing version 0.0.37 to 0.0.38

lib/apiUtils.d.ts

163

lib/index.js

@@ -1,155 +0,8 @@

import { Markdown } from 'js-markdown-extra';
import assign from 'lodash/assign';
import get from 'lodash/get';
import includes from 'lodash/includes';
import isEmpty from 'lodash/isEmpty';
import isString from 'lodash/isString';
import map from 'lodash/map';
import marked from 'marked';
import qs from 'qs';
import orderBy from 'lodash/orderBy';
import uniq from 'lodash/uniq';
import zipObject from 'lodash/zipObject';
function getApiResourceObject(data, isFetching, isError, errorMessage) {
if (isFetching === void 0) { isFetching = false; }
if (isError === void 0) { isError = false; }
if (errorMessage === void 0) { errorMessage = ''; }
return { data: data, isFetching: isFetching, isError: isError, errorMessage: errorMessage };
}
function getRecommendationTitle(doc) {
return !isEmpty(doc.publishedTitle) ? doc.publishedTitle : doc.allTitle;
}
// parses url query params to an obj
function getUrlParsedParams(urlParams) {
return qs.parse(urlParams, { ignoreQueryPrefix: true });
}
function canManageCase(loggedInUserJwtToken) {
return includes(loggedInUserJwtToken.realm_access.roles, 'portal_manage_cases');
}
function scrollIntoSection(sectionRef) {
// Adding setTimeout so that scrolling occures only after width is added/removed from active and previouly active section respectively.
setTimeout(function () {
if (isEmpty(sectionRef) || isEmpty(sectionRef.current)) {
return;
}
sectionRef.current.scrollIntoView({ behavior: 'smooth' });
}, 100);
}
// converts an obj to url query params
function getStringifiedParams(object) {
return qs.stringify(object, { arrayFormat: 'repeat', encode: false });
}
function humanizeSize(fileSize) {
var i = -1;
var size = fileSize;
var byteUnits = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
do {
size = size / 1024;
i++;
} while (size > 1024 && byteUnits[i + 1]);
return Math.max(size, 0.1).toFixed(1) + " " + byteUnits[i];
}
function showFts(sla, severity) {
return isPremiumEntitlement(sla) && isSev1(severity);
}
function isPremiumEntitlement(sla) {
return sla === 'PREMIUM' || sla === 'AMC' || sla === 'PREMIUMPLUS' || sla === 'PREMIUM PLUS';
}
function isSev1(severity) {
return severity && severity.charAt(0) === '1';
}
function toOption(value, labelKey, disabledKey) {
return value && {
value: value,
label: labelKey ? value[labelKey] : value,
disabled: disabledKey ? value[disabledKey] : false,
};
}
function toOptions(values, labelKey, disabledKey) {
return map(values, function (v) { return toOption(v, labelKey, disabledKey); });
}
var defaultMarkdownOptions = { gfm: true, breaks: true, jsMarkdownExtra: false, openLinksInNewTab: false };
function markdownToHTML(md, options, callback) {
if (options === void 0) { options = defaultMarkdownOptions; }
if (!isString(md)) {
return '';
}
// Important Note: jsMarkdownExtra option is depricated to use
// Eventually we will get rid of js-markdown-extra library because it is not longer maintained and has bugs while parsing huge data and special chars
// when jsMarkdownExtra is true, MarkedOptions will not get applied
var parsedHtml = get(options, 'jsMarkdownExtra', false) ? Markdown(md.replace(/```/gi, '')) : marked(md, assign({}, defaultMarkdownOptions, options), callback);
return get(options, 'openLinksInNewTab', false) ? parsedHtml.replace("<a href", '<a target="blank" href') : parsedHtml;
}
var handleProductSearchResponse = function (response) {
var productsResult = response;
// start of calculating feature products
// also we use this object to show default version when user select
// product from homepage and is redirected to SE app
var productList = [];
for (var j = 0, pmax = productsResult.length; j < pmax; j++) {
if (productsResult[j][1] !== 'Other') {
productList.push(productsResult[j][1]);
}
}
var featuredProducts = uniq(productList);
var obj = {};
for (var i = 0, imax = featuredProducts.length; i < imax; i++) {
for (var j = 0, jmax = productsResult.length; j < jmax; j++) {
if (featuredProducts[i] === productsResult[j][1]) {
obj['"' + productsResult[j][1] + '"'] = productsResult[j][2];
break;
}
}
}
var featuredProductsObj = obj;
// end of calculating feature products
// group products based on version
for (var i = 0, max = productsResult.length; i < max; i++) {
if (productsResult[i][1] !== 'Other') {
productsResult[i] = zipObject(['product_version', 'product_name', 'version'], productsResult[i]);
}
}
var groups = {};
// tslint:disable-next-line:prefer-for-of
for (var i = 0; i < productsResult.length; i++) {
if (productsResult[i].product_name) {
var groupName = productsResult[i].product_name;
if (!groups[groupName]) {
groups[groupName] = [];
}
groups[groupName].push(productsResult[i].version);
}
}
var pproductsResult = [];
// tslint:disable-next-line:forin
for (var groupName in groups) {
// sort versions in descending order
var versions = groups[groupName]
.map(function (a) { return a.replace(/\d+/g, function (n) { return +n + 100000; }); }).sort()
.map(function (a) { return a.replace(/\d+/g, function (n) { return +n - 100000; }); }).reverse();
// handle special case
// when we have unknown as the version, we remove it
var index = versions.indexOf('Unknown');
if (index !== -1) {
versions.splice(index, 1);
}
// tslint:disable-next-line:max-line-length
pproductsResult.push({
product_name: groupName, versions: versions, featuredVersion: featuredProductsObj['"' + groupName + '"'],
selectedVersion: featuredProductsObj['"' + groupName + '"']
});
}
// end of group products based on version
// first top 5 products before sorting
// we get products based on the highest number of support cases
return {
topProducts: pproductsResult.slice(0, 5),
otherProducts: orderBy(pproductsResult.slice(5), ['product_name'], ['asc']),
productsResult: pproductsResult
};
};
export { canManageCase, defaultMarkdownOptions, getApiResourceObject, getRecommendationTitle, getStringifiedParams, getUrlParsedParams, handleProductSearchResponse, humanizeSize, isPremiumEntitlement, isSev1, markdownToHTML, scrollIntoSection, showFts, toOption, toOptions };
//# sourceMappingURL=index.js.map
export * from './apiUtils';
export * from './caseUtils';
export * from './dropdownUtils';
export * from './markdownUtils';
export * from './productsUtils';
export * from './scrollUtils';
export * from './urlUtils';
//# sourceMappingURL=index.js.map
{
"name": "@rh-support/utils",
"version": "0.0.37",
"version": "0.0.38",
"description": "> TODO: description",

@@ -11,12 +11,10 @@ "author": "Vikas Rathee <vrathee@redhat.com>",

"jsnext:main": "lib/index.js",
"types": "@types/index.d.ts",
"types": "lib/index.d.ts",
"sideEffects": false,
"directories": {
"lib": "lib",
"types": "@types"
"lib": "lib"
},
"files": [
"lib/*",
"lib/**/*",
"@types/"
"lib/**/*"
],

@@ -37,33 +35,21 @@ "repository": {

"scripts": {
"build:watch": "rollup -c ./node_modules/@rh-support/configs/packages/rollup.config.js --watch & tsc -w -p config/tsconfig.declaration.json",
"build": "rimraf lib && rollup -c ./node_modules/@rh-support/configs/packages/rollup.config.js && tsc -p config/tsconfig.declaration.json",
"build:watch": "../../node_modules/.bin/tsc -w -p config/tsconfig.json",
"build": "npm run clean && ../../node_modules/.bin/tsc -p config/tsconfig.json",
"clean": "../../node_modules/.bin/rimraf lib",
"prepublishOnly": "npm run build"
},
"peerDependencies": {
"@rh-support/api": ">=0.0.8",
"@rh-support/types": ">=0.0.6",
"js-markdown-extra": ">=1.2.4",
"lodash": ">=4.17.15",
"marked": ">=0.7.0",
"qs": ">=6.7.0"
"dependencies": {
"@rh-support/api": "^0.0.38",
"@rh-support/types": "^0.0.38",
"js-markdown-extra": "^1.2.4",
"lodash": "^4.17.15",
"marked": "^0.7.0",
"qs": "^6.7.0"
},
"devDependencies": {
"@rh-support/api": "^0.0.37",
"@rh-support/configs": "^0.0.37",
"@rh-support/types": "^0.0.37",
"@types/marked": "^0.6.5",
"@types/react": "^16.8.23",
"@types/react-dom": "^16.8.5",
"js-markdown-extra": "^1.2.4",
"lodash": "^4.17.15",
"marked": "^0.7.0",
"qs": "^6.7.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"rimraf": "^2.6.3",
"rollup": "^1.20.1",
"tslib": "^1.10.0",
"typescript": "^3.6.2"
"@types/react-dom": "^16.8.5"
},
"gitHead": "fbf98800fdcb881aada5c17a8847dee8ba0ed68b"
"gitHead": "54caab42629ce2610fd9fbaf2cec340ce7acb29c"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc