@snabcentr/client-core 2.56.1 → 2.56.3

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 -10
  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 -19
  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 +802 -823
  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 +1 -5
  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,19 +2931,16 @@ class ScCatalogService {
3056
2931
  * {@link Observable} изменения общего колличества товара со скидкой.
3057
2932
  */
3058
2933
  this.countDiscountedProducts$ = this.firstDiscounted$.pipe(map((data) => data?.meta.total ?? 0));
3059
- /**
3060
- * Список ранее заказанных товаров текущего пользователя.
3061
- *
3062
- * @deprecated Удалить в рамках задачи TASK[#10155].
3063
- */
3064
- this.currentUserPreviouslyOrdered = new ScCachedItem(this.cacheLifeTime.previouslyOrderedData, this.authService.getAuthChange().pipe(filter((state) => state), switchMap(() => this.http.get(`${this.urls.apiUrl}/catalog/products/previously-ordered`).pipe(map((product) => product.map((item, index) => new ScProduct(item, index))), startWith(null)))));
3065
- this.authService
3066
- .getAuthChange()
2934
+ this.userService
2935
+ .getUserChange$()
3067
2936
  .pipe(skip(1))
3068
2937
  .subscribe(() => {
3069
2938
  this.idCategoryMap.clear();
3070
2939
  this.categoryMap.clear();
3071
2940
  this.productHistoryMap.clear();
2941
+ this.productMap.clear();
2942
+ this.categoryProductsMap.clear();
2943
+ this.virtualCategoryMap.clear();
3072
2944
  });
3073
2945
  }
3074
2946
  /**
@@ -3288,7 +3160,7 @@ class ScCatalogService {
3288
3160
  getProductNotifyWhenInStock$(productIdOrSlug, data) {
3289
3161
  return this.http.post(`${this.urls.apiUrl}/catalog/products/${productIdOrSlug}/stock-notify`, data);
3290
3162
  }
3291
- 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 }); }
3292
3164
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScCatalogService, providedIn: 'root' }); }
3293
3165
  }
3294
3166
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScCatalogService, decorators: [{
@@ -3299,37 +3171,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
3299
3171
  }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
3300
3172
  type: Inject,
3301
3173
  args: [SC_URLS]
3302
- }] }, { type: ScUIService }, { type: ScConvertersService }, { type: ScAuthService }, { type: undefined, decorators: [{
3174
+ }] }, { type: ScUIService }, { type: ScConvertersService }, { type: undefined, decorators: [{
3303
3175
  type: Inject,
3304
3176
  args: [SC_CACHE_LIFETIME]
3305
3177
  }] }, { type: ScUserMetrikaService }] });
3306
3178
 
3179
+ /* eslint-disable no-param-reassign,no-return-assign,no-void */
3307
3180
  /**
3308
3181
  * Сервис для работы с избранными товарами и категориями.
3309
3182
  */
3310
3183
  class ScFavoriteService {
3311
- /**
3312
- * Инициализирует экземпляр класса {@link ScFavoriteService}.
3313
- *
3314
- * @param http Сервис для выполнения HTTP-запросов.
3315
- * @param urls Список ссылок на разделы backend'a.
3316
- * @param catalogService Сервис для работы с каталогом.
3317
- * @param authService Сервис аутентификации.
3318
- */
3319
- constructor(http, urls, catalogService, authService) {
3320
- this.http = http;
3321
- this.urls = urls;
3322
- this.catalogService = catalogService;
3323
- this.authService = authService;
3184
+ constructor() {
3185
+ /**
3186
+ * HTTP-клиент.
3187
+ */
3188
+ this.http = inject(HttpClient);
3189
+ /**
3190
+ * Список ссылок приложения.
3191
+ */
3192
+ this.urls = inject(SC_URLS);
3324
3193
  /**
3325
3194
  * {@link BehaviorSubject} обновления списка избранных категорий.
3326
3195
  */
3327
- // eslint-disable-next-line sonarjs/void-use
3328
3196
  this.categoriesUpdateSubject = new BehaviorSubject(void {});
3197
+ /**
3198
+ * Сервис данных о пользователе.
3199
+ */
3200
+ this.user$ = inject(SC_USER_INFO);
3329
3201
  /**
3330
3202
  * {@link Observable} списка избранных категорий.
3331
3203
  */
3332
- 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) // Подогреваем запрос во избежание повторения запросов получения списка избранных категорий для новых подписчиков.
3333
3205
  );
3334
3206
  }
