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
9
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 2.1.13 to 2.1.14

8

lib/cjs/apiUtils.d.ts

@@ -9,2 +9,10 @@ import { IApiCreateState, IApiDeleteState, IApiResponseDetails, IApiUpdateState } from '@rh-support/types/shared';

export declare function haventLoadedProductsMetadata(apiResponse: IApiResponseDetails<ITroubleshootProductResponse>): boolean;
/**
* We are firstly remove the special characters from the string and then encode the string. After that
* we are trimming text as per limit set and then decode the string.
* @param description Description string
* @param limit Limit to trim the string
* @returns
*/
export declare const getTrimmedSpecialCharacters: (description?: string, limit?: number) => string;
//# sourceMappingURL=apiUtils.d.ts.map

22

lib/cjs/apiUtils.js

@@ -6,4 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.haventLoadedProductsMetadata = exports.haventLoadedMetadata = exports.getApiDeletionStatus = exports.getApiUpdationStatus = exports.getApiCreationStatus = exports.getApiResourceObject = void 0;
exports.getTrimmedSpecialCharacters = exports.haventLoadedProductsMetadata = exports.haventLoadedMetadata = exports.getApiDeletionStatus = exports.getApiUpdationStatus = exports.getApiCreationStatus = exports.getApiResourceObject = void 0;
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
const trim_1 = __importDefault(require("lodash/trim"));
function getApiResourceObject(data = undefined, isFetching = false, isError = false, errorMessage = '', error = null) {

@@ -34,1 +35,20 @@ return { data, isFetching, isError, errorMessage, error };

exports.haventLoadedProductsMetadata = haventLoadedProductsMetadata;
/**
* We are firstly remove the special characters from the string and then encode the string. After that
* we are trimming text as per limit set and then decode the string.
* @param description Description string
* @param limit Limit to trim the string
* @returns
*/
const getTrimmedSpecialCharacters = (description = '', limit = 4000) => {
if (description) {
const removeSpecialCharacters = trim_1.default(description.replace(/[^a-zA-Z0-9 ]/g, '').replace(/ {2,}/g, ' '));
const encodedDescription = encodeURIComponent(removeSpecialCharacters);
const trimmedDescription = encodedDescription.slice(0, limit);
return decodeURIComponent(trimmedDescription) || '';
}
else {
return description;
}
};
exports.getTrimmedSpecialCharacters = getTrimmedSpecialCharacters;

@@ -14,3 +14,4 @@ import moment from 'moment-timezone';

export declare const addDaysToDate: (params: AddToDate) => moment.Moment;
export declare const trafficSplit: (testVariationWeight: number, dateString: string) => "A" | "B";
export {};
//# sourceMappingURL=dateUtils.d.ts.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.addDaysToDate = exports.isFutureDate = exports.isCurrentDateSameAsOrBeforeDate = exports.getPastUTCDateFromNow = exports.getTimezoneOffsetFromTZName = exports.isoDate = exports.formatDateTime = exports.formatDate = void 0;
exports.trafficSplit = exports.addDaysToDate = exports.isFutureDate = exports.isCurrentDateSameAsOrBeforeDate = exports.getPastUTCDateFromNow = exports.getTimezoneOffsetFromTZName = exports.isoDate = exports.formatDateTime = exports.formatDate = void 0;
const moment_timezone_1 = __importDefault(require("moment-timezone"));

@@ -58,1 +58,23 @@ const formatDate = (date, locale = 'en-us', format = { month: 'short', day: 'numeric', year: 'numeric' }) => {

exports.addDaysToDate = addDaysToDate;
// split traffic based on time and weight
// for example, if testVariationWeight is 2 and the current time in seconds modulo 10 is less than 2,
// redirect to test version (20% of the time), else redirect to control version (80% of the time)
// @wieght: a number between 0 and 10
// @dateString: date string
const trafficSplit = (testVariationWeight, dateString) => {
if (testVariationWeight === 10)
return 'A'; // test
if (testVariationWeight === 0 || !testVariationWeight || isNaN(testVariationWeight))
return 'B'; // control
const date = new Date(dateString);
const seconds = date.getSeconds();
const totalWeight = 10;
const moduloResult = seconds % totalWeight;
if (moduloResult < testVariationWeight) {
return 'A';
}
else {
return 'B';
}
};
exports.trafficSplit = trafficSplit;

4

lib/cjs/hydraConfigUtils.d.ts

@@ -7,3 +7,5 @@ import { IMaintenance } from '@cee-eng/hydrajs/@types/models/maintenance';

FEATURE_FLAG = "FEATURE-FLAG",
STRING_COMMA_SEPERATED = "STRING-COMMA-SEPERATED"
STRING_COMMA_SEPERATED = "STRING-COMMA-SEPERATED",
STRING = "STRING",
NUMBER = "NUMBER"
}

@@ -10,0 +12,0 @@ declare function getConfigField(config: IMaintenance[], fieldName: string, fieldType?: PCM_CONFIG_FIELD_TYPE): any;

@@ -19,2 +19,4 @@ "use strict";

PCM_CONFIG_FIELD_TYPE["STRING_COMMA_SEPERATED"] = "STRING-COMMA-SEPERATED";
PCM_CONFIG_FIELD_TYPE["STRING"] = "STRING";
PCM_CONFIG_FIELD_TYPE["NUMBER"] = "NUMBER";
})(PCM_CONFIG_FIELD_TYPE = exports.PCM_CONFIG_FIELD_TYPE || (exports.PCM_CONFIG_FIELD_TYPE = {}));

