@snabcentr/client-core 2.56.2 → 2.56.4

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.
Files changed (47) hide show
  1. package/banners/services/sc-banner.service.d.ts +8 -14
  2. package/cart/services/sc-cart.service.d.ts +27 -24
  3. package/catalog/services/sc-catalog.service.d.ts +5 -4
  4. package/catalog/services/sc-favorite.service.d.ts +11 -16
  5. package/catalog/services/sc-recommendation.service.d.ts +19 -19
  6. package/contacts/services/sc-contacts.service.d.ts +14 -16
  7. package/contragent/services/sc-contragent.service.d.ts +24 -14
  8. package/delivery-address/services/sc-delivery-address.service.d.ts +21 -17
  9. package/esm2022/banners/services/sc-banner.service.mjs +17 -22
  10. package/esm2022/cart/services/sc-cart.service.mjs +37 -33
  11. package/esm2022/catalog/services/sc-catalog.service.mjs +19 -16
  12. package/esm2022/catalog/services/sc-favorite.service.mjs +21 -25
  13. package/esm2022/catalog/services/sc-recommendation.service.mjs +26 -25
  14. package/esm2022/contacts/services/sc-contacts.service.mjs +21 -22
  15. package/esm2022/contacts/services/sc-requisites.service.mjs +4 -3
  16. package/esm2022/contragent/services/sc-contragent.service.mjs +34 -27
  17. package/esm2022/delivery-address/services/sc-delivery-address.service.mjs +33 -27
  18. package/esm2022/httpInterceptors/sc-guest.interceptor.mjs +4 -4
  19. package/esm2022/news/services/sc-news.service.mjs +24 -26
  20. package/esm2022/notifications/services/sc-notifications.service.mjs +30 -29
  21. package/esm2022/order/services/sc-orders.service.mjs +40 -36
  22. package/esm2022/pagination/services/sc-pagination.service.mjs +3 -3
  23. package/esm2022/questionnaire/services/sc-questionnaire.service.mjs +25 -25
  24. package/esm2022/references/services/sc-references.service.mjs +25 -25
  25. package/esm2022/user/index.mjs +2 -1
  26. package/esm2022/user/services/sc-user.service.mjs +1 -29
  27. package/esm2022/user/tokens/index.mjs +2 -0
  28. package/esm2022/user/tokens/sc-user-providers.mjs +12 -0
  29. package/esm2022/utm/services/sc-utm.service.mjs +3 -8
  30. package/esm2022/warehouse/services/sc-warehouse.service.mjs +17 -22
  31. package/fesm2022/snabcentr-client-core.mjs +803 -821
  32. package/fesm2022/snabcentr-client-core.mjs.map +1 -1
  33. package/httpInterceptors/sc-guest.interceptor.d.ts +1 -1
  34. package/news/services/sc-news.service.d.ts +13 -13
  35. package/notifications/services/sc-notifications.service.d.ts +17 -12
  36. package/order/services/sc-orders.service.d.ts +27 -18
  37. package/package.json +1 -1
  38. package/pagination/services/sc-pagination.service.d.ts +2 -2
  39. package/questionnaire/services/sc-questionnaire.service.d.ts +12 -13
  40. package/references/services/sc-references.service.d.ts +13 -14
  41. package/release_notes.tmp +9 -3
  42. package/user/index.d.ts +1 -0
  43. package/user/services/sc-user.service.d.ts +0 -24
  44. package/user/tokens/index.d.ts +1 -0
  45. package/user/tokens/sc-user-providers.d.ts +7 -0
  46. package/utm/services/sc-utm.service.d.ts +0 -4
  47. package/warehouse/services/sc-warehouse.service.d.ts +8 -13
@@ -3,17 +3,17 @@ import { InjectionToken, inject, PLATFORM_ID, Injectable, Inject, Optional, LOCA
3
3
  import { WA_LOCAL_STORAGE, WA_USER_AGENT, WA_WINDOW } from '@ng-web-apis/common';
4
4
  import { filterByKey, toValue, WA_STORAGE_EVENT, StorageService } from '@ng-web-apis/storage';
5
5
  import * as i1 from 'rxjs';
6
- import { startWith, Subject, ReplaySubject, partition, combineLatest, map, debounceTime, switchMap, of, tap, shareReplay, BehaviorSubject, distinctUntilKeyChanged, skip, first, distinctUntilChanged, filter, expand, takeWhile, toArray, catchError, throwError, concatMap, finalize, takeUntil, interval, share, scan } from 'rxjs';
6
+ import { startWith, Subject, ReplaySubject, partition, combineLatest, map, debounceTime, switchMap, of, tap, distinctUntilChanged, shareReplay, distinctUntilKeyChanged, skip, first, BehaviorSubject, filter, expand, takeWhile, toArray, catchError, throwError, concatMap, finalize, takeUntil, interval, share, scan } from 'rxjs';
7
7
  import { isPlatformBrowser, isPlatformServer, DOCUMENT, formatDate } from '@angular/common';
8
8
  import { tuiCreateTokenFromFactory, tuiCreateToken, TuiDay, tuiIsPresent, tuiPure } from '@taiga-ui/cdk';
9
9
  import * as i1$1 from '@angular/common/http';
10
10
  import { HttpContextToken, HttpContext, HttpHeaders, HttpClient, HttpParams, HttpResponse, HttpErrorResponse } from '@angular/common/http';
11
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
11
12
  import { tuiCleanObject } from '@taiga-ui/addon-doc/utils';
12
13
  import { __decorate } from 'tslib';
13
14
  import * as i2 from '@angular/router';
14
15
  import { ActivatedRoute, Router, NavigationEnd } from '@angular/router';
15
16
  import { isString, isMatch, isArray } from 'lodash-es';
16
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
17
17
  import { objectToSnake, objectToCamel, toSnake } from 'ts-case-convert';
18
18
  import { parse, isValid, format } from 'date-fns';
19
19
  import * as i1$2 from '@angular/platform-browser';
@@ -898,26 +898,255 @@ class ScBanner {
898
898
  }
899
899
 
900
900
  /**
901
- * Сервис для работы с баннерами.
901
+ * Перечисление типов клиента.
902
902
  */
903
- class ScBannerService {
903
+ // eslint-disable-next-line no-shadow
904
+ var ScClientType;
905
+ (function (ScClientType) {
906
+ /**
907
+ * Физическое лицо.
908
+ */
909
+ ScClientType["person"] = "person";
910
+ /**
911
+ * Индивидуальный предприниматель.
912
+ */
913
+ ScClientType["ic"] = "ic";
904
914
  /**
905
- * Инициализирует экземпляр класса {@link ScBannerService}.
915
+ * Юридическое лицо.
916
+ */
917
+ ScClientType["org"] = "org";
918
+ })(ScClientType || (ScClientType = {}));
919
+
920
+ /**
921
+ * Модель данных пользователя.
922
+ */
923
+ class ScUser {
924
+ /**
925
+ * Инициализирует экземпляр класса {@link ScUser}.
906
926
  *
907
- * @param http HTTP-клиент.
908
- * @param urls Список ссылок на разделы backend'a.
909
- * @param authService Сервис аутентификации пользователей.
927
+ * @param userDTO DTO с данными о пользователе.
910
928
  */
911
- constructor(http, urls, authService) {
912
- this.http = http;
913
- this.urls = urls;
914
- this.authService = authService;
929
+ constructor(userDTO) {
930
+ /**
931
+ * Направление продаж.
932
+ */
933
+ this.direction = 1;
934
+ if ('id' in userDTO) {
935
+ this.id = userDTO.id;
936
+ this.name = userDTO.name;
937
+ this.userType = userDTO.userType ?? ScUserType.guest;
938
+ this.clientType = userDTO.clientType ?? ScClientType.person;
939
+ // eslint-disable-next-line no-param-reassign
940
+ userDTO.contacts.phone.value = userDTO.contacts.phone.value.startsWith('+') ? userDTO.contacts.phone.value : `+${userDTO.contacts.phone.value}`;
941
+ this.contacts = userDTO.contacts;
942
+ this.createdAt = userDTO.createdAt;
943
+ this.getNews = userDTO.getNews;
944
+ this.direction = userDTO.direction;
945
+ this.metadata = userDTO.metadata;
946
+ this.managers = userDTO.managers;
947
+ this.city = userDTO.city;
948
+ this.priceDate = userDTO.priceDate;
949
+ this.debt = userDTO.debt;
950
+ this.region = userDTO.region;
951
+ }
952
+ else {
953
+ this.userType = ScUserType.guest;
954
+ this.metadata = userDTO.metadata;
955
+ }
956
+ }
957
+ /**
958
+ * Признак того, что пользователь является юр. лицом.
959
+ */
960
+ get isOrg() {
961
+ return this.clientType === ScClientType.org;
962
+ }
963
+ /**
964
+ * Признак того, что пользователь является гостем.
965
+ */
966
+ get isGuest() {
967
+ return this.userType === ScUserType.guest;
968
+ }
969
+ /**
970
+ * Округлённая задолженность. В шаблоне не определён {@link Math}.
971
+ */
972
+ get absDebt() {
973
+ return Math.abs(this.debt ?? 0);
974
+ }
975
+ }
976
+
977
+ /**
978
+ * Сервис информации о пользователе.
979
+ */
980
+ class ScUserService {
981
+ constructor() {
982
+ /**
983
+ * {@link ReplaySubject} данных о текущем пользователе.
984
+ */
985
+ this.user$ = new ReplaySubject(1);
986
+ /**
987
+ * Сервис для работы с токенами.
988
+ */
989
+ this.tokenService = inject(ScTokenService);
990
+ /**
991
+ * Признак, что скрипт выполняется в браузере.
992
+ */
993
+ this.isBrowser = inject(IS_BROWSER);
994
+ /**
995
+ * Сервис аутентификации.
996
+ */
997
+ this.authService = inject(ScAuthService);
998
+ /**
999
+ * Список ссылок на разделы backend'a.
1000
+ */
1001
+ this.urls = inject(SC_URLS);
1002
+ /**
1003
+ * HTTP-клиент.
1004
+ */
1005
+ this.http = inject(HttpClient);
1006
+ /**
1007
+ * Сервис для сбора метрик о действиях пользователей.
1008
+ */
1009
+ this.userMetrikaService = inject(ScUserMetrikaService);
1010
+ }
1011
+ /**
1012
+ * Выполняет инициализацию сервиса.
1013
+ */
1014
+ initService() {
1015
+ if (this.isBrowser) {
1016
+ this.authService
1017
+ .getAuthChange()
1018
+ .pipe(switchMap((state) => (state ? this.getUserInfo$() : this.getGuestInfo$())))
1019
+ .subscribe((user) => {
1020
+ this.userMetrikaService.setUserParams(user.id, user.userType);
1021
+ this.user$.next(user);
1022
+ });
1023
+ }
1024
+ else {
1025
+ this.user$.next(new ScUser({ metadata: {} }));
1026
+ }
1027
+ }
1028
+ /**
1029
+ * Возвращает {@link Observable} запроса изменения информации о текущем пользователе.
1030
+ *
1031
+ * @param newData Данные пользователя, которые нужно обновить.
1032
+ */
1033
+ updateUserInfo$(newData) {
1034
+ return this.http.patch(`${this.urls.apiUrl}/user`, newData).pipe(tap(() => {
1035
+ this.userMetrikaService.emitUserMetrikaEvent({
1036
+ target: ScUserMetrikaGoalsEnum.userProfileEdited,
1037
+ });
1038
+ }));
1039
+ }
1040
+ /**
1041
+ * Возвращает {@link Observable} запроса изменения информации о текущем пользователе-госте.
1042
+ *
1043
+ * @param newData Данные пользователя-гостя, которые нужно обновить.
1044
+ */
1045
+ updateGuestInfo$(newData) {
1046
+ return this.http.patch(`${this.urls.apiUrl}/guest`, newData);
1047
+ }
1048
+ /**
1049
+ * Возвращает {@link Observable} запроса регистрации пользователя.
1050
+ *
1051
+ * @param user Данные для регистрации.
1052
+ * @param withAuth Флаг, указывающий, нужно ли устанавливать токен аутентификации.
1053
+ */
1054
+ signUp$(user, withAuth = true) {
1055
+ return this.http.post(`${this.urls.apiUrl}/user/register`, user).pipe(tap((token) => {
1056
+ this.userMetrikaService.emitUserMetrikaEvent({
1057
+ target: ScUserMetrikaGoalsEnum.signedUp,
1058
+ });
1059
+ if (withAuth) {
1060
+ this.tokenService.setAuthToken(token);
1061
+ }
1062
+ }));
1063
+ }
1064
+ /**
1065
+ * Возвращает {@link Observable} запроса на отправку кода изменения пароля на электронную почту.
1066
+ *
1067
+ * @param email Адрес электронной почты.
1068
+ */
1069
+ sendResetPasswordCode$(email) {
1070
+ return this.http.get(`${this.urls.apiUrl}/auth/password/restore`, { params: { email: email } });
1071
+ }
1072
+ /**
1073
+ * Возвращает {@link Observable} запроса изменения пароля.
1074
+ *
1075
+ * @param newPassword Данные для изменения пароля.
1076
+ */
1077
+ resetPassword$(newPassword) {
1078
+ return this.http.post(`${this.urls.apiUrl}/auth/password/restore`, newPassword);
1079
+ }
1080
+ /**
1081
+ * Возвращает {@link Observable} текущего пользователя.
1082
+ */
1083
+ getUserChange$() {
1084
+ return this.user$.asObservable();
1085
+ }
1086
+ /**
1087
+ * Обновляет данные {@link Observable} текущего пользователя.
1088
+ */
1089
+ updateUserChange$() {
1090
+ return this.getUserInfo$().pipe(tap((user) => {
1091
+ this.user$.next(user);
1092
+ }));
1093
+ }
1094
+ /**
1095
+ * Возвращает {@link Observable} запроса на получение информации о текущем пользователе.
1096
+ */
1097
+ getUserInfo$() {
1098
+ return this.http.get(`${this.urls.apiUrl}/user`).pipe(map((user) => new ScUser(user)));
1099
+ }
1100
+ /**
1101
+ * Обновляет данные {@link Observable} текущего пользователя.
1102
+ */
1103
+ updateGuestChange$() {
1104
+ return this.getGuestInfo$().pipe(tap((user) => {
1105
+ this.user$.next(user);
1106
+ }));
1107
+ }
1108
+ /**
1109
+ * Возвращает {@link Observable} запроса на получение информации о текущем пользователе.
1110
+ */
1111
+ getGuestInfo$() {
1112
+ return this.http.get(`${this.urls.apiUrl}/guest`).pipe(map((user) => new ScUser(user)));
1113
+ }
1114
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScUserService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1115
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScUserService, providedIn: 'root' }); }
1116
+ }
1117
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScUserService, decorators: [{
1118
+ type: Injectable,
1119
+ args: [{
1120
+ providedIn: 'root',
1121
+ }]
1122
+ }] });
1123
+
1124
+ /**
1125
+ * Токен потока данных о текущем пользователе.
1126
+ */
1127
+ const SC_USER_INFO = tuiCreateTokenFromFactory(() => inject(ScUserService)
1128
+ .getUserChange$()
1129
+ .pipe(distinctUntilChanged((previous, current) => !current.isGuest && previous.id === current.id), takeUntilDestroyed()));
1130
+
1131
+ /**
1132
+ * Сервис для работы с баннерами.
1133
+ */
1134
+ class ScBannerService {
1135
+ constructor() {
1136
+ /**
1137
+ * HTTP-клиент.
1138
+ */
1139
+ this.http = inject(HttpClient);
1140
+ /**
1141
+ * Список ссылок приложения.
1142
+ */
1143
+ this.urls = inject(SC_URLS);
915
1144
  /**
916
1145
  * Список баннеров.
917
1146
  */
918
- this.banners$ = this.authService.getAuthChange().pipe(switchMap(() => this.http.get(`${this.urls.apiUrl}/banners`)), map((banners) => banners.map((banner) => new ScBanner(banner))), shareReplay(1));
1147
+ this.banners$ = inject(SC_USER_INFO).pipe(switchMap(() => this.http.get(`${this.urls.apiUrl}/banners`)), map((banners) => banners.map((banner) => new ScBanner(banner))), shareReplay(1));
919
1148
  }
920
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScBannerService, deps: [{ token: i1$1.HttpClient }, { token: SC_URLS }, { token: ScAuthService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1149
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScBannerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
921
1150
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScBannerService, providedIn: 'root' }); }
922
1151
  }