3335
3207
  /**
@@ -3378,7 +3250,7 @@ class ScFavoriteService {
3378
3250
  deleteProduct$(productId) {
3379
3251
  return this.http.delete(`${this.urls.apiUrl}/favorites/products/${productId}`);
3380
3252
  }
3381
- 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 }); }
3382
3254
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScFavoriteService, providedIn: 'root' }); }
3383
3255
  }
3384
3256
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScFavoriteService, decorators: [{
@@ -3386,10 +3258,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
3386
3258
  args: [{
3387
3259
  providedIn: 'root',
3388
3260
  }]
3389
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
3390
- type: Inject,
3391
- args: [SC_URLS]
3392
- }] }, { type: ScCatalogService }, { type: ScAuthService }] });
3261
+ }] });
3393
3262
 
3394
3263
  /**
3395
3264
  * Сервис для работы с рекомендуемыми товарами.
@@ -3397,19 +3266,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
3397
3266
  class ScRecommendationService {
3398
3267
  /**
3399
3268
  * Инициализирует экземпляр класса {@link ScRecommendationService}.
3400
- *
3401
- * @param http Сервис для выполнения HTTP-запросов.
3402
- * @param urls Список ссылок на разделы backend'a.
3403
- * @param convertersService Сервис конвертации данных.
3404
- * @param cartService Сервис для работы с корзиной.
3405
- * @param authService Сервис аутентификации.
3406
3269
  */
3407
- constructor(http, urls, convertersService, cartService, authService) {
3408
- this.http = http;
3409
- this.urls = urls;
3410
- this.convertersService = convertersService;
3411
- this.cartService = cartService;
3412
- this.authService = authService;
3270
+ constructor() {
3413
3271
  /**
3414
3272
  * {@link Map} коллекция пар ключ-значение для кэшированных рекомендуемых товаров категории.
3415
3273
  */
@@ -3418,8 +3276,23 @@ class ScRecommendationService {
3418
3276
  * {@link Map} коллекция пар ключ-значение для кэшированных рекомендуемых товаров товара.
3419
3277
  */
3420
3278
  this.productsByProductMap = new Map();
3421
- this.authService
3422
- .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)
3423
3296
  .pipe(skip(1))
3424
3297
  .subscribe(() => {
3425
3298
  this.productsByCategoryMap.clear();
@@ -3484,7 +3357,7 @@ class ScRecommendationService {
3484
3357
  // eslint-disable-next-line sonarjs/no-misleading-array-reverse
3485
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))));
3486
3359
  }
3487
- 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 }); }
3488
3361
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScRecommendationService, providedIn: 'root' }); }
3489
3362
  }
3490
3363
  __decorate([
@@ -3495,10 +3368,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
3495
3368
  args: [{
3496
3369
  providedIn: 'root',
3497
3370
  }]
3498
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
3499
- type: Inject,
3500
- args: [SC_URLS]
3501
- }] }, { type: ScConvertersService }, { type: ScCartService }, { type: ScAuthService }], propDecorators: { getProductsByCart$: [] } });
3371
+ }], ctorParameters: () => [], propDecorators: { getProductsByCart$: [] } });
3502
3372
 
3503
3373
  /**
3504
3374
  * Сервис для работы с конфигуратором.
@@ -3647,30 +3517,132 @@ var ScSocialType;
3647
3517
  */
