🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@infomaximum/utility

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@infomaximum/utility - npm Package Compare versions

Comparing version
9.2.1
to
9.2.2
+2
-0
CHANGELOG.md

@@ -5,2 +5,4 @@ # Changelog

### [9.2.2](https://github.com/Infomaximum/frontend-utility/compare/v9.2.1...v9.2.2) (2026-05-22)
### [9.2.1](https://github.com/Infomaximum/frontend-utility/compare/v9.2.0...v9.2.1) (2026-01-21)

@@ -7,0 +9,0 @@

+1
-5

@@ -10,3 +10,2 @@ import type { TPromiseControls, IDeferred } from "./utils/Promise";

import ErrorHandling from "./services/ErrorHandling";
import { formatTime } from "./utils/Format/Format";
import { localeUpdate } from "./utils/dayjs";

@@ -17,9 +16,6 @@ import type { IDocumentNode, TInferredVariables } from "./utils/graphql/graphqlTag";

export * from "./const";
export * from "./const/utilsLoc";
export * from "./utils/Access";
export * from "./utils/Algorithms";
export * from "./utils/Date/Date";
export * from "./managers/TaskManager";
export * from "./utils/Validators/Validators";
export { ErrorHandling, Deferred, requireAll, requireAllModels, importAll, GraphQlQuery, promised, deferred, enumValue, Feature, userAgent, EnumValue, formatTime, localeUpdate, graphqlTag, TestIdsUtils, };
export { ErrorHandling, Deferred, requireAll, requireAllModels, importAll, GraphQlQuery, promised, deferred, enumValue, Feature, userAgent, EnumValue, localeUpdate, graphqlTag, TestIdsUtils, };
export type { TPromiseControls, IDeferred, TFeatureChecker, TFeatureCacheKeyCreator, TPropInjector, IDocumentNode, TInferredVariables, };

@@ -6,3 +6,3 @@ import forEach from 'lodash/forEach';

import { Model } from '@infomaximum/graphql-model';
import { enumValue, GraphQlQuery } from '@saneksa/graphql-query-builder';
import { GraphQlQuery } from '@saneksa/graphql-query-builder';
export { EnumValue, GraphQlQuery, enumValue } from '@saneksa/graphql-query-builder';

@@ -20,15 +20,6 @@ import isFunction from 'lodash/isFunction';

import sha256 from 'crypto-js/sha256';
import round from 'lodash/round';
import padStart from 'lodash/padStart';
import pad from 'lodash/pad';
import isNumber from 'lodash/isNumber';
import clamp from 'lodash/clamp';
import capitalize from 'lodash/capitalize';
import includes from 'lodash/includes';
import isUndefined from 'lodash/isUndefined';
import { parse } from 'graphql/language';
import isEmpty from 'lodash/isEmpty';
import each from 'lodash/each';
import isObject from 'lodash/isObject';
import { createSelector } from 'reselect';