923
1152
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScBannerService, decorators: [{
@@ -925,10 +1154,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
925
1154
  args: [{
926
1155
  providedIn: 'root',
927
1156
  }]
928
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
929
- type: Inject,
930
- args: [SC_URLS]
931
- }] }, { type: ScAuthService }] });
1157
+ }] });
932
1158
 
933
1159
  const EMPTY_CART = { items: [], result_sum: { rub: 0 }, directions_sum: {} };
934
1160
 
@@ -1426,535 +1652,9 @@ class ScISalesDirectionCart {
1426
1652
  }
1427
1653
  }
1428
1654
 
1655
+ /* eslint-disable security/detect-object-injection,no-param-reassign */
1429
1656
  /**
1430
- * Перечисление типов клиента.
1431
- */
1432
- // eslint-disable-next-line no-shadow
1433
- var ScClientType;
1434
- (function (ScClientType) {
1435
- /**
1436
- * Физическое лицо.
1437
- */
1438
- ScClientType["person"] = "person";
1439
- /**
1440
- * Индивидуальный предприниматель.
1441
- */
1442
- ScClientType["ic"] = "ic";
1443
- /**
1444
- * Юридическое лицо.
1445
- */
1446
- ScClientType["org"] = "org";
1447
- })(ScClientType || (ScClientType = {}));
1448
-
1449
- /**
1450
- * Модель данных пользователя.
1451
- */
1452
- class ScUser {
1453
- /**
1454
- * Инициализирует экземпляр класса {@link ScUser}.
1455
- *
1456
- * @param userDTO DTO с данными о пользователе.
1457
- */
1458
- constructor(userDTO) {
1459
- /**
1460
- * Направление продаж.
1461
- */
1462
- this.direction = 1;
1463
- if ('id' in userDTO) {
1464
- this.id = userDTO.id;
1465
- this.name = userDTO.name;
1466
- this.userType = userDTO.userType ?? ScUserType.guest;
1467
- this.clientType = userDTO.clientType ?? ScClientType.person;
1468
- // eslint-disable-next-line no-param-reassign
1469
- userDTO.contacts.phone.value = userDTO.contacts.phone.value.startsWith('+') ? userDTO.contacts.phone.value : `+${userDTO.contacts.phone.value}`;
1470
- this.contacts = userDTO.contacts;
1471
- this.createdAt = userDTO.createdAt;
1472
- this.getNews = userDTO.getNews;
1473
- this.direction = userDTO.direction;
1474
- this.metadata = userDTO.metadata;
1475
- this.managers = userDTO.managers;
1476
- this.city = userDTO.city;
1477
- this.priceDate = userDTO.priceDate;
1478
- this.debt = userDTO.debt;
1479
- this.region = userDTO.region;
1480
- }
1481
- else {
1482
- this.userType = ScUserType.guest;
1483
- this.metadata = userDTO.metadata;
1484
- }
1485
- }
1486
- /**
1487
- * Признак того, что пользователь является юр. лицом.
1488
- */
1489
- get isOrg() {
1490
- return this.clientType === ScClientType.org;
1491
- }
1492
- /**
1493
- * Признак того, что пользователь является гостем.
1494
- */
1495
- get isGuest() {
1496
- return this.userType === ScUserType.guest;
1497
- }
1498
- /**
1499
- * Округлённая задолженность. В шаблоне не определён {@link Math}.
1500
- */
1501
- get absDebt() {
1502
- return Math.abs(this.debt ?? 0);
1503
- }
1504
- }
1505
-
1506
- /**
1507
- * Формат отображения каталога.
1508
- */
1509
- // eslint-disable-next-line no-shadow
1510
- var ScCatalogFormat;
1511
- (function (ScCatalogFormat) {
1512
- /**
1513
- * Отображение каталога в виде карточек.
1514
- */
1515
- ScCatalogFormat["normal"] = "normal";
1516
- /**
1517
- * Отображение каталога в виде раскрывающегося древовидного списка.
1518
- */
1519
- ScCatalogFormat["tree"] = "tree";
1520
- })(ScCatalogFormat || (ScCatalogFormat = {}));
1521
-
1522
- /**
1523
- * Перечисление представления вида плиток товаров.
1524
- */
1525
- // eslint-disable-next-line no-shadow
1526
- var ScProductTileType;
1527
- (function (ScProductTileType) {
1528
- /**
1529
- * Сетка из вертикальных плиток товаров.
1530
- */
1531
- ScProductTileType["grid"] = "grid";
1532
- /**
1533
- * Товары в виде строк, во всю ширину блока.
1534
- */
1535
- ScProductTileType["lines"] = "lines";
1536
- })(ScProductTileType || (ScProductTileType = {}));
1537
-
1538
- /**
1539
- * Метаданные пользователя.
1540
- */
1541
- class ScUserMetadata {
1542
- /**
1543
- * Инициализирует экземпляр класса {@link ScUserMetadata}.
1544
- *
1545
- * @param data Данные для первоначальной инициализации объекта.
1546
- */
1547
- constructor(data = {}) {
1548
- /**
1549
- * Список идентификаторов категорий, которые необходимо скрыть в каталоге.
1550
- */
1551
- this.hiddenCategories = [];
1552
- /**
1553
- * Вид отображения плиток товаров.
1554
- */
1555
- this.productTileType = ScProductTileType.grid;
1556
- /**
1557
- * Метаданные не оформленных заказов.
1558
- */
1559
- this.newOrdersMetadata = [];
1560
- /**
1561
- * Формат отображения каталога.
1562
- */
1563
- this.catalogFormat = ScCatalogFormat.normal;
1564
- Object.assign(this, data);
1565
- }
1566
- }
1567
-
1568
- /**
1569
- * Модель кэшированных данных.
1570
- */
1571
- class ScCachedItem {
1572
- /**
1573
- * Инициализирует экземпляр класса {@link ScCachedItem}.
1574
- *
1575
- * @param lifeTime Время жизни записи в ms.
1576
- * @param item$ {@link Observable} запроса кэшируемых данных.
1577
- */
1578
- constructor(lifeTime, item$) {
1579
- /**
1580
- * {@link Observable} обновления данных.
1581
- */
1582
- this.update$ = new BehaviorSubject(undefined);
1583
- this.item$ = this.update$.pipe(switchMap(() => item$.pipe(tap(() => {
1584
- this.cachedUntil = Date.now() + lifeTime;
1585
- }), startWith(null))), shareReplay(1));
1586
- }
1587
- /**
1588
- * Возвращает признак того, что кэшированные данные актуальны.
1589
- */
1590
- cachedDataIsActual() {
1591
- return !this.cachedUntil || this.cachedUntil > Date.now();
1592
- }
1593
- /**
1594
- * Выполняет обновления {@link Observable} запроса кэшируемых данных.
1595
- */
1596
- update() {
1597
- this.cachedUntil = undefined;
1598
- this.update$.next();
1599
- }
1600
- }
1601
-
1602
- /**
1603
- * Сервис для работы с контактными лицами.
1604
- */
1605
- class ScContactsService {
1606
- /**
1607
- * Инициализирует экземпляр класса {@link ScContactsService}.
1608
- *
1609
- * @param http HTTP-клиент.
1610
- * @param urls Список ссылок на разделы backend'a.
1611
- * @param authService Сервис аутентификации.
1612
- */
1613
- constructor(http, urls, authService) {
1614
- this.http = http;
1615
- this.urls = urls;
1616
- this.authService = authService;
1617
- /**
1618
- * {@link Observable} получения списка контактных лиц пользователя, контрагентов пользователя и адресов доставки пользователя.
1619
- */
1620
- this.allContacts = new ScCachedItem(0, this.authService.getAuthChange().pipe(switchMap((state) => (state ? this.http.get(`${this.urls.apiUrl}/user/contacts/all`) : of(null)))));
1621
- /**
1622
- * {@link Observable} получения списка контактных лиц пользователя.
1623
- */
1624
- this.userContacts = new ScCachedItem(0, this.authService.getAuthChange().pipe(switchMap((state) => (state ? this.http.get(`${this.urls.apiUrl}/user/contacts`) : of(null)))));
1625
- /**
1626
- * {@link Map} коллекция пар ключ-значение с данными о контактных лицах адресов доставки.
1627
- */
1628
- this.deliveryAddressContactsMap = new Map();
1629
- /**
1630
- * {@link Map} коллекция пар ключ-значение с данными о контактных лицах контрагентов.
1631
- */
1632
- this.contragentContactsMap = new Map();
1633
- }
1634
- /**
1635
- * Возвращает список всех контактов.
1636
- */
1637
- getContact$() {
1638
- return this.allContacts.item$;
1639
- }
1640
- /**
1641
- * Создаёт запрос создания контактного лица.
1642
- *
1643
- * @param newContact Данные требуемые для создания контактного лица.
1644
- */
1645
- createContact$(newContact) {
1646
- return this.http.post(`${this.urls.apiUrl}/user/contacts`, newContact).pipe(tap(() => {
1647
- this.allContacts.update();
1648
- if (newContact.client) {
1649
- this.userContacts.update();
1650
- }
1651
- if (newContact.addresses) {
1652
- newContact.addresses.forEach((item) => this.deliveryAddressContactsMap.get(item.id)?.update());
1653
- }
1654
- if (newContact.contragents) {
1655
- newContact.contragents.forEach((item) => this.contragentContactsMap.get(item.id)?.update());
1656
- }
1657
- }));
1658
- }
1659
- /**
1660
- * Создаёт запрос изменения контактного лица пользователя.
1661
- *
1662
- * @param contactId Идентификатор контакта пользователя.
1663
- * @param newContact Данные требуемые для создания контактного лица.
1664
- */
1665
- editContact$(contactId, newContact) {
1666
- return this.http.patch(`${this.urls.apiUrl}/user/contacts/${contactId}`, newContact).pipe(tap(() => {
1667
- this.allContacts.update();
1668
- }));
1669
- }
1670
- /**
1671
- * Создаёт запрос удаления контактного лица пользователя.
1672
- *
1673
- * @param contactId Идентификатор контакта пользователя.
1674
- */
1675
- deleteContact$(contactId) {
1676
- return this.http.delete(`${this.urls.apiUrl}/user/contacts/${contactId}`).pipe(tap(() => {
1677
- this.allContacts.update();
1678
- }));
1679
- }
1680
- /**
1681
- * Содаёт запрос на получение списка контактов для помощи клиенту.
1682
- *
1683
- * @param params Параметры поиска контактов (телефон или ID города).
1684
- * @param params.phone Телефон клиента.
1685
- * @param params.cityId ID города.
1686
- */
1687
- getHelpContacts$(params) {
1688
- return this.http.get(`${this.urls.apiUrl}/contacts/help`, {
1689
- params: params,
1690
- });
1691
- }
1692
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScContactsService, deps: [{ token: i1$1.HttpClient }, { token: SC_URLS }, { token: ScAuthService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1693
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScContactsService, providedIn: 'root' }); }
1694
- }
1695
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScContactsService, decorators: [{
1696
- type: Injectable,
1697
- args: [{
1698
- providedIn: 'root',
1699
- }]
1700
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
1701
- type: Inject,
1702
- args: [SC_URLS]
1703
- }] }, { type: ScAuthService }] });
1704
-
1705
- /**
1706
- * Сервис информации о пользователе.
1707
- */
1708
- class ScUserService {
1709
- constructor() {
1710
- /**
1711
- * {@link ReplaySubject} данных о текущем пользователе.
1712
- */
1713
- this.user$ = new ReplaySubject(1);
1714
- /**
1715
- * Сервис для работы с токенами.
1716
- */
1717
- this.tokenService = inject(ScTokenService);
1718
- /**
1719
- * Признак, что скрипт выполняется в браузере.
1720
- */
1721
- this.isBrowser = inject(IS_BROWSER);
1722
- /**
1723
- * Сервис аутентификации.
1724
- */
1725
- this.authService = inject(ScAuthService);
1726
- /**
1727
- * Список ссылок на разделы backend'a.
1728
- */
1729
- this.urls = inject(SC_URLS);
1730
- /**
1731
- * HTTP-клиент.
1732
- */
1733
- this.http = inject(HttpClient);
1734
- /**
1735
- * Сервис для сбора метрик о действиях пользователей.
1736
- */
1737
- this.userMetrikaService = inject(ScUserMetrikaService);
1738
- /**
1739
- * Сервис для работы с контактными лицами.
1740
- */
1741
- this.contactsService = inject(ScContactsService);
1742
- }
1743
- /**
1744
- * Выполняет инициализацию сервиса.
1745
- */
1746
- initService() {
1747
- if (this.isBrowser) {
1748
- this.authService
1749
- .getAuthChange()
1750
- .pipe(switchMap((state) => (state ? this.getUserInfo$() : this.getGuestInfo$())))
1751
- .subscribe((user) => {
1752
- this.userMetrikaService.setUserParams(user.id, user.userType);
1753
- this.user$.next(user);
1754
- });
1755
- }
1756
- else {
1757
- this.user$.next(new ScUser({ metadata: {} }));
1758
- }
1759
- }
1760
- /**
1761
- * Возвращает {@link Observable} запроса изменения информации о текущем пользователе.
1762
- *
1763
- * @param newData Данные пользователя, которые нужно обновить.
1764
- */
1765
- updateUserInfo$(newData) {
1766
- return this.http.patch(`${this.urls.apiUrl}/user`, newData).pipe(tap(() => {
1767
- this.userMetrikaService.emitUserMetrikaEvent({
1768
- target: ScUserMetrikaGoalsEnum.userProfileEdited,
1769
- });
1770
- }));
1771
- }
1772
- /**
1773
- * Возвращает {@link Observable} запроса изменения информации о текущем пользователе-госте.
1774
- *
1775
- * @param newData Данные пользователя-гостя, которые нужно обновить.
1776
- */
1777
- updateGuestInfo$(newData) {
1778
- return this.http.patch(`${this.urls.apiUrl}/guest`, newData);
1779
- }
1780
- /**
1781
- * Возвращает {@link Observable} запроса регистрации пользователя.
1782
- *
1783
- * @param user Данные для регистрации.
1784
- * @param withAuth Флаг, указывающий, нужно ли устанавливать токен аутентификации.
1785
- */
1786
- signUp$(user, withAuth = true) {
1787
- return this.http.post(`${this.urls.apiUrl}/user/register`, user).pipe(tap((token) => {
1788
- this.userMetrikaService.emitUserMetrikaEvent({
1789
- target: ScUserMetrikaGoalsEnum.signedUp,
1790
- });
1791
- if (withAuth) {
1792
- this.tokenService.setAuthToken(token);
1793
- }
1794
- }));
1795
- }
1796
- /**
1797
- * Возвращает {@link Observable} запроса на отправку кода изменения пароля на электронную почту.
1798
- *
1799
- * @param email Адрес электронной почты.
1800
- */
1801
- sendResetPasswordCode$(email) {
1802
- return this.http.get(`${this.urls.apiUrl}/auth/password/restore`, { params: { email: email } });
1803
- }
1804
- /**
1805
- * Возвращает {@link Observable} запроса изменения пароля.
1806
- *
1807
- * @param newPassword Данные для изменения пароля.
1808
- */
1809
- resetPassword$(newPassword) {
1810
- return this.http.post(`${this.urls.apiUrl}/auth/password/restore`, newPassword);
1811
- }
1812
- /**
1813
- * Возвращает {@link Observable} текущего пользователя.
1814
- */
1815
- getUserChange$() {
1816
- return this.user$.asObservable();
1817
- }
1818
- /**
1819
- * Обновляет данные {@link Observable} текущего пользователя.
1820
- */
1821
- updateUserChange$() {
1822
- return this.getUserInfo$().pipe(tap((user) => {
1823
- this.user$.next(user);
1824
- }));
1825
- }
1826
- /**
1827
- * Возвращает {@link Observable} запроса на получение информации о текущем пользователе.
1828
- */
1829
- getUserInfo$() {
1830
- return this.http.get(`${this.urls.apiUrl}/user`).pipe(map((user) => new ScUser(user)));
1831
- }
1832
- /**
1833
- * Обновляет данные {@link Observable} текущего пользователя.
1834
- */
1835
- updateGuestChange$() {
1836
- return this.getGuestInfo$().pipe(tap((user) => {
1837
- this.user$.next(user);
1838
- }));
1839
- }
1840
- /**
1841
- * Возвращает {@link Observable} запроса на получение информации о текущем пользователе.
1842
- */
1843
- getGuestInfo$() {
1844
- return this.http.get(`${this.urls.apiUrl}/guest`).pipe(map((user) => new ScUser(user)));
1845
- }
1846
- /**
1847
- * Возвращает {@link Observable} изменения списка контактных лиц пользователя.
1848
- */
1849
- getUserContacts$() {
1850
- return this.contactsService.userContacts.item$;
1851
- }
1852
- /**
1853
- * Создаёт запрос создания контактного лица клиенту.
1854
- *
1855
- * @param userId Идентификатор пользователя.
1856
- * @param newContact Данные требуемые для создания контактного лица.
1857
- */
1858
- createUserContact$(userId, newContact) {
1859
- return this.contactsService.createContact$({ ...newContact, client: { id: userId } });
1860
- }
1861
- /**
1862
- * Создаёт запрос удаления контактного лица адреса доставки.
1863
- *
1864
- * @param contactId Идентификатор контактного лица.
1865
- */
1866
- deleteUserContact$(contactId) {
1867
- return this.contactsService.deleteContact$(contactId);
1868
- }
1869
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScUserService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1870
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScUserService, providedIn: 'root' }); }
1871
- }
1872
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScUserService, decorators: [{
1873
- type: Injectable,
1874
- args: [{
1875
- providedIn: 'root',
1876
- }]
1877
- }] });
1878
-
1879
- /**
1880
- * Перечисление названий справочников.
1881
- */
1882
- // eslint-disable-next-line no-shadow
1883
- var ScReferenceName;
1884
- (function (ScReferenceName) {
1885
- /**
1886
- * Тип канала сообщений чата.
1887
- */
1888
- ScReferenceName["chatChannel"] = "chat-channel";
1889
- /**
1890
- * Город.
1891
- */
1892
- ScReferenceName["city"] = "city";
1893
- /**
1894
- * Город с информацией о регионе и стране.
1895
- */
1896
- ScReferenceName["cityWithRegionAndCountry"] = "city-with-region-and-country";
1897
- /**
1898
- * Город с информацией о регионе.
1899
- */
1900
- ScReferenceName["cityWithRegion"] = "city-with-region";
1901
- /**
1902
- * Страна.
1903
- */
1904
- ScReferenceName["country"] = "country";
1905
- /**
1906
- * Тип доставки.
1907
- */
1908
- ScReferenceName["deliveryType"] = "delivery-type";
1909
- /**
1910
- * Статус оплаты заказа.
1911
- */
1912
- ScReferenceName["orderPaymentStatus"] = "order-payment-status";
1913
- /**
1914
- * Статус заказа.
1915
- */
1916
- ScReferenceName["orderStatus"] = "order-status";
1917
- /**
1918
- * Тип оплаты заказа.
1919
- */
1920
- ScReferenceName["paymentType"] = "payment-type";
1921
- /**
1922
- * Статус рекламации.
1923
- */
1924
- ScReferenceName["reclamationStatus"] = "reclamation-status";
1925
- /**
1926
- * Регион.
1927
- */
1928
- ScReferenceName["region"] = "region";
1929
- /**
1930
- * Регион с информацией о стране.
1931
- */
1932
- ScReferenceName["regionWithCountry"] = "region-with-country";
1933
- /**
1934
- * Направление продаж.
1935
- */
1936
- ScReferenceName["salesDirection"] = "salesDirection";
1937
- /**
1938
- * Розничный магазин.
1939
- */
1940
- ScReferenceName["store"] = "store";
1941
- /**
1942
- * Склад.
1943
- */
1944
- ScReferenceName["warehouse"] = "warehouse";
1945
- /**
1946
- * ОПФ (организационно-правовая форма).
1947
- */
1948
- ScReferenceName["opf"] = "opf";
1949
- /**
1950
- * Валюта.
1951
- */
1952
- ScReferenceName["currency"] = "currency";
1953
- })(ScReferenceName || (ScReferenceName = {}));
1954
-
1955
- /* eslint-disable security/detect-object-injection,no-param-reassign */
1956
- /**
1957
- * Сервис конвертации данных.
1657
+ * Сервис конвертации данных.
1958
1658
  */