3648
3518
  ScSocialType["ok"] = "ok";
3649
3519
  /**
3650
- * @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 Данные требуемые для создания контактного лица.
3651
3609
  */
3652
- 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
+ }
3653
3615
  /**
3654
- * @see Контакте](https://vk.com/)
3616
+ * Создаёт запрос удаления контактного лица пользователя.
3617
+ *
3618
+ * @param contactId Идентификатор контакта пользователя.
3655
3619
  */
3656
- ScSocialType["vk"] = "vk";
3657
- })(ScSocialType || (ScSocialType = {}));
3658
-
3659
- /**
3660
- * Модель данных для загружаемого файла.
3661
- */
3662
- class ScUploadedFile {
3620
+ deleteContact$(contactId) {
3621
+ return this.http.delete(`${this.urls.apiUrl}/user/contacts/${contactId}`).pipe(tap(() => {
3622
+ this.allContacts.update();
3623
+ }));
3624
+ }
3663
3625
  /**
3664
- * Инициализирует экземпляр класса {@link ScUploadedFile}.
3626
+ * Содаёт запрос на получение списка контактов для помощи клиенту.
3665
3627
  *
3666
- * @param name Название загружаемого пользователем файла.
3667
- * @param content Содержимое файла кодированное в base64.
3628
+ * @param params Параметры поиска контактов (телефон или ID города).
3629
+ * @param params.phone Телефон клиента.
3630
+ * @param params.cityId ID города.
3668
3631
  */
3669
- constructor(name, content) {
3670
- this.name = name;
3671
- this.content = content;
3632
+ getHelpContacts$(params) {
3633
+ return this.http.get(`${this.urls.apiUrl}/contacts/help`, {
3634
+ params: params,
3635
+ });
3672
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' }); }
3673
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
+ }] });
3674
3646
 
3675
3647
  /**
3676
3648
  * Токен, указывающий на необходимость добавления заголовков в исходящие запросы.
@@ -3885,10 +3857,6 @@ class ScUTMService {
3885
3857
  * Сервис для выполнения HTTP-запросов.
3886
3858
  */
3887
3859
  this.http = inject(HttpClient);
3888
- /**
3889
- * Сервис аутентификации пользователей.
3890
- */
3891
- this.authService = inject(ScAuthService);
3892
3860
  /**
3893
3861
  * Сервис предоставляющий доступ к данным о маршруте.
3894
3862
  */
@@ -3936,8 +3904,7 @@ class ScUTMService {
3936
3904
  };
3937
3905
  }));
3938
3906
  // При получении UTM-метки сохраняем ее в Storage и создаём запрос сохранения метки за клиентом.