@@ -25,2 +27,8 @@ function getConfigField(config, fieldName, fieldType = null) {

}, []);
if (fieldType && fieldType === PCM_CONFIG_FIELD_TYPE.STRING) {
return values[0];
}
if (fieldType && fieldType === PCM_CONFIG_FIELD_TYPE.NUMBER) {
return parseInt(values[0], 10);
}
if (fieldType && fieldType === PCM_CONFIG_FIELD_TYPE.FEATURE_FLAG) {

@@ -27,0 +35,0 @@ return values.length === 0 ? false : Boolean(parseInt(values[0]));

@@ -32,3 +32,5 @@ "use strict";

// when we are uploading a file before adding issue summary no highlighting doc is present hence passing an empty object
const highlightObj = highlighting[doc.resource_uri] || highlighting[doc.uri] || highlighting[doc.view_uri] || {};
const highlightObj = highlighting
? highlighting[doc.resource_uri] || highlighting[doc.uri] || highlighting[doc.view_uri] || {}
: {};
return Object.assign(Object.assign({}, doc), { abstract: (highlightObj.abstract && highlightObj.abstract[0]) || doc.abstract || '', publishedAbstract: (highlightObj.publishedAbstract && highlightObj.publishedAbstract[0]) || doc.publishedAbstract || '', issue: highlightObj.issue || doc.issue || [] });

@@ -35,0 +37,0 @@ });

@@ -39,2 +39,3 @@ import { ISearchSolrQuery } from '@cee-eng/hydrajs/@types/api/search';

'facet.mincount'?: string;
rerank?: boolean;
q?: string;

@@ -41,0 +42,0 @@ start?: number;

@@ -9,2 +9,10 @@ import { IApiCreateState, IApiDeleteState, IApiResponseDetails, IApiUpdateState } from '@rh-support/types/shared';

export declare function haventLoadedProductsMetadata(apiResponse: IApiResponseDetails<ITroubleshootProductResponse>): boolean;
/**
* We are firstly remove the special characters from the string and then encode the string. After that
* we are trimming text as per limit set and then decode the string.
* @param description Description string
* @param limit Limit to trim the string
* @returns
*/
export declare const getTrimmedSpecialCharacters: (description?: string, limit?: number) => string;
//# sourceMappingURL=apiUtils.d.ts.map
import isEmpty from 'lodash/isEmpty';
import trim from 'lodash/trim';
export function getApiResourceObject(data = undefined, isFetching = false, isError = false, errorMessage = '', error = null) {

@@ -21,1 +22,19 @@ return { data, isFetching, isError, errorMessage, error };

}
/**
* We are firstly remove the special characters from the string and then encode the string. After that
* we are trimming text as per limit set and then decode the string.
* @param description Description string
* @param limit Limit to trim the string
* @returns
*/
export const getTrimmedSpecialCharacters = (description = '', limit = 4000) => {
if (description) {
const removeSpecialCharacters = trim(description.replace(/[^a-zA-Z0-9 ]/g, '').replace(/ {2,}/g, ' '));
const encodedDescription = encodeURIComponent(removeSpecialCharacters);
const trimmedDescription = encodedDescription.slice(0, limit);
return decodeURIComponent(trimmedDescription) || '';
}
else {
return description;
}
};

@@ -14,3 +14,4 @@ import moment from 'moment-timezone';

export declare const addDaysToDate: (params: AddToDate) => moment.Moment;
export declare const trafficSplit: (testVariationWeight: number, dateString: string) => "A" | "B";
export {};
//# sourceMappingURL=dateUtils.d.ts.map