1959
1659
  class ScConvertersService {
1960
1660
  /**
@@ -2085,23 +1785,165 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
2085
1785
  args: [LOCALE_ID]
2086
1786
  }] }] });
2087
1787
 
1788
+ /**
1789
+ * Формат отображения каталога.
1790
+ */
1791
+ // eslint-disable-next-line no-shadow
1792
+ var ScCatalogFormat;
1793
+ (function (ScCatalogFormat) {
1794
+ /**
1795
+ * Отображение каталога в виде карточек.
1796
+ */
1797
+ ScCatalogFormat["normal"] = "normal";
1798
+ /**
1799
+ * Отображение каталога в виде раскрывающегося древовидного списка.
1800
+ */
1801
+ ScCatalogFormat["tree"] = "tree";
1802
+ })(ScCatalogFormat || (ScCatalogFormat = {}));
1803
+
1804
+ /**
1805
+ * Перечисление представления вида плиток товаров.
1806
+ */
1807
+ // eslint-disable-next-line no-shadow
1808
+ var ScProductTileType;
1809
+ (function (ScProductTileType) {
1810
+ /**
1811
+ * Сетка из вертикальных плиток товаров.
1812
+ */
1813
+ ScProductTileType["grid"] = "grid";
1814
+ /**
1815
+ * Товары в виде строк, во всю ширину блока.
1816
+ */
1817
+ ScProductTileType["lines"] = "lines";
1818
+ })(ScProductTileType || (ScProductTileType = {}));
1819
+
1820
+ /**
1821
+ * Метаданные пользователя.
1822
+ */
1823
+ class ScUserMetadata {
1824
+ /**
1825
+ * Инициализирует экземпляр класса {@link ScUserMetadata}.
1826
+ *
1827
+ * @param data Данные для первоначальной инициализации объекта.
1828
+ */
1829
+ constructor(data = {}) {
1830
+ /**
1831
+ * Список идентификаторов категорий, которые необходимо скрыть в каталоге.
1832
+ */
1833
+ this.hiddenCategories = [];
1834
+ /**
1835
+ * Вид отображения плиток товаров.
1836
+ */
1837
+ this.productTileType = ScProductTileType.grid;
1838
+ /**
1839
+ * Метаданные не оформленных заказов.
1840
+ */
1841
+ this.newOrdersMetadata = [];
1842
+ /**
1843
+ * Формат отображения каталога.
1844
+ */
1845
+ this.catalogFormat = ScCatalogFormat.normal;
1846
+ Object.assign(this, data);
1847
+ }
1848
+ }
1849
+
1850
+ /**
1851
+ * Перечисление названий справочников.
1852
+ */
1853
+ // eslint-disable-next-line no-shadow
1854
+ var ScReferenceName;
1855
+ (function (ScReferenceName) {
1856
+ /**
1857
+ * Тип канала сообщений чата.
1858
+ */
1859
+ ScReferenceName["chatChannel"] = "chat-channel";
1860
+ /**
1861
+ * Город.
1862
+ */
1863
+ ScReferenceName["city"] = "city";
1864
+ /**
1865
+ * Город с информацией о регионе и стране.
1866
+ */
1867
+ ScReferenceName["cityWithRegionAndCountry"] = "city-with-region-and-country";
1868
+ /**
1869
+ * Город с информацией о регионе.
1870
+ */
1871
+ ScReferenceName["cityWithRegion"] = "city-with-region";
1872
+ /**
1873
+ * Страна.
1874
+ */
1875
+ ScReferenceName["country"] = "country";
1876
+ /**
1877
+ * Тип доставки.
1878
+ */
1879
+ ScReferenceName["deliveryType"] = "delivery-type";
1880
+ /**
1881
+ * Статус оплаты заказа.
1882
+ */
1883
+ ScReferenceName["orderPaymentStatus"] = "order-payment-status";
1884
+ /**
1885
+ * Статус заказа.
1886
+ */
1887
+ ScReferenceName["orderStatus"] = "order-status";
1888
+ /**
1889
+ * Тип оплаты заказа.
1890
+ */
1891
+ ScReferenceName["paymentType"] = "payment-type";
1892
+ /**
1893
+ * Статус рекламации.
1894
+ */
1895
+ ScReferenceName["reclamationStatus"] = "reclamation-status";
1896
+ /**
1897
+ * Регион.
1898
+ */
1899
+ ScReferenceName["region"] = "region";
1900
+ /**
1901
+ * Регион с информацией о стране.
1902
+ */
1903
+ ScReferenceName["regionWithCountry"] = "region-with-country";
1904
+ /**
1905
+ * Направление продаж.
1906
+ */
1907
+ ScReferenceName["salesDirection"] = "salesDirection";
1908
+ /**
1909
+ * Розничный магазин.
1910
+ */
1911
+ ScReferenceName["store"] = "store";
1912
+ /**
1913
+ * Склад.
1914
+ */
1915
+ ScReferenceName["warehouse"] = "warehouse";
1916
+ /**
1917
+ * ОПФ (организационно-правовая форма).
1918
+ */
1919
+ ScReferenceName["opf"] = "opf";
1920
+ /**
1921
+ * Валюта.
1922
+ */
1923
+ ScReferenceName["currency"] = "currency";
1924
+ })(ScReferenceName || (ScReferenceName = {}));
1925
+
2088
1926
  /**
2089
1927
  * Сервис справочников.
2090
1928
  */
2091
1929
  class ScReferencesService {
2092
- /**
2093
- * Инициализирует экземпляр класса {@link ScReferencesService}.
2094
- *
2095
- * @param http HTTP-клиент.
2096
- * @param urls Список ссылок на разделы backend'a.
2097
- * @param authService Сервис аутентификации пользователей.
2098
- * @param convertersService Сервис конвертации данных.
2099
- */
2100
- constructor(http, urls, authService, convertersService) {
2101
- this.http = http;
2102
- this.urls = urls;
2103
- this.authService = authService;
2104
- this.convertersService = convertersService;
1930
+ constructor() {
1931
+ /**
1932
+ * HTTP-клиент.
1933
+ */
1934
+ this.http = inject(HttpClient);
1935
+ /**
1936
+ * Список ссылок приложения.
1937
+ */
1938
+ this.urls = inject(SC_URLS);
1939
+ /**
1940
+ * {@link Observable} данных о текущем пользователе.
1941
+ */
1942
+ this.user$ = inject(SC_USER_INFO);
1943
+ /**
1944
+ * Сервис конвертации данных.
1945
+ */
1946
+ this.convertersService = inject(ScConvertersService);
2105
1947
  /**
2106
1948
  * Список направлений продаж.
2107
1949
  */
@@ -2144,7 +1986,7 @@ class ScReferencesService {
2144
1986
  /**
2145
1987
  * Список типов оплаты заказа.
2146
1988
  */
2147
- this.paymentTypes$ = this.authService.getAuthChange().pipe(switchMap(() => this.getReference$(ScReferenceName.paymentType)), shareReplay(1));
1989
+ this.paymentTypes$ = this.user$.pipe(switchMap(() => this.getReference$(ScReferenceName.paymentType)), shareReplay(1));
2148
1990
  }
2149
1991
  /**
2150
1992
  * Возвращает данные справочника.
@@ -2259,7 +2101,7 @@ class ScReferencesService {
2259
2101
  getCurrencyById$(currencyId) {
2260
2102
  return this.currencies$.pipe(map((types) => types.find((type) => type.id === currencyId)));
2261
2103
  }
2262
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScReferencesService, deps: [{ token: i1$1.HttpClient }, { token: SC_URLS }, { token: ScAuthService }, { token: ScConvertersService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2104
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScReferencesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2263
2105
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScReferencesService, providedIn: 'root' }); }
2264
2106
  }
2265
2107
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScReferencesService, decorators: [{
@@ -2267,10 +2109,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
2267
2109
  args: [{
2268
2110
  providedIn: 'root',
2269
2111
  }]
2270
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
2271
- type: Inject,
2272
- args: [SC_URLS]
2273
- }] }, { type: ScAuthService }, { type: ScConvertersService }] });
2112
+ }] });
2274
2113
 
2275
2114
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2276
2115
  /**
@@ -2518,21 +2357,20 @@ const TERMINAL_PROVIDERS = [
2518
2357
  class ScWarehouseService {
2519
2358
  /**
2520
2359
  * Инициализирует экземпляр класса {@link ScWarehouseService}.
2521
- *
2522
- * @param userService Сервис информации о пользователе.
2523
- * @param uiService Сервис для работы с UI.
2524
- * @param referencesService Сервис справочников.
2525
- * @param terminal Токен с данными о терминале.
2526
2360
  */
2527
- constructor(userService, uiService, referencesService, terminal) {
2528
- this.userService = userService;
2529
- this.uiService = uiService;
2530
- this.referencesService = referencesService;
2531
- this.terminal = terminal;
2361
+ constructor() {
2362
+ /**
2363
+ * {@link Observable} данных о текущем пользователе.
2364
+ */
2365
+ this.user$ = inject(SC_USER_INFO);
2366
+ /**
2367
+ * {@link ScITerminalProvider} данных о терминале.
2368
+ */
2369
+ this.terminal = inject(IS_RUNNING_ON_TERMINAL);
2532
2370
  /**
2533
2371
  * Список складов.
2534
2372
  */
2535
- this.warehouses$ = this.referencesService.getReference$(ScReferenceName.warehouse).pipe(shareReplay(1));
2373
+ this.warehouses$ = inject(ScReferencesService).getReference$(ScReferenceName.warehouse).pipe(shareReplay(1));
2536
2374
  /**
2537
2375
  * {@link BehaviorSubject} идентификатора выбранного склада.
2538
2376
  */
@@ -2544,7 +2382,7 @@ class ScWarehouseService {
2544
2382
  */
2545
2383
  initSubscriptionOnUser() {
2546
2384
  // Observable данных для обработки сигналов изменения пользователя.
2547
- const data$ = this.warehouses$.pipe(switchMap((warehouses) => this.userService.getUserChange$().pipe(map((user) => ({
2385
+ const data$ = this.warehouses$.pipe(switchMap((warehouses) => this.user$.pipe(map((user) => ({
2548
2386
  warehouses: warehouses,
2549
2387
  selectedIdMetadata: user.metadata.selectedWarehouseId,
2550
2388
  city: user.city,
@@ -2614,7 +2452,7 @@ class ScWarehouseService {
2614
2452
  getCurrentWarehouseIdSelect() {
2615
2453
  return this.warehouseIdSelectSubject.getValue();
2616
2454
  }
2617
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScWarehouseService, deps: [{ token: ScUserService }, { token: ScUIService }, { token: ScReferencesService }, { token: IS_RUNNING_ON_TERMINAL }], target: i0.ɵɵFactoryTarget.Injectable }); }
2455
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScWarehouseService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2618
2456
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScWarehouseService, providedIn: 'root' }); }
2619
2457
  }
2620
2458
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScWarehouseService, decorators: [{
@@ -2622,10 +2460,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
2622
2460
  args: [{
2623
2461
  providedIn: 'root',
2624
2462
  }]
2625
- }], ctorParameters: () => [{ type: ScUserService }, { type: ScUIService }, { type: ScReferencesService }, { type: undefined, decorators: [{
2626
- type: Inject,
2627
- args: [IS_RUNNING_ON_TERMINAL]
2628
- }] }] });
2463
+ }], ctorParameters: () => [] });
2629
2464
 
2630
2465
  /**
2631
2466
  * Сервис для работы с корзиной.
@@ -2634,22 +2469,8 @@ class ScCartService {
2634
2469
  /**
2635
2470
  * Инициализирует экземпляр класса {@link ScCartService}.
2636
2471
  *
2637
- * @param http Сервис для выполнения HTTP-запросов.
2638
- * @param urls Список ссылок на разделы backend'a.
2639
- * @param referencesService Сервис справочников.
2640
- * @param uiService Сервис для работы с UI.
2641
- * @param warehouseService Сервис для работы со складами.
2642
- * @param authService Сервис аутентификации.
2643
- * @param userMetrikaService Сервис для сбора метрик о действиях пользователей.
2644
2472
  */
2645
- constructor(http, urls, referencesService, uiService, warehouseService, authService, userMetrikaService) {
2646
- this.http = http;
2647
- this.urls = urls;
2648
- this.referencesService = referencesService;
2649
- this.uiService = uiService;
2650
- this.warehouseService = warehouseService;
2651
- this.authService = authService;
2652
- this.userMetrikaService = userMetrikaService;
2473
+ constructor() {
2653
2474
  /**
2654
2475
  * {@link ReplaySubject} для содержимого корзины.
2655
2476
  */
@@ -2658,18 +2479,39 @@ class ScCartService {
2658
2479
  * Признак, что скрипт выполняется в браузере.
2659
2480
  */
2660
2481
  this.isBrowser = inject(IS_BROWSER);
2482
+ /**
2483
+ * {@link Observable} данных о текущем пользователе.
2484
+ */
2485
+ this.user$ = inject(SC_USER_INFO);
2486
+ /**
2487
+ * HTTP-клиент.
2488
+ */
2489
+ this.http = inject(HttpClient);
2490
+ /**
2491
+ * Список ссылок приложения.
2492
+ */
2493
+ this.urls = inject(SC_URLS);
2494
+ /**
2495
+ * Сервис для работы с UI.
2496
+ */
2497
+ this.uiService = inject(ScUIService);
2498
+ /**
2499
+ * Сервис для работы со складами.
2500
+ */
2501
+ this.warehouseService = inject(ScWarehouseService);
2502
+ /**
2503
+ * Сервис для сбора метрик о действиях пользователей.
2504
+ */
2505
+ this.userMetrikaService = inject(ScUserMetrikaService);
2661
2506
  if (this.isBrowser) {
2662
- authService
2663
- .getAuthChange()
2664
- .pipe(switchMap(() => this.updateCart$()))
2665
- .subscribe((cart) => {
2507
+ this.user$.pipe(switchMap(() => this.updateCart$())).subscribe((cart) => {
2666
2508
  this.cart$.next(cart);
2667
2509
  });
2668
2510
  }
2669
2511
  else {
2670
2512
  this.cart$.next(new ScCart());
2671
2513
  }
2672
- this.cartDirections$ = referencesService.directions$.pipe(switchMap((directions) => this.cart$.pipe(switchMap((cart) => this.warehouseService.getWarehouseSelectChange$().pipe(map((warehouse) => directions
2514
+ this.cartDirections$ = inject(ScReferencesService).directions$.pipe(switchMap((directions) => this.cart$.pipe(switchMap((cart) => this.warehouseService.getWarehouseSelectChange$().pipe(map((warehouse) => directions
2673
2515
  .map((direction) => new ScISalesDirectionCart(direction, cart.items.filter((cartItem) => !cartItem.product.isNull && !cartItem.product.isHidden && cartItem.salesDirection === direction.id), cart.directionsSum[direction.id], warehouse.id))
2674
2516
  .filter((direction) => direction.items.length > 0 || direction.itemsOnOrder.length > 0 || direction.itemsNotInWarehouseStock.length > 0)))))));
2675
2517
  }
@@ -2789,7 +2631,7 @@ class ScCartService {
2789
2631
  });
2790
2632
  }));
2791
2633
  }
2792
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScCartService, deps: [{ token: i1$1.HttpClient }, { token: SC_URLS }, { token: ScReferencesService }, { token: ScUIService }, { token: ScWarehouseService }, { token: ScAuthService }, { token: ScUserMetrikaService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2634
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScCartService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2793
2635
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScCartService, providedIn: 'root' }); }
2794
2636
  }
2795
2637
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScCartService, decorators: [{
@@ -2797,10 +2639,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
2797
2639
  args: [{
2798
2640
  providedIn: 'root',
2799
2641
  }]
2800
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
2801
- type: Inject,
2802
- args: [SC_URLS]
2803
- }] }, { type: ScReferencesService }, { type: ScUIService }, { type: ScWarehouseService }, { type: ScAuthService }, { type: ScUserMetrikaService }] });
2642
+ }], ctorParameters: () => [] });
2804
2643
 
2805
2644
  /* eslint-disable @typescript-eslint/no-duplicate-enum-values */
2806
2645
  /**
@@ -2906,6 +2745,40 @@ class ScCachedData {
2906
2745
  }
2907
2746
  }
2908
2747
 
2748
+ /**
2749
+ * Модель кэшированных данных.
2750
+ */
2751
+ class ScCachedItem {
2752
+ /**
2753
+ * Инициализирует экземпляр класса {@link ScCachedItem}.
2754
+ *
2755
+ * @param lifeTime Время жизни записи в ms.
2756
+ * @param item$ {@link Observable} запроса кэшируемых данных.
2757
+ */
2758
+ constructor(lifeTime, item$) {
2759
+ /**
2760
+ * {@link Observable} обновления данных.
2761
+ */
2762
+ this.update$ = new BehaviorSubject(undefined);
2763
+ this.item$ = this.update$.pipe(switchMap(() => item$.pipe(tap(() => {
2764
+ this.cachedUntil = Date.now() + lifeTime;
2765
+ }), startWith(null))), shareReplay(1));
2766
+ }
2767
+ /**
2768
+ * Возвращает признак того, что кэшированные данные актуальны.
2769
+ */
2770
+ cachedDataIsActual() {
2771
+ return !this.cachedUntil || this.cachedUntil > Date.now();
2772
+ }
2773
+ /**
2774
+ * Выполняет обновления {@link Observable} запроса кэшируемых данных.
2775
+ */
2776
+ update() {
2777
+ this.cachedUntil = undefined;
2778
+ this.update$.next();
2779
+ }
2780
+ }
2781
+
2909
2782
  /**
2910
2783
  * Данные о виртуальной категории.
2911
2784
  */
@@ -2989,16 +2862,14 @@ class ScCatalogService {
2989
2862
  * @param urls Список ссылок на разделы backend'a.
2990
2863
  * @param uiService Сервис для работы с UI.
2991
2864
  * @param convertersService Сервис конвертации данных.
2992
- * @param authService Сервис аутентификации.
2993
2865
  * @param cacheLifeTime Объект с информацией о времени жизни данных.
2994
2866
  * @param userMetrikaService Сервис для сбора метрик о действиях пользователей.
2995
2867
  */
2996
- constructor(http, urls, uiService, convertersService, authService, cacheLifeTime, userMetrikaService) {
2868
+ constructor(http, urls, uiService, convertersService, cacheLifeTime, userMetrikaService) {
2997
2869
  this.http = http;
2998
2870
  this.urls = urls;
2999
2871
  this.uiService = uiService;
3000
2872
  this.convertersService = convertersService;
3001
- this.authService = authService;
3002
2873
  this.cacheLifeTime = cacheLifeTime;
3003
2874
  this.userMetrikaService = userMetrikaService;
3004
2875
  /**
@@ -3044,10 +2915,14 @@ class ScCatalogService {
3044
2915
  * Число первых записей товаров со скидкой.
3045
2916
  */
3046
2917
  this.countFirstDiscountedProducts = inject(SC_COUNT_FIRST_DISCOUNTED_PRODUCTS);
2918
+ /**
2919
+ * Сервис информации о пользователе.
2920
+ */
2921
+ this.userService = inject(ScUserService);
3047
2922
  /**
3048
2923
  * {@link Observable} изменения списка товаров со скидкой.
3049
2924
  */
3050
- this.firstDiscounted$ = this.authService.getAuthChange().pipe(switchMap((auth) => (auth ? this.getProducts$({ filters: { onlyDiscounted: true }, paginate: true, page: 1, perPage: this.countFirstDiscountedProducts }) : of(null))), shareReplay(1));
2925
+ this.firstDiscounted$ = inject(SC_USER_INFO).pipe(switchMap((user) => user.isGuest ? of(null) : this.getProducts$({ filters: { onlyDiscounted: true }, paginate: true, page: 1, perPage: this.countFirstDiscountedProducts })), shareReplay(1));
3051
2926
  /**
3052
2927
  * {@link Observable} изменения списка из первых товаров со скидкой.
3053
2928
  */
@@ -3056,8 +2931,8 @@ class ScCatalogService {
3056
2931
  * {@link Observable} изменения общего колличества товара со скидкой.
3057
2932
  */
3058
2933
  this.countDiscountedProducts$ = this.firstDiscounted$.pipe(map((data) => data?.meta.total ?? 0));
3059
- this.authService
3060
- .getAuthChange()
2934
+ this.userService
2935
+ .getUserChange$()
3061
2936
  .pipe(skip(1))
3062
2937
  .subscribe(() => {
3063
2938
  this.idCategoryMap.clear();
@@ -3090,8 +2965,8 @@ class ScCatalogService {
3090
2965
  */
3091
2966
  getCategoryData$(categoryIdOrSlug) {
3092
2967
  return this.http.get(`${this.urls.apiUrl}/catalog/categories/${categoryIdOrSlug ?? ''}`).pipe(map((category) => new ScCategory(category)), tap((category) => {
3093
- if (categoryIdOrSlug && typeof this.idOrSlugPipe.transform(category) !== typeof categoryIdOrSlug) {
3094
- this.categoryIdOrSlugMap.set(this.idOrSlugPipe.transform(category), categoryIdOrSlug);
2968
+ if (categoryIdOrSlug) {
2969
+ this.categoryIdOrSlugMap.set(typeof categoryIdOrSlug === 'string' ? category.id : category.slug, categoryIdOrSlug);
3095
2970
  }
3096
2971
  }),
3097
2972
  // eslint-disable-next-line no-param-reassign
@@ -3234,8 +3109,8 @@ class ScCatalogService {
3234
3109
  */
3235
3110
  getProductData$(productIdOrSlug) {
3236
3111
  return this.http.get(`${this.urls.apiUrl}/catalog/products/${productIdOrSlug}`).pipe(map((productDTO) => new ScProduct(productDTO)), tap((product) => {
3237
- if (productIdOrSlug && typeof this.idOrSlugPipe.transform(product) !== typeof productIdOrSlug) {
3238
- this.productIdOrSlugMap.set(this.idOrSlugPipe.transform(product), productIdOrSlug);
3112
+ if (productIdOrSlug) {
3113
+ this.productIdOrSlugMap.set(typeof productIdOrSlug === 'string' ? product.id : product.slug, productIdOrSlug);
3239
3114
  }
3240
3115
  }));
3241
3116
  }
@@ -3285,7 +3160,7 @@ class ScCatalogService {
3285
3160
  getProductNotifyWhenInStock$(productIdOrSlug, data) {
3286
3161
  return this.http.post(`${this.urls.apiUrl}/catalog/products/${productIdOrSlug}/stock-notify`, data);
3287
3162
  }
3288
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScCatalogService, deps: [{ token: i1$1.HttpClient }, { token: SC_URLS }, { token: ScUIService }, { token: ScConvertersService }, { token: ScAuthService }, { token: SC_CACHE_LIFETIME }, { token: ScUserMetrikaService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3163
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScCatalogService, deps: [{ token: i1$1.HttpClient }, { token: SC_URLS }, { token: ScUIService }, { token: ScConvertersService }, { token: SC_CACHE_LIFETIME }, { token: ScUserMetrikaService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3289
3164
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScCatalogService, providedIn: 'root' }); }
3290
3165
  }
3291
3166
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScCatalogService, decorators: [{
@@ -3296,37 +3171,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
3296
3171
  }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
3297
3172
  type: Inject,
3298
3173
  args: [SC_URLS]
3299
- }] }, { type: ScUIService }, { type: ScConvertersService }, { type: ScAuthService }, { type: undefined, decorators: [{
3174
+ }] }, { type: ScUIService }, { type: ScConvertersService }, { type: undefined, decorators: [{
3300
3175
  type: Inject,
3301
3176
  args: [SC_CACHE_LIFETIME]
3302
3177
  }] }, { type: ScUserMetrikaService }] });
3303
3178
 
3179
+ /* eslint-disable no-param-reassign,no-return-assign,no-void */
3304
3180
  /**
3305
3181
  * Сервис для работы с избранными товарами и категориями.
3306
3182
  */
3307
3183
  class ScFavoriteService {
3308
- /**
3309
- * Инициализирует экземпляр класса {@link ScFavoriteService}.
3310
- *
3311
- * @param http Сервис для выполнения HTTP-запросов.
3312
- * @param urls Список ссылок на разделы backend'a.
3313
- * @param catalogService Сервис для работы с каталогом.
3314
- * @param authService Сервис аутентификации.
3315
- */
3316
- constructor(http, urls, catalogService, authService) {
3317
- this.http = http;
3318
- this.urls = urls;
3319
- this.catalogService = catalogService;
3320
- this.authService = authService;
3184
+ constructor() {
3185
+ /**
3186
+ * HTTP-клиент.
3187
+ */
3188
+ this.http = inject(HttpClient);
3189
+ /**
3190
+ * Список ссылок приложения.
3191
+ */
3192
+ this.urls = inject(SC_URLS);
3321
3193
  /**
3322
3194
  * {@link BehaviorSubject} обновления списка избранных категорий.
3323
3195
  */
3324
- // eslint-disable-next-line sonarjs/void-use
3325
3196
  this.categoriesUpdateSubject = new BehaviorSubject(void {});
3197
+ /**
3198
+ * Сервис данных о пользователе.
3199
+ */
3200
+ this.user$ = inject(SC_USER_INFO);
3326
3201
  /**
3327
3202
  * {@link Observable} списка избранных категорий.
3328
3203
  */
3329
- this.categories$ = this.categoriesUpdateSubject.pipe(switchMap(() => this.authService.getAuthChange()), switchMap((state) => (state ? this.getFavoriteCategories$() : of([]))), shareReplay(1) // Подогреваем запрос во избежание повторения запросов получения списка избранных категорий для новых подписчиков.
3204
+ this.categories$ = this.categoriesUpdateSubject.pipe(switchMap(() => this.user$), switchMap((user) => (user.isGuest ? of([]) : this.getFavoriteCategories$())), shareReplay(1) // Подогреваем запрос во избежание повторения запросов получения списка избранных категорий для новых подписчиков.
3330
3205
  );
3331
3206
  }
3332
3207
  /**
@@ -3375,7 +3250,7 @@ class ScFavoriteService {
3375
3250
  deleteProduct$(productId) {
3376
3251
  return this.http.delete(`${this.urls.apiUrl}/favorites/products/${productId}`);
3377
3252
  }
3378
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScFavoriteService, deps: [{ token: i1$1.HttpClient }, { token: SC_URLS }, { token: ScCatalogService }, { token: ScAuthService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3253
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScFavoriteService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3379
3254
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScFavoriteService, providedIn: 'root' }); }
3380
3255
  }
3381
3256
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScFavoriteService, decorators: [{
@@ -3383,10 +3258,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
3383
3258
  args: [{
3384
3259
  providedIn: 'root',
3385
3260
  }]
3386
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
3387
- type: Inject,
3388
- args: [SC_URLS]
3389
- }] }, { type: ScCatalogService }, { type: ScAuthService }] });
3261
+ }] });
3390
3262
 
3391
3263
  /**
3392
3264
  * Сервис для работы с рекомендуемыми товарами.
@@ -3394,19 +3266,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
3394
3266
  class ScRecommendationService {
3395
3267
  /**
3396
3268
  * Инициализирует экземпляр класса {@link ScRecommendationService}.
3397
- *
3398
- * @param http Сервис для выполнения HTTP-запросов.
3399
- * @param urls Список ссылок на разделы backend'a.
3400
- * @param convertersService Сервис конвертации данных.
3401
- * @param cartService Сервис для работы с корзиной.
3402
- * @param authService Сервис аутентификации.
3403
3269
  */
3404
- constructor(http, urls, convertersService, cartService, authService) {
3405
- this.http = http;
3406
- this.urls = urls;
3407
- this.convertersService = convertersService;
3408
- this.cartService = cartService;
3409
- this.authService = authService;
3270
+ constructor() {
3410
3271
  /**
3411
3272
  * {@link Map} коллекция пар ключ-значение для кэшированных рекомендуемых товаров категории.
3412
3273
  */
@@ -3415,8 +3276,23 @@ class ScRecommendationService {
3415
3276
  * {@link Map} коллекция пар ключ-значение для кэшированных рекомендуемых товаров товара.
3416
3277
  */
3417
3278
  this.productsByProductMap = new Map();
3418
- this.authService
3419
- .getAuthChange()
3279
+ /**
3280
+ * HTTP-клиент.
3281
+ */
3282
+ this.http = inject(HttpClient);
3283
+ /**
3284
+ * Список ссылок приложения.
3285
+ */
3286
+ this.urls = inject(SC_URLS);
3287
+ /**
3288
+ * Сервис конвертации данных.
3289
+ */
3290
+ this.convertersService = inject(ScConvertersService);
3291
+ /**
3292
+ * Сервис для работы с корзиной.
3293
+ */
3294
+ this.cartService = inject(ScCartService);
3295
+ inject(SC_USER_INFO)
3420
3296
  .pipe(skip(1))
3421
3297
  .subscribe(() => {
3422
3298
  this.productsByCategoryMap.clear();
@@ -3481,7 +3357,7 @@ class ScRecommendationService {
3481
3357
  // eslint-disable-next-line sonarjs/no-misleading-array-reverse
3482
3358
  distinctUntilChanged((previous, current) => JSON.stringify(previous.sort((a, b) => a - b)) === JSON.stringify(current.sort((a, b) => a - b))), switchMap((productIds) => this.getProductsByProductIds$(productIds).pipe(startWith(null))));
3483
3359
  }
3484
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScRecommendationService, deps: [{ token: i1$1.HttpClient }, { token: SC_URLS }, { token: ScConvertersService }, { token: ScCartService }, { token: ScAuthService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3360
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScRecommendationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3485
3361
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScRecommendationService, providedIn: 'root' }); }
3486
3362
  }
3487
3363
  __decorate([
@@ -3492,10 +3368,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
3492
3368
  args: [{
3493
3369
  providedIn: 'root',
3494
3370
  }]
3495
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
3496
- type: Inject,
3497
- args: [SC_URLS]
3498
- }] }, { type: ScConvertersService }, { type: ScCartService }, { type: ScAuthService }], propDecorators: { getProductsByCart$: [] } });
3371
+ }], ctorParameters: () => [], propDecorators: { getProductsByCart$: [] } });
3499
3372
 
3500
3373
  /**
3501
3374
  * Сервис для работы с конфигуратором.
@@ -3644,30 +3517,132 @@ var ScSocialType;
3644
3517
  */
3645
3518
  ScSocialType["ok"] = "ok";
3646
3519
  /**
3647
- * @see [Telegram](https://telegram.org/)
3520
+ * @see [Telegram](https://telegram.org/)
3521
+ */
3522
+ ScSocialType["telegram"] = "telegram";
3523
+ /**
3524
+ * @see [В Контакте](https://vk.com/)
3525
+ */
3526
+ ScSocialType["vk"] = "vk";
3527
+ })(ScSocialType || (ScSocialType = {}));
3528
+
3529
+ /**
3530
+ * Модель данных для загружаемого файла.
3531
+ */
3532
+ class ScUploadedFile {
3533
+ /**
3534
+ * Инициализирует экземпляр класса {@link ScUploadedFile}.
3535
+ *
3536
+ * @param name Название загружаемого пользователем файла.
3537
+ * @param content Содержимое файла кодированное в base64.
3538
+ */
3539
+ constructor(name, content) {
3540
+ this.name = name;
3541
+ this.content = content;
3542
+ }
3543
+ }
3544
+
3545
+ /**
3546
+ * Сервис для работы с контактными лицами.
3547
+ */
3548
+ class ScContactsService {
3549
+ constructor() {
3550
+ /**
3551
+ * HTTP-клиент.
3552
+ */
3553
+ this.http = inject(HttpClient);
3554
+ /**
3555
+ * Список ссылок приложения.
3556
+ */
3557
+ this.urls = inject(SC_URLS);
3558
+ /**
3559
+ * {@link Observable} данных о текущем пользователе.
3560
+ */
3561
+ this.user$ = inject(SC_USER_INFO);
3562
+ /**
3563
+ * {@link Observable} получения списка контактных лиц пользователя, контрагентов пользователя и адресов доставки пользователя.
3564
+ */
3565
+ this.allContacts = new ScCachedItem(0, this.user$.pipe(switchMap((user) => (user.isGuest ? of(null) : this.http.get(`${this.urls.apiUrl}/user/contacts/all`)))));
3566
+ /**
3567
+ * {@link Observable} получения списка контактных лиц пользователя.
3568
+ */
3569
+ this.userContacts = new ScCachedItem(0, this.user$.pipe(switchMap((user) => (user.isGuest ? of(null) : this.http.get(`${this.urls.apiUrl}/user/contacts`)))));
3570
+ /**
3571
+ * {@link Map} коллекция пар ключ-значение с данными о контактных лицах адресов доставки.
3572
+ */
3573
+ this.deliveryAddressContactsMap = new Map();
3574
+ /**
3575
+ * {@link Map} коллекция пар ключ-значение с данными о контактных лицах контрагентов.
3576
+ */
3577
+ this.contragentContactsMap = new Map();
3578
+ }
3579
+ /**
3580
+ * Возвращает список всех контактов.
3581
+ */
3582
+ getContact$() {
3583
+ return this.allContacts.item$;
3584
+ }
3585
+ /**
3586
+ * Создаёт запрос создания контактного лица.
3587
+ *
3588
+ * @param newContact Данные требуемые для создания контактного лица.
3589
+ */
3590
+ createContact$(newContact) {
3591
+ return this.http.post(`${this.urls.apiUrl}/user/contacts`, newContact).pipe(tap(() => {
3592
+ this.allContacts.update();
3593
+ if (newContact.client) {
3594
+ this.userContacts.update();
3595
+ }
3596
+ if (newContact.addresses) {
3597
+ newContact.addresses.forEach((item) => this.deliveryAddressContactsMap.get(item.id)?.update());
3598
+ }
3599
+ if (newContact.contragents) {
3600
+ newContact.contragents.forEach((item) => this.contragentContactsMap.get(item.id)?.update());
3601
+ }
3602
+ }));
3603
+ }
3604
+ /**
3605
+ * Создаёт запрос изменения контактного лица пользователя.
3606
+ *
3607
+ * @param contactId Идентификатор контакта пользователя.
3608
+ * @param newContact Данные требуемые для создания контактного лица.
3648
3609
  */
3649
- ScSocialType["telegram"] = "telegram";
3610
+ editContact$(contactId, newContact) {
3611
+ return this.http.patch(`${this.urls.apiUrl}/user/contacts/${contactId}`, newContact).pipe(tap(() => {
3612
+ this.allContacts.update();
3613
+ }));
3614
+ }
3650
3615
  /**
3651
- * @see Контакте](https://vk.com/)
3616
+ * Создаёт запрос удаления контактного лица пользователя.
3617
+ *
3618
+ * @param contactId Идентификатор контакта пользователя.
3652
3619
  */
3653
- ScSocialType["vk"] = "vk";
3654
- })(ScSocialType || (ScSocialType = {}));
3655
-
3656
- /**
3657
- * Модель данных для загружаемого файла.
3658
- */
3659
- class ScUploadedFile {
3620
+ deleteContact$(contactId) {
3621
+ return this.http.delete(`${this.urls.apiUrl}/user/contacts/${contactId}`).pipe(tap(() => {
3622
+ this.allContacts.update();
3623
+ }));
3624
+ }
3660
3625
  /**
3661
- * Инициализирует экземпляр класса {@link ScUploadedFile}.
3626
+ * Содаёт запрос на получение списка контактов для помощи клиенту.
3662
3627
  *
3663
- * @param name Название загружаемого пользователем файла.
3664
- * @param content Содержимое файла кодированное в base64.
3628
+ * @param params Параметры поиска контактов (телефон или ID города).
3629
+ * @param params.phone Телефон клиента.
3630
+ * @param params.cityId ID города.
3665
3631
  */
3666
- constructor(name, content) {
3667
- this.name = name;
3668
- this.content = content;
3632
+ getHelpContacts$(params) {
3633
+ return this.http.get(`${this.urls.apiUrl}/contacts/help`, {
3634
+ params: params,
3635
+ });
3669
3636
  }
3637
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScContactsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3638
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScContactsService, providedIn: 'root' }); }
3670
3639
  }
3640
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScContactsService, decorators: [{
3641
+ type: Injectable,
3642
+ args: [{
3643
+ providedIn: 'root',
3644
+ }]
3645
+ }] });
3671
3646
 
3672
3647
  /**
3673
3648
  * Токен, указывающий на необходимость добавления заголовков в исходящие запросы.
@@ -3882,10 +3857,6 @@ class ScUTMService {
3882
3857
  * Сервис для выполнения HTTP-запросов.
3883
3858
  */
3884
3859
  this.http = inject(HttpClient);
3885
- /**
3886
- * Сервис аутентификации пользователей.
3887
- */
3888
- this.authService = inject(ScAuthService);
3889
3860
  /**
3890
3861
  * Сервис предоставляющий доступ к данным о маршруте.
3891
3862
  */
@@ -3933,8 +3904,7 @@ class ScUTMService {
3933
3904
  };
3934
3905
  }));