3939
- this.authService
3940
- .getAuthChange()
3907
+ inject(SC_USER_INFO)
3941
3908
  .pipe(switchMap(() => this.utmParamsFromRoute$), tap(() => {
3942
3909
  this.updateTimestamp();
3943
3910
  }), filter((utm) => !this.isExistingUTM(utm)), tap((utm) => {
@@ -4108,7 +4075,7 @@ class ScRequisitesService {
4108
4075
  /**
4109
4076
  * Создаёт запрос получения списка всех контактов.
4110
4077
  */
4111
- 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));
4112
4079
  /**
4113
4080
  * Создаёт запрос получения списка контактов для решения возникающих вопросов.
4114
4081
  */
@@ -4223,18 +4190,28 @@ class ScContragentService {
4223
4190
  /**
4224
4191
  * Инициализирует экземпляр класса {@link ScContragentService}.
4225
4192
  *
4226
- * @param http HTTP-клиент.
4227
- * @param urls Список ссылок на разделы backend'a.
4228
- * @param authService Сервис аутентификации.
4229
- * @param userMetrikaService Сервис для сбора метрик о действиях пользователей.
4230
- * @param contactsService Сервис для работы с контактными лицами.
4231
4193
  */
4232
- constructor(http, urls, authService, userMetrikaService, contactsService) {
4233
- this.http = http;
4234
- this.urls = urls;
4235
- this.authService = authService;
4236
- this.userMetrikaService = userMetrikaService;
4237
- 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);
4238
4215
  /**
4239
4216
  * {@link BehaviorSubject} обновления контрагентов.
4240
4217
  */
@@ -4246,11 +4223,8 @@ class ScContragentService {
4246
4223
  /**
4247
4224
  * {@link Observable} данных о контрагентах пользователя.
4248
4225
  */
4249
- 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));
4250
- authService
4251
- .getAuthChange()
4252
- .pipe(filter((state) => !state))
4253
- .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(() => {
4254
4228
  this.contactsService.contragentContactsMap.clear();
4255
4229
  this.contragentBankAccountsMap.clear();
4256
4230
  });
@@ -4355,7 +4329,7 @@ class ScContragentService {
4355
4329
  .delete(`${this.urls.apiUrl}/user/contragents/${contragentId}/bank-accounts/${bankAccountId}`)
4356
4330
  .pipe(tap(() => this.contragentBankAccountsMap.get(contragentId)?.update()));
4357
4331
  }
4358
- 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 }); }
4359
4333
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScContragentService, providedIn: 'root' }); }
4360
4334
  }
4361
4335
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScContragentService, decorators: [{
@@ -4363,30 +4337,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
4363
4337
  args: [{
4364
4338
  providedIn: 'root',
4365
4339
  }]
4366
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
4367
- type: Inject,
4368
- args: [SC_URLS]
4369
- }] }, { type: ScAuthService }, { type: ScUserMetrikaService }, { type: ScContactsService }] });
4340
+ }], ctorParameters: () => [] });
4370
4341
 
4371
4342
  /**
4372
4343
  * Сервис работы с адресами доставки.
4373
4344
  */
4374
4345
  class ScDeliveryAddressService {
4375
- /**
4376
- * Инициализирует экземпляр класса {@link ScDeliveryAddressService}.
4377
- *
4378
- * @param http HTTP-клиент.
4379
- * @param urls Список ссылок на разделы backend'a.
4380
- * @param authService Сервис аутентификации.
4381
- * @param userMetrikaService Сервис для сбора метрик о действиях пользователей.
4382
- * @param contactsService Сервис для работы с контактными лицами.
4383
- */
4384
- constructor(http, urls, authService, userMetrikaService, contactsService) {
4385
- this.http = http;
4386
- this.urls = urls;
4387
- this.authService = authService;
4388
- this.userMetrikaService = userMetrikaService;
4389
- 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);
4390
4367
  /**
4391
4368
  * {@link BehaviorSubject} обновление адресов доставки.
4392
4369
  */
@@ -4394,7 +4371,7 @@ class ScDeliveryAddressService {
4394
4371
  /**
4395
4372
  * {@link Observable} данных адресов доставки.
4396
4373
  */
4397
- 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));
4398
4375
  }
4399
4376
  /**
4400
4377
  * Создаёт запрос создания нового адреса доставки.
@@ -4460,7 +4437,7 @@ class ScDeliveryAddressService {
4460
4437
  deleteDeliveryAddressContact$(addressId, contactId) {
4461
4438
  return this.contactsService.deleteContact$(contactId).pipe(tap(() => this.contactsService.deliveryAddressContactsMap.get(addressId)?.update()));
4462
4439
  }
4463
- 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 }); }
4464
4441
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScDeliveryAddressService, providedIn: 'root' }); }
4465
4442
  }
4466
4443
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScDeliveryAddressService, decorators: [{
@@ -4468,10 +4445,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
4468
4445
  args: [{
4469
4446
  providedIn: 'root',
4470
4447
  }]
4471
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
4472
- type: Inject,
4473
- args: [SC_URLS]
4474
- }] }, { type: ScAuthService }, { type: ScUserMetrikaService }, { type: ScContactsService }] });
4448
+ }] });
4475
4449
 
4476
4450
  /**
4477
4451
  * Сервис для работы с часто задаваемыми вопросами (FAQ).
@@ -5214,7 +5188,7 @@ class ScGuestInterceptor {
5214
5188
  /**
5215
5189
  * Сервис аутентификации пользователей.
5216
5190
  */
