Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@crowdlinker/nestjs-commons

Package Overview
Dependencies
Maintainers
4
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crowdlinker/nestjs-commons - npm Package Compare versions

Comparing version 0.0.16 to 0.0.17

helpers/entity.d.ts

9

helpers/query.d.ts

@@ -89,1 +89,10 @@ import { SearchQuery, StringQuery } from '../interfaces/query';

export declare const convertDateToRawBetween: (startDate: Date | Dayjs, endDate: Date | Dayjs) => FindOperator<any>;
/**
* Creates an alter sequence query by table & column name.
*
* @param {string} tableName
* @param {string} columnName
*
* @returns {string}
*/
export declare const createAlterSeqQueryForPostgresTables: (tableName: string, columnName?: string) => string;

16

helpers/query.js

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.convertDateToRawBetween = exports.generatePaginatedResult = exports.generateRelationalSearchQueryBuilder = exports.convertQueriedInputsToStringBasedQueries = exports.validatePostgresUUID = void 0;
exports.createAlterSeqQueryForPostgresTables = exports.convertDateToRawBetween = exports.generatePaginatedResult = exports.generateRelationalSearchQueryBuilder = exports.convertQueriedInputsToStringBasedQueries = exports.validatePostgresUUID = void 0;
const map_1 = __importDefault(require("lodash/map"));

@@ -30,3 +30,3 @@ const flatMap_1 = __importDefault(require("lodash/flatMap"));

if (!isValid && throws) {
throw new common_1.NotFoundException(message);
throw new common_1.BadRequestException(message);
}

@@ -213,1 +213,13 @@ return isValid;

exports.convertDateToRawBetween = convertDateToRawBetween;
/**
* Creates an alter sequence query by table & column name.
*
* @param {string} tableName
* @param {string} columnName
*
* @returns {string}
*/
const createAlterSeqQueryForPostgresTables = (tableName, columnName = 'readableId') => {
return `ALTER SEQUENCE "${tableName}_${columnName}_seq" RESTART WITH 1`;
};
exports.createAlterSeqQueryForPostgresTables = createAlterSeqQueryForPostgresTables;

@@ -78,1 +78,46 @@ /**

export declare const removeTrailingSpaces: (input: string) => string;
/**
* Trims email string and converts to lower case.
*
* @param {string} input
*
* @returns {string}
*/
export declare const convertToEmailString: (input: string) => string;
/**
* Generates a random code of max 10 characters.
*
* @see https://stackoverflow.com/a/17484158/2528625
*
* @param {number} length
*
* @returns {string}
*/
export declare const createNumericCode: (length?: number) => string;
/**
* Add query params to url string
*
* @param {string} url
* @param {Record<string,string>} queryParams
*
* @returns {string}
*/
export declare const addQueryParamsToUrl: (url: string, queryParams: Record<string, string>) => string;
/**
* Converts a number to a numeric string
*
* @param {number} value
* @param {number} precision
*
* @returns {string}
*/
export declare const toNumericString: (value: string | number, precision?: number) => string;
/**
* If data can be parsed using JSON.parse, return the parsed data.
* Otherwise, return the original data.
*
* @param {any} data
*
* @returns {any}
*/
export declare const parseJSONString: (data: any) => any;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.removeTrailingSpaces = exports.isNull = exports.join = exports.toLowerCase = exports.sentenceCase = exports.ucWords = exports.getWords = exports.ucFirst = void 0;
exports.parseJSONString = exports.toNumericString = exports.addQueryParamsToUrl = exports.createNumericCode = exports.convertToEmailString = exports.removeTrailingSpaces = exports.isNull = exports.join = exports.toLowerCase = exports.sentenceCase = exports.ucWords = exports.getWords = exports.ucFirst = void 0;
const map_1 = __importDefault(require("lodash/map"));
const keys_1 = __importDefault(require("lodash/keys"));
const trim_1 = __importDefault(require("lodash/trim"));
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
const isObject_1 = __importDefault(require("lodash/isObject"));
const isString_1 = __importDefault(require("lodash/isString"));
const snakeCase_1 = __importDefault(require("lodash/snakeCase"));
const sampleSize_1 = __importDefault(require("lodash/sampleSize"));
const isNull_1 = __importDefault(require("lodash/isNull"));

@@ -117,1 +122,77 @@ /**

exports.removeTrailingSpaces = removeTrailingSpaces;
/**
* Trims email string and converts to lower case.
*
* @param {string} input
*
* @returns {string}
*/
const convertToEmailString = (input) => {
return trim_1.default(input).toLowerCase();
};
exports.convertToEmailString = convertToEmailString;
/**
* Generates a random code of max 10 characters.
*
* @see https://stackoverflow.com/a/17484158/2528625
*
* @param {number} length
*
* @returns {string}
*/
const createNumericCode = (length = 10) => {
return sampleSize_1.default('1234567890', length).join('');
};
exports.createNumericCode = createNumericCode;
/**
* Add query params to url string
*
* @param {string} url
* @param {Record<string,string>} queryParams
*
* @returns {string}
*/
const addQueryParamsToUrl = (url, queryParams) => {
if (isEmpty_1.default(queryParams)) {
return url;
}
const queryStringElements = [];
keys_1.default(queryParams).map((paramName) => {
queryStringElements.push(`${paramName}=${queryParams[paramName]}`);
});
return `${url}&${queryStringElements.join('&')}`;
};
exports.addQueryParamsToUrl = addQueryParamsToUrl;
/**
* Converts a number to a numeric string
*
* @param {number} value
* @param {number} precision
*
* @returns {string}
*/
const toNumericString = (value, precision = 2) => {
return Number(value).toFixed(precision);
};
exports.toNumericString = toNumericString;
/**
* If data can be parsed using JSON.parse, return the parsed data.
* Otherwise, return the original data.
*
* @param {any} data
*
* @returns {any}
*/
const parseJSONString = (data) => {
try {
const parsedData = JSON.parse(data);
if (parsedData && isObject_1.default(parsedData)) {
return parsedData;
}
}
catch (e) {
return data;
}
return data;
};
exports.parseJSONString = parseJSONString;

6

package.json
{
"name": "@crowdlinker/nestjs-commons",
"version": "0.0.16",
"version": "0.0.17",
"description": "Commons for NestJS based projects",

@@ -14,3 +14,3 @@ "author": "Crowdlinker Inc.",

"devDependencies": {
"@nestjs/common": "^7.6.18",
"@nestjs/common": "^8.4.7",
"@types/bull": "^3.15.1",

@@ -22,3 +22,3 @@ "@types/express": "^4.17.12",

"class-transformer": "^0.4.0",
"class-validator": "^0.13.1",
"class-validator": "^0.14.1",
"dayjs": "^1.10.5",

@@ -25,0 +25,0 @@ "typeorm": "^0.3.14",

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