3935
3906
  // При получении UTM-метки сохраняем ее в Storage и создаём запрос сохранения метки за клиентом.
3936
- this.authService
3937
- .getAuthChange()
3907
+ inject(SC_USER_INFO)
3938
3908
  .pipe(switchMap(() => this.utmParamsFromRoute$), tap(() => {
3939
3909
  this.updateTimestamp();
3940
3910
  }), filter((utm) => !this.isExistingUTM(utm)), tap((utm) => {
@@ -4105,7 +4075,7 @@ class ScRequisitesService {
4105
4075
  /**
4106
4076
  * Создаёт запрос получения списка всех контактов.
4107
4077
  */
4108
- this.contacts$ = this.authService.getAuthChange().pipe(switchMap(() => this.http.get(`${this.urls.apiUrl}/contacts`)), shareReplay(1));
4078
+ this.contacts$ = inject(SC_USER_INFO).pipe(switchMap(() => this.http.get(`${this.urls.apiUrl}/contacts`)), shareReplay(1));
4109
4079
  /**
4110
4080
  * Создаёт запрос получения списка контактов для решения возникающих вопросов.
4111
4081
  */
@@ -4220,18 +4190,28 @@ class ScContragentService {
4220
4190
  /**
4221
4191
  * Инициализирует экземпляр класса {@link ScContragentService}.
4222
4192
  *
4223
- * @param http HTTP-клиент.
4224
- * @param urls Список ссылок на разделы backend'a.
4225
- * @param authService Сервис аутентификации.
4226
- * @param userMetrikaService Сервис для сбора метрик о действиях пользователей.
4227
- * @param contactsService Сервис для работы с контактными лицами.
4228
4193
  */
4229
- constructor(http, urls, authService, userMetrikaService, contactsService) {
4230
- this.http = http;
4231
- this.urls = urls;
4232
- this.authService = authService;
4233
- this.userMetrikaService = userMetrikaService;
4234
- this.contactsService = contactsService;
4194
+ constructor() {
4195
+ /**
4196
+ * HTTP-клиент.
4197
+ */
4198
+ this.http = inject(HttpClient);
4199
+ /**
4200
+ * Список ссылок приложения.
4201
+ */
4202
+ this.urls = inject(SC_URLS);
4203
+ /**
4204
+ * {@link Observable} данных о текущем пользователе.
4205
+ */
4206
+ this.user$ = inject(SC_USER_INFO);
4207
+ /**
4208
+ * Сервис для сбора метрик о действиях пользователей.
4209
+ */
4210
+ this.userMetrikaService = inject(ScUserMetrikaService);
4211
+ /**
4212
+ * Сервис для работы с контактными лицами.
4213
+ */
4214
+ this.contactsService = inject(ScContactsService);
4235
4215
  /**
4236
4216
  * {@link BehaviorSubject} обновления контрагентов.
4237
4217
  */
@@ -4243,11 +4223,8 @@ class ScContragentService {
4243
4223
  /**
4244
4224
  * {@link Observable} данных о контрагентах пользователя.
4245
4225
  */
4246
- this.contragents$ = this.contragentsUpdate$.pipe(switchMap(() => this.authService.getAuthChange()), switchMap((state) => (state ? this.http.get(`${this.urls.apiUrl}/user/contragents`).pipe(startWith(null)) : of(null))), shareReplay(1));
4247
- authService
4248
- .getAuthChange()
4249
- .pipe(filter((state) => !state))
4250
- .subscribe(() => {
4226
+ this.contragents$ = this.contragentsUpdate$.pipe(switchMap(() => this.user$), switchMap((user) => (user.isGuest ? of(null) : this.http.get(`${this.urls.apiUrl}/user/contragents`).pipe(startWith(null)))), shareReplay(1));
4227
+ this.user$.pipe(filter((user) => user.isGuest)).subscribe(() => {
4251
4228
  this.contactsService.contragentContactsMap.clear();
4252
4229
  this.contragentBankAccountsMap.clear();
4253
4230
  });
@@ -4352,7 +4329,7 @@ class ScContragentService {
4352
4329
  .delete(`${this.urls.apiUrl}/user/contragents/${contragentId}/bank-accounts/${bankAccountId}`)
4353
4330
  .pipe(tap(() => this.contragentBankAccountsMap.get(contragentId)?.update()));
4354
4331
  }
4355
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScContragentService, deps: [{ token: i1$1.HttpClient }, { token: SC_URLS }, { token: ScAuthService }, { token: ScUserMetrikaService }, { token: ScContactsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4332
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScContragentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4356
4333
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScContragentService, providedIn: 'root' }); }
4357
4334
  }
4358
4335
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScContragentService, decorators: [{
@@ -4360,30 +4337,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
4360
4337
  args: [{
4361
4338
  providedIn: 'root',
4362
4339
  }]
4363
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
4364
- type: Inject,
4365
- args: [SC_URLS]
4366
- }] }, { type: ScAuthService }, { type: ScUserMetrikaService }, { type: ScContactsService }] });
4340
+ }], ctorParameters: () => [] });
4367
4341
 
