@astral/features 3.50.0 → 3.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +1 -0
  3. package/package.json +2 -2
  4. package/productSwitcher/components/AstralProductSwitcher/AstralProductSwitcher.d.ts +12 -0
  5. package/productSwitcher/components/AstralProductSwitcher/AstralProductSwitcher.js +25 -0
  6. package/productSwitcher/components/AstralProductSwitcher/index.d.ts +1 -0
  7. package/productSwitcher/components/AstralProductSwitcher/index.js +1 -0
  8. package/productSwitcher/components/IdentityProductSwitcher/IdentityProductSwitcher.d.ts +8 -0
  9. package/productSwitcher/components/IdentityProductSwitcher/IdentityProductSwitcher.js +16 -0
  10. package/productSwitcher/components/IdentityProductSwitcher/hooks/index.d.ts +1 -0
  11. package/productSwitcher/components/IdentityProductSwitcher/hooks/index.js +1 -0
  12. package/productSwitcher/components/IdentityProductSwitcher/hooks/useLogic/index.d.ts +1 -0
  13. package/productSwitcher/components/IdentityProductSwitcher/hooks/useLogic/index.js +1 -0
  14. package/productSwitcher/components/IdentityProductSwitcher/hooks/useLogic/useLogic.d.ts +12 -0
  15. package/productSwitcher/components/IdentityProductSwitcher/hooks/useLogic/useLogic.js +63 -0
  16. package/productSwitcher/components/IdentityProductSwitcher/index.d.ts +1 -0
  17. package/productSwitcher/components/IdentityProductSwitcher/index.js +1 -0
  18. package/productSwitcher/components/IdentityProductSwitcher/styles.d.ts +20 -0
  19. package/productSwitcher/components/IdentityProductSwitcher/styles.js +42 -0
  20. package/productSwitcher/components/IdentityProductSwitcher/utils/getIdentityTenants/getIdentityTenants.d.ts +6 -0
  21. package/productSwitcher/components/IdentityProductSwitcher/utils/getIdentityTenants/getIdentityTenants.js +21 -0
  22. package/productSwitcher/components/IdentityProductSwitcher/utils/getIdentityTenants/index.d.ts +1 -0
  23. package/productSwitcher/components/IdentityProductSwitcher/utils/getIdentityTenants/index.js +1 -0
  24. package/productSwitcher/components/IdentityProductSwitcher/utils/getTenantsProducts/getTenantsProducts.d.ts +7 -0
  25. package/productSwitcher/components/IdentityProductSwitcher/utils/getTenantsProducts/getTenantsProducts.js +24 -0
  26. package/productSwitcher/components/IdentityProductSwitcher/utils/getTenantsProducts/index.d.ts +1 -0
  27. package/productSwitcher/components/IdentityProductSwitcher/utils/getTenantsProducts/index.js +1 -0
  28. package/productSwitcher/components/IdentityProductSwitcher/utils/index.d.ts +2 -0
  29. package/productSwitcher/components/IdentityProductSwitcher/utils/index.js +2 -0
  30. package/productSwitcher/components/index.d.ts +2 -0
  31. package/productSwitcher/components/index.js +2 -0
  32. package/productSwitcher/index.d.ts +1 -0
  33. package/productSwitcher/index.js +1 -0
  34. package/productSwitcher/types.d.ts +54 -0
  35. package/productSwitcher/types.js +1 -0
  36. package/productSwitcher/utils/formatIdentityProducts/formatIdentityProducts.d.ts +8 -0
  37. package/productSwitcher/utils/formatIdentityProducts/formatIdentityProducts.js +14 -0
  38. package/productSwitcher/utils/formatIdentityProducts/index.d.ts +1 -0
  39. package/productSwitcher/utils/formatIdentityProducts/index.js +1 -0
  40. package/productSwitcher/utils/getIdentityProducts/getIdentityProducts.d.ts +6 -0
  41. package/productSwitcher/utils/getIdentityProducts/getIdentityProducts.js +27 -0
  42. package/productSwitcher/utils/getIdentityProducts/index.d.ts +1 -0
  43. package/productSwitcher/utils/getIdentityProducts/index.js +1 -0
  44. package/productSwitcher/utils/index.d.ts +2 -0
  45. package/productSwitcher/utils/index.js +2 -0