5217
- this.authService = inject(ScAuthService);
5191
+ this.user$ = inject(SC_USER_INFO);
5218
5192
  }
5219
5193
  /** @inheritDoc */
5220
5194
  intercept(request, next) {
@@ -5222,7 +5196,7 @@ class ScGuestInterceptor {
5222
5196
  if (!isGuestEndpoint) {
5223
5197
  return next.handle(request);
5224
5198
  }
5225
- 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))));
5226
5200
  }
5227
5201
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScGuestInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
5228
5202
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScGuestInterceptor }); }
@@ -5603,23 +5577,27 @@ const SC_COUNT_LAST_NEWS = new InjectionToken('countLasNews', {
5603
5577
  * Сервис для получения списка новостей.
5604
5578
  */
5605
5579
  class ScNewsService {
5606
- /**
5607
- * Инициализирует экземпляр класса {@link ScNewsService}.
5608
- *
5609
- * @param http HTTP-клиент.
5610
- * @param urls Список ссылок на разделы backend.
5611
- * @param countLasNews число записей новостей отображаемых в "Последние новости".
5612
- * @param authService Сервис аутентификации.
5613
- */
5614
- constructor(http, urls, countLasNews, authService) {
5615
- this.http = http;
5616
- this.urls = urls;
5617
- this.countLasNews = countLasNews;
5618
- 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);
5619
5597
  /**
5620
5598
  * {@link Observable} получения списка последних новостей.
5621
5599
  */
5622
- 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 во избежание повторения запросов получения списка последних новостей.
5623
5601
  );
5624
5602
  }
5625
5603
  /**
@@ -5645,7 +5623,7 @@ class ScNewsService {
5645
5623
  getLastNewsList$() {
5646
5624
  return this.lastNewsList$;
5647
5625
  }
5648
- 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 }); }
5649
5627
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScNewsService, providedIn: 'root' }); }
5650
5628
  }
5651
5629
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScNewsService, decorators: [{
@@ -5653,13 +5631,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
5653
5631
  args: [{
5654
5632
  providedIn: 'root',
5655
5633
  }]
5656
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
5657
- type: Inject,
5658
- args: [SC_URLS]
5659
- }] }, { type: undefined, decorators: [{
5660
- type: Inject,
5661
- args: [SC_COUNT_LAST_NEWS]
5662
- }] }, { type: ScAuthService }] });
5634
+ }] });
5663
5635
 
5664
5636
  /*
5665
5637
  * Публичное API библиотеки бизнес-логики.
@@ -5717,16 +5689,24 @@ class ScNotificationsService {
5717
5689
  /**
5718
5690
  * Инициализирует экземпляр класса {@link ScNotificationsService}.
5719
5691
  *
5720
- * @param http Сервис для выполнения HTTP-запросов.
5721
- * @param authService Сервис аутентификации.
5722
- * @param urls Список ссылок на разделы backend.
5723
- * @param updateInterval Интервалы обновления данных.
5724
5692
  */
5725
- constructor(http, authService, urls, updateInterval) {
5726
- this.http = http;
5727
- this.authService = authService;
5728
- this.urls = urls;
5729
- 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);
5730
5710
  /**
5731
5711
  * {@link ReplaySubject} данных о количестве уведомлений пользователя.
5732
5712
  */
@@ -5741,18 +5721,17 @@ class ScNotificationsService {
5741
5721
  this.interval$ = interval(this.updateInterval.notificationsUpdate).pipe(tap(() => {
5742
5722
  this.updateUserNotificationsCount();
5743
5723
  }));
5744
- this.authService
5745
- .getAuthChange()
5746
- .pipe(tap((state) => {
5724
+ this.user$
5725
+ .pipe(tap((user) => {
5747
5726
  // eslint-disable-next-line sonarjs/no-selector-parameter
5748
- if (state) {
5749
- this.updateUserNotificationsCount();
5750
- }
5751
- else {
5727
+ if (user.isGuest) {
5752
5728
  // eslint-disable-next-line unicorn/no-useless-undefined
5753
5729
  this.notificationsCount$.next(undefined);
5754
5730
  }
5755
- }), switchMap((state) => (state ? this.interval$ : of())))
5731
+ else {
5732
+ this.updateUserNotificationsCount();
5733
+ }
5734
+ }), switchMap((user) => (user.isGuest ? of() : this.interval$)))
5756
5735
  .subscribe();
5757
5736
  }
5758
5737
  /**
@@ -5853,7 +5832,7 @@ class ScNotificationsService {
5853
5832
  setNotificationsChange(notifications) {
5854
5833
  this.notifications$.next(notifications);
5855
5834
  }
5856
- 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 }); }
5857
5836
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScNotificationsService, providedIn: 'root' }); }
5858
5837
  }
5859
5838
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScNotificationsService, decorators: [{
@@ -5861,13 +5840,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
5861
5840
  args: [{
5862
5841
  providedIn: 'root',
5863
5842
  }]
5864
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: ScAuthService }, { type: undefined, decorators: [{
5865
- type: Inject,
5866
- args: [SC_URLS]
5867
- }] }, { type: undefined, decorators: [{
5868
- type: Inject,
5869
- args: [SC_UPDATE_INTERVAL]
5870
- }] }] });
5843
+ }], ctorParameters: () => [] });
5871
5844
 
5872
5845
  /**
5873
5846
  * Модель данных о бесплатной доставке.
@@ -6112,29 +6085,43 @@ class ScOrderShort {
6112
6085
  }
6113
6086
  }
6114
6087
 
6088
+ /* eslint-disable no-param-reassign */
6115
6089
  /**
6116
6090
  * Сервис для работы с заказами.
6117
6091
  */
6118
6092
  class ScOrdersService {
6119
6093
  /**
6120
6094
  * Инициализирует экземпляр класса {@link ScOrdersService}.
6121
- *
6122
- * @param http Сервис для выполнения HTTP-запросов.
6123
- * @param authService Сервис аутентификации.
6124
- * @param urls Список ссылок на разделы backend.
6125
- * @param updateInterval Интервалы обновления данных.
6126
- * @param cartService Сервис для работы с корзиной.
6127
- * @param uiService Сервис для работы с UI.
6128
- * @param userMetrikaService Сервис для сбора метрик о действиях пользователей.
6129
6095
  */
6130
- constructor(http, authService, urls, updateInterval, cartService, uiService, userMetrikaService) {
6131
- this.http = http;
6132
- this.authService = authService;
6133
- this.urls = urls;
6134
- this.updateInterval = updateInterval;
6135
- this.cartService = cartService;
6136
- this.uiService = uiService;
6137
- 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);
6138
6125
  /**
6139
6126
  * Коллекция пар ключ-значение для заказов пользователя.
6140
6127
  */
@@ -6143,10 +6130,7 @@ class ScOrdersService {
6143
6130
  * Формат дат.
6144
6131
  */
6145
6132
  this.dateFormats = inject(SC_DATE_FORMAT);
6146
- authService
6147
- .getAuthChange()
6148
- .pipe(filter((state) => !state))
6149
- .subscribe(() => {
6133
+ this.user$.pipe(filter((user) => user.isGuest)).subscribe(() => {
6150
6134
  this.idOrderMap.clear();
6151
6135
  });
6152
6136
  }
@@ -6296,7 +6280,7 @@ class ScOrdersService {
6296
6280
  return new ScDeliveryCost(ordersPaginateDTO, formattedDate);
6297
6281
  }));
6298
6282
  }
6299
- 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 }); }
6300
6284
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScOrdersService, providedIn: 'root' }); }
6301
6285
  }