4368
4342
  /**
4369
4343
  * Сервис работы с адресами доставки.
4370
4344
  */
4371
4345
  class ScDeliveryAddressService {
4372
- /**
4373
- * Инициализирует экземпляр класса {@link ScDeliveryAddressService}.
4374
- *
4375
- * @param http HTTP-клиент.
4376
- * @param urls Список ссылок на разделы backend'a.
4377
- * @param authService Сервис аутентификации.
4378
- * @param userMetrikaService Сервис для сбора метрик о действиях пользователей.
4379
- * @param contactsService Сервис для работы с контактными лицами.
4380
- */
4381
- constructor(http, urls, authService, userMetrikaService, contactsService) {
4382
- this.http = http;
4383
- this.urls = urls;
4384
- this.authService = authService;
4385
- this.userMetrikaService = userMetrikaService;
4386
- this.contactsService = contactsService;
4346
+ constructor() {
4347
+ /**
4348
+ * HTTP-клиент.
4349
+ */
4350
+ this.http = inject(HttpClient);
4351
+ /**
4352
+ * Список ссылок приложения.
4353
+ */
4354
+ this.urls = inject(SC_URLS);
4355
+ /**
4356
+ * {@link Observable} данных о текущем пользователе.
4357
+ */
4358
+ this.user$ = inject(SC_USER_INFO);
4359
+ /**
4360
+ * Сервис для сбора метрик о действиях пользователей.
4361
+ */
4362
+ this.userMetrikaService = inject(ScUserMetrikaService);
4363
+ /**
4364
+ * Сервис для работы с контактными лицами.
4365
+ */
4366
+ this.contactsService = inject(ScContactsService);
4387
4367
  /**
4388
4368
  * {@link BehaviorSubject} обновление адресов доставки.
4389
4369
  */
@@ -4391,7 +4371,7 @@ class ScDeliveryAddressService {
4391
4371
  /**
4392
4372
  * {@link Observable} данных адресов доставки.
4393
4373
  */
4394
- this.deliveryAddresses$ = this.deliveryAddressesUpdate$.pipe(switchMap(() => this.authService.getAuthChange()), switchMap((state) => (state ? this.http.get(`${this.urls.apiUrl}/user/delivery-addresses`).pipe(startWith(null)) : of(null))), shareReplay(1));
4374
+ this.deliveryAddresses$ = this.deliveryAddressesUpdate$.pipe(switchMap(() => this.user$), switchMap((user) => (user.isGuest ? of(null) : this.http.get(`${this.urls.apiUrl}/user/delivery-addresses`).pipe(startWith(null)))), shareReplay(1));
4395
4375
  }
4396
4376
  /**
4397
4377
  * Создаёт запрос создания нового адреса доставки.
@@ -4457,7 +4437,7 @@ class ScDeliveryAddressService {
4457
4437
  deleteDeliveryAddressContact$(addressId, contactId) {
4458
4438
  return this.contactsService.deleteContact$(contactId).pipe(tap(() => this.contactsService.deliveryAddressContactsMap.get(addressId)?.update()));
4459
4439
  }
4460
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScDeliveryAddressService, deps: [{ token: i1$1.HttpClient }, { token: SC_URLS }, { token: ScAuthService }, { token: ScUserMetrikaService }, { token: ScContactsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4440
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScDeliveryAddressService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4461
4441
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScDeliveryAddressService, providedIn: 'root' }); }
4462
4442
  }
4463
4443
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScDeliveryAddressService, decorators: [{
@@ -4465,10 +4445,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
4465
4445
  args: [{
4466
4446
  providedIn: 'root',
4467
4447
  }]
4468
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
4469
- type: Inject,
4470
- args: [SC_URLS]
4471
- }] }, { type: ScAuthService }, { type: ScUserMetrikaService }, { type: ScContactsService }] });
4448
+ }] });
4472
4449
 
4473
4450
  /**
4474
4451
  * Сервис для работы с часто задаваемыми вопросами (FAQ).
@@ -5211,7 +5188,7 @@ class ScGuestInterceptor {
5211
5188
  /**
5212
5189
  * Сервис аутентификации пользователей.
5213
5190
  */
5214
- this.authService = inject(ScAuthService);
5191
+ this.user$ = inject(SC_USER_INFO);
5215
5192
  }
5216
5193
  /** @inheritDoc */
5217
5194
  intercept(request, next) {
@@ -5219,7 +5196,7 @@ class ScGuestInterceptor {
5219
5196
  if (!isGuestEndpoint) {
5220
5197
  return next.handle(request);
5221
5198
  }
5222
- return this.authService.getAuthChange().pipe(first(), switchMap((status) => (status ? next.handle(request) : next.handle(request.clone({ params: request.params.append(this.guestParameterName, true) })))));
5199
+ return this.user$.pipe(first(), switchMap((user) => (user.isGuest ? next.handle(request.clone({ params: request.params.append(this.guestParameterName, true) })) : next.handle(request))));
5223
5200
  }
5224
5201
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScGuestInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
5225
5202
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScGuestInterceptor }); }
@@ -5600,23 +5577,27 @@ const SC_COUNT_LAST_NEWS = new InjectionToken('countLasNews', {
5600
5577
  * Сервис для получения списка новостей.
5601
5578
  */
5602
5579
  class ScNewsService {
5603
- /**
5604
- * Инициализирует экземпляр класса {@link ScNewsService}.
5605
- *
5606
- * @param http HTTP-клиент.
5607
- * @param urls Список ссылок на разделы backend.
5608
- * @param countLasNews число записей новостей отображаемых в "Последние новости".
5609
- * @param authService Сервис аутентификации.
5610
- */
5611
- constructor(http, urls, countLasNews, authService) {
5612
- this.http = http;
5613
- this.urls = urls;
5614
- this.countLasNews = countLasNews;
5615
- this.authService = authService;
5580
+ constructor() {
5581
+ /**
5582
+ * HTTP-клиент.
5583
+ */
5584
+ this.http = inject(HttpClient);
5585
+ /**
5586
+ * Список ссылок приложения.
5587
+ */
5588
+ this.urls = inject(SC_URLS);
5589
+ /**
5590
+ * Количество последних новостей.
5591
+ */
5592
+ this.countLasNews = inject(SC_COUNT_LAST_NEWS);
5593
+ /**
5594
+ * {@link Observable} данных о текущем пользователе.
5595
+ */
5596
+ this.user$ = inject(SC_USER_INFO);
5616
5597
  /**
5617
5598
  * {@link Observable} получения списка последних новостей.
5618
5599
  */
5619
- this.lastNewsList$ = this.authService.getAuthChange().pipe(switchMap(() => this.http.get(`${this.urls.apiUrl}/news`, { params: { perPage: this.countLasNews } })), shareReplay(1) // Подогреваем Observable во избежание повторения запросов получения списка последних новостей.
5600
+ this.lastNewsList$ = this.user$.pipe(switchMap(() => this.http.get(`${this.urls.apiUrl}/news`, { params: { perPage: this.countLasNews } })), shareReplay(1) // Подогреваем Observable во избежание повторения запросов получения списка последних новостей.
5620
5601
  );
5621
5602
  }
5622
5603
  /**
@@ -5642,7 +5623,7 @@ class ScNewsService {
5642
5623
  getLastNewsList$() {
5643
5624
  return this.lastNewsList$;
5644
5625
  }
5645
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScNewsService, deps: [{ token: i1$1.HttpClient }, { token: SC_URLS }, { token: SC_COUNT_LAST_NEWS }, { token: ScAuthService }], target: i0.ɵɵFactoryTarget.Injectable }); }
5626
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScNewsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
5646
5627
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScNewsService, providedIn: 'root' }); }
5647
5628
  }
5648
5629
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScNewsService, decorators: [{
@@ -5650,13 +5631,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
5650
5631
  args: [{
5651
5632
  providedIn: 'root',
5652
5633
  }]
5653
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
5654
- type: Inject,
5655
- args: [SC_URLS]
5656
- }] }, { type: undefined, decorators: [{
5657
- type: Inject,
5658
- args: [SC_COUNT_LAST_NEWS]
5659
- }] }, { type: ScAuthService }] });
5634
+ }] });
5660
5635
 
5661
5636
  /*
5662
5637
  * Публичное API библиотеки бизнес-логики.
@@ -5714,16 +5689,24 @@ class ScNotificationsService {
5714
5689
  /**
5715
5690
  * Инициализирует экземпляр класса {@link ScNotificationsService}.
5716
5691
  *
5717
- * @param http Сервис для выполнения HTTP-запросов.
5718
- * @param authService Сервис аутентификации.
5719
- * @param urls Список ссылок на разделы backend.
5720
- * @param updateInterval Интервалы обновления данных.
5721
5692
  */
5722
- constructor(http, authService, urls, updateInterval) {
5723
- this.http = http;
5724
- this.authService = authService;
5725
- this.urls = urls;
5726
- this.updateInterval = updateInterval;
5693
+ constructor() {
5694
+ /**
5695
+ * HTTP-клиент.
5696
+ */
5697
+ this.http = inject(HttpClient);
5698
+ /**
5699
+ * Список ссылок приложения.
5700
+ */
5701
+ this.urls = inject(SC_URLS);
5702
+ /**
5703
+ * {@link Observable} данных о текущем пользователе.
5704
+ */
5705
+ this.user$ = inject(SC_USER_INFO);
5706
+ /**
5707
+ * Интервалы обновления данных.
5708
+ */
5709
+ this.updateInterval = inject(SC_UPDATE_INTERVAL);
5727
5710
  /**
5728
5711
  * {@link ReplaySubject} данных о количестве уведомлений пользователя.
5729
5712
  */
@@ -5738,18 +5721,17 @@ class ScNotificationsService {
5738
5721
  this.interval$ = interval(this.updateInterval.notificationsUpdate).pipe(tap(() => {
5739
5722
  this.updateUserNotificationsCount();
5740
5723
  }));
5741
- this.authService
5742
- .getAuthChange()
5743
- .pipe(tap((state) => {
5724
+ this.user$
5725
+ .pipe(tap((user) => {
5744
5726
  // eslint-disable-next-line sonarjs/no-selector-parameter
5745
- if (state) {
5746
- this.updateUserNotificationsCount();
5747
- }
5748
- else {
5727
+ if (user.isGuest) {
5749
5728
  // eslint-disable-next-line unicorn/no-useless-undefined
5750
5729
  this.notificationsCount$.next(undefined);
5751
5730
  }
5752
- }), switchMap((state) => (state ? this.interval$ : of())))
5731
+ else {
5732
+ this.updateUserNotificationsCount();
5733
+ }
5734
+ }), switchMap((user) => (user.isGuest ? of() : this.interval$)))
5753
5735
  .subscribe();
5754
5736
  }
5755
5737
  /**
@@ -5850,7 +5832,7 @@ class ScNotificationsService {
5850
5832
  setNotificationsChange(notifications) {
5851
5833
  this.notifications$.next(notifications);
5852
5834
  }
5853
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScNotificationsService, deps: [{ token: i1$1.HttpClient }, { token: ScAuthService }, { token: SC_URLS }, { token: SC_UPDATE_INTERVAL }], target: i0.ɵɵFactoryTarget.Injectable }); }
5835
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScNotificationsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
5854
5836
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScNotificationsService, providedIn: 'root' }); }
5855
5837
  }
5856
5838
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScNotificationsService, decorators: [{
@@ -5858,13 +5840,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
5858
5840
  args: [{
5859
5841
  providedIn: 'root',
5860
5842
  }]
5861
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: ScAuthService }, { type: undefined, decorators: [{
5862
- type: Inject,
5863
- args: [SC_URLS]
5864
- }] }, { type: undefined, decorators: [{
5865
- type: Inject,
5866
- args: [SC_UPDATE_INTERVAL]
5867
- }] }] });
5843
+ }], ctorParameters: () => [] });
5868
5844
 
5869
5845
  /**
5870
5846
  * Модель данных о бесплатной доставке.
@@ -6109,29 +6085,43 @@ class ScOrderShort {
6109
6085
  }
6110
6086
  }
6111
6087
 
6088
+ /* eslint-disable no-param-reassign */
6112
6089
  /**
6113
6090
  * Сервис для работы с заказами.
6114
6091
  */
6115
6092
  class ScOrdersService {
6116
6093
  /**
6117
6094
  * Инициализирует экземпляр класса {@link ScOrdersService}.
6118
- *
6119
- * @param http Сервис для выполнения HTTP-запросов.
6120
- * @param authService Сервис аутентификации.
6121
- * @param urls Список ссылок на разделы backend.
6122
- * @param updateInterval Интервалы обновления данных.
6123
- * @param cartService Сервис для работы с корзиной.
6124
- * @param uiService Сервис для работы с UI.
6125
- * @param userMetrikaService Сервис для сбора метрик о действиях пользователей.
6126
6095
  */
6127
- constructor(http, authService, urls, updateInterval, cartService, uiService, userMetrikaService) {
6128
- this.http = http;
6129
- this.authService = authService;
6130
- this.urls = urls;
6131
- this.updateInterval = updateInterval;
6132
- this.cartService = cartService;
6133
- this.uiService = uiService;
6134
- this.userMetrikaService = userMetrikaService;
6096
+ constructor() {
6097
+ /**
6098
+ * HTTP-клиент.
6099
+ */
6100
+ this.http = inject(HttpClient);
6101
+ /**
6102
+ * Список ссылок приложения.
6103
+ */
6104
+ this.urls = inject(SC_URLS);
6105
+ /**
6106
+ * {@link Observable} данных о текущем пользователе.
6107
+ */
6108
+ this.user$ = inject(SC_USER_INFO);
6109
+ /**
6110
+ * Интервалы обновления данных.
6111
+ */
6112
+ this.updateInterval = inject(SC_UPDATE_INTERVAL);
6113
+ /**
6114
+ * Сервис для работы с корзиной.
6115
+ */
6116
+ this.cartService = inject(ScCartService);
6117
+ /**
6118
+ * Сервис для работы с UI.
6119
+ */
6120
+ this.uiService = inject(ScUIService);
6121
+ /**
6122
+ * Сервис для сбора метрик о действиях пользователей.
6123
+ */
6124
+ this.userMetrikaService = inject(ScUserMetrikaService);
6135
6125
  /**
6136
6126
  * Коллекция пар ключ-значение для заказов пользователя.
6137
6127
  */
@@ -6140,10 +6130,7 @@ class ScOrdersService {
6140
6130
  * Формат дат.
6141
6131
  */
6142
6132
  this.dateFormats = inject(SC_DATE_FORMAT);
6143
- authService
6144
- .getAuthChange()
6145
- .pipe(filter((state) => !state))
6146
- .subscribe(() => {
6133
+ this.user$.pipe(filter((user) => user.isGuest)).subscribe(() => {
6147
6134
  this.idOrderMap.clear();
6148
6135
  });
6149
6136
  }
@@ -6293,7 +6280,7 @@ class ScOrdersService {
6293
6280
  return new ScDeliveryCost(ordersPaginateDTO, formattedDate);
6294
6281
  }));
6295
6282
  }
6296
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScOrdersService, deps: [{ token: i1$1.HttpClient }, { token: ScAuthService }, { token: SC_URLS }, { token: SC_UPDATE_INTERVAL }, { token: ScCartService }, { token: ScUIService }, { token: ScUserMetrikaService }], target: i0.ɵɵFactoryTarget.Injectable }); }
6283
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScOrdersService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
6297
6284
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScOrdersService, providedIn: 'root' }); }
6298
6285
  }
6299
6286
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScOrdersService, decorators: [{
@@ -6301,13 +6288,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
6301
6288
  args: [{
6302
6289
  providedIn: 'root',
6303
6290
  }]
6304
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: ScAuthService }, { type: undefined, decorators: [{
6305
- type: Inject,
6306
- args: [SC_URLS]
6307
- }] }, { type: undefined, decorators: [{
6308
- type: Inject,
6309
- args: [SC_UPDATE_INTERVAL]
6310
- }] }, { type: ScCartService }, { type: ScUIService }, { type: ScUserMetrikaService }] });
6291
+ }], ctorParameters: () => [] });
6311
6292
 
