@snabcentr/client-core 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,7 +2,7 @@ import * as i1 from 'rxjs';
|
|
|
2
2
|
import { of, startWith as startWith$1, Subject, ReplaySubject, partition, combineLatest, map as map$1, debounceTime, switchMap, tap, filter, shareReplay, distinctUntilChanged, BehaviorSubject, materialize, dematerialize, merge, distinctUntilKeyChanged, skip, first, catchError as catchError$1, throwError, expand, takeWhile, toArray, take, defaultIfEmpty, concatMap, finalize, takeUntil, interval, share, scan } from 'rxjs';
|
|
3
3
|
import { map, startWith, catchError } from 'rxjs/operators';
|
|
4
4
|
import { parseISO, parse, isValid, format } from 'date-fns';
|
|
5
|
-
import { isString, isNil, isMatch, isArray, get } from 'lodash-es';
|
|
5
|
+
import { isString, isNil, isObject, isDate, isMatch, isArray, get, isNumber, isBoolean } from 'lodash-es';
|
|
6
6
|
import * as i0 from '@angular/core';
|
|
7
7
|
import { InjectionToken, inject, PLATFORM_ID, Inject, Optional, Injectable, EventEmitter, DestroyRef, LOCALE_ID, Pipe, RendererFactory2 } from '@angular/core';
|
|
8
8
|
import { WA_LOCAL_STORAGE, WA_USER_AGENT, WA_WINDOW } from '@ng-web-apis/common';
|
|
@@ -2424,9 +2424,8 @@ class ScConvertersService {
|
|
|
2424
2424
|
}
|
|
2425
2425
|
this.removeNullRecursive(object);
|
|
2426
2426
|
}
|
|
2427
|
-
else if (
|
|
2427
|
+
else if (isObject(object[k])) {
|
|
2428
2428
|
this.removeNullRecursive(object[k]);
|
|
2429
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2430
2429
|
if (Array.isArray(object) && Object.keys(object[k]).length === 0) {
|
|
2431
2430
|
object.splice(+k, 1);
|
|
2432
2431
|
}
|
|
@@ -2443,7 +2442,7 @@ class ScConvertersService {
|
|
|
2443
2442
|
// eslint-disable-next-line class-methods-use-this
|
|
2444
2443
|
removeByStrLength(object, minLength) {
|
|
2445
2444
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2446
|
-
return Object.fromEntries(Object.entries(object).filter(([_, v]) => (
|
|
2445
|
+
return Object.fromEntries(Object.entries(object).filter(([_, v]) => (isString(v) && v.length > minLength) || !isString(v)));
|
|
2447
2446
|
}
|
|
2448
2447
|
/**
|
|
2449
2448
|
* Конвертирует поля, имеющие тип {@link Date}, в {@link object}, и возвращает как новый объект.
|
|
@@ -2451,7 +2450,7 @@ class ScConvertersService {
|
|
|
2451
2450
|
* @param object Объект, в котором необходимо преобразовать поля Date в string.
|
|
2452
2451
|
*/
|
|
2453
2452
|
convertDateToString(object) {
|
|
2454
|
-
return Object.fromEntries(Object.entries(object).map(([_, v]) => (v
|
|
2453
|
+
return Object.fromEntries(Object.entries(object).map(([_, v]) => (isDate(v) ? [_, v.toLocaleDateString(this.locale)] : [_, v])));
|
|
2455
2454
|
}
|
|
2456
2455
|
// eslint-disable-next-line class-methods-use-this
|
|
2457
2456
|
createParamKeyString(keys) {
|
|
@@ -2473,7 +2472,7 @@ class ScConvertersService {
|
|
|
2473
2472
|
// eslint-disable-next-line no-restricted-syntax
|
|
2474
2473
|
for (const key in object) {
|
|
2475
2474
|
if (object.hasOwnProperty.call(object, key)) {
|
|
2476
|
-
if (
|
|
2475
|
+
if (isObject(object[key]) && !isDate(object[key])) {
|
|
2477
2476
|
this.toSimpleObjectRecursive(object[key], [...keys, key], resultObject);
|
|
2478
2477
|
}
|
|
2479
2478
|
else {
|
|
@@ -3342,7 +3341,7 @@ class ScCatalogService {
|
|
|
3342
3341
|
getCategoryData$(categoryIdOrSlug) {
|
|
3343
3342
|
return this.http.get(`${this.urls.apiUrl}/catalog/categories/${categoryIdOrSlug ?? ''}`).pipe(map$1((category) => new ScCategory(category)), tap((category) => {
|
|
3344
3343
|
if (categoryIdOrSlug) {
|
|
3345
|
-
this.categoryIdOrSlugMap.set(
|
|
3344
|
+
this.categoryIdOrSlugMap.set(isString(categoryIdOrSlug) ? category.id : category.slug, categoryIdOrSlug);
|
|
3346
3345
|
}
|
|
3347
3346
|
}));
|
|
3348
3347
|
}
|
|
@@ -3484,7 +3483,7 @@ class ScCatalogService {
|
|
|
3484
3483
|
getProductData$(productIdOrSlug) {
|
|
3485
3484
|
return this.http.get(`${this.urls.apiUrl}/catalog/products/${productIdOrSlug}`).pipe(map$1((productDTO) => new ScProduct(productDTO)), tap((product) => {
|
|
3486
3485
|
if (productIdOrSlug) {
|
|
3487
|
-
this.productIdOrSlugMap.set(
|
|
3486
|
+
this.productIdOrSlugMap.set(isString(productIdOrSlug) ? product.id : product.slug, productIdOrSlug);
|
|
3488
3487
|
}
|
|
3489
3488
|
}));
|
|
3490
3489
|
}
|
|
@@ -7903,7 +7902,7 @@ class ScSeoService {
|
|
|
7903
7902
|
if (isString(value)) {
|
|
7904
7903
|
return value;
|
|
7905
7904
|
}
|
|
7906
|
-
if (
|
|
7905
|
+
if (isNumber(value) || isBoolean(value)) {
|
|
7907
7906
|
return String(value);
|
|
7908
7907
|
}
|
|
7909
7908
|
return '';
|