package/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './cryproPro';
2
+ export { IdentityProductSwitcher, AstralProductSwitcher, } from './productSwitcher';
package/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export * from './cryproPro';
2
+ export { IdentityProductSwitcher, AstralProductSwitcher, } from './productSwitcher';
package/package.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@astral/features",
3
3
  "browser": "./index.js",
4
4
  "main": "./index.js",
5
- "version": "3.50.0",
5
+ "version": "3.51.0",
6
6
  "dependencies": {
7
- "@astral/ui": "^3.50.0",
7
+ "@astral/ui": "^3.51.0",
8
8
  "mobx": "^6.8.0",
9
9
  "mobx-react-lite": "^3.4.0",
10
10
  "@astral/cryptopro-cades": "^1.5.1"
@@ -0,0 +1,12 @@
1
+ export type AstralProductSwitcherType = {
2
+ /**
3
+ * Адрес identity
4
+ * */
5
+ identityUrl: string;
6
+ /**
7
+ * Идентификатор экосистемы
8
+ * @default astral
9
+ * */
10
+ tenantId?: string;
11
+ };
12
+ export declare const AstralProductSwitcher: ({ identityUrl, tenantId, }: AstralProductSwitcherType) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { ProductSwitcher } from '@astral/ui';
12
+ import { useState } from 'react';
13
+ import { getIdentityProducts } from '../../utils';
14
+ export const AstralProductSwitcher = ({ identityUrl, tenantId = 'astral', }) => {
15
+ const [products, setProducts] = useState([]);
16
+ const handleGetProducts = () => __awaiter(void 0, void 0, void 0, function* () {
17
+ if (!products.length) {
18
+ const productsList = yield getIdentityProducts(identityUrl, tenantId);
19
+ setProducts(productsList);
20
+ return productsList;
21
+ }
22
+ return products;
23
+ });
24
+ return _jsx(ProductSwitcher, { getProducts: handleGetProducts });
25
+ };
@@ -0,0 +1 @@
1
+ export * from './AstralProductSwitcher';
@@ -0,0 +1 @@
1
+ export * from './AstralProductSwitcher';
@@ -0,0 +1,8 @@
1
+ export declare const ASTRAL_IDENTITY_DEFAULT_TENANT = "astral";
2
+ export type IdentityProductSwitcherType = {
3
+ /**
4
+ * Адрес identity
5
+ * */
6
+ identityUrl: string;
7
+ };
8
+ export declare const IdentityProductSwitcher: ({ identityUrl, }: IdentityProductSwitcherType) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { ContentState, ErrorFillSm, IconButton, MenuGroup, ProductsFillMd, Typography, useMenu, } from '@astral/ui';
3
+ import { IdentityProductSwitcherErrorContainer, IdentityProductSwitcherItem, IdentityProductSwitcherLogo, IdentityProductSwitcherMenu, TenantToggleButton, TenantsToggleButtonGroup, } from './styles';
4
+ import { useLogic } from './hooks';
5
+ export const ASTRAL_IDENTITY_DEFAULT_TENANT = 'astral';
6
+ export const IdentityProductSwitcher = ({ identityUrl, }) => {
7
+ const { open, anchorRef, handleOpenMenu, handleCloseMenu } = useMenu();
8
+ const { isLoading, isError, tenantId, tenants, productList, handleChangeTenant, handleShowProducts, } = useLogic(identityUrl, handleOpenMenu);
9
+ return (_jsxs(_Fragment, { children: [_jsx(IconButton, { ref: anchorRef, selected: open, variant: "text", onClick: handleShowProducts, children: _jsx(ProductsFillMd, {}) }), _jsx(IdentityProductSwitcherMenu, { open: open, anchorEl: anchorRef.current, onClose: handleCloseMenu, children: _jsx(MenuGroup, { label: "\u041F\u0440\u043E\u0434\u0443\u043A\u0442\u044B \u044D\u043A\u043E\u0441\u0438\u0441\u0442\u0435\u043C\u044B", children: _jsxs(ContentState, { isLoading: isLoading, isCustom: isError, customState: {
10
+ imgAlt: 'Что-то пошло не так',
11
+ title: (_jsxs(IdentityProductSwitcherErrorContainer, { container: true, autoFlow: "column", alignItems: "center", justifyContent: "center", component: "span", children: [_jsx(ErrorFillSm, { color: "inherit" }), _jsx(Typography, { variant: "h6", color: "grey", colorIntensity: "900", children: "\u0427\u0442\u043E-\u0442\u043E \u043F\u043E\u0448\u043B\u043E \u043D\u0435 \u0442\u0430\u043A" })] })),
12
+ description: 'Произошла ошибка. Повторите попытку позже.',
13
+ }, children: [Boolean(tenants === null || tenants === void 0 ? void 0 : tenants.length) && (_jsx(TenantsToggleButtonGroup, { exclusive: true, onChange: handleChangeTenant, value: tenantId, children: tenants === null || tenants === void 0 ? void 0 : tenants.map(({ id, name }) => (_jsx(TenantToggleButton, { value: id, children: name }, id))) })), productList === null || productList === void 0 ? void 0 : productList.map((product) => {
14
+ return (_jsx("li", { children: _jsxs(IdentityProductSwitcherItem, { component: "a", href: product.url, children: [_jsx(IdentityProductSwitcherLogo, { src: product.logoUrl, color: product.color }), _jsx(Typography, { variant: "ui", color: "grey", colorIntensity: "900", children: product.name })] }) }, product.id));
15
+ })] }) }) })] }));
16
+ };
@@ -0,0 +1 @@
1
+ export { useLogic } from './useLogic';
@@ -0,0 +1 @@
1
+ export { useLogic } from './useLogic';
@@ -0,0 +1 @@
1
+ export * from './useLogic';
@@ -0,0 +1 @@
1
+ export * from './useLogic';
@@ -0,0 +1,12 @@
1
+ import { MouseEvent } from 'react';
2
+ import { WidgetProduct } from '@astral/ui';
3
+ import { IdentityTenantsDTO } from '../../../../types';
4
+ export declare const useLogic: (identityUrl: string, openMenu: () => void) => {
5
+ handleShowProducts: () => void;
6
+ isLoading: boolean;
7
+ isError: boolean;
8
+ tenants: IdentityTenantsDTO[] | undefined;
9
+ handleChangeTenant: (_event: MouseEvent<HTMLElement>, selectedValue: string) => void;
10
+ tenantId: string;
11
+ productList: WidgetProduct[] | undefined;
12
+ };
@@ -0,0 +1,63 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useContext, useMemo, useState } from 'react';
11
+ import { ConfigContext } from '@astral/ui';
12
+ import { getIdentityTenants, getTenantsProducts } from '../../utils';
13
+ import { ASTRAL_IDENTITY_DEFAULT_TENANT } from '../../IdentityProductSwitcher';
14
+ export const useLogic = (identityUrl, openMenu) => {
15
+ const { captureException } = useContext(ConfigContext);
16
+ const [tenantsProductsMap, setTenantsProductsMap] = useState();
17
+ const [tenants, setTenants] = useState();
18
+ const [tenantId, setTenantId] = useState(ASTRAL_IDENTITY_DEFAULT_TENANT);
19
+ const [isLoading, setIsLoading] = useState(false);
20
+ const [isError, setIsError] = useState(false);
21
+ const productList = useMemo(() => tenantsProductsMap === null || tenantsProductsMap === void 0 ? void 0 : tenantsProductsMap[tenantId], [tenantsProductsMap, tenantId]);
22
+ const loadProducts = () => __awaiter(void 0, void 0, void 0, function* () {
23
+ try {
24
+ const tenantsInfo = yield getIdentityTenants(identityUrl);
25
+ const tenantsIds = tenantsInfo.map(({ id }) => id);
26
+ const tenantsProducts = yield getTenantsProducts(identityUrl, tenantsIds);
27
+ if (tenantsIds[0] !== tenantId) {
28
+ setTenantId(tenantsIds[0]);
29
+ }
30
+ setTenants(tenantsInfo);
31
+ setTenantsProductsMap(tenantsProducts);
32
+ }
33
+ catch (error) {
34
+ setIsError(true);
35
+ captureException(error);
36
+ }
37
+ finally {
38
+ setIsLoading(false);
39
+ }
40
+ });
41
+ const handleShowProducts = () => {
42
+ setIsError(false);
43
+ openMenu();
44
+ if (!tenantsProductsMap) {
45
+ setIsLoading(true);
46
+ loadProducts().then();
47
+ }
48
+ };
49
+ const handleChangeTenant = (_event, selectedValue) => {
50
+ if (selectedValue) {
51
+ setTenantId(selectedValue);
52
+ }
53
+ };
54
+ return {
55
+ handleShowProducts,
56
+ isLoading,
57
+ isError,
58
+ tenants,
59
+ handleChangeTenant,
60
+ tenantId,
61
+ productList,
62
+ };
63
+ };
@@ -0,0 +1 @@
1
+ export * from './IdentityProductSwitcher';
@@ -0,0 +1 @@
1
+ export * from './IdentityProductSwitcher';
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ export declare const IdentityProductSwitcherMenu: import("@emotion/styled").StyledComponent<import("@astral/ui").MenuProps & {
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ }, {}, {}>;
5
+ export declare const IdentityProductSwitcherItem: import("@mui/material").ExtendButtonBase<import("@mui/material").MenuItemTypeMap<{}, "li">>;
6
+ export declare const IdentityProductSwitcherLogo: import("@emotion/styled").StyledComponent<{
7
+ theme?: import("@emotion/react").Theme | undefined;
8
+ as?: import("react").ElementType<any> | undefined;
9
+ }, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
10
+ export declare const IdentityProductSwitcherErrorContainer: import("@emotion/styled").StyledComponent<import("@astral/ui").GridContainerProps & import("@astral/ui").GridElementsProps & {
11
+ children?: import("react").ReactNode;
12
+ } & import("react").RefAttributes<HTMLElement> & {
13
+ theme?: import("@emotion/react").Theme | undefined;
14
+ }, {}, {}>;
15
+ export declare const TenantsToggleButtonGroup: import("@emotion/styled").StyledComponent<Omit<import("@astral/ui").ToggleButtonGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement> & {
16
+ theme?: import("@emotion/react").Theme | undefined;
17
+ }, {}, {}>;
18
+ export declare const TenantToggleButton: import("@emotion/styled").StyledComponent<Omit<import("@astral/ui").ToggleButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement> & {
19
+ theme?: import("@emotion/react").Theme | undefined;
20
+ }, {}, {}>;
@@ -0,0 +1,42 @@
1
+ import { LegacyGrid, Menu, MenuItem, ToggleButton, ToggleButtonGroup, styled, } from '@astral/ui';
2
+ export const IdentityProductSwitcherMenu = styled(Menu) `
3
+ .MuiPaper-root > .MuiList-root {
4
+ display: flex;
5
+ flex-direction: column;
6
+ align-items: center;
7
+ justify-content: center;
8
+
9
+ width: 285px;
10
+ min-height: 100px;
11
+ padding: ${({ theme }) => theme.spacing(3, 0)};
12
+ }
13
+ `;
14
+ // as typeof MenuItem необходим для возможности прокинуть component
15
+ // https://github.com/mui/material-ui/issues/15695
16
+ export const IdentityProductSwitcherItem = styled(MenuItem) `
17
+ padding-left: ${({ theme }) => theme.spacing(6)};
18
+ `;
19
+ export const IdentityProductSwitcherLogo = styled('img', {
20
+ shouldForwardProp: (prop) => prop !== 'color',
21
+ }) `
22
+ width: 40px;
23
+ height: 40px;
24
+ margin-right: ${({ theme }) => theme.spacing(4)};
25
+
26
+ background-color: ${({ color }) => color};
27
+ border-radius: ${({ theme }) => theme.shape.small};
28
+ `;
29
+ export const IdentityProductSwitcherErrorContainer = styled(LegacyGrid) `
30
+ column-gap: ${({ theme }) => theme.spacing(2)};
31
+
32
+ color: ${({ theme }) => theme.palette.error.dark};
33
+ `;
34
+ export const TenantsToggleButtonGroup = styled(ToggleButtonGroup) `
35
+ width: 100%;
36
+ padding: ${({ theme }) => theme.spacing(1, 4, 4)};
37
+ `;
38
+ export const TenantToggleButton = styled(ToggleButton) `
39
+ flex: 1;
40
+
41
+ text-transform: uppercase;
42
+ `;
@@ -0,0 +1,6 @@
1
+ import { IdentityTenantsDTO } from '../../../../types';
2
+ /**
3
+ * Получение данных из identity
4
+ * @param identityUrl - адрес identity
5
+ */
6
+ export declare const getIdentityTenants: (identityUrl: string) => Promise<IdentityTenantsDTO[]>;
@@ -0,0 +1,21 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ /**
11
+ * Получение данных из identity
12
+ * @param identityUrl - адрес identity
13
+ */
14
+ export const getIdentityTenants = (identityUrl) => __awaiter(void 0, void 0, void 0, function* () {
15
+ return fetch(`${identityUrl}/api/tenants/widget`).then((response) => {
16
+ if (!response.ok) {
17
+ throw new Error(response.statusText);
18
+ }
19
+ return response.json();
20
+ });
21
+ });
@@ -0,0 +1 @@
1
+ export * from './getIdentityTenants';
@@ -0,0 +1 @@
1
+ export * from './getIdentityTenants';
@@ -0,0 +1,7 @@
1
+ import { WidgetProduct } from '@astral/ui';
2
+ /**
3
+ * Получение всех продуктов из разных экосистем и группировка в единую мапу
4
+ * @param identityUrl - сслыка на identity
5
+ * @param tenants - список экосистем, чтобы была возможность не все экосистемы показывать в виджете.
6
+ */
7
+ export declare const getTenantsProducts: (identityUrl: string, tenants: string[]) => Promise<Record<string, WidgetProduct[]>>;
@@ -0,0 +1,24 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { getIdentityProducts } from '../../../../utils';
11
+ /**
12
+ * Получение всех продуктов из разных экосистем и группировка в единую мапу
13
+ * @param identityUrl - сслыка на identity
14
+ * @param tenants - список экосистем, чтобы была возможность не все экосистемы показывать в виджете.
15
+ */
16
+ export const getTenantsProducts = (identityUrl, tenants) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const { hostname } = new URL(window.origin);
18
+ const tenantsProducts = tenants.map((tenant) => __awaiter(void 0, void 0, void 0, function* () {
19
+ const products = yield getIdentityProducts(identityUrl, tenant).then((tenantProducts) => tenantProducts.filter((product) => new URL(product.url).hostname !== hostname));
20
+ return [tenant, products];
21
+ }));
22
+ const products = yield Promise.all(tenantsProducts);
23
+ return Object.fromEntries(products);
24
+ });
@@ -0,0 +1 @@
1
+ export * from './getTenantsProducts';
@@ -0,0 +1 @@
1
+ export * from './getTenantsProducts';
@@ -0,0 +1,2 @@
1
+ export * from './getTenantsProducts';
2
+ export * from './getIdentityTenants';
@@ -0,0 +1,2 @@
1
+ export * from './getTenantsProducts';
2
+ export * from './getIdentityTenants';
@@ -0,0 +1,2 @@
1
+ export * from './AstralProductSwitcher';
2
+ export * from './IdentityProductSwitcher';
@@ -0,0 +1,2 @@
1
+ export * from './AstralProductSwitcher';
2
+ export * from './IdentityProductSwitcher';
@@ -0,0 +1 @@
1
+ export { AstralProductSwitcher, IdentityProductSwitcher } from './components';
@@ -0,0 +1 @@
1
+ export { AstralProductSwitcher, IdentityProductSwitcher } from './components';
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Информация о продукте в identity
3
+ * */
4
+ export type IdentityProductsWidgetDTO = {
5
+ /**
6
+ * ИД продукта
7
+ * */
8
+ id: string;
9
+ /**
10
+ * Наименование продукта
11
+ * */
12
+ name?: string;
13
+ /**
14
+ * URL адрес продукта
15
+ * */
16
+ productUrl?: string;
17
+ /**
18
+ * Описание продукта
19
+ * */
20
+ description?: string;
21
+ /**
22
+ * Короткое описание продукта
23
+ * */
24
+ shortDescription?: string;
25
+ /**
26
+ * Идентификатор иконки продукта
27
+ * */
28
+ iconFileId: string;
29
+ /**
30
+ * Ссылка на логотип продукта
31
+ * */
32
+ logoUrl?: string;
33
+ /**
34
+ * Цвет продукта
35
+ * */
36
+ backgroundHexColor?: string;
37
+ /**
38
+ * Идентификатор экосистемы
39
+ * */
40
+ tenantId?: string;
41
+ };
42
+ /**
43
+ * Описание экосистем
44
+ */
45
+ export type IdentityTenantsDTO = {
46
+ /**
47
+ * Идентификатор экосистемы
48
+ * */
49
+ id: string;
50
+ /**
51
+ * Наименование экосистемы
52
+ * */
53
+ name: string;
54
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { WidgetProduct } from '@astral/ui';
2
+ import { IdentityProductsWidgetDTO } from '../../types';
3
+ /**
4
+ * Форматирование данных identity под виджет UIKIT
5
+ * @param identityProducts - список продуктов от identity
6
+ * @param identityUrl - Url адрес identity
7
+ */
8
+ export declare const formatIdentityProducts: (identityUrl: string, identityProducts?: IdentityProductsWidgetDTO[]) => WidgetProduct[];
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Форматирование данных identity под виджет UIKIT
3
+ * @param identityProducts - список продуктов от identity
4
+ * @param identityUrl - Url адрес identity
5
+ */
6
+ export const formatIdentityProducts = (identityUrl, identityProducts = []) => (identityProducts === null || identityProducts === void 0 ? void 0 : identityProducts.map(({ id, productUrl = '', name = '', logoUrl, iconFileId, backgroundHexColor = '', }) => {
7
+ return {
8
+ id: id,
9
+ url: productUrl,
10
+ name: name,
11
+ logoUrl: logoUrl || `${identityUrl}/api/files/${iconFileId}`,
12
+ color: backgroundHexColor,
13
+ };
14
+ })) || [];
@@ -0,0 +1 @@
1
+ export * from './formatIdentityProducts';
@@ -0,0 +1 @@
1
+ export * from './formatIdentityProducts';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Получение данных из identity
3
+ * @param identityUrl - адрес identity
4
+ * @param tenantId - идентификатор экосистемы
5
+ */
6
+ export declare const getIdentityProducts: (identityUrl: string, tenantId?: string) => Promise<import("@astral/components").WidgetProduct[]>;
@@ -0,0 +1,27 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { formatIdentityProducts } from '../formatIdentityProducts';
11
+ /**
12
+ * Получение данных из identity
13
+ * @param identityUrl - адрес identity
14
+ * @param tenantId - идентификатор экосистемы
15
+ */
16
+ export const getIdentityProducts = (identityUrl, tenantId = 'astral') => __awaiter(void 0, void 0, void 0, function* () {
17
+ return fetch(`${identityUrl}/api/products/widget?tenantId=${tenantId}`)
18
+ .then((response) => {
19
+ if (!response.ok) {
20
+ throw new Error(response.statusText);
21
+ }
22
+ return response.json();
23
+ })
24
+ .then(({ data }) => {
25
+ return formatIdentityProducts(identityUrl, data);
26
+ });
27
+ });
@@ -0,0 +1 @@
1
+ export * from './getIdentityProducts';
@@ -0,0 +1 @@
1
+ export * from './getIdentityProducts';
@@ -0,0 +1,2 @@
1
+ export * from './getIdentityProducts';
2
+ export * from './formatIdentityProducts';
@@ -0,0 +1,2 @@
1
+ export * from './getIdentityProducts';
2
+ export * from './formatIdentityProducts';