6312
6293
  /**
6313
6294
  * Сервис пагинации.
@@ -6332,7 +6313,7 @@ class ScPaginationService {
6332
6313
  /**
6333
6314
  * {@link Observable} изменения статуса аутентификации.
6334
6315
  */
6335
- this.authStatus$ = inject(ScAuthService).getAuthChange();
6316
+ this.authStatus$ = inject(SC_USER_INFO).pipe(map((user) => user.isGuest));
6336
6317
  /**
6337
6318
  * Сервис работы с каталогом.
6338
6319
  */
@@ -6484,25 +6465,29 @@ var ScQuestionnaireStatusEnum;
6484
6465
  * Сервис для работы с опросниками.
6485
6466
  */
6486
6467
  class ScQuestionnaireService {
6487
- /**
6488
- * Инициализирует экземпляр класса {@link ScQuestionnaireService}.
6489
- *
6490
- * @param http HTTP-клиент.
6491
- * @param urls Список ссылок на разделы backend'a.
6492
- * @param authService Сервис аутентификации.
6493
- * @param userMetrikaService Сервис для сбора метрик о действиях пользователей.
6494
- */
6495
- constructor(http, urls, authService, userMetrikaService) {
6496
- this.http = http;
6497
- this.urls = urls;
6498
- this.authService = authService;
6499
- this.userMetrikaService = userMetrikaService;
6468
+ constructor() {
6469
+ /**
6470
+ * HTTP-клиент.
6471
+ */
6472
+ this.http = inject(HttpClient);
6473
+ /**
6474
+ * Список ссылок приложения.
6475
+ */
6476
+ this.urls = inject(SC_URLS);
6477
+ /**
6478
+ * {@link Observable} данных о текущем пользователе.
6479
+ */
6480
+ this.user$ = inject(SC_USER_INFO);
6481
+ /**
6482
+ * Сервис для сбора метрик о действиях пользователей.
6483
+ */
6484
+ this.userMetrikaService = inject(ScUserMetrikaService);
6500
6485
  }
6501
6486
  /**
6502
6487
  * Выполняет запрос получения списка опросников.
6503
6488
  */
6504
6489
  getQuestionnaires$() {
6505
- return this.authService.getAuthChange().pipe(switchMap((auth) => (auth ? this.http.get(`${this.urls.apiUrl}/questionnaires`) : of([]))));
6490
+ return this.user$.pipe(switchMap((user) => (user.isGuest ? of([]) : this.http.get(`${this.urls.apiUrl}/questionnaires`))));
6506
6491
  }
6507
6492
  /**
6508
6493
  * Выполняет запрос получения списка вопросов опросника.
@@ -6540,7 +6525,7 @@ class ScQuestionnaireService {
6540
6525
  // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
6541
6526
  return this.http.get(`${this.urls.apiUrl}/questionnaires/${questionnaire.id}/statuses/${status}`);
6542
6527
  }
6543
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScQuestionnaireService, deps: [{ token: i1$1.HttpClient }, { token: SC_URLS }, { token: ScAuthService }, { token: ScUserMetrikaService }], target: i0.ɵɵFactoryTarget.Injectable }); }
6528
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScQuestionnaireService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
6544
6529
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScQuestionnaireService, providedIn: 'root' }); }
6545
6530
  }
6546
6531
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScQuestionnaireService, decorators: [{
@@ -6548,10 +6533,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
6548
6533
  args: [{
6549
6534
  providedIn: 'root',
6550
6535
  }]
6551
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
6552
- type: Inject,
6553
- args: [SC_URLS]
6554
- }] }, { type: ScAuthService }, { type: ScUserMetrikaService }] });
6536
+ }] });
6555
6537
 
6556
6538
  /**
6557
6539
  * Сервис для работы с рекламациями.
@@ -7310,5 +7292,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
7310
7292
  * Generated bundle index. Do not edit.
7311
7293
  */
7312
7294
 
7313
- export { EMPTY_CART, IS_BROWSER, IS_RUNNING_ON_TERMINAL, IS_SERVER, RESPONSE, SC_ACCESS_AUTH_TOKEN_STORAGE_KEY, SC_API_KEYS, SC_AUTH_ADD_HEADER_REQUIRED, SC_AUTH_AS_CLIENT_DEFAULT_OPTIONS, SC_AUTH_AS_CLIENT_OPTIONS, SC_CACHE_LIFETIME, SC_CACHE_SETTINGS, SC_COMPANY_NAME, SC_CONFIGURATOR_COMPONENTS, SC_CONFIGURATOR_SETTINGS, SC_COUNT_FIRST_DISCOUNTED_PRODUCTS, SC_COUNT_LAST_NEWS, SC_DATE_FORMAT, SC_DEFAULT_PAGE_META, SC_FEEDBACK_API, SC_GUEST_ENDPOINTS_TOKEN, SC_GUEST_PARAMETER_NAME_TOKEN, SC_GUEST_TOKEN_STORAGE_KEY, SC_ID_OR_SLUG_IN_ROUTE, SC_IS_HEADER_REQUIRED, SC_IS_HIDDEN_ERROR_ALERT, SC_IS_HIDDEN_ERROR_ALERT_HTTP_CONTEXT, SC_IS_LOGOUT_REQUEST, SC_IS_REFRESH_REQUIRED, SC_LINEAR_VALUES, SC_LINEAR_VALUES_TOKEN, SC_MAX_LENGTH_SEARCH_TERM, SC_MIN_LENGTH_SEARCH_TERM, SC_NEXT_PAGE_PAGINATION_CLICK, SC_PATH_IMAGE_NOT_FOUND, SC_PRODUCT_PAGINATION_DEFAULT_OPTIONS, SC_PRODUCT_PAGINATION_OPTIONS, SC_REFRESH_AUTH_TOKEN_STORAGE_KEY, SC_RELEASE, SC_UPDATE_INTERVAL, SC_URLS, SC_VACANCIES_DATA_SOURCE, SC_VIRTUAL_CATEGORY_INFO, SC_VIRTUAL_CATEGORY_PROVIDERS, SEARCH_TERM, SEARCH_TERM_PROVIDERS, ScAuthAsClientGuard, ScAuthInterceptor, ScAuthService, ScBanner, ScBannerService, ScCacheInterceptor, ScCacheSettings, ScCachedData, ScCachedItem, ScCart, ScCartItem, ScCartService, ScCatalogFormat, ScCatalogService, ScCategory, ScClientType, ScConfiguratorService, ScContactsService, ScContragentService, ScConvertInterceptor, ScConvertersService, ScDateFormatInterceptor, ScDeliveryAddressService, ScDeliveryCost, ScDeliveryType, ScDocumentInfoNode, ScDocumentInfoTypesEnum, ScErrorsInterceptor, ScFavoriteService, ScFeedbackForms, ScFeedbackService, ScFilesService, ScFrequentlyAskedQuestionsService, ScGuestInterceptor, ScISalesDirectionCart, ScISuggestionType, ScIconTypesEnum, ScIdOrSlugGuard, ScIdOrSlugPipe, ScImage, ScImageHelper, ScJsonLdComponent, ScJsonLdModule, ScLocationsService, ScMediaImageTransformerPipe, ScMimeTypes, ScNews, ScNewsService, ScNotificationActionTypes, ScNotificationLevelNames, ScNotificationsService, ScOpfList, ScOptionsInterceptor, ScOrder, ScOrderShort, ScOrderStateStatus, ScOrdersService, ScPaginationService, ScPaymentStatus, ScPaymentType, ScPhoneService, ScProduct, ScProductTileType, ScQuestionnaireService, ScQuestionnaireStatusEnum, ScReclamationService, ScReclamationStatus, ScRecommendationService, ScReferenceName, ScReferencesService, ScRequisitesService, ScSearchService, ScSeoResource, ScSeoService, ScSocialType, ScSuggestionService, ScSum, ScTokenService, ScUIService, ScUTMService, ScUnitsHelper, ScUploadedFile, ScUser, ScUserMetadata, ScUserMetrikaGoalsEnum, ScUserMetrikaService, ScUserService, ScUserType, ScVCardService, ScVacanciesList, ScVacanciesService, ScVacancy, ScVerificationService, ScVirtualCategory, ScWarehouseService, TERMINAL_PROVIDERS, USER_AGENT_TERMINAL, filterChangedByKey, runningOnTerminalFactory, searchTermFactory };
7295
+ export { EMPTY_CART, IS_BROWSER, IS_RUNNING_ON_TERMINAL, IS_SERVER, RESPONSE, SC_ACCESS_AUTH_TOKEN_STORAGE_KEY, SC_API_KEYS, SC_AUTH_ADD_HEADER_REQUIRED, SC_AUTH_AS_CLIENT_DEFAULT_OPTIONS, SC_AUTH_AS_CLIENT_OPTIONS, SC_CACHE_LIFETIME, SC_CACHE_SETTINGS, SC_COMPANY_NAME, SC_CONFIGURATOR_COMPONENTS, SC_CONFIGURATOR_SETTINGS, SC_COUNT_FIRST_DISCOUNTED_PRODUCTS, SC_COUNT_LAST_NEWS, SC_DATE_FORMAT, SC_DEFAULT_PAGE_META, SC_FEEDBACK_API, SC_GUEST_ENDPOINTS_TOKEN, SC_GUEST_PARAMETER_NAME_TOKEN, SC_GUEST_TOKEN_STORAGE_KEY, SC_ID_OR_SLUG_IN_ROUTE, SC_IS_HEADER_REQUIRED, SC_IS_HIDDEN_ERROR_ALERT, SC_IS_HIDDEN_ERROR_ALERT_HTTP_CONTEXT, SC_IS_LOGOUT_REQUEST, SC_IS_REFRESH_REQUIRED, SC_LINEAR_VALUES, SC_LINEAR_VALUES_TOKEN, SC_MAX_LENGTH_SEARCH_TERM, SC_MIN_LENGTH_SEARCH_TERM, SC_NEXT_PAGE_PAGINATION_CLICK, SC_PATH_IMAGE_NOT_FOUND, SC_PRODUCT_PAGINATION_DEFAULT_OPTIONS, SC_PRODUCT_PAGINATION_OPTIONS, SC_REFRESH_AUTH_TOKEN_STORAGE_KEY, SC_RELEASE, SC_UPDATE_INTERVAL, SC_URLS, SC_USER_INFO, SC_VACANCIES_DATA_SOURCE, SC_VIRTUAL_CATEGORY_INFO, SC_VIRTUAL_CATEGORY_PROVIDERS, SEARCH_TERM, SEARCH_TERM_PROVIDERS, ScAuthAsClientGuard, ScAuthInterceptor, ScAuthService, ScBanner, ScBannerService, ScCacheInterceptor, ScCacheSettings, ScCachedData, ScCachedItem, ScCart, ScCartItem, ScCartService, ScCatalogFormat, ScCatalogService, ScCategory, ScClientType, ScConfiguratorService, ScContactsService, ScContragentService, ScConvertInterceptor, ScConvertersService, ScDateFormatInterceptor, ScDeliveryAddressService, ScDeliveryCost, ScDeliveryType, ScDocumentInfoNode, ScDocumentInfoTypesEnum, ScErrorsInterceptor, ScFavoriteService, ScFeedbackForms, ScFeedbackService, ScFilesService, ScFrequentlyAskedQuestionsService, ScGuestInterceptor, ScISalesDirectionCart, ScISuggestionType, ScIconTypesEnum, ScIdOrSlugGuard, ScIdOrSlugPipe, ScImage, ScImageHelper, ScJsonLdComponent, ScJsonLdModule, ScLocationsService, ScMediaImageTransformerPipe, ScMimeTypes, ScNews, ScNewsService, ScNotificationActionTypes, ScNotificationLevelNames, ScNotificationsService, ScOpfList, ScOptionsInterceptor, ScOrder, ScOrderShort, ScOrderStateStatus, ScOrdersService, ScPaginationService, ScPaymentStatus, ScPaymentType, ScPhoneService, ScProduct, ScProductTileType, ScQuestionnaireService, ScQuestionnaireStatusEnum, ScReclamationService, ScReclamationStatus, ScRecommendationService, ScReferenceName, ScReferencesService, ScRequisitesService, ScSearchService, ScSeoResource, ScSeoService, ScSocialType, ScSuggestionService, ScSum, ScTokenService, ScUIService, ScUTMService, ScUnitsHelper, ScUploadedFile, ScUser, ScUserMetadata, ScUserMetrikaGoalsEnum, ScUserMetrikaService, ScUserService, ScUserType, ScVCardService, ScVacanciesList, ScVacanciesService, ScVacancy, ScVerificationService, ScVirtualCategory, ScWarehouseService, TERMINAL_PROVIDERS, USER_AGENT_TERMINAL, filterChangedByKey, runningOnTerminalFactory, searchTermFactory };
7314
7296
  //# sourceMappingURL=snabcentr-client-core.mjs.map