@@ -43,1 +43,22 @@ import moment from 'moment-timezone';

};
// split traffic based on time and weight
// for example, if testVariationWeight is 2 and the current time in seconds modulo 10 is less than 2,
// redirect to test version (20% of the time), else redirect to control version (80% of the time)
// @wieght: a number between 0 and 10
// @dateString: date string
export const trafficSplit = (testVariationWeight, dateString) => {
if (testVariationWeight === 10)
return 'A'; // test
if (testVariationWeight === 0 || !testVariationWeight || isNaN(testVariationWeight))
return 'B'; // control
const date = new Date(dateString);
const seconds = date.getSeconds();
const totalWeight = 10;
const moduloResult = seconds % totalWeight;
if (moduloResult < testVariationWeight) {
return 'A';
}
else {
return 'B';
}
};

@@ -7,3 +7,5 @@ import { IMaintenance } from '@cee-eng/hydrajs/@types/models/maintenance';

FEATURE_FLAG = "FEATURE-FLAG",
STRING_COMMA_SEPERATED = "STRING-COMMA-SEPERATED"
STRING_COMMA_SEPERATED = "STRING-COMMA-SEPERATED",
STRING = "STRING",
NUMBER = "NUMBER"
}

@@ -10,0 +12,0 @@ declare function getConfigField(config: IMaintenance[], fieldName: string, fieldType?: PCM_CONFIG_FIELD_TYPE): any;

@@ -13,2 +13,4 @@ import concat from 'lodash/concat';

PCM_CONFIG_FIELD_TYPE["STRING_COMMA_SEPERATED"] = "STRING-COMMA-SEPERATED";
PCM_CONFIG_FIELD_TYPE["STRING"] = "STRING";
PCM_CONFIG_FIELD_TYPE["NUMBER"] = "NUMBER";
})(PCM_CONFIG_FIELD_TYPE || (PCM_CONFIG_FIELD_TYPE = {}));

@@ -19,2 +21,8 @@ function getConfigField(config, fieldName, fieldType = null) {

}, []);
if (fieldType && fieldType === PCM_CONFIG_FIELD_TYPE.STRING) {
return values[0];
}
if (fieldType && fieldType === PCM_CONFIG_FIELD_TYPE.NUMBER) {
return parseInt(values[0], 10);
}
if (fieldType && fieldType === PCM_CONFIG_FIELD_TYPE.FEATURE_FLAG) {

@@ -21,0 +29,0 @@ return values.length === 0 ? false : Boolean(parseInt(values[0]));

@@ -22,3 +22,5 @@ import DOMPurify from 'dompurify';

// when we are uploading a file before adding issue summary no highlighting doc is present hence passing an empty object
const highlightObj = highlighting[doc.resource_uri] || highlighting[doc.uri] || highlighting[doc.view_uri] || {};
const highlightObj = highlighting
? highlighting[doc.resource_uri] || highlighting[doc.uri] || highlighting[doc.view_uri] || {}
: {};
return Object.assign(Object.assign({}, doc), { abstract: (highlightObj.abstract && highlightObj.abstract[0]) || doc.abstract || '', publishedAbstract: (highlightObj.publishedAbstract && highlightObj.publishedAbstract[0]) || doc.publishedAbstract || '', issue: highlightObj.issue || doc.issue || [] });

@@ -25,0 +27,0 @@ });

@@ -39,2 +39,3 @@ import { ISearchSolrQuery } from '@cee-eng/hydrajs/@types/api/search';

'facet.mincount'?: string;
rerank?: boolean;
q?: string;

@@ -41,0 +42,0 @@ start?: number;

{
"name": "@rh-support/utils",
"version": "2.1.13",
"version": "2.1.14",
"description": "> TODO: description",

@@ -48,3 +48,3 @@ "author": "Vikas Rathee <vrathee@redhat.com>",

"peerDependencies": {
"@cee-eng/hydrajs": "4.16.39",
"@cee-eng/hydrajs": "4.16.43",
"@cee-eng/ui-toolkit": "1.1.6",

@@ -63,3 +63,3 @@ "dompurify": "^2.2.6",

"dependencies": {
"@cee-eng/hydrajs": "4.16.39",
"@cee-eng/hydrajs": "4.16.43",
"@cee-eng/ui-toolkit": "1.1.6",

@@ -93,3 +93,3 @@ "@rh-support/types": "2.0.2",

],
"gitHead": "d17dacfd35aa08c446f37c8f0f92760346b8eb7a"
"gitHead": "c5a573ae8bd924caf9689a0179fde2181038b4e9"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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