6302
6286
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScOrdersService, decorators: [{
@@ -6304,13 +6288,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
6304
6288
  args: [{
6305
6289
  providedIn: 'root',
6306
6290
  }]
6307
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: ScAuthService }, { type: undefined, decorators: [{
6308
- type: Inject,
6309
- args: [SC_URLS]
6310
- }] }, { type: undefined, decorators: [{
6311
- type: Inject,
6312
- args: [SC_UPDATE_INTERVAL]
6313
- }] }, { type: ScCartService }, { type: ScUIService }, { type: ScUserMetrikaService }] });
6291
+ }], ctorParameters: () => [] });
6314
6292
 
6315
6293
  /**
6316
6294
  * Сервис пагинации.
@@ -6335,7 +6313,7 @@ class ScPaginationService {
6335
6313
  /**
6336
6314
  * {@link Observable} изменения статуса аутентификации.
6337
6315
  */
6338
- this.authStatus$ = inject(ScAuthService).getAuthChange();
6316
+ this.authStatus$ = inject(SC_USER_INFO).pipe(map((user) => user.isGuest));
6339
6317
  /**
6340
6318
  * Сервис работы с каталогом.
6341
6319
  */
@@ -6487,25 +6465,29 @@ var ScQuestionnaireStatusEnum;
6487
6465
  * Сервис для работы с опросниками.
