@antscorp/antsomi-ui 1.3.5-beta.529 → 1.3.5-beta.530

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.
@@ -1,3 +1,4 @@
1
+ var _a;
1
2
  // Libraries
2
3
  import React, { memo, useState } from 'react';
3
4
  import Icon from '@antscorp/icons';
@@ -21,11 +22,13 @@ import { useNavigatePath } from '../../../hooks';
21
22
  import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
22
23
  // Contexts
23
24
  import { useLeftMenuContext } from '../../../contexts';
25
+ import { THEME } from '@antscorp/antsomi-ui/es/constants';
24
26
  const noDashboardItem = {
25
27
  key: 'no_dashboard',
26
- label: 'No dashboard available',
28
+ label: 'Click Create to make a dashboard',
27
29
  disabled: true,
28
30
  icon: null,
31
+ style: { fontSize: '10px', color: (_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.bw8 },
29
32
  };
30
33
  const styles = {
31
34
  dropdownMenu: { width: '130px', padding: '8px 0' },
@@ -160,9 +163,9 @@ export const ChildMenu = memo(props => {
160
163
  const customMenuItems = (args) => {
161
164
  var _a;
162
165
  return (_a = args === null || args === void 0 ? void 0 : args.items) === null || _a === void 0 ? void 0 : _a.map(item => {
163
- const { key, label, children, icon, logo_url, menu_item_path = null, menu_item_domain = null, options, disabled, optionCallback, } = item;
166
+ const { key, label, children, icon, logo_url, menu_item_path = null, menu_item_domain = null, options, disabled, style, optionCallback, } = item;
164
167
  const isOwnerDashboardKey = key === HOME_MENU_ITEMS.DASHBOARD.menu_item_code;
165
- const renderLabel = () => (React.createElement(LabelWrapper, { gap: 10, align: "center", justify: "space-between" },
168
+ const renderLabel = () => (React.createElement(LabelWrapper, { gap: 10, align: "center", justify: "space-between", style: style },
166
169
  React.createElement(LabelCustom, { ellipsis: { tooltip: label } }, label),
167
170
  (options === null || options === void 0 ? void 0 : options.length) && !isRecommendation && (React.createElement(OptionDropdownWrapper, { align: "center" },
168
171
  React.createElement(Dropdown, { menu: {
@@ -8,6 +8,7 @@ export declare const APP_KEYS: {
8
8
  DATA: string;
9
9
  INSIGHTS: string;
10
10
  SETTINGS: string;
11
+ SHARE_ACCESS: string;
11
12
  };
12
13
  export declare const MENU_ITEM_TYPE: {
13
14
  APP: number;
@@ -40,3 +41,10 @@ export declare const SETTING_APP: {
40
41
  path: string;
41
42
  };
42
43
  };
44
+ /** Some app in old menu permission is deprecated then we should remove */
45
+ export declare const APP_EXCLUDED_KEYS: string[];
46
+ /** Some app need to map app code to check duplicate permission_code */
47
+ export declare const MAP_MENU_TO_PARENT_APP_CODE: {
48
+ DATA_SOURCE: string;
49
+ DF_DATA_SOURCE: string;
50
+ };
@@ -7,6 +7,7 @@ export const APP_KEYS = {
7
7
  DATA: 'DATA',
8
8
  INSIGHTS: 'INSIGHT',
9
9
  SETTINGS: 'SETTING',
10
+ SHARE_ACCESS: 'SHARE_ACCESS',
10
11
  };
11
12
  export const MENU_ITEM_TYPE = {
12
13
  APP: 1,
@@ -52,3 +53,10 @@ export const SETTING_APP = {
52
53
  path: '/gen2/:networkId/:user_id/marketing-hub/destinations/:channelId',
53
54
  },
54
55
  };
56
+ /** Some app in old menu permission is deprecated then we should remove */
57
+ export const APP_EXCLUDED_KEYS = [APP_KEYS.SHARE_ACCESS];
58
+ /** Some app need to map app code to check duplicate permission_code */
59
+ export const MAP_MENU_TO_PARENT_APP_CODE = {
60
+ DATA_SOURCE: 'APP_ANTALYSER',
61
+ DF_DATA_SOURCE: 'DATAFLOWS',
62
+ };
@@ -10,6 +10,7 @@ import { CDP_API, PERMISSION_API, POST_MESSAGE_TYPES } from '@antscorp/antsomi-u
10
10
  import { ENV } from '@antscorp/antsomi-ui/es/config';
11
11
  // Utils
12
12
  import { findLastMatchedItemByUrl, findPathOfActiveItem, flattenMenuArray, getMappingAppChildren, recursivePermissionMenu, } from '../utils';
13
+ import { useCheckUserPermission } from '@antscorp/antsomi-ui/es/queries';
13
14
  const { DEV, SANDBOX, SANDBOX_CDP } = ENV;
14
15
  export const usePermission = () => {
15
16
  const appConfig = useLeftMenuContext(store => store.appConfig);
@@ -42,6 +43,16 @@ export const usePermission = () => {
42
43
  enabled: !!(auth === null || auth === void 0 ? void 0 : auth.userId) && !!auth.portalId,
43
44
  },
44
45
  });
46
+ const { data: userPermission } = useCheckUserPermission({
47
+ apiConfig: {
48
+ userId: +((auth === null || auth === void 0 ? void 0 : auth.userId) || 0),
49
+ accountId: +((auth === null || auth === void 0 ? void 0 : auth.accountId) || 0),
50
+ portalId: auth === null || auth === void 0 ? void 0 : auth.portalId,
51
+ token: auth === null || auth === void 0 ? void 0 : auth.token,
52
+ languageCode,
53
+ domain: 'https://sandbox-app.cdp.asia',
54
+ },
55
+ });
45
56
  const { data: dashboardData, refetch: refetchDashboard } = useGetDashboard({
46
57
  args: {
47
58
  auth: {
@@ -113,6 +124,7 @@ export const usePermission = () => {
113
124
  destinationChannelEntries: destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries,
114
125
  destinationChannelGen2Entries: destinationChannelGen2 === null || destinationChannelGen2 === void 0 ? void 0 : destinationChannelGen2.entries,
115
126
  isRecommendation,
127
+ userPermission,
116
128
  }), [
117
129
  auth,
118
130
  dashboardList,
@@ -120,6 +132,7 @@ export const usePermission = () => {
120
132
  destinationChannelGen2 === null || destinationChannelGen2 === void 0 ? void 0 : destinationChannelGen2.entries,
121
133
  isRecommendation,
122
134
  permissionMenu,
135
+ userPermission,
123
136
  ]);
124
137
  const activeItemPath = useMemo(() => {
125
138
  const url = `${pathname}${hash}`;
@@ -116,6 +116,10 @@ export const FeatureMenu = styled.ul `
116
116
 
117
117
  .menu-content {
118
118
  flex-shrink: 0;
119
+
120
+ &.scroll-content {
121
+ margin-right: 0px !important;
122
+ }
119
123
  }
120
124
 
121
125
  .nav-blank {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { TFeatureMenu } from '@antscorp/antsomi-ui/es/models/LeftMenu';
2
3
  export type TMenuItem = Omit<Partial<TFeatureMenu>, 'children' | keyof TRequireMenuItemKey> & {
3
4
  key: string;
@@ -5,6 +6,7 @@ export type TMenuItem = Omit<Partial<TFeatureMenu>, 'children' | keyof TRequireM
5
6
  icon: string | null;
6
7
  disabled?: boolean;
7
8
  children?: TMenuItem[];
9
+ style?: React.CSSProperties;
8
10
  } & TOption;
9
11
  export type TMenuFeatureItem = Omit<Partial<TFeatureMenu>, 'children'> & TRequireMenuItemKey & TOption & {
10
12
  children?: TMenuFeatureItem[];
@@ -2,6 +2,7 @@ import { FeatureMenuPermission, TDashboard, TDestinationChannel, TFeatureMenu }
2
2
  import { PayloadInfo } from '@antscorp/antsomi-ui/es/types';
3
3
  import { TMenuFeatureItem, TMenuItem } from '../types';
4
4
  import { TEnv } from '@antscorp/antsomi-ui/es/types/config';
5
+ import { TAccountPermission } from '@antscorp/antsomi-ui/es/models/AccountListing';
5
6
  /**
6
7
  * Converts a feature menu item to a menu item suitable for rendering in the UI.
7
8
  * @param {TMenuFeatureItem} featureMenu - The feature menu item to convert.
@@ -15,7 +16,7 @@ export declare const getMenuItem: (featureMenu: TMenuFeatureItem) => TMenuItem;
15
16
  * @param {string} childKey - The key representing the children array in each menu item.
16
17
  * @returns {T[]} The flattened array of menu items.
17
18
  */
18
- export declare const flattenMenuArray: <T>(menuItems: T[], childKey: string) => T[];
19
+ export declare const flattenMenuArray: (menuItems: FeatureMenuPermission[], childKey: string, parentAppCode?: FeatureMenuPermission['parent_app_code']) => FeatureMenuPermission[];
19
20
  /**
20
21
  * Recursively filters menu items based on permissions.
21
22
  * check permission if menu item has menu_type of @alias MENU_ITEM_TYPE.MENU
@@ -70,6 +71,7 @@ export declare const getMappingAppChildren: (args: {
70
71
  destinationChannelEntries?: TDestinationChannel[];
71
72
  destinationChannelGen2Entries?: TDestinationChannel[];
72
73
  isRecommendation?: boolean;
74
+ userPermission?: TAccountPermission;
73
75
  }) => TFeatureMenu[];
74
76
  /**
75
77
  * Finds the app code of the active menu item based on the provided URL within the given menu items.
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  // Libraries
13
13
  import { cloneDeep, isArray, isEmpty, sortBy } from 'lodash';
14
14
  // Constants
15
- import { APP_KEYS, MARKETING_CHANNEL_KEY, HOME_MENU_ITEMS, MARKETING_ROUTES, MENU_ITEM_TYPE, RENDER_OPTION, HOME_REPORT_ROUTES, SETTING_APP, } from '../constants';
15
+ import { APP_KEYS, MARKETING_CHANNEL_KEY, HOME_MENU_ITEMS, MARKETING_ROUTES, MENU_ITEM_TYPE, RENDER_OPTION, HOME_REPORT_ROUTES, SETTING_APP, APP_EXCLUDED_KEYS, MAP_MENU_TO_PARENT_APP_CODE, } from '../constants';
16
16
  import { MARKETING_CHANNEL_CODE, KEEP_HASH_PATH_DEV } from '../../../template/Layout/constants';
17
17
  // Utils
18
18
  import { handleError } from '@antscorp/antsomi-ui/es/utils';
@@ -35,15 +35,19 @@ export const getMenuItem = (featureMenu) => {
35
35
  * @param {string} childKey - The key representing the children array in each menu item.
36
36
  * @returns {T[]} The flattened array of menu items.
37
37
  */
38
- export const flattenMenuArray = (menuItems, childKey) => {
38
+ export const flattenMenuArray = (menuItems, childKey, parentAppCode) => {
39
39
  let result = [];
40
- menuItems.forEach(item => {
40
+ for (const item of menuItems) {
41
+ // If item has app_code and the app code is in the excluded list, skip it
42
+ if (!!item.app_code && APP_EXCLUDED_KEYS.includes(item.app_code)) {
43
+ continue;
44
+ }
41
45
  const children = (item === null || item === void 0 ? void 0 : item[childKey]) || [];
42
- result.push(Object.assign(Object.assign({}, item), { [childKey]: [] }));
46
+ result.push(Object.assign(Object.assign(Object.assign({}, item), (parentAppCode ? { parent_app_code: parentAppCode } : {})), { [childKey]: [] }));
43
47
  if (children.length > 0) {
44
- result = [...result, ...flattenMenuArray(children, childKey)];
48
+ result = [...result, ...flattenMenuArray(children, childKey, item.app_code)];
45
49
  }
46
- });
50
+ }
47
51
  return result;
48
52
  };
49
53
  /**
@@ -52,11 +56,22 @@ export const flattenMenuArray = (menuItems, childKey) => {
52
56
  */
53
57
  export const recursivePermissionMenu = (menuItems, menuPermissions) => {
54
58
  var _a, _b;
55
- const menu = (_b = (_a = menuItems === null || menuItems === void 0 ? void 0 : menuItems.filter(({ permission_code, menu_item_type }) => {
59
+ const menu = (_b = (_a = menuItems === null || menuItems === void 0 ? void 0 : menuItems.filter(({ permission_code, menu_item_type, menu_item_code }) => {
56
60
  if (Number(menu_item_type) !== MENU_ITEM_TYPE.MENU) {
57
61
  return true;
58
62
  }
59
- return !!(menuPermissions === null || menuPermissions === void 0 ? void 0 : menuPermissions.find(({ menu_code = '' }) => !!permission_code && [menu_code].includes(permission_code)));
63
+ return !!(menuPermissions === null || menuPermissions === void 0 ? void 0 : menuPermissions.find(({ menu_code = '', parent_app_code }) => {
64
+ if (permission_code) {
65
+ const parentAppCode = MAP_MENU_TO_PARENT_APP_CODE[menu_item_code];
66
+ // If parent app code is exist in the MAP_MENU_TO_PARENT_APP_CODE then check with parent app code
67
+ if (parentAppCode && parent_app_code) {
68
+ return parentAppCode === parent_app_code && [menu_code].includes(permission_code);
69
+ }
70
+ // Else just check with menu_code
71
+ return [menu_code].includes(permission_code);
72
+ }
73
+ return false;
74
+ }));
60
75
  })) === null || _a === void 0 ? void 0 : _a.map(item => (Object.assign(Object.assign({}, item), (isArray(item.children)
61
76
  ? {
62
77
  children: recursivePermissionMenu(sortBy(item.children || [], ['level_position']), menuPermissions),
@@ -71,13 +86,6 @@ export const recursivePermissionMenu = (menuItems, menuPermissions) => {
71
86
  export const getGeneratePath = (path, params) => {
72
87
  try {
73
88
  const { portalId, userId, dashboardId, channelId } = params || {};
74
- // return generatePath(path, {
75
- // user_id: userId ?? '-1',
76
- // networkId: portalId ?? -1,
77
- // portalId: portalId ?? -1,
78
- // dashboardId: dashboardId ?? '-1',
79
- // channelId: channelId ?? -1,
80
- // });
81
89
  const paramsObjects = {
82
90
  user_id: userId !== null && userId !== void 0 ? userId : '-1',
83
91
  networkId: portalId !== null && portalId !== void 0 ? portalId : -1,
@@ -133,7 +141,7 @@ export const recursiveGetMenuItemByPermission = (featureMenuItem) => {
133
141
  };
134
142
  /** Map children to each App Item */
135
143
  export const getMappingAppChildren = (args) => {
136
- const { menuList, dashboardList, auth, destinationChannelEntries, destinationChannelGen2Entries, isRecommendation, } = args;
144
+ const { menuList, dashboardList, auth, destinationChannelEntries, destinationChannelGen2Entries, isRecommendation, userPermission, } = args;
137
145
  const recursiveAddRenderOption = (menuItem) => {
138
146
  var _a;
139
147
  const cloneMenuItem = cloneDeep(menuItem);
@@ -207,10 +215,17 @@ export const getMappingAppChildren = (args) => {
207
215
  })), { children: (_a = dashboardObject === null || dashboardObject === void 0 ? void 0 : dashboardObject[childMenuItem.menu_item_code]) === null || _a === void 0 ? void 0 : _a.map(item => {
208
216
  const { shareAccess } = item || {};
209
217
  const dashboardEditable = (() => {
210
- var _a, _b;
211
- if (isEmpty(shareAccess))
212
- return true;
213
- return (((_b = (_a = shareAccess === null || shareAccess === void 0 ? void 0 : shareAccess.list_access) === null || _a === void 0 ? void 0 : _a.find(item => item.user_id === (auth === null || auth === void 0 ? void 0 : auth.userId))) === null || _b === void 0 ? void 0 : _b.allow_edit) === FEATURE_PERMISSIONS.EVERYTHING);
218
+ var _a, _b, _c;
219
+ switch ((_a = userPermission === null || userPermission === void 0 ? void 0 : userPermission.permissions) === null || _a === void 0 ? void 0 : _a.edit) {
220
+ case 'EVERYTHING':
221
+ return true;
222
+ case 'NONE':
223
+ return false;
224
+ default:
225
+ if (isEmpty(shareAccess))
226
+ return true;
227
+ return (((_c = (_b = shareAccess === null || shareAccess === void 0 ? void 0 : shareAccess.list_access) === null || _b === void 0 ? void 0 : _b.find(item => item.user_id === (auth === null || auth === void 0 ? void 0 : auth.userId))) === null || _c === void 0 ? void 0 : _c.allow_edit) === FEATURE_PERMISSIONS.EVERYTHING);
228
+ }
214
229
  })();
215
230
  return Object.assign({}, getInitialFeatureMenuItem({
216
231
  menu_item: String(item.dashboardId),
@@ -51,9 +51,7 @@ export const Layout = memo(props => {
51
51
  const [noSpaceTopContent, setNoSpaceTopContent] = useState(false);
52
52
  const [activeMenuCode, setActiveMenuCode] = useState('');
53
53
  const [activePageTitle, setActivePageTitle] = useState('');
54
- // Refs
55
54
  const notificationWrapperRef = useRef(null);
56
- // Hooks
57
55
  useMutationObserver(() => {
58
56
  if (notificationWrapperRef.current) {
59
57
  const child = notificationWrapperRef.current.querySelector('div');
@@ -67,7 +65,6 @@ export const Layout = memo(props => {
67
65
  attributeOldValue: true,
68
66
  characterDataOldValue: true,
69
67
  });
70
- // Memo
71
68
  const permissionDomain = useDeepCompareMemo(() => {
72
69
  var _a;
73
70
  /**
@@ -21,6 +21,9 @@ export const MenuWrapper = styled.div `
21
21
  height: 100%;
22
22
  max-height: 100%;
23
23
  overflow: auto;
24
+ &::-webkit-scrollbar {
25
+ display: none !important;
26
+ }
24
27
 
25
28
  li {
26
29
  min-height: 40px !important;
@@ -26,6 +26,7 @@ export declare const QUERY_KEYS: {
26
26
  GET_ACCOUNT_LISTING: string;
27
27
  GET_PERMISSION_ACCOUNT_LISTING: string;
28
28
  GET_RECENT_ACCOUNT: string;
29
+ CHECK_ACCOUNT_PERMISSION: string;
29
30
  GET_ABSTRACT_USERS: string;
30
31
  GET_COLUMN_METRICS: string;
31
32
  GET_DATA_TABLE_LISTING: string;
@@ -37,6 +37,7 @@ export const QUERY_KEYS = {
37
37
  GET_ACCOUNT_LISTING: 'GET_ACCOUNT_LISTING',
38
38
  GET_PERMISSION_ACCOUNT_LISTING: 'GET_PERMISSION_ACCOUNT_LISTING',
39
39
  GET_RECENT_ACCOUNT: 'GET_RECENT_ACCOUNT',
40
+ CHECK_ACCOUNT_PERMISSION: 'CHECK_ACCOUNT_PERMISSION',
40
41
  // ABSTRACT
41
42
  GET_ABSTRACT_USERS: 'GET_ABSTRACT_USERS',
42
43
  // DATA TABLE
@@ -13,3 +13,15 @@ export interface AccountRecent {
13
13
  userId: number;
14
14
  value: number[];
15
15
  }
16
+ export type TAccountPermission = {
17
+ objectType?: number;
18
+ isView?: boolean;
19
+ isEdit?: boolean;
20
+ isExist?: boolean;
21
+ permissions?: {
22
+ view: string;
23
+ edit: string;
24
+ loginView: string;
25
+ loginEdit: string;
26
+ };
27
+ };
@@ -1,5 +1,5 @@
1
1
  export type FeatureMenuPermission = {
2
- app_id?: number;
2
+ app_id?: string | number;
3
3
  app_name?: string;
4
4
  app_code?: string | null;
5
5
  path?: string;
@@ -12,6 +12,7 @@ export type FeatureMenuPermission = {
12
12
  menu_code?: string | null;
13
13
  menu_name?: string;
14
14
  menu_parent?: number | null;
15
+ parent_app_code?: string | null;
15
16
  menu_order?: number;
16
17
  icon?: string;
17
18
  menu_path?: string;
@@ -1,15 +1,20 @@
1
1
  import { UseQueryOptions } from '@tanstack/react-query';
2
- import { GetAccountList } from '../../services/Account';
3
- import { AccountListing, AccountRecent } from '../../models/AccountListing';
2
+ import { TAccountParams } from '../../services/Account';
3
+ import { AccountListing, AccountRecent, TAccountPermission } from '../../models/AccountListing';
4
4
  type OptionHasDefault = 'queryKey' | 'queryFn';
5
5
  type GetAccountListProps = {
6
- apiConfig: GetAccountList;
6
+ apiConfig: TAccountParams;
7
7
  options?: Omit<UseQueryOptions<AccountListing, any, AccountListing, any[]>, OptionHasDefault>;
8
8
  };
9
9
  type GetRecentAccountProps = {
10
- apiConfig: GetAccountList;
10
+ apiConfig: TAccountParams;
11
11
  options?: Omit<UseQueryOptions<any, any, AccountRecent, any[]>, OptionHasDefault>;
12
12
  };
13
+ type TCheckUserPermissionProps = {
14
+ apiConfig: TAccountParams;
15
+ options?: Omit<UseQueryOptions<any, any, TAccountPermission | undefined, any[]>, OptionHasDefault>;
16
+ };
13
17
  export declare const useGetAccountList: (props: GetAccountListProps) => import("@tanstack/react-query").UseQueryResult<AccountListing, any>;
14
18
  export declare const useGetRecentAccount: (props: GetRecentAccountProps) => import("@tanstack/react-query").UseQueryResult<AccountRecent, any>;
19
+ export declare const useCheckUserPermission: (props: TCheckUserPermissionProps) => import("@tanstack/react-query").UseQueryResult<TAccountPermission | undefined, any>;
15
20
  export {};
@@ -4,7 +4,7 @@ import { useQuery } from '@tanstack/react-query';
4
4
  import { accountService } from '../../services/Account';
5
5
  // Constants
6
6
  import { QUERY_KEYS } from '../../constants/queries';
7
- const { getList, getRecentAccount } = accountService;
7
+ const { getList, getRecentAccount, checkPermission } = accountService;
8
8
  export const useGetAccountList = (props) => {
9
9
  const { apiConfig, options } = props;
10
10
  return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_ACCOUNT_LISTING, apiConfig], queryFn: () => getList(apiConfig) }, options));
@@ -13,3 +13,8 @@ export const useGetRecentAccount = (props) => {
13
13
  const { apiConfig, options } = props;
14
14
  return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_RECENT_ACCOUNT], queryFn: () => getRecentAccount(apiConfig) }, options));
15
15
  };
16
+ export const useCheckUserPermission = (props) => {
17
+ const { apiConfig, options } = props;
18
+ const { languageCode, userId, portalId } = apiConfig;
19
+ return useQuery(Object.assign({ queryKey: [QUERY_KEYS.CHECK_ACCOUNT_PERMISSION, languageCode, userId, portalId], queryFn: () => checkPermission(apiConfig) }, options));
20
+ };
@@ -1,12 +1,14 @@
1
- import { AccountListing, AccountRecent } from '../../models/AccountListing';
2
- export type GetAccountList = {
1
+ import { AccountListing, AccountRecent, TAccountPermission } from '../../models/AccountListing';
2
+ export type TAccountParams = {
3
3
  domain: string;
4
4
  portalId?: number;
5
5
  languageCode?: string;
6
6
  userId?: number;
7
- token: string;
7
+ accountId?: number;
8
+ token?: string;
8
9
  };
9
10
  export declare const accountService: {
10
- getList: (config: GetAccountList) => Promise<AccountListing>;
11
- getRecentAccount: (config: GetAccountList) => Promise<AccountRecent | undefined>;
11
+ getList: (config: TAccountParams) => Promise<AccountListing>;
12
+ getRecentAccount: (config: TAccountParams) => Promise<AccountRecent | undefined>;
13
+ checkPermission: (config: TAccountParams) => Promise<TAccountPermission>;
12
14
  };
@@ -62,4 +62,28 @@ export const accountService = {
62
62
  return Promise.reject(error);
63
63
  }
64
64
  }),
65
+ checkPermission: (config) => __awaiter(void 0, void 0, void 0, function* () {
66
+ var _g, _h, _j;
67
+ const { domain, languageCode = 'en', portalId = 33167, userId, token, accountId } = config;
68
+ try {
69
+ const response = yield axios({
70
+ method: 'POST',
71
+ url: `${domain}/hub/toolkit/v2.0/operate/check-permission`,
72
+ params: {
73
+ portalId,
74
+ languageCode,
75
+ _user_id: userId,
76
+ _owner_id: accountId,
77
+ },
78
+ data: { objects: [{ objectType: 1 }] },
79
+ headers: {
80
+ Token: token,
81
+ },
82
+ });
83
+ return ((_j = (_h = (_g = response === null || response === void 0 ? void 0 : response.data) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.entries) === null || _j === void 0 ? void 0 : _j[0]) || {};
84
+ }
85
+ catch (error) {
86
+ return Promise.reject(error);
87
+ }
88
+ }),
65
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.529",
3
+ "version": "1.3.5-beta.530",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",