@@ -298,149 +289,2 @@ var promised = function (func) {

var HOURS_SHORT = {
ru: "ч",
en: "h",
};
var MINUTES_SHORT = {
ru: "мин",
en: "m",
};
var SECONDS_SHORT = {
ru: "сек",
en: "s",
};
var HOURS_LONG = {
ru: {
s: "час",
p1: "часов",
p2: "часа",
},
en: {
s: "hour",
p1: "hours",
},
};
var MINUTES_LONG = {
ru: {
s: "минута",
p1: "минут",
p2: "минуты",
},
en: {
s: "minute",
p1: "minutes",
},
};
var SECONDS_LONG = {
ru: {
s: "секунду",
p1: "секунд",
p2: "секунды",
},
en: {
s: "second",
p1: "seconds",
},
};
var MONTHS = {
ru: {
s: "месяц",
p1: "месяцев",
p2: "месяца",
},
en: {
s: "month",
p1: "months",
},
};
var YEARS = {
ru: {
s: "год",
p1: "лет",
p2: "года",
},
en: {
s: "year",
p1: "years",
},
};
var DAY = {
ru: {
s: "день",
p1: "дней",
p2: "дня",
},
en: {
s: "day",
p1: "days",
},
};
var THOUSAND_HOURS_SHORT = {
ru: "тыс. ч",
en: "thsnd h",
};
var THOUSAND_SHORT = {
ru: "тыс",
en: "K",
};
var MILLION_SHORT = {
ru: "млн",
en: "M",
};
var FIELD_EMPTY = {
ru: "Поле должно быть заполнено",
en: "Field can not be empty",
};
var ENTER_CORRECT_EMAIL = {
ru: "Введите корректный e-mail",
en: "Enter a correct email address",
};
var HOURS_ABBREVIATION = {
ru: "ч.",
en: "h",
};
function formatNumber(number, localization) {
var absNumber = Math.abs(number);
if (absNumber < 100) {
return "".concat(Math.round(number * 100) / 100);
}
if (Math.round(absNumber) < 10000) {
return "".concat(Math.round(number));
}
if (Math.round(absNumber / 1000) < 10000) {
return "".concat(Math.round(number / 1000)).concat(localization.getLocalized(THOUSAND_SHORT));
}
return "".concat(Math.round(number / 1000000)).concat(localization.getLocalized(MILLION_SHORT));
}
function formatTime(milliseconds, localization) {
if (milliseconds >= 0 &&
Math.round(milliseconds / MillisecondsPerSecond) < SecondsPerMinute) {
return "".concat(Math.round(milliseconds / MillisecondsPerSecond), " ").concat(localization.getLocalized(SECONDS_SHORT));
}
if (Math.round(milliseconds / MillisecondsPerMinute) < 10) {
var seconds = Math.round((milliseconds % MillisecondsPerMinute) / MillisecondsPerSecond);
var minutes = Math.floor(milliseconds / MillisecondsPerMinute);
return "".concat(minutes, " ").concat(localization.getLocalized(MINUTES_SHORT), " ").concat(seconds, " ").concat(localization.getLocalized(SECONDS_SHORT));
}
if (Math.round(milliseconds / MillisecondsPerMinute) < MinutesPerHour) {
return "".concat(Math.round(milliseconds / MillisecondsPerMinute), " ").concat(localization.getLocalized(MINUTES_SHORT));
}
if (Math.round(milliseconds / MillisecondsPerMinute) < 100 * MinutesPerHour) {
var minutes = Math.round((milliseconds % MillisecondsPerHour) / MillisecondsPerMinute);
var hours = Math.floor(milliseconds / MillisecondsPerHour);
if (minutes === MinutesPerHour) {
return "".concat(hours + 1, " ").concat(localization.getLocalized(HOURS_SHORT));
}
if (minutes === 0) {
return "".concat(hours, " ").concat(localization.getLocalized(HOURS_SHORT));
}
return "".concat(hours, " ").concat(localization.getLocalized(HOURS_SHORT), " ").concat(minutes, " ").concat(localization.getLocalized(MINUTES_SHORT));
}
if (Math.round(milliseconds / MillisecondsPerHour) >= 100) {
return "".concat(formatNumber(Math.floor(milliseconds / MillisecondsPerHour), localization), " ").concat(localization.getLocalized(HOURS_SHORT));
}
assertSimple(false, "Некорректное время!");
return null;
}
dayjs.extend(updateLocale);

@@ -608,420 +452,2 @@ dayjs.extend(utc);

var splitWithDelimiters = function (str, count, delimiter) {
var newStr = str.toString();
var leftPartCount = newStr.length % count;
var leftPart = newStr.slice(0, leftPartCount);
var rightPart = newStr.slice(leftPartCount);
var counter = 0;
var res = "";
for (var i = 0, l = rightPart.length; i < l; i += 1) {
counter += 1;
res += rightPart[i];
if (counter === count && i !== l - 1) {
counter = 0;
res += delimiter;
}
}
if (leftPart !== "") {
res = leftPart + (res !== "" ? delimiter + res : "");
}
return res;
};
var _a;
var DateFormats = {
SHORT: {
format: "D dd",
excel: "ddd\\,\\ dd",
},
DOW: {
format: "dd",
},
DOW_MIDDLE: {
format: "dd, D MMM",
},
DOW_LONG: {
format: "dddd",
},
LONG: {
format: "D MMMM YYYY",
},
DAY: {
format: "D",
},
DAY_MONTH: {
format: "D MMMM",
},
MONTH_MIDDLE: {
func: function (time) { return dayjs.utc(time).format("MMM").substr(0, 3); },
},
MONTH_YEAR: {
format: "MMMM YYYY",
},
MONTH: {
format: "MMMM",
},
YEAR: {
format: "YYYY",
},
HOUR_MINUTES_LONG: {
format: "h:mm / D MMMM YYYY",
},
FULL_HOUR_MINUTES_LONG: {
format: "HH:mm / D MMMM YYYY",
},
DAY_MONTH_YEAR_SHORT: {
format: "DD.MM.YYYY",
},
};
var getConvertedMsToHours = function (time, precision) {
return dayjs.duration(time, "ms").asHours().toFixed(precision);
};
var getCollapsedDateRangeLabel = function (dateFrom, dateTo, dateFormat) {
if (dateFormat === void 0) { dateFormat = "D MMMM YYYY"; }
var dateFromFormattedArray = dateFrom
.format(dateFormat)
.split(" ");
var dateToFormattedArray = dateTo.format(dateFormat).split(" ");
var uniqueDateFromFormattedArray = __spreadArray([], __read(dateFromFormattedArray), false);
for (var i = 2; i >= 0; i -= 1) {
if (dateToFormattedArray[i] === dateFromFormattedArray[i]) {
uniqueDateFromFormattedArray.splice(i, 1);
}
else {
break;
}
}
var divider = uniqueDateFromFormattedArray.length === 0 ? "" : " - ";
return "".concat(uniqueDateFromFormattedArray.join(" ")).concat(divider).concat(dateToFormattedArray.join(" "));
};
var formatEnteredTime = function (value) {
var clearedValue = value.replace(/[^0-9]/gim, "");
var chunkSize = clearedValue.length <= 2 ? 1 : 2;
var parts = [];
for (var end = clearedValue.length; end >= 1; end -= chunkSize) {
var begin = clamp(end - chunkSize, 0, Infinity);
parts.unshift(clearedValue.slice(begin, end));
}
return parts.join(":");
};
var getLocalizedHours = function (ms, localization) {
var hours = dayjs.duration(ms).asHours();
return "".concat(round(hours, 2), " ").concat(localization.getLocalized(HOURS_ABBREVIATION));
};
var dayjsToServerObject = function (time, isMonthEnum) {
if (isMonthEnum === void 0) { isMonthEnum = false; }
if (time) {
if (dayjs.isDuration(time)) {
return {
time: {
hour: time.hours(),
minute: time.minutes(),
second: time.seconds(),
},
};
}
var month = EMonths[time.month()];
return {
time: { hour: time.hour(), minute: time.minute(), second: time.second() },
date: {
year: time.year(),
month: isMonthEnum ? enumValue(month) : month,
day: time.date(),
},
};
}
return null;
};
var utcTimestampToServerObject = function (utcTimestamp, isMonthEnum) {
if (isMonthEnum === void 0) { isMonthEnum = false; }
return isNumber(utcTimestamp)
? dayjsToServerObject(dayjs.unix(utcTimestamp).utc(), isMonthEnum)
: null;
};
var getDateServerObject = function (date, isMonthEnum) {
var _a;
if (isMonthEnum === void 0) { isMonthEnum = false; }
return (_a = dayjsToServerObject(date, isMonthEnum)) === null || _a === void 0 ? void 0 : _a.date;
};
var getTimeServerObject = function (date) { var _a; return (_a = dayjsToServerObject(date)) === null || _a === void 0 ? void 0 : _a.time; };
var getLocalDateServerObject = function (date, isMonthEnum) {
var _a;
if (isMonthEnum === void 0) { isMonthEnum = false; }
return ({
local_date: (_a = dayjsToServerObject(date, isMonthEnum)) === null || _a === void 0 ? void 0 : _a.date,
offset: getUtcOffset(),
});
};
var getLocalTimeServerObject = function (date) {
var _a;
return ({
local_time: (_a = dayjsToServerObject(date)) === null || _a === void 0 ? void 0 : _a.time,
offset: getUtcOffset(),
});
};
var getLocalDateTimeServerObject = function (date, isMonthEnum) {
if (isMonthEnum === void 0) { isMonthEnum = false; }
return (__assign(__assign({}, getLocalDateServerObject(date, isMonthEnum)), getLocalTimeServerObject(date)));
};
var getUtcOffset = function () { return dayjs().utcOffset() * 60000; };
var getFormattedDate = function (time, format) {
return capitalize(dayjs.utc(time).format(format));
};
var format = function (time, format) {
var dateFormat = DateFormats[format];
if (dateFormat &&
"func" in dateFormat &&
typeof dateFormat.func === "function") {
return dateFormat.func(time);
}
if (dateFormat && "format" in dateFormat) {
return getFormattedDate(time, dateFormat.format);
}
return getFormattedDate(time, undefined);
};
var excelFormat = function (format) {
var dateFormat = DateFormats[format];
if (dateFormat && "excel" in dateFormat) {
return dateFormat.excel;
}
if (dateFormat && "format" in dateFormat) {
return dateFormat.format;
}
return undefined;
};
var capitalizedShortFormat = function (time) {
return "".concat(getFormattedDate(time, "D"), " ").concat(getFormattedDate(time, "dd"));
};
var getFormattedTime = function (time, asHours, seconds) {
var date = dayjs.duration(time);
return "".concat(padStart(String(Math.floor(asHours ? date.asHours() : date.hours())), 2, "0"), ":").concat(padStart(String(date.minutes()), 2, "0")).concat(seconds ? ":".concat(padStart(String(date.seconds()), 2, "0")) : "");
};
var getSignFormattedTime = function (time, asHours, seconds) {
var sign = "";
var _time = time;
if (time < 0) {
sign = "-";
_time = Math.abs(_time);
}
return sign + getFormattedTime(_time, asHours, seconds);
};
var getClockTime = function (milliseconds) {
return getFormattedTime(roundToMinutes(milliseconds), true, undefined);
};
var getDateTimeClockTime = function (time) {
return getFormattedTime(roundToMinutes(time), false, undefined);
};
var getDurationTime = function (time, localization) {
var leftTime = dayjs.duration(time);
var yearsCount = leftTime.years();
if (yearsCount > 0) {
return "".concat(yearsCount, " ").concat(localization.getLocalized(YEARS, {
count: yearsCount,
}));
}
var monthsCount = leftTime.months();
if (monthsCount > 0) {
return "".concat(monthsCount, " ").concat(localization.getLocalized(MONTHS, {
count: monthsCount,
}));
}
var daysCount = leftTime.days();
if (daysCount > 0) {
return "".concat(daysCount, " ").concat(localization.getLocalized(DAY, {
count: daysCount,
}));
}
var hoursCount = leftTime.hours();
if (hoursCount > 0) {
return "".concat(hoursCount, " ").concat(localization.getLocalized(HOURS_LONG, {
count: hoursCount,
}));
}
var minutesCount = leftTime.minutes();
if (minutesCount > 0) {
return "".concat(minutesCount, " ").concat(localization.getLocalized(MINUTES_LONG, {
count: minutesCount,
}));
}
var secondsCount = leftTime.seconds();
if (secondsCount > 0) {
return "".concat(secondsCount, " ").concat(localization.getLocalized(SECONDS_LONG, {
count: secondsCount,
}));
}
return null;
};
var getDayTime = function (milliseconds) {
if (milliseconds === -1) {
return -1;
}
var timeDayjs = dayjs.utc(milliseconds);
var duration = dayjs
.duration({
hours: timeDayjs.hour(),
minutes: timeDayjs.minute(),
seconds: timeDayjs.second(),
})
.valueOf();
return duration;
};
var FORMATTED_DURATION_DESCRIPTION_TYPE;
(function (FORMATTED_DURATION_DESCRIPTION_TYPE) {
FORMATTED_DURATION_DESCRIPTION_TYPE[FORMATTED_DURATION_DESCRIPTION_TYPE["SHORT"] = 1] = "SHORT";
FORMATTED_DURATION_DESCRIPTION_TYPE[FORMATTED_DURATION_DESCRIPTION_TYPE["LONG"] = 2] = "LONG";
FORMATTED_DURATION_DESCRIPTION_TYPE[FORMATTED_DURATION_DESCRIPTION_TYPE["H_LONG_M_SHORT_S_SHORT"] = 3] = "H_LONG_M_SHORT_S_SHORT";
})(FORMATTED_DURATION_DESCRIPTION_TYPE || (FORMATTED_DURATION_DESCRIPTION_TYPE = {}));
var descriptionLocalizations = (_a = {},
_a[FORMATTED_DURATION_DESCRIPTION_TYPE.SHORT] = {
hours: HOURS_SHORT,
minutes: MINUTES_SHORT,
seconds: SECONDS_SHORT,
},
_a[FORMATTED_DURATION_DESCRIPTION_TYPE.LONG] = {
hours: HOURS_LONG,
minutes: MINUTES_LONG,
seconds: SECONDS_LONG,
},
_a[FORMATTED_DURATION_DESCRIPTION_TYPE.H_LONG_M_SHORT_S_SHORT] = {
hours: HOURS_LONG,
minutes: MINUTES_SHORT,
seconds: SECONDS_SHORT,
},
_a);
var getFormattedDuration = function (_a) {
var value = _a.value, localization = _a.localization, _b = _a.digits, digits = _b === void 0 ? 2 : _b, _c = _a.conditions, conditions = _c === void 0 ? TimeFormatConditions : _c, _d = _a.descriptionType, descriptionType = _d === void 0 ? FORMATTED_DURATION_DESCRIPTION_TYPE.SHORT : _d;
var string;
var seconds = getDurationDescription(value).seconds;
var _e = getDurationDescription(value), hours = _e.hours, minutes = _e.minutes;
var padDigits = getPadDigits(digits);
var minutesPlusSeconds = Math.round(minutes + seconds / SecondsPerMinute);
if (minutesPlusSeconds === MinutesPerHour) {
hours += 1;
minutes = 0;
}
var writeHours = conditions.hours
? conditions.hours(hours)
: hours || digits === 2;
var writeMinutes = conditions.minutes
? conditions.minutes(hours, minutes, seconds)
: (minutes || digits === 2) && hours < 1000;
var writeSeconds = conditions.seconds
? conditions.seconds(hours, minutes, seconds)
: !hours && !minutes && seconds;
if (writeHours &&
hours >= 10000 &&
!writeMinutes &&
!writeSeconds &&
descriptionType === FORMATTED_DURATION_DESCRIPTION_TYPE.SHORT) {
string =
splitWithDelimiters(pad(String(Math.round(hours / 1000)), padDigits(), "0"), 3, " ") + localization.getLocalized(THOUSAND_HOURS_SHORT);
}
else {
string =
(writeHours
? "".concat(splitWithDelimiters(pad(String(hours), padDigits(), "0"), 3, " "), " ").concat(localization.getLocalized(descriptionLocalizations[descriptionType].hours, {
count: hours,
}))
: "") +
(writeMinutes
? " ".concat(padStart(String(minutes), padDigits(), "0"), " ").concat(localization.getLocalized(descriptionLocalizations[descriptionType].minutes, {
count: minutes,
}))
: "") +
(writeSeconds
? " ".concat(padStart(String(seconds), padDigits(), "0"), " ").concat(localization.getLocalized(descriptionLocalizations[descriptionType].seconds, {
count: seconds,
}))
: "");
}
return string.trim();
};
var TimeFormatConditions = {
seconds: function (h, m, s) {
return s !== 0 && h === 0 && m === 0;
},
minutes: function (h, m, s) {
return !!((h > 0 && h < 100 && m) ||
(h === 0 && m) ||
(h === 0 && m === 0 && s === 0));
},
hours: function (h) {
return h !== 0;
},
};
var CompactFormatConditions = {
seconds: function (h, m, s) {
return s !== 0 && h === 0 && m === 0;
},
minutes: function (h, m, s) {
return m !== 0 || (h === 0 && m === 0 && s === 0);
},
hours: function (h) {
return h !== 0;
},
};
var FullFormatConditions = {
seconds: function (h, m, s) {
return s !== 0;
},
minutes: function (h, m, s) {
return m !== 0 || (h === 0 && m === 0 && s === 0);
},
hours: function (h) {
return h !== 0;
},
};
var ShortFormatConditions = {
minutes: function (h, m) {
return m !== 0 || (h === 0 && m === 0);
},
hours: function (h) {
return h !== 0;
},
};
var getDurationDescription = function (milliseconds) {
var duration = dayjs.duration(milliseconds, "milliseconds");
return {
hours: Math.floor(duration.asHours()),
minutes: duration.minutes(),
seconds: duration.seconds(),
};
};
var getDurationInHours = function (milliseconds) {
var interval = getDurationDescription(roundToMinutes(milliseconds));
var result = interval.hours + interval.minutes / MinutesPerHour;
return result.toString();
};
var getUTCStartOfDay = function (date) {
return dayjs.utc(dayjs()
.set("year", date.year())
.set("month", date.month())
.set("date", date.date())
.set("hour", 0)
.set("minute", 0)
.set("second", 0));
};
var getPadDigits = function (digits) {
var first = true;
return function () {
if (first) {
first = false;
return 1;
}
return digits;
};
};
var roundToMinutes = function (milliseconds) {
return (Math.round(milliseconds / MillisecondsPerMinute) * MillisecondsPerMinute);
};
var getTimeZone = function () {
return -dayjs().utcOffset() * SecondsPerMinute;
};
var floorMillisecondsToHour = function (time) {
return Math.floor(time / MillisecondsPerHour) * MillisecondsPerHour;
};
var ceilMillisecondsToHour = function (time) {
return Math.ceil(time / MillisecondsPerHour) * MillisecondsPerHour;
};
var TaskManager = (function () {

@@ -1143,115 +569,3 @@ function TaskManager() {

var emailRegexp = new RegExp(".+@.+");
var messageDivider = ". ";
var codeDivider = "_and_";
var notEmptyFieldLoc = FIELD_EMPTY;
var isValidEmailLoc = ENTER_CORRECT_EMAIL;
var alternatelyValidators = function (validators) {
return function (value, allValues, meta) {
for (var i = 0; i < validators.length; i++) {
var validator = validators[i];
var error = validator === null || validator === void 0 ? void 0 : validator(value, allValues, meta);
if (error) {
return error;
}
}
};
};
var combineValidators = function (validators) {
return createSelector(function (locale) { return locale; }, function (locale, arg1) { return arg1; }, function (locale, arg1, arg2) { return arg2; }, function (locale, arg1, arg2, arg3) { return arg3; }, function (locale, arg1, arg2, arg3) {
var localizedValidators = validators === null || validators === void 0 ? void 0 : validators.map(function (validator) {
return validator(locale, arg1, arg2, arg3);
});
return function (value, allValues, meta) {
var resultMessage = "";
var resultCode = "";
var resultedErrorsCount = 0;
each(localizedValidators, function (validator) {
var validateResult = validator(value, allValues, meta);
if (validateResult) {
resultedErrorsCount += 1;
resultMessage += validateResult.message + messageDivider;
resultCode += validateResult.code + codeDivider;
}
});
if (resultedErrorsCount === 1) {
resultMessage = resultMessage.slice(0, resultMessage.length - 2);
resultCode = resultCode.slice(0, resultCode.length - 5);
}
if (resultMessage && resultCode) {
return {
message: resultMessage,
code: resultCode,
};
}
return undefined;
};
});
};
var notEmpty = function (error) { return function (value) {
return value === null ||
value === undefined ||
(Array.isArray(value) && value.length === 0) ||
(isObject(value) && isEmpty(value) && !(value instanceof Model)) ||
(typeof value === "string" && value.trim() === "")
? error
: undefined;
}; };
var notEmptyMemoizeWithoutMessage = notEmpty({
code: TestIdsUtils.FIELD_EMPTY,
});
var notEmptyMemoize = createSelector(function (local) { return local.getLocalized(notEmptyFieldLoc); }, function (message) {
return notEmpty({
message: message,
code: TestIdsUtils.FIELD_EMPTY,
});
});
var notEmptyMemoizeWithCustomMessage = createSelector(function (local) { return local; }, function (local, customMessageLoc) {
return customMessageLoc;
}, function (local, customMessageLoc) {
return notEmpty({
message: local.getLocalized(customMessageLoc),
code: TestIdsUtils.FIELD_EMPTY,
});
});
var isValidEmail = function (error) { return function (value, allValues, meta) {
return value && meta && meta.initial !== value && !emailRegexp.test(value)
? error
: undefined;
}; };
var isValidEmailMemoize = createSelector(function (local) { return local.getLocalized(isValidEmailLoc); }, function (message) {
return isValidEmail({
message: message,
code: TestIdsUtils.ENTER_CORRECT_EMAIL,
});
});
var isValidEmailAndNotEmptyMemoize = combineValidators([
notEmptyMemoize,
isValidEmailMemoize,
]);
var notEmptyTimepickers = function (error) { return function (value) {
return !value || !value.begin || !value.end ? error : undefined;
}; };
var isValidTimepickers = function (error) { return function (value) {
return value.begin.hour * SecondsPerHour +
value.begin.minute * SecondsPerMinute +
value.begin.second >
value.end.hour * SecondsPerHour +
value.end.minute * SecondsPerMinute +
value.end.second
? error
: undefined;
}; };
var notEmptyTimepickersWithoutMessage = notEmptyTimepickers({
code: TestIdsUtils.FIELD_EMPTY,
});
var isValidTimepickersWithoutMessage = isValidTimepickers({
code: TestIdsUtils.FIELD_EMPTY,
});
var isValidNumber = function (error) { return function (value) { return (isNaN(value) ? error : undefined); }; };
var isValidNumberWithoutMessage = isValidNumber({
code: TestIdsUtils.ENTER_CORRECT_NUMBER,
});
export { CancelRequest, CompactFormatConditions, DAY, DateFormats, Deferred, EDays, EHttpCodes, EKeyNames, EMonths, ENTER_CORRECT_EMAIL, EOperationType, EUserAgents, ErrorHandling, FIELD_EMPTY, FORMATTED_DURATION_DESCRIPTION_TYPE, Feature, FormCancelSymbol, FullFormatConditions, HOURS_ABBREVIATION, HOURS_LONG, HOURS_SHORT, HoursPerDay, InvalidIndex, Key, MILLION_SHORT, MINUTES_LONG, MINUTES_SHORT, MONTHS, MillisecondsPerDay, MillisecondsPerHour, MillisecondsPerMinute, MillisecondsPerSecond, MillisecondsPerWeek, MinutesPerDay, MinutesPerHour, MonthsPerYear, NetworkFailResendAttemptsCount, ResendDelays, SECONDS_LONG, SECONDS_SHORT, ScrollContainerClassName, SecondsPerDay, SecondsPerHour, SecondsPerMinute, SecondsPerWeek, ShortFormatConditions, THOUSAND_HOURS_SHORT, THOUSAND_SHORT, TaskManager, TestIdAttr, TestIdsUtils, TimeFormatConditions, WeekDays, XRequestIdHeaderKey, XTraceIdHeaderKey, YEARS, alternatelyValidators, capitalizedShortFormat, ceilMillisecondsToHour, combineValidators, dayjsToServerObject, deferred, excelFormat, floorMillisecondsToHour, format, formatEnteredTime, formatTime, getAccessParameters, getClockTime, getCollapsedDateRangeLabel, getConvertedMsToHours, getDateServerObject, getDateTimeClockTime, getDayTime, getDurationDescription, getDurationInHours, getDurationTime, getFormattedDate, getFormattedDuration, getFormattedTime, getLocalDateServerObject, getLocalDateTimeServerObject, getLocalTimeServerObject, getLocalizedHours, getNullReplacedValue, getNullifyValue, getPadDigits, getSignFormattedTime, getTimeServerObject, getTimeZone, getUTCStartOfDay, getUtcOffset, graphqlTag, hashPassword, importAll, isValidEmailAndNotEmptyMemoize, isValidEmailMemoize, isValidNumberWithoutMessage, isValidTimepickersWithoutMessage, localeUpdate, notEmptyMemoize, notEmptyMemoizeWithCustomMessage, notEmptyMemoizeWithoutMessage, notEmptyTimepickersWithoutMessage, nullReplacedValue, promised, readOnlyAccess, requireAll, requireAllModels, roundToMinutes, runDfs, userAgent, utcTimestampToServerObject };
export { CancelRequest, Deferred, EDays, EHttpCodes, EKeyNames, EMonths, EOperationType, EUserAgents, ErrorHandling, Feature, FormCancelSymbol, HoursPerDay, InvalidIndex, Key, MillisecondsPerDay, MillisecondsPerHour, MillisecondsPerMinute, MillisecondsPerSecond, MillisecondsPerWeek, MinutesPerDay, MinutesPerHour, MonthsPerYear, NetworkFailResendAttemptsCount, ResendDelays, ScrollContainerClassName, SecondsPerDay, SecondsPerHour, SecondsPerMinute, SecondsPerWeek, TaskManager, TestIdAttr, TestIdsUtils, WeekDays, XRequestIdHeaderKey, XTraceIdHeaderKey, deferred, getAccessParameters, getNullReplacedValue, getNullifyValue, graphqlTag, hashPassword, importAll, localeUpdate, nullReplacedValue, promised, readOnlyAccess, requireAll, requireAllModels, runDfs, userAgent };
//# sourceMappingURL=index.esm.js.map

@@ -20,15 +20,6 @@ 'use strict';

var sha256 = require('crypto-js/sha256');
var round = require('lodash/round');
var padStart = require('lodash/padStart');
var pad = require('lodash/pad');
var isNumber = require('lodash/isNumber');
var clamp = require('lodash/clamp');
var capitalize = require('lodash/capitalize');
var includes = require('lodash/includes');
var isUndefined = require('lodash/isUndefined');
var language = require('graphql/language');
var isEmpty = require('lodash/isEmpty');
var each = require('lodash/each');
var isObject = require('lodash/isObject');
var reselect = require('reselect');

@@ -298,149 +289,2 @@ var promised = function (func) {

var HOURS_SHORT = {
ru: "ч",
en: "h",
};
var MINUTES_SHORT = {
ru: "мин",
en: "m",
};
var SECONDS_SHORT = {
ru: "сек",
en: "s",
};
var HOURS_LONG = {
ru: {
s: "час",
p1: "часов",
p2: "часа",
},
en: {
s: "hour",
p1: "hours",
},
};
var MINUTES_LONG = {
ru: {
s: "минута",
p1: "минут",
p2: "минуты",
},
en: {
s: "minute",
p1: "minutes",
},
};
var SECONDS_LONG = {
ru: {
s: "секунду",
p1: "секунд",
p2: "секунды",
},
en: {
s: "second",
p1: "seconds",
},
};
var MONTHS = {
ru: {
s: "месяц",
p1: "месяцев",
p2: "месяца",
},
en: {
s: "month",
p1: "months",
},
};
var YEARS = {
ru: {
s: "год",
p1: "лет",
p2: "года",
},
en: {
s: "year",
p1: "years",
},
};
var DAY = {
ru: {
s: "день",
p1: "дней",
p2: "дня",
},
en: {
s: "day",
p1: "days",
},
};
var THOUSAND_HOURS_SHORT = {
ru: "тыс. ч",
en: "thsnd h",
};
var THOUSAND_SHORT = {
ru: "тыс",
en: "K",
};
var MILLION_SHORT = {
ru: "млн",
en: "M",
};
var FIELD_EMPTY = {
ru: "Поле должно быть заполнено",
en: "Field can not be empty",
};
var ENTER_CORRECT_EMAIL = {
ru: "Введите корректный e-mail",
en: "Enter a correct email address",
};
var HOURS_ABBREVIATION = {
ru: "ч.",
en: "h",
};
function formatNumber(number, localization) {
var absNumber = Math.abs(number);
if (absNumber < 100) {
return "".concat(Math.round(number * 100) / 100);
}
if (Math.round(absNumber) < 10000) {
return "".concat(Math.round(number));
}
if (Math.round(absNumber / 1000) < 10000) {
return "".concat(Math.round(number / 1000)).concat(localization.getLocalized(THOUSAND_SHORT));
}
return "".concat(Math.round(number / 1000000)).concat(localization.getLocalized(MILLION_SHORT));
}
function formatTime(milliseconds, localization) {
if (milliseconds >= 0 &&
Math.round(milliseconds / MillisecondsPerSecond) < SecondsPerMinute) {
return "".concat(Math.round(milliseconds / MillisecondsPerSecond), " ").concat(localization.getLocalized(SECONDS_SHORT));
}
if (Math.round(milliseconds / MillisecondsPerMinute) < 10) {
var seconds = Math.round((milliseconds % MillisecondsPerMinute) / MillisecondsPerSecond);
var minutes = Math.floor(milliseconds / MillisecondsPerMinute);
return "".concat(minutes, " ").concat(localization.getLocalized(MINUTES_SHORT), " ").concat(seconds, " ").concat(localization.getLocalized(SECONDS_SHORT));
}
if (Math.round(milliseconds / MillisecondsPerMinute) < MinutesPerHour) {
return "".concat(Math.round(milliseconds / MillisecondsPerMinute), " ").concat(localization.getLocalized(MINUTES_SHORT));
}
if (Math.round(milliseconds / MillisecondsPerMinute) < 100 * MinutesPerHour) {
var minutes = Math.round((milliseconds % MillisecondsPerHour) / MillisecondsPerMinute);
var hours = Math.floor(milliseconds / MillisecondsPerHour);
if (minutes === MinutesPerHour) {
return "".concat(hours + 1, " ").concat(localization.getLocalized(HOURS_SHORT));
}
if (minutes === 0) {
return "".concat(hours, " ").concat(localization.getLocalized(HOURS_SHORT));
}
return "".concat(hours, " ").concat(localization.getLocalized(HOURS_SHORT), " ").concat(minutes, " ").concat(localization.getLocalized(MINUTES_SHORT));
}
if (Math.round(milliseconds / MillisecondsPerHour) >= 100) {
return "".concat(formatNumber(Math.floor(milliseconds / MillisecondsPerHour), localization), " ").concat(localization.getLocalized(HOURS_SHORT));
}
assert.assertSimple(false, "Некорректное время!");
return null;
}
dayjs.extend(updateLocale);

@@ -608,420 +452,2 @@ dayjs.extend(utc);

var splitWithDelimiters = function (str, count, delimiter) {
var newStr = str.toString();
var leftPartCount = newStr.length % count;
var leftPart = newStr.slice(0, leftPartCount);
var rightPart = newStr.slice(leftPartCount);
var counter = 0;
var res = "";
for (var i = 0, l = rightPart.length; i < l; i += 1) {
counter += 1;
res += rightPart[i];
if (counter === count && i !== l - 1) {
counter = 0;
res += delimiter;
}
}
if (leftPart !== "") {
res = leftPart + (res !== "" ? delimiter + res : "");
}
return res;
};
var _a;
var DateFormats = {
SHORT: {
format: "D dd",
excel: "ddd\\,\\ dd",
},
DOW: {
format: "dd",
},
DOW_MIDDLE: {
format: "dd, D MMM",
},
DOW_LONG: {
format: "dddd",
},
LONG: {
format: "D MMMM YYYY",
},
DAY: {
format: "D",
},
DAY_MONTH: {
format: "D MMMM",
},
MONTH_MIDDLE: {
func: function (time) { return dayjs.utc(time).format("MMM").substr(0, 3); },
},
MONTH_YEAR: {
format: "MMMM YYYY",
},
MONTH: {
format: "MMMM",
},
YEAR: {
format: "YYYY",
},
HOUR_MINUTES_LONG: {
format: "h:mm / D MMMM YYYY",
},
FULL_HOUR_MINUTES_LONG: {
format: "HH:mm / D MMMM YYYY",
},
DAY_MONTH_YEAR_SHORT: {
format: "DD.MM.YYYY",
},
};
var getConvertedMsToHours = function (time, precision) {
return dayjs.duration(time, "ms").asHours().toFixed(precision);
};
var getCollapsedDateRangeLabel = function (dateFrom, dateTo, dateFormat) {
if (dateFormat === void 0) { dateFormat = "D MMMM YYYY"; }
var dateFromFormattedArray = dateFrom
.format(dateFormat)
.split(" ");
var dateToFormattedArray = dateTo.format(dateFormat).split(" ");
var uniqueDateFromFormattedArray = __spreadArray([], __read(dateFromFormattedArray), false);
for (var i = 2; i >= 0; i -= 1) {
if (dateToFormattedArray[i] === dateFromFormattedArray[i]) {
uniqueDateFromFormattedArray.splice(i, 1);
}
else {
break;
}
}
var divider = uniqueDateFromFormattedArray.length === 0 ? "" : " - ";
return "".concat(uniqueDateFromFormattedArray.join(" ")).concat(divider).concat(dateToFormattedArray.join(" "));
};
var formatEnteredTime = function (value) {
var clearedValue = value.replace(/[^0-9]/gim, "");
var chunkSize = clearedValue.length <= 2 ? 1 : 2;
var parts = [];
for (var end = clearedValue.length; end >= 1; end -= chunkSize) {
var begin = clamp(end - chunkSize, 0, Infinity);
parts.unshift(clearedValue.slice(begin, end));
}
return parts.join(":");
};
var getLocalizedHours = function (ms, localization) {
var hours = dayjs.duration(ms).asHours();
return "".concat(round(hours, 2), " ").concat(localization.getLocalized(HOURS_ABBREVIATION));
};
var dayjsToServerObject = function (time, isMonthEnum) {
if (isMonthEnum === void 0) { isMonthEnum = false; }
if (time) {
if (dayjs.isDuration(time)) {
return {
time: {
hour: time.hours(),
minute: time.minutes(),
second: time.seconds(),
},
};
}
var month = exports.EMonths[time.month()];
return {
time: { hour: time.hour(), minute: time.minute(), second: time.second() },
date: {
year: time.year(),
month: isMonthEnum ? graphqlQueryBuilder.enumValue(month) : month,
day: time.date(),
},
};
}
return null;
};
var utcTimestampToServerObject = function (utcTimestamp, isMonthEnum) {
if (isMonthEnum === void 0) { isMonthEnum = false; }
return isNumber(utcTimestamp)
? dayjsToServerObject(dayjs.unix(utcTimestamp).utc(), isMonthEnum)
: null;
};
var getDateServerObject = function (date, isMonthEnum) {
var _a;
if (isMonthEnum === void 0) { isMonthEnum = false; }
return (_a = dayjsToServerObject(date, isMonthEnum)) === null || _a === void 0 ? void 0 : _a.date;
};
var getTimeServerObject = function (date) { var _a; return (_a = dayjsToServerObject(date)) === null || _a === void 0 ? void 0 : _a.time; };
var getLocalDateServerObject = function (date, isMonthEnum) {
var _a;
if (isMonthEnum === void 0) { isMonthEnum = false; }
return ({
local_date: (_a = dayjsToServerObject(date, isMonthEnum)) === null || _a === void 0 ? void 0 : _a.date,
offset: getUtcOffset(),
});
};
var getLocalTimeServerObject = function (date) {
var _a;
return ({
local_time: (_a = dayjsToServerObject(date)) === null || _a === void 0 ? void 0 : _a.time,
offset: getUtcOffset(),
});
};
var getLocalDateTimeServerObject = function (date, isMonthEnum) {
if (isMonthEnum === void 0) { isMonthEnum = false; }
return (__assign(__assign({}, getLocalDateServerObject(date, isMonthEnum)), getLocalTimeServerObject(date)));
};
var getUtcOffset = function () { return dayjs().utcOffset() * 60000; };
var getFormattedDate = function (time, format) {
return capitalize(dayjs.utc(time).format(format));
};
var format = function (time, format) {
var dateFormat = DateFormats[format];
if (dateFormat &&
"func" in dateFormat &&
typeof dateFormat.func === "function") {
return dateFormat.func(time);
}
if (dateFormat && "format" in dateFormat) {
return getFormattedDate(time, dateFormat.format);
}
return getFormattedDate(time, undefined);
};
var excelFormat = function (format) {
var dateFormat = DateFormats[format];
if (dateFormat && "excel" in dateFormat) {
return dateFormat.excel;
}
if (dateFormat && "format" in dateFormat) {
return dateFormat.format;
}
return undefined;
};
var capitalizedShortFormat = function (time) {
return "".concat(getFormattedDate(time, "D"), " ").concat(getFormattedDate(time, "dd"));
};
var getFormattedTime = function (time, asHours, seconds) {
var date = dayjs.duration(time);
return "".concat(padStart(String(Math.floor(asHours ? date.asHours() : date.hours())), 2, "0"), ":").concat(padStart(String(date.minutes()), 2, "0")).concat(seconds ? ":".concat(padStart(String(date.seconds()), 2, "0")) : "");
};
var getSignFormattedTime = function (time, asHours, seconds) {
var sign = "";
var _time = time;
if (time < 0) {
sign = "-";
_time = Math.abs(_time);
}
return sign + getFormattedTime(_time, asHours, seconds);
};
var getClockTime = function (milliseconds) {
return getFormattedTime(roundToMinutes(milliseconds), true, undefined);
};
var getDateTimeClockTime = function (time) {
return getFormattedTime(roundToMinutes(time), false, undefined);
};
var getDurationTime = function (time, localization) {
var leftTime = dayjs.duration(time);
var yearsCount = leftTime.years();
if (yearsCount > 0) {
return "".concat(yearsCount, " ").concat(localization.getLocalized(YEARS, {
count: yearsCount,
}));
}
var monthsCount = leftTime.months();
if (monthsCount > 0) {
return "".concat(monthsCount, " ").concat(localization.getLocalized(MONTHS, {
count: monthsCount,
}));
}
var daysCount = leftTime.days();
if (daysCount > 0) {
return "".concat(daysCount, " ").concat(localization.getLocalized(DAY, {
count: daysCount,
}));
}
var hoursCount = leftTime.hours();
if (hoursCount > 0) {
return "".concat(hoursCount, " ").concat(localization.getLocalized(HOURS_LONG, {
count: hoursCount,
}));
}
var minutesCount = leftTime.minutes();
if (minutesCount > 0) {
return "".concat(minutesCount, " ").concat(localization.getLocalized(MINUTES_LONG, {
count: minutesCount,
}));
}
var secondsCount = leftTime.seconds();
if (secondsCount > 0) {
return "".concat(secondsCount, " ").concat(localization.getLocalized(SECONDS_LONG, {
count: secondsCount,
}));
}
return null;
};
var getDayTime = function (milliseconds) {
if (milliseconds === -1) {
return -1;
}
var timeDayjs = dayjs.utc(milliseconds);
var duration = dayjs
.duration({
hours: timeDayjs.hour(),
minutes: timeDayjs.minute(),
seconds: timeDayjs.second(),
})
.valueOf();
return duration;
};
exports.FORMATTED_DURATION_DESCRIPTION_TYPE = void 0;
(function (FORMATTED_DURATION_DESCRIPTION_TYPE) {
FORMATTED_DURATION_DESCRIPTION_TYPE[FORMATTED_DURATION_DESCRIPTION_TYPE["SHORT"] = 1] = "SHORT";
FORMATTED_DURATION_DESCRIPTION_TYPE[FORMATTED_DURATION_DESCRIPTION_TYPE["LONG"] = 2] = "LONG";
FORMATTED_DURATION_DESCRIPTION_TYPE[FORMATTED_DURATION_DESCRIPTION_TYPE["H_LONG_M_SHORT_S_SHORT"] = 3] = "H_LONG_M_SHORT_S_SHORT";
})(exports.FORMATTED_DURATION_DESCRIPTION_TYPE || (exports.FORMATTED_DURATION_DESCRIPTION_TYPE = {}));
var descriptionLocalizations = (_a = {},
_a[exports.FORMATTED_DURATION_DESCRIPTION_TYPE.SHORT] = {
hours: HOURS_SHORT,
minutes: MINUTES_SHORT,
seconds: SECONDS_SHORT,
},
_a[exports.FORMATTED_DURATION_DESCRIPTION_TYPE.LONG] = {
hours: HOURS_LONG,
minutes: MINUTES_LONG,
seconds: SECONDS_LONG,
},
_a[exports.FORMATTED_DURATION_DESCRIPTION_TYPE.H_LONG_M_SHORT_S_SHORT] = {
hours: HOURS_LONG,
minutes: MINUTES_SHORT,
seconds: SECONDS_SHORT,
},
_a);
var getFormattedDuration = function (_a) {
var value = _a.value, localization = _a.localization, _b = _a.digits, digits = _b === void 0 ? 2 : _b, _c = _a.conditions, conditions = _c === void 0 ? TimeFormatConditions : _c, _d = _a.descriptionType, descriptionType = _d === void 0 ? exports.FORMATTED_DURATION_DESCRIPTION_TYPE.SHORT : _d;
var string;
var seconds = getDurationDescription(value).seconds;
var _e = getDurationDescription(value), hours = _e.hours, minutes = _e.minutes;
var padDigits = getPadDigits(digits);
var minutesPlusSeconds = Math.round(minutes + seconds / SecondsPerMinute);
if (minutesPlusSeconds === MinutesPerHour) {
hours += 1;
minutes = 0;
}
var writeHours = conditions.hours
? conditions.hours(hours)
: hours || digits === 2;
var writeMinutes = conditions.minutes
? conditions.minutes(hours, minutes, seconds)
: (minutes || digits === 2) && hours < 1000;
var writeSeconds = conditions.seconds
? conditions.seconds(hours, minutes, seconds)
: !hours && !minutes && seconds;
if (writeHours &&
hours >= 10000 &&
!writeMinutes &&
!writeSeconds &&
descriptionType === exports.FORMATTED_DURATION_DESCRIPTION_TYPE.SHORT) {
string =
splitWithDelimiters(pad(String(Math.round(hours / 1000)), padDigits(), "0"), 3, " ") + localization.getLocalized(THOUSAND_HOURS_SHORT);
}
else {
string =
(writeHours
? "".concat(splitWithDelimiters(pad(String(hours), padDigits(), "0"), 3, " "), " ").concat(localization.getLocalized(descriptionLocalizations[descriptionType].hours, {
count: hours,
}))
: "") +
(writeMinutes
? " ".concat(padStart(String(minutes), padDigits(), "0"), " ").concat(localization.getLocalized(descriptionLocalizations[descriptionType].minutes, {
count: minutes,
}))
: "") +
(writeSeconds
? " ".concat(padStart(String(seconds), padDigits(), "0"), " ").concat(localization.getLocalized(descriptionLocalizations[descriptionType].seconds, {
count: seconds,
}))
: "");
}
return string.trim();
};
var TimeFormatConditions = {
seconds: function (h, m, s) {
return s !== 0 && h === 0 && m === 0;
},
minutes: function (h, m, s) {
return !!((h > 0 && h < 100 && m) ||
(h === 0 && m) ||
(h === 0 && m === 0 && s === 0));
},
hours: function (h) {
return h !== 0;
},
};
var CompactFormatConditions = {
seconds: function (h, m, s) {
return s !== 0 && h === 0 && m === 0;
},
minutes: function (h, m, s) {
return m !== 0 || (h === 0 && m === 0 && s === 0);
},
hours: function (h) {
return h !== 0;
},
};
var FullFormatConditions = {
seconds: function (h, m, s) {
return s !== 0;
},
minutes: function (h, m, s) {
return m !== 0 || (h === 0 && m === 0 && s === 0);
},
hours: function (h) {
return h !== 0;
},
};
var ShortFormatConditions = {
minutes: function (h, m) {
return m !== 0 || (h === 0 && m === 0);
},
hours: function (h) {
return h !== 0;
},
};
var getDurationDescription = function (milliseconds) {
var duration = dayjs.duration(milliseconds, "milliseconds");
return {
hours: Math.floor(duration.asHours()),
minutes: duration.minutes(),
seconds: duration.seconds(),
};
};
var getDurationInHours = function (milliseconds) {
var interval = getDurationDescription(roundToMinutes(milliseconds));
var result = interval.hours + interval.minutes / MinutesPerHour;
return result.toString();
};
var getUTCStartOfDay = function (date) {
return dayjs.utc(dayjs()
.set("year", date.year())
.set("month", date.month())
.set("date", date.date())
.set("hour", 0)
.set("minute", 0)
.set("second", 0));
};
var getPadDigits = function (digits) {
var first = true;
return function () {
if (first) {
first = false;
return 1;
}
return digits;
};
};
var roundToMinutes = function (milliseconds) {
return (Math.round(milliseconds / MillisecondsPerMinute) * MillisecondsPerMinute);
};
var getTimeZone = function () {
return -dayjs().utcOffset() * SecondsPerMinute;
};
var floorMillisecondsToHour = function (time) {
return Math.floor(time / MillisecondsPerHour) * MillisecondsPerHour;
};
var ceilMillisecondsToHour = function (time) {
return Math.ceil(time / MillisecondsPerHour) * MillisecondsPerHour;
};
var TaskManager = (function () {

@@ -1143,114 +569,2 @@ function TaskManager() {

var emailRegexp = new RegExp(".+@.+");
var messageDivider = ". ";
var codeDivider = "_and_";
var notEmptyFieldLoc = FIELD_EMPTY;
var isValidEmailLoc = ENTER_CORRECT_EMAIL;
var alternatelyValidators = function (validators) {
return function (value, allValues, meta) {
for (var i = 0; i < validators.length; i++) {
var validator = validators[i];
var error = validator === null || validator === void 0 ? void 0 : validator(value, allValues, meta);
if (error) {
return error;
}
}
};
};
var combineValidators = function (validators) {
return reselect.createSelector(function (locale) { return locale; }, function (locale, arg1) { return arg1; }, function (locale, arg1, arg2) { return arg2; }, function (locale, arg1, arg2, arg3) { return arg3; }, function (locale, arg1, arg2, arg3) {
var localizedValidators = validators === null || validators === void 0 ? void 0 : validators.map(function (validator) {
return validator(locale, arg1, arg2, arg3);
});
return function (value, allValues, meta) {
var resultMessage = "";
var resultCode = "";
var resultedErrorsCount = 0;
each(localizedValidators, function (validator) {
var validateResult = validator(value, allValues, meta);
if (validateResult) {
resultedErrorsCount += 1;
resultMessage += validateResult.message + messageDivider;
resultCode += validateResult.code + codeDivider;
}
});
if (resultedErrorsCount === 1) {
resultMessage = resultMessage.slice(0, resultMessage.length - 2);
resultCode = resultCode.slice(0, resultCode.length - 5);
}
if (resultMessage && resultCode) {
return {
message: resultMessage,
code: resultCode,
};
}
return undefined;
};
});
};
var notEmpty = function (error) { return function (value) {
return value === null ||
value === undefined ||
(Array.isArray(value) && value.length === 0) ||
(isObject(value) && isEmpty(value) && !(value instanceof graphqlModel.Model)) ||
(typeof value === "string" && value.trim() === "")
? error
: undefined;
}; };
var notEmptyMemoizeWithoutMessage = notEmpty({
code: TestIdsUtils.FIELD_EMPTY,
});
var notEmptyMemoize = reselect.createSelector(function (local) { return local.getLocalized(notEmptyFieldLoc); }, function (message) {
return notEmpty({
message: message,
code: TestIdsUtils.FIELD_EMPTY,
});
});
var notEmptyMemoizeWithCustomMessage = reselect.createSelector(function (local) { return local; }, function (local, customMessageLoc) {
return customMessageLoc;
}, function (local, customMessageLoc) {
return notEmpty({
message: local.getLocalized(customMessageLoc),
code: TestIdsUtils.FIELD_EMPTY,
});
});
var isValidEmail = function (error) { return function (value, allValues, meta) {
return value && meta && meta.initial !== value && !emailRegexp.test(value)
? error
: undefined;
}; };
var isValidEmailMemoize = reselect.createSelector(function (local) { return local.getLocalized(isValidEmailLoc); }, function (message) {
return isValidEmail({
message: message,
code: TestIdsUtils.ENTER_CORRECT_EMAIL,
});
});
var isValidEmailAndNotEmptyMemoize = combineValidators([
notEmptyMemoize,
isValidEmailMemoize,
]);
var notEmptyTimepickers = function (error) { return function (value) {
return !value || !value.begin || !value.end ? error : undefined;
}; };
var isValidTimepickers = function (error) { return function (value) {
return value.begin.hour * SecondsPerHour +
value.begin.minute * SecondsPerMinute +
value.begin.second >
value.end.hour * SecondsPerHour +
value.end.minute * SecondsPerMinute +
value.end.second
? error
: undefined;
}; };
var notEmptyTimepickersWithoutMessage = notEmptyTimepickers({
code: TestIdsUtils.FIELD_EMPTY,
});
var isValidTimepickersWithoutMessage = isValidTimepickers({
code: TestIdsUtils.FIELD_EMPTY,
});
var isValidNumber = function (error) { return function (value) { return (isNaN(value) ? error : undefined); }; };
var isValidNumberWithoutMessage = isValidNumber({
code: TestIdsUtils.ENTER_CORRECT_NUMBER,
});
Object.defineProperty(exports, "EnumValue", {

@@ -1269,22 +583,9 @@ enumerable: true,

exports.CancelRequest = CancelRequest;
exports.CompactFormatConditions = CompactFormatConditions;
exports.DAY = DAY;
exports.DateFormats = DateFormats;
exports.Deferred = Deferred;
exports.ENTER_CORRECT_EMAIL = ENTER_CORRECT_EMAIL;
exports.ErrorHandling = ErrorHandling;
exports.FIELD_EMPTY = FIELD_EMPTY;
exports.Feature = Feature;
exports.FormCancelSymbol = FormCancelSymbol;
exports.FullFormatConditions = FullFormatConditions;
exports.HOURS_ABBREVIATION = HOURS_ABBREVIATION;
exports.HOURS_LONG = HOURS_LONG;
exports.HOURS_SHORT = HOURS_SHORT;
exports.HoursPerDay = HoursPerDay;
exports.InvalidIndex = InvalidIndex;
exports.Key = Key;
exports.MILLION_SHORT = MILLION_SHORT;
exports.MINUTES_LONG = MINUTES_LONG;
exports.MINUTES_SHORT = MINUTES_SHORT;
exports.MONTHS = MONTHS;
exports.MillisecondsPerDay = MillisecondsPerDay;

@@ -1300,4 +601,2 @@ exports.MillisecondsPerHour = MillisecondsPerHour;

exports.ResendDelays = ResendDelays;
exports.SECONDS_LONG = SECONDS_LONG;
exports.SECONDS_SHORT = SECONDS_SHORT;
exports.ScrollContainerClassName = ScrollContainerClassName;

@@ -1308,61 +607,16 @@ exports.SecondsPerDay = SecondsPerDay;

exports.SecondsPerWeek = SecondsPerWeek;
exports.ShortFormatConditions = ShortFormatConditions;
exports.THOUSAND_HOURS_SHORT = THOUSAND_HOURS_SHORT;
exports.THOUSAND_SHORT = THOUSAND_SHORT;
exports.TaskManager = TaskManager;
exports.TestIdAttr = TestIdAttr;
exports.TestIdsUtils = TestIdsUtils;
exports.TimeFormatConditions = TimeFormatConditions;
exports.WeekDays = WeekDays;
exports.XRequestIdHeaderKey = XRequestIdHeaderKey;
exports.XTraceIdHeaderKey = XTraceIdHeaderKey;
exports.YEARS = YEARS;
exports.alternatelyValidators = alternatelyValidators;
exports.capitalizedShortFormat = capitalizedShortFormat;
exports.ceilMillisecondsToHour = ceilMillisecondsToHour;
exports.combineValidators = combineValidators;
exports.dayjsToServerObject = dayjsToServerObject;
exports.deferred = deferred;
exports.excelFormat = excelFormat;
exports.floorMillisecondsToHour = floorMillisecondsToHour;
exports.format = format;
exports.formatEnteredTime = formatEnteredTime;
exports.formatTime = formatTime;
exports.getAccessParameters = getAccessParameters;
exports.getClockTime = getClockTime;
exports.getCollapsedDateRangeLabel = getCollapsedDateRangeLabel;
exports.getConvertedMsToHours = getConvertedMsToHours;
exports.getDateServerObject = getDateServerObject;
exports.getDateTimeClockTime = getDateTimeClockTime;
exports.getDayTime = getDayTime;
exports.getDurationDescription = getDurationDescription;
exports.getDurationInHours = getDurationInHours;
exports.getDurationTime = getDurationTime;
exports.getFormattedDate = getFormattedDate;
exports.getFormattedDuration = getFormattedDuration;
exports.getFormattedTime = getFormattedTime;
exports.getLocalDateServerObject = getLocalDateServerObject;
exports.getLocalDateTimeServerObject = getLocalDateTimeServerObject;
exports.getLocalTimeServerObject = getLocalTimeServerObject;
exports.getLocalizedHours = getLocalizedHours;
exports.getNullReplacedValue = getNullReplacedValue;
exports.getNullifyValue = getNullifyValue;
exports.getPadDigits = getPadDigits;
exports.getSignFormattedTime = getSignFormattedTime;
exports.getTimeServerObject = getTimeServerObject;
exports.getTimeZone = getTimeZone;
exports.getUTCStartOfDay = getUTCStartOfDay;
exports.getUtcOffset = getUtcOffset;
exports.graphqlTag = graphqlTag;
exports.hashPassword = hashPassword;
exports.importAll = importAll;
exports.isValidEmailAndNotEmptyMemoize = isValidEmailAndNotEmptyMemoize;
exports.isValidEmailMemoize = isValidEmailMemoize;
exports.isValidNumberWithoutMessage = isValidNumberWithoutMessage;
exports.isValidTimepickersWithoutMessage = isValidTimepickersWithoutMessage;
exports.localeUpdate = localeUpdate;
exports.notEmptyMemoize = notEmptyMemoize;
exports.notEmptyMemoizeWithCustomMessage = notEmptyMemoizeWithCustomMessage;
exports.notEmptyMemoizeWithoutMessage = notEmptyMemoizeWithoutMessage;
exports.notEmptyTimepickersWithoutMessage = notEmptyTimepickersWithoutMessage;
exports.nullReplacedValue = nullReplacedValue;

@@ -1373,6 +627,4 @@ exports.promised = promised;

exports.requireAllModels = requireAllModels;
exports.roundToMinutes = roundToMinutes;
exports.runDfs = runDfs;
exports.userAgent = userAgent;
exports.utcTimestampToServerObject = utcTimestampToServerObject;
//# sourceMappingURL=index.js.map
{
"name": "@infomaximum/utility",
"version": "9.2.1",
"version": "9.2.2",
"main": "./dist/index.js",

@@ -14,6 +14,6 @@ "module": "./dist/index.esm.js",

"dependencies": {
"@infomaximum/assert": "^1.1.3",
"@infomaximum/graphql-model": "^1.6.0",
"@saneksa/graphql-query-builder": "^3.1.1",
"@types/hoist-non-react-statics": "^3.3.1",
"lodash": "^4.17.21",
"reselect": "4.0.0",
"crypto-js": "^4.1.1",

@@ -23,5 +23,4 @@ "dayjs": "^1.11.10",

"graphql-tag": "^2.12.6",
"@infomaximum/graphql-model": "^1.6.0",
"@infomaximum/localization": "^1.1.0",
"@infomaximum/assert": "^1.1.3"
"lodash": "^4.17.21",
"reselect": "4.0.0"
},

@@ -42,3 +41,2 @@ "devDependencies": {

"@types/webpack-env": "1.18.0",
"universal-cookie": "^4.0.4",
"babel-jest": "^29.7.0",

@@ -56,3 +54,4 @@ "cross-env": "^7.0.3",

"tslib": "^2.6.2",
"typescript": "5.4.5"
"typescript": "5.4.5",
"universal-cookie": "^4.0.4"
},

@@ -59,0 +58,0 @@ "scripts": {

export declare const HOURS_SHORT: {
ru: string;
en: string;
};
export declare const MINUTES_SHORT: {
ru: string;
en: string;
};
export declare const SECONDS_SHORT: {
ru: string;
en: string;
};
export declare const HOURS_LONG: {
ru: {
s: string;
p1: string;
p2: string;
};
en: {
s: string;
p1: string;
};
};
export declare const MINUTES_LONG: {
ru: {
s: string;
p1: string;
p2: string;
};
en: {
s: string;
p1: string;
};
};
export declare const SECONDS_LONG: {
ru: {
s: string;
p1: string;
p2: string;
};
en: {
s: string;
p1: string;
};
};
export declare const MONTHS: {
ru: {
s: string;
p1: string;
p2: string;
};
en: {
s: string;
p1: string;
};
};
export declare const YEARS: {
ru: {
s: string;
p1: string;
p2: string;
};
en: {
s: string;
p1: string;
};
};
export declare const DAY: {
ru: {
s: string;
p1: string;
p2: string;
};
en: {
s: string;
p1: string;
};
};
export declare const THOUSAND_HOURS_SHORT: {
ru: string;
en: string;
};
export declare const THOUSAND_SHORT: {
ru: string;
en: string;
};
export declare const MILLION_SHORT: {
ru: string;
en: string;
};
export declare const FIELD_EMPTY: {
ru: string;
en: string;
};
export declare const ENTER_CORRECT_EMAIL: {
ru: string;
en: string;
};
export declare const HOURS_ABBREVIATION: {
ru: string;
en: string;
};
import dayjs, { type Dayjs } from "dayjs";
import type { Localization } from "@infomaximum/localization";
export type TMilliseconds = number | null;
export type TSeconds = number | null;
export type TDuration = number;
export type TTimeFormatConditions = {
hours(hours: number, minutes?: number, seconds?: number): boolean;
minutes(hours: number, minutes: number, seconds: number): boolean;
seconds?(hours: number, minutes: number, seconds: number): boolean;
};
export interface IDateLocaleFormat {
short: string;
middle: string;
long: string;
}
export type TDurationDescription = {
hours: number;
minutes: number;
seconds: number;
};
export type TTimeString = string;
export declare const DateFormats: {
SHORT: {
format: string;
excel: string;
};
DOW: {
format: string;
};
DOW_MIDDLE: {
format: string;
};
DOW_LONG: {
format: string;
};
LONG: {
format: string;
};
DAY: {
format: string;
};
DAY_MONTH: {
format: string;
};
MONTH_MIDDLE: {
func: (time: number) => string;
};
MONTH_YEAR: {
format: string;
};
MONTH: {
format: string;
};
YEAR: {
format: string;
};
HOUR_MINUTES_LONG: {
format: string;
};
FULL_HOUR_MINUTES_LONG: {
format: string;
};
DAY_MONTH_YEAR_SHORT: {
format: string;
};
};
export declare const getConvertedMsToHours: (time: number, precision: number) => string;
export declare const getCollapsedDateRangeLabel: (dateFrom: Dayjs, dateTo: Dayjs, dateFormat?: string) => string;
export declare const formatEnteredTime: (value: string) => string;
export declare const getLocalizedHours: (ms: number, localization: Localization) => string;
export declare const dayjsToServerObject: (time: Dayjs | plugin.Duration | undefined, isMonthEnum?: boolean) => {
time: {
hour: number;
minute: number;
second: number;
};
date?: never;
} | {
time: {
hour: number;
minute: number;
second: number;
};
date: {
year: number;
month: string;
day: number;
};
} | null;
export declare const utcTimestampToServerObject: (utcTimestamp: number | null, isMonthEnum?: boolean) => {
time: {
hour: number;
minute: number;
second: number;
};
date?: never;
} | {
time: {
hour: number;
minute: number;
second: number;
};
date: {
year: number;
month: string;
day: number;
};
} | null;
export declare const getDateServerObject: (date: Dayjs, isMonthEnum?: boolean) => {
year: number;
month: string;
day: number;
} | undefined;
export declare const getTimeServerObject: (date: Dayjs | plugin.Duration) => {
hour: number;
minute: number;
second: number;
} | {
hour: number;
minute: number;
second: number;
} | undefined;
export declare const getLocalDateServerObject: (date: Dayjs, isMonthEnum?: boolean) => {
local_date: {
year: number;
month: string;
day: number;
} | undefined;
offset: number;
};
export declare const getLocalTimeServerObject: (date: Dayjs | plugin.Duration) => {
local_time: {
hour: number;
minute: number;
second: number;
} | {
hour: number;
minute: number;
second: number;
} | undefined;
offset: number;
};
export declare const getLocalDateTimeServerObject: (date: Dayjs, isMonthEnum?: boolean) => {
local_time: {
hour: number;
minute: number;
second: number;
} | {
hour: number;
minute: number;
second: number;
} | undefined;
offset: number;
local_date: {
year: number;
month: string;
day: number;
} | undefined;
};
export declare const getUtcOffset: () => number;
export declare const getFormattedDate: (time: number, format: string | undefined) => string;
export declare const format: (time: number, format: keyof typeof DateFormats) => string;
export declare const excelFormat: (format: keyof typeof DateFormats) => string | undefined;
export declare const capitalizedShortFormat: (time: number) => string;
export declare const getFormattedTime: (time: number, asHours?: boolean, seconds?: boolean) => string;
export declare const getSignFormattedTime: (time: number, asHours: boolean, seconds: boolean) => string;
export declare const getClockTime: (milliseconds: number) => string;
export declare const getDateTimeClockTime: (time: number) => string;
export declare const getDurationTime: (time: number, localization: Localization) => string | null;
export declare const getDayTime: (milliseconds: number) => number;
export declare enum FORMATTED_DURATION_DESCRIPTION_TYPE {
SHORT = 1,
LONG = 2,
H_LONG_M_SHORT_S_SHORT = 3
}
export declare const getFormattedDuration: ({ value, localization, digits, conditions, descriptionType, }: {
value: number;
localization: Localization;
digits?: number;
conditions?: TTimeFormatConditions;
descriptionType?: (typeof FORMATTED_DURATION_DESCRIPTION_TYPE)[keyof typeof FORMATTED_DURATION_DESCRIPTION_TYPE];
}) => string;
export declare const TimeFormatConditions: {
seconds(h: number, m: number, s: number): boolean;
minutes(h: number, m: number, s: number): boolean;
hours(h: number): boolean;
};
export declare const CompactFormatConditions: {
seconds(h: number, m: number, s: number): boolean;
minutes(h: number, m: number, s: number): boolean;
hours(h: number): boolean;
};
export declare const FullFormatConditions: {
seconds(h: number, m: number, s: number): boolean;
minutes(h: number, m: number, s: number): boolean;
hours(h: number): boolean;
};
export declare const ShortFormatConditions: {
minutes(h: number, m: number): boolean;
hours(h: number): boolean;
};
export declare const getDurationDescription: (milliseconds: number) => {
hours: number;
minutes: number;
seconds: number;
};
export declare const getDurationInHours: (milliseconds: number) => string;
export declare const getUTCStartOfDay: (date: Dayjs) => dayjs.Dayjs;
export declare const getPadDigits: (digits: number) => () => number;
export declare const roundToMinutes: (milliseconds: number) => number;
export declare const getTimeZone: () => number;
export declare const floorMillisecondsToHour: (time: number) => number;
export declare const ceilMillisecondsToHour: (time: number) => number;
import "dayjs/locale/ru";
import type { Localization } from "@infomaximum/localization";
export declare function formatNumber(number: number, localization: Localization): string;
export declare function formatTime(milliseconds: number, localization: Localization): string | null;
import type { Localization, TLocalizationDescription } from "@infomaximum/localization";
type FieldValidator<FieldValue> = (value: FieldValue, allValues: object, meta?: any) => any | Promise<any>;
export type TValidationError = {
code: string;
message?: string;
};
export type TFieldValidatorSelector<FV = any> = (...args: any[]) => FieldValidator<FV>;
export declare const alternatelyValidators: (validators: FieldValidator<any>[]) => FieldValidator<any>;
export declare const combineValidators: (validators: TFieldValidatorSelector[]) => import("reselect").OutputSelector<Localization, FieldValidator<any>, (res1: Localization, res2: any, res3: any, res4: any) => FieldValidator<any>>;
export declare const notEmptyMemoizeWithoutMessage: FieldValidator<any>;
export declare const notEmptyMemoize: import("reselect").OutputSelector<Localization, FieldValidator<any>, (res: string) => FieldValidator<any>>;
export declare const notEmptyMemoizeWithCustomMessage: import("reselect").OutputParametricSelector<Localization, TLocalizationDescription, FieldValidator<any>, (res1: Localization, res2: TLocalizationDescription) => FieldValidator<any>>;
export declare const isValidEmailMemoize: import("reselect").OutputSelector<Localization, FieldValidator<any>, (res: string) => FieldValidator<any>>;
export declare const isValidEmailAndNotEmptyMemoize: import("reselect").OutputSelector<Localization, FieldValidator<any>, (res1: Localization, res2: any, res3: any, res4: any) => FieldValidator<any>>;
export declare const notEmptyTimepickersWithoutMessage: FieldValidator<any>;
export declare const isValidTimepickersWithoutMessage: FieldValidator<any>;
export declare const isValidNumberWithoutMessage: FieldValidator<any>;
export {};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display