6488
6466
  */
6489
6467
  class ScQuestionnaireService {
6490
- /**
6491
- * Инициализирует экземпляр класса {@link ScQuestionnaireService}.
6492
- *
6493
- * @param http HTTP-клиент.
6494
- * @param urls Список ссылок на разделы backend'a.
6495
- * @param authService Сервис аутентификации.
6496
- * @param userMetrikaService Сервис для сбора метрик о действиях пользователей.
6497
- */
6498
- constructor(http, urls, authService, userMetrikaService) {
6499
- this.http = http;
6500
- this.urls = urls;
6501
- this.authService = authService;
6502
- 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);
6503
6485
  }
6504
6486
  /**
6505
6487
  * Выполняет запрос получения списка опросников.
6506
6488
  */
6507
6489
  getQuestionnaires$() {
6508
- 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`))));
6509
6491
  }
6510
6492
  /**
6511
6493
  * Выполняет запрос получения списка вопросов опросника.
@@ -6543,7 +6525,7 @@ class ScQuestionnaireService {
6543
6525
  // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
6544
6526
  return this.http.get(`${this.urls.apiUrl}/questionnaires/${questionnaire.id}/statuses/${status}`);
6545
6527
  }
6546
- 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 }); }
6547
6529
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScQuestionnaireService, providedIn: 'root' }); }
6548
6530
  }
6549
6531
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: ScQuestionnaireService, decorators: [{
@@ -6551,10 +6533,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
6551
6533
  args: [{
6552
6534
  providedIn: 'root',
6553
6535
  }]
6554
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
6555
- type: Inject,
6556
- args: [SC_URLS]
6557
- }] }, { type: ScAuthService }, { type: ScUserMetrikaService }] });
6536
+ }] });
6558
6537
 
6559
6538
  /**
6560
6539
  * Сервис для работы с рекламациями.
@@ -7313,5 +7292,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
7313
7292
  * Generated bundle index. Do not edit.
7314
7293
  */
7315
7294
 
7316
- 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 };
7317
7296
  //# sourceMappingURL=snabcentr-client-core.mjs.map