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

@crowdlinker/nestjs-commons

Package Overview
Dependencies
Maintainers
2
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.19 to 0.1.0

2

constants/jobs.js

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

removeOnComplete: true,
backoff: 600000,
backoff: 600000, // 10 mins (In ms),
attempts: 2,
};

@@ -12,12 +12,12 @@ "use strict";

exports.QUEUES_LIMIT_DURATION = {
DEFAULT: 30000,
DEFAULT: 30000, // 30 seconds
SCRAPE: 60000, // 1 min
};
exports.QUEUES_LOCK_DURATION = {
DEFAULT: 60000,
DEFAULT: 60000, // 1 min
SCRAPE: 300000, // 5 mins
};
exports.QUEUES_STALLED_INTERVAL = {
DEFAULT: 60000,
DEFAULT: 60000, // 1 min
SCRAPE: 300000, // 5 mins
};

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

*/
exports.CreateRequest = common_1.createParamDecorator((data = ['id'], ctx) => {
exports.CreateRequest = (0, common_1.createParamDecorator)((data = ['id'], ctx) => {
const req = ctx.switchToHttp().getRequest();

@@ -18,0 +18,0 @@ const { body } = req;

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

*/
exports.EditRequest = common_1.createParamDecorator((data = ['id'], ctx) => {
exports.EditRequest = (0, common_1.createParamDecorator)((data = ['id'], ctx) => {
const req = ctx.switchToHttp().getRequest();

@@ -18,0 +18,0 @@ const requestParamsToReturn = {};

@@ -16,8 +16,8 @@ "use strict";

*/
exports.EntityBeingQueried = common_1.createParamDecorator((data, ctx) => {
exports.EntityBeingQueried = (0, common_1.createParamDecorator)((data, ctx) => {
const req = ctx.switchToHttp().getRequest();
if (data) {
return get_1.default(req, `${data}BeingQueried`);
return (0, get_1.default)(req, `${data}BeingQueried`);
}
return get_1.default(req, 'entityBeingQueried');
return (0, get_1.default)(req, 'entityBeingQueried');
});

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

*/
exports.ParamizedRequestBody = common_1.createParamDecorator((data = ['id'], ctx) => {
exports.ParamizedRequestBody = (0, common_1.createParamDecorator)((data = ['id'], ctx) => {
const req = ctx.switchToHttp().getRequest();

@@ -19,0 +19,0 @@ const requestParamsToReturn = {};

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

*/
exports.RequestWithUser = common_1.createParamDecorator((data, ctx) => {
exports.RequestWithUser = (0, common_1.createParamDecorator)((data, ctx) => {
const req = ctx.switchToHttp().getRequest();
const userId = get_1.default(req, 'user.id', null);
const userId = (0, get_1.default)(req, 'user.id', null);
return userId ? Object.assign(Object.assign({}, req.body), { userId }) : req.body;
});

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

return (object, propertyName) => {
class_validator_1.registerDecorator({
(0, class_validator_1.registerDecorator)({
name: 'ArrayDistinct',

@@ -15,0 +15,0 @@ target: object.constructor,

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

return function (object, propertyName) {
class_validator_1.registerDecorator({
(0, class_validator_1.registerDecorator)({
target: object.constructor,

@@ -52,4 +52,4 @@ constraints: [property],

const relatedValue = args.object[relatedPropertyName];
return (isNumber_1.default(value) &&
isNumber_1.default(relatedValue) &&
return ((0, isNumber_1.default)(value) &&
(0, isNumber_1.default)(relatedValue) &&
value > relatedValue);

@@ -62,5 +62,5 @@ }

};
IsBiggerThanConstraint = __decorate([
class_validator_1.ValidatorConstraint({ name: 'IsBiggerThan' })
exports.IsBiggerThanConstraint = IsBiggerThanConstraint;
exports.IsBiggerThanConstraint = IsBiggerThanConstraint = __decorate([
(0, class_validator_1.ValidatorConstraint)({ name: 'IsBiggerThan' })
], IsBiggerThanConstraint);
exports.IsBiggerThanConstraint = IsBiggerThanConstraint;

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

return function (object, propertyName) {
class_validator_1.registerDecorator({
(0, class_validator_1.registerDecorator)({
target: object.constructor,

@@ -52,4 +52,4 @@ constraints: [property],

const relatedValue = args.object[relatedPropertyName];
return (isNumber_1.default(value) &&
isNumber_1.default(relatedValue) &&
return ((0, isNumber_1.default)(value) &&
(0, isNumber_1.default)(relatedValue) &&
value < relatedValue);

@@ -62,5 +62,5 @@ }

};
IsLesserThanConstraint = __decorate([
class_validator_1.ValidatorConstraint({ name: 'IsLesserThan' })
exports.IsLesserThanConstraint = IsLesserThanConstraint;
exports.IsLesserThanConstraint = IsLesserThanConstraint = __decorate([
(0, class_validator_1.ValidatorConstraint)({ name: 'IsLesserThan' })
], IsLesserThanConstraint);
exports.IsLesserThanConstraint = IsLesserThanConstraint;

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

return (object, propertyName) => {
class_validator_1.registerDecorator({
(0, class_validator_1.registerDecorator)({
target: object.constructor,

@@ -59,5 +59,5 @@ propertyName,

};
MatchesFieldConstraint = __decorate([
class_validator_1.ValidatorConstraint({ name: 'MatchesField' })
exports.MatchesFieldConstraint = MatchesFieldConstraint;
exports.MatchesFieldConstraint = MatchesFieldConstraint = __decorate([
(0, class_validator_1.ValidatorConstraint)({ name: 'MatchesField' })
], MatchesFieldConstraint);
exports.MatchesFieldConstraint = MatchesFieldConstraint;

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

return function (object, propertyName) {
class_validator_1.registerDecorator({
(0, class_validator_1.registerDecorator)({
target: object.constructor,

@@ -45,3 +45,3 @@ propertyName: propertyName,

const relatedValue = args.object[relatedPropertyName];
return !isNil_1.default(relatedValue);
return !(0, isNil_1.default)(relatedValue);
}

@@ -53,5 +53,5 @@ defaultMessage(args) {

};
RequiredWithConstraint = __decorate([
class_validator_1.ValidatorConstraint({ name: 'RequiredWith' })
exports.RequiredWithConstraint = RequiredWithConstraint;
exports.RequiredWithConstraint = RequiredWithConstraint = __decorate([
(0, class_validator_1.ValidatorConstraint)({ name: 'RequiredWith' })
], RequiredWithConstraint);
exports.RequiredWithConstraint = RequiredWithConstraint;

@@ -15,2 +15,2 @@ "use strict";

AppEnvironment["production"] = "production";
})(AppEnvironment = exports.AppEnvironment || (exports.AppEnvironment = {}));
})(AppEnvironment || (exports.AppEnvironment = AppEnvironment = {}));

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

let exceptionData = exception.getResponse();
if (isString_1.default(exceptionData)) {
if ((0, isString_1.default)(exceptionData)) {
exceptionData = { message: exceptionData };
}
else if (isObject_1.default(exceptionData)) {
else if ((0, isObject_1.default)(exceptionData)) {
exceptionData = exceptionData;

@@ -74,6 +74,6 @@ exceptionData = exceptionData.message

};
HttpExceptionFilter = __decorate([
common_1.Catch(common_1.HttpException),
exports.HttpExceptionFilter = HttpExceptionFilter;
exports.HttpExceptionFilter = HttpExceptionFilter = __decorate([
(0, common_1.Catch)(common_1.HttpException),
__metadata("design:paramtypes", [Object])
], HttpExceptionFilter);
exports.HttpExceptionFilter = HttpExceptionFilter;

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

.map((input) => {
const value = get_1.default(input, key, null);
const value = (0, get_1.default)(input, key, null);
return callback ? callback(value) : value;

@@ -34,0 +34,0 @@ })

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

const toDateString = (date) => {
if (isNull_1.default(date)) {
if ((0, isNull_1.default)(date)) {
return null;
}
const newDate = date ? dayjs_1.default(date) : dayjs_1.default();
const newDate = date ? (0, dayjs_1.default)(date) : (0, dayjs_1.default)();
return newDate.isValid() ? newDate.startOf('date').format(date_1.DATE_FORMAT) : null;

@@ -41,6 +41,6 @@ };

const toDateTimeString = (date, format = date_1.DATE_TIME_FORMAT) => {
if (isNull_1.default(date)) {
if ((0, isNull_1.default)(date)) {
return null;
}
const newDate = date ? dayjs_1.default(date) : dayjs_1.default();
const newDate = date ? (0, dayjs_1.default)(date) : (0, dayjs_1.default)();
return newDate.isValid() ? newDate.format(format) : null;

@@ -60,3 +60,3 @@ };

const toDateTimeISOString = (date) => {
return exports.toDateTimeString(date, date_1.DATE_TIME_ISO_FORMAT);
return (0, exports.toDateTimeString)(date, date_1.DATE_TIME_ISO_FORMAT);
};

@@ -75,6 +75,6 @@ exports.toDateTimeISOString = toDateTimeISOString;

const toDateDayjs = (date) => {
if (isNull_1.default(date)) {
if ((0, isNull_1.default)(date)) {
return null;
}
const newDate = date ? dayjs_1.default(date) : dayjs_1.default();
const newDate = date ? (0, dayjs_1.default)(date) : (0, dayjs_1.default)();
return newDate.isValid() ? newDate.startOf('date') : null;

@@ -91,5 +91,5 @@ };

const getDayTimes = (date) => {
date = dayjs_1.default(date).clone();
date = (0, dayjs_1.default)(date).clone();
return [
date.startOf('date'),
date.startOf('date'), // startDate
date.endOf('date'), // endDate,

@@ -109,6 +109,6 @@ ];

const getMonthDates = (date) => {
const today = date ? dayjs_1.default(date) : dayjs_1.default();
const today = date ? (0, dayjs_1.default)(date) : (0, dayjs_1.default)();
return [
today.startOf('month'),
today.endOf('month'),
today.startOf('month'), // startDate of each month
today.endOf('month'), // endDate of each month
today

@@ -134,5 +134,5 @@ .startOf('month')

if (timeZone === 'UTC') {
return dayjs_1.default(parsedDate).clone();
return (0, dayjs_1.default)(parsedDate).clone();
}
return dayjs_1.default(parsedDate.toLocaleString('en-US', { timeZone })).clone();
return (0, dayjs_1.default)(parsedDate.toLocaleString('en-US', { timeZone })).clone();
};

@@ -150,3 +150,3 @@ exports.getDayjsDateByTimezone = getDayjsDateByTimezone;

const getTorontoDayjsDate = (date) => {
return exports.getDayjsDateByTimezone(date_1.TIMEZONES.toronto, date);
return (0, exports.getDayjsDateByTimezone)(date_1.TIMEZONES.toronto, date);
};

@@ -164,9 +164,9 @@ exports.getTorontoDayjsDate = getTorontoDayjsDate;

const convertToTorontoTime = (date) => {
const currentTime = dayjs_1.default();
const currentTorontoTime = exports.getTorontoDayjsDate();
const currentTorontoTimeInUTC = dayjs_1.default(currentTorontoTime.format(date_1.DATE_TIME_FORMAT));
const currentTime = (0, dayjs_1.default)();
const currentTorontoTime = (0, exports.getTorontoDayjsDate)();
const currentTorontoTimeInUTC = (0, dayjs_1.default)(currentTorontoTime.format(date_1.DATE_TIME_FORMAT));
const difference = currentTorontoTimeInUTC
.clone()
.diff(currentTime, 'second');
const newDate = (date ? dayjs_1.default(date) : currentTime).clone();
const newDate = (date ? (0, dayjs_1.default)(date) : currentTime).clone();
return newDate.add(difference, 'second');

@@ -187,3 +187,3 @@ };

const isLeapYear = (year) => {
year = !year ? dayjs_1.default().get('year') : year;
year = !year ? (0, dayjs_1.default)().get('year') : year;
return (year & 3) == 0 && (year % 25 != 0 || (year & 15) == 0);

@@ -202,3 +202,3 @@ };

const daysInYear = (year) => {
return exports.isLeapYear(year) ? 366 : 365;
return (0, exports.isLeapYear)(year) ? 366 : 365;
};

@@ -214,4 +214,4 @@ exports.daysInYear = daysInYear;

const getDateIntervals = (startDate, endDate) => {
const convertedEndDate = exports.toDateDayjs(endDate);
const convertedStartDate = exports.toDateDayjs(startDate);
const convertedEndDate = (0, exports.toDateDayjs)(endDate);
const convertedStartDate = (0, exports.toDateDayjs)(startDate);
if (!convertedStartDate || !convertedEndDate) {

@@ -218,0 +218,0 @@ throw new Error('Start/end date is invalid.');

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

partial['readableId'] =
isString_1.default(partial['readableId']) || isNumber_1.default(partial['readableId'])
(0, isString_1.default)(partial['readableId']) || (0, isNumber_1.default)(partial['readableId'])
? parseInt(partial['readableId'])

@@ -47,10 +47,10 @@ : null;

const setEntityVariableValues = (classToSerialize, partial, variables) => {
const variablesToAssign = get_1.default(variables, 'variablesToAssign', []);
const booleans = get_1.default(variables, 'booleans', []);
const integers = get_1.default(variables, 'integers', []);
const floats = get_1.default(variables, 'floats', []);
const enums = get_1.default(variables, 'enums', {});
const manyToOneRelations = get_1.default(variables, 'manyToOneRelations', {});
const oneToManyRelations = get_1.default(variables, 'oneToManyRelations', {});
const manyToManyRelations = get_1.default(variables, 'manyToManyRelations', {});
const variablesToAssign = (0, get_1.default)(variables, 'variablesToAssign', []);
const booleans = (0, get_1.default)(variables, 'booleans', []);
const integers = (0, get_1.default)(variables, 'integers', []);
const floats = (0, get_1.default)(variables, 'floats', []);
const enums = (0, get_1.default)(variables, 'enums', {});
const manyToOneRelations = (0, get_1.default)(variables, 'manyToOneRelations', {});
const oneToManyRelations = (0, get_1.default)(variables, 'oneToManyRelations', {});
const manyToManyRelations = (0, get_1.default)(variables, 'manyToManyRelations', {});
/**

@@ -64,7 +64,7 @@ * Set integer based values for the entity.

const setIntegerValueInLoop = (partial, integers, currentVariable) => {
if (!isEmpty_1.default(integers) &&
isArray_1.default(integers) &&
if (!(0, isEmpty_1.default)(integers) &&
(0, isArray_1.default)(integers) &&
integers.includes(currentVariable)) {
partial[currentVariable] =
isString_1.default(partial[currentVariable]) || isNumber_1.default(partial[currentVariable])
(0, isString_1.default)(partial[currentVariable]) || (0, isNumber_1.default)(partial[currentVariable])
? parseInt(partial[currentVariable])

@@ -82,7 +82,7 @@ : null;

const setFloatValueInLoop = (partial, floats, currentVariable) => {
if (!isEmpty_1.default(floats) &&
isArray_1.default(floats) &&
if (!(0, isEmpty_1.default)(floats) &&
(0, isArray_1.default)(floats) &&
floats.includes(currentVariable)) {
partial[currentVariable] =
isString_1.default(partial[currentVariable]) || isNumber_1.default(partial[currentVariable])
(0, isString_1.default)(partial[currentVariable]) || (0, isNumber_1.default)(partial[currentVariable])
? parseFloat(partial[currentVariable])

@@ -100,5 +100,5 @@ : null;

const setEnumValueInLoop = (partial, enums, currentVariable) => {
if (!isEmpty_1.default(enums) &&
isObject_1.default(enums) &&
keys_1.default(enums).includes(currentVariable)) {
if (!(0, isEmpty_1.default)(enums) &&
(0, isObject_1.default)(enums) &&
(0, keys_1.default)(enums).includes(currentVariable)) {
partial[currentVariable] = partial[currentVariable]

@@ -117,5 +117,5 @@ ? enums[currentVariable][partial[currentVariable]]

const setOneToManyRelationValueInLoop = (partial, oneToManyRelations, currentVariable) => {
if (!isEmpty_1.default(oneToManyRelations) &&
isObject_1.default(oneToManyRelations) &&
keys_1.default(oneToManyRelations).includes(currentVariable)) {
if (!(0, isEmpty_1.default)(oneToManyRelations) &&
(0, isObject_1.default)(oneToManyRelations) &&
(0, keys_1.default)(oneToManyRelations).includes(currentVariable)) {
const Entity = oneToManyRelations[currentVariable];

@@ -135,5 +135,5 @@ partial[currentVariable] = Array.isArray(partial[currentVariable])

const setManyToOneRelationValueInLoop = (partial, manyToOneRelations, currentVariable) => {
if (!isEmpty_1.default(manyToOneRelations) &&
isObject_1.default(manyToOneRelations) &&
keys_1.default(manyToOneRelations).includes(currentVariable)) {
if (!(0, isEmpty_1.default)(manyToOneRelations) &&
(0, isObject_1.default)(manyToOneRelations) &&
(0, keys_1.default)(manyToOneRelations).includes(currentVariable)) {
const Entity = manyToOneRelations[currentVariable];

@@ -160,6 +160,6 @@ partial[currentVariable] = partial[currentVariable]

!booleans.includes(variable) &&
!keys_1.default(enums).includes(variable) &&
!keys_1.default(oneToManyRelations).includes(variable) &&
!keys_1.default(manyToOneRelations).includes(variable) &&
!keys_1.default(manyToManyRelations).includes(variable)) {
!(0, keys_1.default)(enums).includes(variable) &&
!(0, keys_1.default)(oneToManyRelations).includes(variable) &&
!(0, keys_1.default)(manyToOneRelations).includes(variable) &&
!(0, keys_1.default)(manyToManyRelations).includes(variable)) {
partial[variable] = null;

@@ -166,0 +166,0 @@ }

@@ -18,4 +18,4 @@ "use strict";

function randomFromEnum(enumeration) {
return sample_1.default(Object.values(enumeration));
return (0, sample_1.default)(Object.values(enumeration));
}
exports.randomFromEnum = randomFromEnum;

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

const convertToRoundedDecimal = (dividend, divisor = 100, roundPrecision = 2) => {
return round_1.default(divide_1.default(dividend, divisor), roundPrecision);
return (0, round_1.default)((0, divide_1.default)(dividend, divisor), roundPrecision);
};

@@ -31,3 +31,3 @@ exports.convertToRoundedDecimal = convertToRoundedDecimal;

*/
const inchesToFeet = (value) => ceil_1.default(0.0833333 * (value || 0), 3);
const inchesToFeet = (value) => (0, ceil_1.default)(0.0833333 * (value || 0), 3);
exports.inchesToFeet = inchesToFeet;

@@ -45,3 +45,3 @@ /**

case 'in':
return exports.inchesToFeet(value);
return (0, exports.inchesToFeet)(value);
case 'ft':

@@ -69,7 +69,7 @@ default:

default:
return (exports.convertToFeet(lengthValue, lengthUnit) *
exports.convertToFeet(widthValue, widthUnit) *
exports.convertToFeet(heightValue, heightUnit));
return ((0, exports.convertToFeet)(lengthValue, lengthUnit) *
(0, exports.convertToFeet)(widthValue, widthUnit) *
(0, exports.convertToFeet)(heightValue, heightUnit));
}
};
exports.calculateVolume = calculateVolume;

@@ -29,12 +29,12 @@ "use strict";

const unsetObjectProperties = (data, keys = [], shouldClone = true) => {
if (!data || !keys.length || !isObject_1.default(data)) {
if (!data || !keys.length || !(0, isObject_1.default)(data)) {
return data;
}
const newData = shouldClone ? cloneDeep_1.default(data) : data;
const newData = shouldClone ? (0, cloneDeep_1.default)(data) : data;
keys.forEach((key) => {
if (has_1.default(newData, key)) {
unset_1.default(newData, key);
if ((0, has_1.default)(newData, key)) {
(0, unset_1.default)(newData, key);
}
});
return omit_1.default(newData, keys);
return (0, omit_1.default)(newData, keys);
};

@@ -51,6 +51,6 @@ exports.unsetObjectProperties = unsetObjectProperties;

const mapKeysDeep = (data, callback) => {
if (!data || isArray_1.default(data) || !isObject_1.default(data)) {
if (!data || (0, isArray_1.default)(data) || !(0, isObject_1.default)(data)) {
return data;
}
return mapValues_1.default(mapKeys_1.default(data, callback), (value) => isObject_1.default(value) ? exports.mapKeysDeep(value, callback) : value);
return (0, mapValues_1.default)((0, mapKeys_1.default)(data, callback), (value) => (0, isObject_1.default)(value) ? (0, exports.mapKeysDeep)(value, callback) : value);
};

@@ -67,7 +67,7 @@ exports.mapKeysDeep = mapKeysDeep;

const mapValuesDeep = (data, callback) => {
if (!data || isArray_1.default(data) || !isObject_1.default(data)) {
if (!data || (0, isArray_1.default)(data) || !(0, isObject_1.default)(data)) {
return data;
}
return isObject_1.default(data)
? mapValues_1.default(data, (value) => exports.mapValuesDeep(value, callback))
return (0, isObject_1.default)(data)
? (0, mapValues_1.default)(data, (value) => (0, exports.mapValuesDeep)(value, callback))
: callback(data);

@@ -86,6 +86,6 @@ };

const convertKeysFromSnakeToCamel = (data) => {
if (!data || isArray_1.default(data) || !isObject_1.default(data)) {
if (!data || (0, isArray_1.default)(data) || !(0, isObject_1.default)(data)) {
return data;
}
return exports.mapKeysDeep(data, (_, key) => camelCase_1.default(key));
return (0, exports.mapKeysDeep)(data, (_, key) => (0, camelCase_1.default)(key));
};

@@ -103,7 +103,7 @@ exports.convertKeysFromSnakeToCamel = convertKeysFromSnakeToCamel;

const convertKeysFromCamelToSnake = (data) => {
if (!data || isArray_1.default(data) || !isObject_1.default(data)) {
if (!data || (0, isArray_1.default)(data) || !(0, isObject_1.default)(data)) {
return data;
}
return mapKeys_1.default(data, (_, key) => snakeCase_1.default(key));
return (0, mapKeys_1.default)(data, (_, key) => (0, snakeCase_1.default)(key));
};
exports.convertKeysFromCamelToSnake = convertKeysFromCamelToSnake;

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

const validatePostgresUUID = (id, throws = true, message = 'Invalid UUID') => {
const isValid = class_validator_1.isUUID(id);
const isValid = (0, class_validator_1.isUUID)(id);
if (!isValid && throws) {

@@ -79,7 +79,7 @@ throw new common_1.BadRequestException(message);

if (queriedInput.constructor.name !== 'FindOperator') {
return exports.convertQueriedInputsToStringBasedQueries(queriedInput, queriedInputsKey, Object.keys(queriedInput).length > 1 ? false : true, lastIndex);
return (0, exports.convertQueriedInputsToStringBasedQueries)(queriedInput, queriedInputsKey, Object.keys(queriedInput).length > 1 ? false : true, lastIndex);
}
// If yes, convert it a "StringQuery" type object.
else {
const operatorData = class_transformer_1.classToPlain(queriedInput);
const operatorData = (0, class_transformer_1.classToPlain)(queriedInput);
let currentKey = queriedInputsKey;

@@ -127,3 +127,3 @@ if (parentKey) {

query: `${currentKey} ${keyword}${valueType}`,
paramIndex: lastIndex.count - 1,
paramIndex: lastIndex.count - 1, // Because of line 130.
value: operatorData._value,

@@ -136,4 +136,4 @@ };

return flatten
? flatMap_1.default(queriedInputsKeys, convertor)
: map_1.default(queriedInputsKeys, convertor);
? (0, flatMap_1.default)(queriedInputsKeys, convertor)
: (0, map_1.default)(queriedInputsKeys, convertor);
};

@@ -156,3 +156,3 @@ exports.convertQueriedInputsToStringBasedQueries = convertQueriedInputsToStringBasedQueries;

// Get string based queries.
const convertedQueries = exports.convertQueriedInputsToStringBasedQueries(queriedInputs);
const convertedQueries = (0, exports.convertQueriedInputsToStringBasedQueries)(queriedInputs);
// Add queries to query builder.

@@ -214,3 +214,3 @@ convertedQueries.forEach((convertedQuery) => {

*/
const convertDateToRawBetween = (startDate, endDate) => typeorm_1.Raw((columnName) => `${columnName} >= '${startDate.toISOString()}' AND ${columnName} <= '${endDate.toISOString()}'`);
const convertDateToRawBetween = (startDate, endDate) => (0, typeorm_1.Raw)((columnName) => `${columnName} >= '${startDate.toISOString()}' AND ${columnName} <= '${endDate.toISOString()}'`);
exports.convertDateToRawBetween = convertDateToRawBetween;

@@ -217,0 +217,0 @@ /**

/// <reference types="node" />
/// <reference types="express-serve-static-core" />
/// <reference types="multer" />
import { MulterFileFilter } from '../interfaces/file';

@@ -5,0 +3,0 @@ /**

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

const getFile = (path, encoding) => __awaiter(void 0, void 0, void 0, function* () {
const readFile = util_1.promisify(fs_1.default.readFile);
const readFile = (0, util_1.promisify)(fs_1.default.readFile);
return encoding ? readFile(path, encoding) : readFile(path, {});

@@ -55,7 +55,7 @@ });

*/
const createFile = (path, fileName, data, append = false) => __awaiter(void 0, void 0, void 0, function* () {
if (!exports.checkIfFileOrDirectoryExists(path)) {
const createFile = (path_2, fileName_1, data_1, ...args_1) => __awaiter(void 0, [path_2, fileName_1, data_1, ...args_1], void 0, function* (path, fileName, data, append = false) {
if (!(0, exports.checkIfFileOrDirectoryExists)(path)) {
fs_1.default.mkdirSync(path);
}
const writeFile = append ? util_1.promisify(fs_1.default.appendFile) : util_1.promisify(fs_1.default.writeFile);
const writeFile = append ? (0, util_1.promisify)(fs_1.default.appendFile) : (0, util_1.promisify)(fs_1.default.writeFile);
return yield writeFile(`${path}/${fileName}`, data, 'utf8');

@@ -72,3 +72,3 @@ });

const deleteFile = (path) => __awaiter(void 0, void 0, void 0, function* () {
const unlink = util_1.promisify(fs_1.default.unlink);
const unlink = (0, util_1.promisify)(fs_1.default.unlink);
return yield unlink(path);

@@ -89,3 +89,3 @@ });

const name = file.originalname.split('.')[0];
const fileExtension = path_1.extname(file.originalname);
const fileExtension = (0, path_1.extname)(file.originalname);
callback(null, `${name}-${new Date().toISOString()}${fileExtension}`);

@@ -120,3 +120,3 @@ };

*/
const isCSVExtension = (fileName) => file_1.CSV_EXTENSION === path_1.extname(fileName);
const isCSVExtension = (fileName) => file_1.CSV_EXTENSION === (0, path_1.extname)(fileName);
exports.isCSVExtension = isCSVExtension;

@@ -130,3 +130,3 @@ /**

*/
const isPDFExtension = (fileName) => file_1.PDF_EXTENSION === path_1.extname(fileName);
const isPDFExtension = (fileName) => file_1.PDF_EXTENSION === (0, path_1.extname)(fileName);
exports.isPDFExtension = isPDFExtension;

@@ -140,3 +140,3 @@ /**

*/
const isImageExtension = (fileName) => file_1.IMAGE_EXTENSIONS.includes(path_1.extname(fileName));
const isImageExtension = (fileName) => file_1.IMAGE_EXTENSIONS.includes((0, path_1.extname)(fileName));
exports.isImageExtension = isImageExtension;

@@ -181,6 +181,6 @@ /**

const { mimetype, originalname } = file;
if (mimetype && mimetype.length && exports.isCSVMimeType(mimetype)) {
if (mimetype && mimetype.length && (0, exports.isCSVMimeType)(mimetype)) {
cb(null, true);
}
else if (exports.isCSVExtension(originalname)) {
else if ((0, exports.isCSVExtension)(originalname)) {
cb(null, true);

@@ -205,6 +205,6 @@ }

const { mimetype, originalname } = file;
if (mimetype && mimetype.length && exports.isImageMimeType(mimetype)) {
if (mimetype && mimetype.length && (0, exports.isImageMimeType)(mimetype)) {
cb(null, true);
}
else if (exports.isImageExtension(originalname)) {
else if ((0, exports.isImageExtension)(originalname)) {
cb(null, true);

@@ -211,0 +211,0 @@ }

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

const getWords = (input) => {
return isString_1.default(input) ? snakeCase_1.default(input).split('_') : [];
return (0, isString_1.default)(input) ? (0, snakeCase_1.default)(input).split('_') : [];
};

@@ -53,3 +53,3 @@ exports.getWords = getWords;

const ucWords = (input) => {
return map_1.default(exports.getWords(input), exports.ucFirst).join(' ');
return (0, map_1.default)((0, exports.getWords)(input), exports.ucFirst).join(' ');
};

@@ -67,3 +67,3 @@ exports.ucWords = ucWords;

const sentenceCase = (input) => {
return exports.ucFirst(exports.getWords(input).join(' ').toLowerCase());
return (0, exports.ucFirst)((0, exports.getWords)(input).join(' ').toLowerCase());
};

@@ -81,3 +81,3 @@ exports.sentenceCase = sentenceCase;

const toLowerCase = (input) => {
return isString_1.default(input) ? input.toLowerCase() : input;
return (0, isString_1.default)(input) ? input.toLowerCase() : input;
};

@@ -107,3 +107,3 @@ exports.toLowerCase = toLowerCase;

const isNull = (input) => {
return isNull_1.default(input) ? true : input === 'null' ? true : false;
return (0, isNull_1.default)(input) ? true : input === 'null' ? true : false;
};

@@ -134,3 +134,3 @@ exports.isNull = isNull;

const convertToEmailString = (input) => {
return trim_1.default(input).toLowerCase();
return (0, trim_1.default)(input).toLowerCase();
};

@@ -148,3 +148,3 @@ exports.convertToEmailString = convertToEmailString;

const createNumericCode = (length = 10) => {
return sampleSize_1.default('1234567890', length).join('');
return (0, sampleSize_1.default)('1234567890', length).join('');
};

@@ -161,7 +161,7 @@ exports.createNumericCode = createNumericCode;

const addQueryParamsToUrl = (url, queryParams) => {
if (isEmpty_1.default(queryParams)) {
if ((0, isEmpty_1.default)(queryParams)) {
return url;
}
const queryStringElements = [];
keys_1.default(queryParams).map((paramName) => {
(0, keys_1.default)(queryParams).map((paramName) => {
queryStringElements.push(`${paramName}=${queryParams[paramName]}`);

@@ -195,3 +195,3 @@ });

const parsedData = JSON.parse(data);
if (parsedData && isObject_1.default(parsedData)) {
if (parsedData && (0, isObject_1.default)(parsedData)) {
return parsedData;

@@ -198,0 +198,0 @@ }

@@ -18,2 +18,2 @@ /// <reference types="node" />

}
export declare type MulterFileFilter = (req: any, file: UploadedFile, callback: (error: Error | null, acceptFile: boolean) => void) => void;
export type MulterFileFilter = (req: any, file: UploadedFile, callback: (error: Error | null, acceptFile: boolean) => void) => void;

@@ -13,2 +13,2 @@ "use strict";

PaginationOrder["desc"] = "DESC";
})(PaginationOrder = exports.PaginationOrder || (exports.PaginationOrder = {}));
})(PaginationOrder || (exports.PaginationOrder = PaginationOrder = {}));

@@ -13,2 +13,2 @@ "use strict";

QueryType["and"] = "and";
})(QueryType = exports.QueryType || (exports.QueryType = {}));
})(QueryType || (exports.QueryType = QueryType = {}));

@@ -74,5 +74,5 @@ "use strict";

};
BaseMiddleware = __decorate([
common_1.Injectable()
exports.BaseMiddleware = BaseMiddleware;
exports.BaseMiddleware = BaseMiddleware = __decorate([
(0, common_1.Injectable)()
], BaseMiddleware);
exports.BaseMiddleware = BaseMiddleware;
{
"name": "@crowdlinker/nestjs-commons",
"version": "0.0.19",
"version": "0.1.0",
"description": "Commons for NestJS based projects",

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

"devDependencies": {
"@nestjs/common": "^8.4.7",
"@types/bull": "^3.15.1",
"@types/express": "^4.17.12",
"@types/lodash": "^4.14.170",
"@types/multer": "^1.4.5",
"bull": "^3.22.8",
"class-transformer": "^0.4.0",
"@nestjs/common": "^10.3.4",
"@types/bull": "^4.10.0",
"@types/express": "^4.17.21",
"@types/lodash": "^4.17.0",
"@types/multer": "^1.4.11",
"bull": "^4.12.2",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"dayjs": "^1.10.5",
"typeorm": "^0.3.14",
"typescript": "^4.3.4"
"dayjs": "^1.11.10",
"typeorm": "^0.3.20",
"typescript": "^5.4.3"
},

@@ -27,0 +27,0 @@ "repository": {

@@ -44,5 +44,5 @@ "use strict";

};
PaginationPipe = __decorate([
common_1.Injectable()
exports.PaginationPipe = PaginationPipe;
exports.PaginationPipe = PaginationPipe = __decorate([
(0, common_1.Injectable)()
], PaginationPipe);
exports.PaginationPipe = PaginationPipe;

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

};
ValidationPipe = __decorate([
__param(0, common_1.Optional()),
exports.ValidationPipe = ValidationPipe;
exports.ValidationPipe = ValidationPipe = __decorate([
__param(0, (0, common_1.Optional)()),
__metadata("design:paramtypes", [Object, Array])
], ValidationPipe);
exports.ValidationPipe = ValidationPipe;

@@ -98,3 +98,3 @@ # NestJS Commons

- Code is written in Typescript (v4.3.4)
- Code is written in Typescript (v5.4.3)

@@ -101,0 +101,0 @@ ## Contributors

@@ -17,5 +17,5 @@ "use strict";

super();
entity_1.setEntityId(this, partial);
(0, entity_1.setEntityId)(this, partial);
}
}
exports.ModelEntity = ModelEntity;

@@ -17,5 +17,5 @@ "use strict";

super(partial);
entity_1.setEntityReadableId(this, partial);
(0, entity_1.setEntityReadableId)(this, partial);
}
}
exports.ReadableModelEntity = ReadableModelEntity;

@@ -55,7 +55,7 @@ "use strict";

}
exports.ValidationErrorEntity = ValidationErrorEntity;
__decorate([
class_transformer_1.Transform((params) => (isArray_1.default(params.value) ? params.value : [])),
class_transformer_1.Type(() => class_validator_1.ValidationError),
(0, class_transformer_1.Transform)((params) => ((0, isArray_1.default)(params.value) ? params.value : [])),
(0, class_transformer_1.Type)(() => class_validator_1.ValidationError),
__metadata("design:type", Array)
], ValidationErrorEntity.prototype, "children", void 0);
exports.ValidationErrorEntity = ValidationErrorEntity;

@@ -36,4 +36,4 @@ "use strict";

const { startDate } = args.object;
const newStartDate = date_1.toDateDayjs(startDate);
const newEndDate = date_1.toDateDayjs(endDate);
const newStartDate = (0, date_1.toDateDayjs)(startDate);
const newEndDate = (0, date_1.toDateDayjs)(endDate);
return newStartDate && newEndDate && newEndDate.isAfter(newStartDate);

@@ -52,6 +52,6 @@ }

};
EndDateGreaterThanStartDate = __decorate([
class_validator_1.ValidatorConstraint({ name: 'endDateGreaterThanStartDate', async: true }),
common_1.Injectable()
exports.EndDateGreaterThanStartDate = EndDateGreaterThanStartDate;
exports.EndDateGreaterThanStartDate = EndDateGreaterThanStartDate = __decorate([
(0, class_validator_1.ValidatorConstraint)({ name: 'endDateGreaterThanStartDate', async: true }),
(0, common_1.Injectable)()
], EndDateGreaterThanStartDate);
exports.EndDateGreaterThanStartDate = EndDateGreaterThanStartDate;

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

return function (object, propertyName) {
class_validator_1.registerDecorator({
(0, class_validator_1.registerDecorator)({
name: 'isValidDate',

@@ -28,7 +28,7 @@ target: object.constructor,

validate(value) {
if (!isString_1.default(value)) {
if (!(0, isString_1.default)(value)) {
return false;
}
const now = dayjs_1.default();
const enteredDate = dayjs_1.default(value);
const now = (0, dayjs_1.default)();
const enteredDate = (0, dayjs_1.default)(value);
return (enteredDate.isValid() &&

@@ -35,0 +35,0 @@ (enteredDate.isBefore(now) || enteredDate.isSame(now)));

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