@dropins/storefront-company-management 1.0.0-beta7 → 1.0.0-beta9

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 (71) hide show
  1. package/api/companyRoles/createCompanyRole.d.ts +7 -0
  2. package/api/companyRoles/deleteCompanyRole.d.ts +7 -0
  3. package/api/companyRoles/getCompanyAclResources.d.ts +7 -0
  4. package/api/companyRoles/getCompanyRole.d.ts +8 -0
  5. package/api/companyRoles/getCompanyRoles.d.ts +8 -0
  6. package/api/companyRoles/graphql/fragments.d.ts +18 -0
  7. package/api/companyRoles/graphql/index.d.ts +20 -0
  8. package/api/companyRoles/graphql/mutations.d.ts +20 -0
  9. package/api/companyRoles/graphql/queries.d.ts +21 -0
  10. package/api/companyRoles/index.d.ts +27 -0
  11. package/api/companyRoles/isCompanyRoleNameAvailable.d.ts +7 -0
  12. package/api/companyRoles/updateCompanyRole.d.ts +7 -0
  13. package/api/companyRoles/utils.d.ts +11 -0
  14. package/api/index.d.ts +1 -0
  15. package/api.js +2 -2
  16. package/api.js.map +1 -1
  17. package/chunks/company-permissions.js +4 -0
  18. package/chunks/company-permissions.js.map +1 -0
  19. package/chunks/createCompany.js +1 -1
  20. package/chunks/fetchUserPermissions.js +27 -0
  21. package/chunks/fetchUserPermissions.js.map +1 -0
  22. package/chunks/isCompanyRoleNameAvailable.js +121 -0
  23. package/chunks/isCompanyRoleNameAvailable.js.map +1 -0
  24. package/chunks/updateCompany.js +8 -31
  25. package/chunks/updateCompany.js.map +1 -1
  26. package/chunks/useCompanyContextListener.js.map +1 -1
  27. package/chunks/useCompanyContextListener2.js +4 -0
  28. package/chunks/useCompanyContextListener2.js.map +1 -0
  29. package/chunks/useInLineAlert.js +4 -0
  30. package/chunks/useInLineAlert.js.map +1 -0
  31. package/chunks/validateCompanyEmail.js +3 -3
  32. package/chunks/validateCompanyEmail.js.map +1 -1
  33. package/components/DeleteRoleModal/DeleteRoleModal.d.ts +9 -0
  34. package/components/DeleteRoleModal/index.d.ts +19 -0
  35. package/components/EditRoleAndPermission/EditRoleAndPermission.d.ts +24 -0
  36. package/components/EditRoleAndPermission/index.d.ts +19 -0
  37. package/components/RoleAndPermissionTable/RoleAndPermissionTable.d.ts +20 -0
  38. package/components/RoleAndPermissionTable/index.d.ts +19 -0
  39. package/components/Tree/Tree.d.ts +2 -0
  40. package/components/index.d.ts +3 -0
  41. package/containers/CompanyProfile.js +1 -1
  42. package/containers/CompanyProfile.js.map +1 -1
  43. package/containers/CompanyRegistration.js +1 -1
  44. package/containers/CompanyRegistration.js.map +1 -1
  45. package/containers/CompanyUsers/hooks/index.d.ts +19 -0
  46. package/containers/CompanyUsers/hooks/useCompanyContextListener.d.ts +62 -0
  47. package/containers/CompanyUsers/hooks.d.ts +1 -0
  48. package/containers/CompanyUsers/hooks.js +4 -0
  49. package/containers/CompanyUsers/hooks.js.map +1 -0
  50. package/containers/CustomerCompanyInfo.js +1 -1
  51. package/containers/CustomerCompanyInfo.js.map +1 -1
  52. package/containers/RolesAndPermissions/RolesAndPermissions.d.ts +8 -0
  53. package/containers/RolesAndPermissions/index.d.ts +19 -0
  54. package/containers/RolesAndPermissions.d.ts +3 -0
  55. package/containers/RolesAndPermissions.js +4 -0
  56. package/containers/RolesAndPermissions.js.map +1 -0
  57. package/containers/index.d.ts +1 -0
  58. package/data/models/company-role.d.ts +48 -0
  59. package/data/models/company.d.ts +4 -17
  60. package/data/models/index.d.ts +1 -0
  61. package/data/transforms/index.d.ts +1 -0
  62. package/data/transforms/transform-company-roles.d.ts +15 -0
  63. package/hooks/index.d.ts +3 -0
  64. package/hooks/useCompanyRoles.d.ts +28 -0
  65. package/hooks/useUserPermissions.d.ts +12 -0
  66. package/i18n/en_US.json.d.ts +71 -2
  67. package/lib/company-permissions.d.ts +7 -0
  68. package/package.json +1 -1
  69. package/render.js +5 -4
  70. package/render.js.map +1 -1
  71. package/types/api/companyRoles.types.d.ts +137 -0
@@ -0,0 +1,7 @@
1
+ import { CompanyRoleModel, CompanyRoleCreateInputModel } from '../../data/models/company-role';
2
+
3
+ /**
4
+ * Create a new company role
5
+ */
6
+ export declare const createCompanyRole: (input: CompanyRoleCreateInputModel) => Promise<CompanyRoleModel>;
7
+ //# sourceMappingURL=createCompanyRole.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { DeleteCompanyRoleVariables } from '../../types/api/companyRoles.types';
2
+
3
+ /**
4
+ * Delete a company role
5
+ */
6
+ export declare const deleteCompanyRole: (variables: DeleteCompanyRoleVariables) => Promise<boolean>;
7
+ //# sourceMappingURL=deleteCompanyRole.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { CompanyAclResourceModel } from '../../data/models/company-role';
2
+
3
+ /**
4
+ * Fetch all available ACL resources (permissions)
5
+ */
6
+ export declare const getCompanyAclResources: () => Promise<CompanyAclResourceModel[]>;
7
+ //# sourceMappingURL=getCompanyAclResources.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { GetCompanyRoleVariables } from '../../types/api/companyRoles.types';
2
+ import { CompanyRoleModel } from '../../data/models/company-role';
3
+
4
+ /**
5
+ * Fetch a single company role by ID
6
+ */
7
+ export declare const getCompanyRole: (variables: GetCompanyRoleVariables) => Promise<CompanyRoleModel>;
8
+ //# sourceMappingURL=getCompanyRole.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { GetCompanyRolesVariables } from '../../types/api/companyRoles.types';
2
+ import { CompanyRolesResponseModel } from '../../data/models/company-role';
3
+
4
+ /**
5
+ * Fetch all company roles with pagination
6
+ */
7
+ export declare const getCompanyRoles: (variables?: GetCompanyRolesVariables) => Promise<CompanyRolesResponseModel>;
8
+ //# sourceMappingURL=getCompanyRoles.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export declare const COMPANY_ROLE_FRAGMENT = "\n fragment CompanyRoleFragment on CompanyRole {\n id\n name\n users_count\n permissions {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n }\n }\n }\n }\n }\n }\n";
18
+ //# sourceMappingURL=fragments.d.ts.map
@@ -0,0 +1,20 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export * from './fragments';
18
+ export * from './queries';
19
+ export * from './mutations';
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,20 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export declare const CREATE_COMPANY_ROLE: string;
18
+ export declare const UPDATE_COMPANY_ROLE: string;
19
+ export declare const DELETE_COMPANY_ROLE = "\n mutation DeleteCompanyRole($id: ID!) {\n deleteCompanyRole(id: $id) {\n success\n }\n }\n";
20
+ //# sourceMappingURL=mutations.d.ts.map
@@ -0,0 +1,21 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export declare const GET_COMPANY_ROLES: string;
18
+ export declare const GET_COMPANY_ROLE: string;
19
+ export declare const GET_COMPANY_ACL_RESOURCES = "\n query GetCompanyAclResources {\n company {\n acl_resources {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n }\n }\n }\n }\n }\n }\n }\n";
20
+ export declare const IS_COMPANY_ROLE_NAME_AVAILABLE = "\n query IsCompanyRoleNameAvailable($name: String!) {\n isCompanyRoleNameAvailable(name: $name) {\n is_role_name_available\n }\n }\n";
21
+ //# sourceMappingURL=queries.d.ts.map
@@ -0,0 +1,27 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export { getCompanyRoles } from './getCompanyRoles';
18
+ export { getCompanyRole } from './getCompanyRole';
19
+ export { getCompanyAclResources } from './getCompanyAclResources';
20
+ export { createCompanyRole } from './createCompanyRole';
21
+ export { updateCompanyRole } from './updateCompanyRole';
22
+ export { deleteCompanyRole } from './deleteCompanyRole';
23
+ export { isCompanyRoleNameAvailable } from './isCompanyRoleNameAvailable';
24
+ export { flattenPermissionIds, buildPermissionTree } from './utils';
25
+ export type { CompanyAclResourceModel, CompanyRoleModel, PageInfoModel, CompanyRolesResponseModel, CompanyRoleCreateInputModel, CompanyRoleUpdateInputModel, } from '../../data/models/company-role';
26
+ export type { GetCompanyRolesVariables, GetCompanyRoleVariables, DeleteCompanyRoleVariables, IsCompanyRoleNameAvailableVariables, } from '../../types/api/companyRoles.types';
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { IsCompanyRoleNameAvailableVariables } from '../../types/api/companyRoles.types';
2
+
3
+ /**
4
+ * Check if a role name is available
5
+ */
6
+ export declare const isCompanyRoleNameAvailable: (variables: IsCompanyRoleNameAvailableVariables) => Promise<boolean>;
7
+ //# sourceMappingURL=isCompanyRoleNameAvailable.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { CompanyRoleModel, CompanyRoleUpdateInputModel } from '../../data/models/company-role';
2
+
3
+ /**
4
+ * Update an existing company role
5
+ */
6
+ export declare const updateCompanyRole: (input: CompanyRoleUpdateInputModel) => Promise<CompanyRoleModel>;
7
+ //# sourceMappingURL=updateCompanyRole.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { CompanyAclResourceModel } from '../../data/models/company-role';
2
+
3
+ /**
4
+ * Helper function to flatten ACL resources into a list of permission IDs
5
+ */
6
+ export declare const flattenPermissionIds: (resources: CompanyAclResourceModel[]) => string[];
7
+ /**
8
+ * Helper function to build a permission tree from flat permission IDs
9
+ */
10
+ export declare const buildPermissionTree: (allResources: CompanyAclResourceModel[], selectedIds: string[]) => CompanyAclResourceModel[];
11
+ //# sourceMappingURL=utils.d.ts.map
package/api/index.d.ts CHANGED
@@ -28,4 +28,5 @@ export * from './allowCompanyRegistration';
28
28
  export * from './createCompany';
29
29
  export * from './isCompanyUser';
30
30
  export * from './isCompanyAdmin';
31
+ export * from './companyRoles';
31
32
  //# sourceMappingURL=index.d.ts.map
package/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{f as i}from"./chunks/fetch-graphql.js";import{g,r as E,s as h,a as S,b as T}from"./chunks/fetch-graphql.js";import{f as O,g as A,u as R}from"./chunks/updateCompany.js";import{g as G,v as U}from"./chunks/validateCompanyEmail.js";import{D as H,S as I,c as L,g as M}from"./chunks/createCompany.js";import{c as P,g as Q}from"./chunks/getCustomerCompany.js";import{a as v,i as D}from"./chunks/isCompanyUser.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/fetch-error.js";import"@dropins/tools/event-bus.js";const u=async(r={})=>({success:!0,config:r}),m=`
3
+ import{f as m}from"./chunks/fetch-graphql.js";import{g as x,r as I,s as N,a as P,b as U}from"./chunks/fetch-graphql.js";import{f as b}from"./chunks/fetchUserPermissions.js";import{g as H,u as L}from"./chunks/updateCompany.js";import{g as v,v as Q}from"./chunks/validateCompanyEmail.js";import{D as k,S as W,c as Y,g as q}from"./chunks/createCompany.js";import{c as j,g as B}from"./chunks/getCustomerCompany.js";import{a as K,i as V}from"./chunks/isCompanyUser.js";import{G as c,t as l}from"./chunks/isCompanyRoleNameAvailable.js";import{c as Z,d as $,a as ee,g as re,i as ae,u as te}from"./chunks/isCompanyRoleNameAvailable.js";import{a as p}from"./chunks/fetch-error.js";import{a as f}from"./chunks/company-permissions.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/event-bus.js";const R=async e=>{try{const a=await m(c,{variables:e,method:"GET",cache:"no-cache"});return l(a)}catch(a){return p(a)}},T=e=>f(e),S=(e,a)=>{const n=new Set(a),o=r=>{var t;const s=((t=r.children)==null?void 0:t.map(o).filter(i=>i!==null))||[];return n.has(r.id)||s.length>0?{...r,children:s}:null};return e.map(o).filter(r=>r!==null)},_=async(e={})=>({success:!0,config:e}),u=`
4
4
  query GET_CUSTOMER_COMPANIES_WITH_ROLES {
5
5
  customer {
6
6
  companies(input: {}) {
@@ -15,5 +15,5 @@ import{f as i}from"./chunks/fetch-graphql.js";import{g,r as E,s as h,a as S,b as
15
15
  }
16
16
  }
17
17
  }
18
- `,C=async()=>{var r,o,t;try{const a=await i(m,{method:"POST"});if((r=a.errors)!=null&&r.length)return!1;const s=(o=a.data)==null?void 0:o.customer;if(!s)return!1;const n=((t=s.companies)==null?void 0:t.items)??[];if(!Array.isArray(n)||n.length===0)return!1;const e=s.role;return e?e.id==="0"||typeof e.id=="number"&&e.id===0||e.name==="Company Administrator":!1}catch(a){return console.error("Error checking if customer is company admin:",a),!1}};export{H as DEFAULT_COUNTRY,I as STORE_CONFIG_DEFAULTS,v as allowCompanyRegistration,P as companyEnabled,L as createCompany,i as fetchGraphQl,O as fetchUserPermissions,A as getCompany,g as getConfig,G as getCountries,Q as getCustomerCompany,M as getStoreConfig,u as initialize,C as isCompanyAdmin,D as isCompanyUser,E as removeFetchGraphQlHeader,h as setEndpoint,S as setFetchGraphQlHeader,T as setFetchGraphQlHeaders,R as updateCompany,U as validateCompanyEmail};
18
+ `,A=async()=>{var e,a,n;try{const o=await m(u,{method:"POST"});if((e=o.errors)!=null&&e.length)return!1;const r=(a=o.data)==null?void 0:a.customer;if(!r)return!1;const s=((n=r.companies)==null?void 0:n.items)??[];if(!Array.isArray(s)||s.length===0)return!1;const t=r.role;return t?t.id==="0"||typeof t.id=="number"&&t.id===0||t.name==="Company Administrator":!1}catch(o){return console.error("Error checking if customer is company admin:",o),!1}};export{k as DEFAULT_COUNTRY,W as STORE_CONFIG_DEFAULTS,K as allowCompanyRegistration,S as buildPermissionTree,j as companyEnabled,Y as createCompany,Z as createCompanyRole,$ as deleteCompanyRole,m as fetchGraphQl,b as fetchUserPermissions,T as flattenPermissionIds,H as getCompany,ee as getCompanyAclResources,R as getCompanyRole,re as getCompanyRoles,x as getConfig,v as getCountries,B as getCustomerCompany,q as getStoreConfig,_ as initialize,A as isCompanyAdmin,ae as isCompanyRoleNameAvailable,V as isCompanyUser,I as removeFetchGraphQlHeader,N as setEndpoint,P as setFetchGraphQlHeader,U as setFetchGraphQlHeaders,L as updateCompany,te as updateCompanyRole,Q as validateCompanyEmail};
19
19
  //# sourceMappingURL=api.js.map
package/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sources":["/@dropins/storefront-company-management/src/api/initialize/initialize.ts","/@dropins/storefront-company-management/src/api/isCompanyAdmin/graphql/isCompanyAdmin.graphql.ts","/@dropins/storefront-company-management/src/api/isCompanyAdmin/isCompanyAdmin.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n// import { events } from '@adobe-commerce/event-bus';\n\n\nexport interface CompanyDropinConfig {\n langDefinitions?: Record<string, Record<string, string>>;\n models?: Record<string, any>;\n}\n\nexport const initialize = async (config: CompanyDropinConfig = {}) => {\n return {\n success: true,\n config,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_CUSTOMER_COMPANIES_WITH_ROLES = /* GraphQL */ `\n query GET_CUSTOMER_COMPANIES_WITH_ROLES {\n customer {\n companies(input: {}) {\n items {\n id\n name\n }\n }\n role {\n id\n name\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n \nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_CUSTOMER_COMPANIES_WITH_ROLES } from './graphql/isCompanyAdmin.graphql';\n\ninterface CompanyRole {\n id: string;\n name: string;\n}\n\ninterface CompanyBasicInfo {\n id: string;\n name: string;\n}\n\ninterface CustomerCompaniesWithRolesResponse {\n customer: {\n companies: {\n items: CompanyBasicInfo[];\n };\n role: CompanyRole | null;\n } | null;\n}\n\n/**\n * Check if the current authenticated customer is a company administrator in any company\n * @returns Promise<boolean> - true if customer is a company admin in at least one company, false otherwise\n */\nexport const isCompanyAdmin = async (): Promise<boolean> => {\n try {\n const response = await fetchGraphQl<CustomerCompaniesWithRolesResponse>(GET_CUSTOMER_COMPANIES_WITH_ROLES, {\n method: 'POST',\n });\n\n if (response.errors?.length) {\n return false;\n }\n\n const customer = response.data?.customer;\n if (!customer) {\n return false;\n }\n\n // Check if user is part of at least one company\n const companies = customer.companies?.items ?? [];\n if (!Array.isArray(companies) || companies.length === 0) {\n return false;\n }\n\n // Check if user has admin role\n const customerRole = customer.role;\n if (!customerRole) {\n return false;\n }\n\n // Check if user is company administrator by role ID or name\n return customerRole.id === '0' || \n (typeof customerRole.id === 'number' && customerRole.id === 0) ||\n customerRole.name === 'Company Administrator';\n } catch (error) {\n console.error('Error checking if customer is company admin:', error);\n return false;\n }\n};\n"],"names":["initialize","config","GET_CUSTOMER_COMPANIES_WITH_ROLES","isCompanyAdmin","response","fetchGraphQl","_a","customer","_b","companies","_c","customerRole","error"],"mappings":"ygBAyBO,MAAMA,EAAa,MAAOC,EAA8B,MACtD,CACL,QAAS,GACT,OAAAA,CACF,GCZWC,EAAkD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EC0BlDC,EAAiB,SAA8B,WACtD,GAAA,CACI,MAAAC,EAAW,MAAMC,EAAiDH,EAAmC,CACzG,OAAQ,MAAA,CACT,EAEG,IAAAI,EAAAF,EAAS,SAAT,MAAAE,EAAiB,OACZ,MAAA,GAGH,MAAAC,GAAWC,EAAAJ,EAAS,OAAT,YAAAI,EAAe,SAChC,GAAI,CAACD,EACI,MAAA,GAIT,MAAME,IAAYC,EAAAH,EAAS,YAAT,YAAAG,EAAoB,QAAS,CAAC,EAChD,GAAI,CAAC,MAAM,QAAQD,CAAS,GAAKA,EAAU,SAAW,EAC7C,MAAA,GAIT,MAAME,EAAeJ,EAAS,KAC9B,OAAKI,EAKEA,EAAa,KAAO,KACnB,OAAOA,EAAa,IAAO,UAAYA,EAAa,KAAO,GAC5DA,EAAa,OAAS,wBANpB,SAOFC,EAAO,CACN,eAAA,MAAM,+CAAgDA,CAAK,EAC5D,EAAA,CAEX"}
1
+ {"version":3,"file":"api.js","sources":["/@dropins/storefront-company-management/src/api/companyRoles/getCompanyRole.ts","/@dropins/storefront-company-management/src/api/companyRoles/utils.ts","/@dropins/storefront-company-management/src/api/initialize/initialize.ts","/@dropins/storefront-company-management/src/api/isCompanyAdmin/graphql/isCompanyAdmin.graphql.ts","/@dropins/storefront-company-management/src/api/isCompanyAdmin/isCompanyAdmin.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { GET_COMPANY_ROLE } from './graphql/queries';\nimport { GetCompanyRoleVariables, GetCompanyRoleResponse } from '../../types/api/companyRoles.types';\nimport { CompanyRoleModel } from '../../data/models/company-role';\nimport { transformGetCompanyRoleResponse } from '../../data/transforms/transform-company-roles';\n\n/**\n * Fetch a single company role by ID\n */\nexport const getCompanyRole = async (\n variables: GetCompanyRoleVariables\n): Promise<CompanyRoleModel> => {\n try {\n const response: GetCompanyRoleResponse = await fetchGraphQl(GET_COMPANY_ROLE, {\n variables,\n method: 'GET',\n cache: 'no-cache',\n });\n\n return transformGetCompanyRoleResponse(response);\n } catch (error) {\n return handleNetworkError(error as Error);\n }\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { flattenIdsToArray } from '../../lib/company-permissions';\nimport { CompanyAclResourceModel } from '../../data/models/company-role';\n\n/**\n * Helper function to flatten ACL resources into a list of permission IDs\n */\nexport const flattenPermissionIds = (resources: CompanyAclResourceModel[]): string[] => {\n return flattenIdsToArray(resources);\n};\n\n/**\n * Helper function to build a permission tree from flat permission IDs\n */\nexport const buildPermissionTree = (\n allResources: CompanyAclResourceModel[],\n selectedIds: string[]\n): CompanyAclResourceModel[] => {\n const selectedSet = new Set(selectedIds);\n \n const filterTree = (resource: CompanyAclResourceModel): CompanyAclResourceModel | null => {\n const filteredChildren = resource.children\n ?.map(filterTree)\n .filter((child): child is CompanyAclResourceModel => child !== null) || [];\n \n if (selectedSet.has(resource.id) || filteredChildren.length > 0) {\n return {\n ...resource,\n children: filteredChildren,\n };\n }\n \n return null;\n };\n \n return allResources\n .map(filterTree)\n .filter((resource): resource is CompanyAclResourceModel => resource !== null);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n// import { events } from '@adobe-commerce/event-bus';\n\n\nexport interface CompanyDropinConfig {\n langDefinitions?: Record<string, Record<string, string>>;\n models?: Record<string, any>;\n}\n\nexport const initialize = async (config: CompanyDropinConfig = {}) => {\n return {\n success: true,\n config,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_CUSTOMER_COMPANIES_WITH_ROLES = /* GraphQL */ `\n query GET_CUSTOMER_COMPANIES_WITH_ROLES {\n customer {\n companies(input: {}) {\n items {\n id\n name\n }\n }\n role {\n id\n name\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n \nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_CUSTOMER_COMPANIES_WITH_ROLES } from './graphql/isCompanyAdmin.graphql';\n\ninterface CompanyRole {\n id: string;\n name: string;\n}\n\ninterface CompanyBasicInfo {\n id: string;\n name: string;\n}\n\ninterface CustomerCompaniesWithRolesResponse {\n customer: {\n companies: {\n items: CompanyBasicInfo[];\n };\n role: CompanyRole | null;\n } | null;\n}\n\n/**\n * Check if the current authenticated customer is a company administrator in any company\n * @returns Promise<boolean> - true if customer is a company admin in at least one company, false otherwise\n */\nexport const isCompanyAdmin = async (): Promise<boolean> => {\n try {\n const response = await fetchGraphQl<CustomerCompaniesWithRolesResponse>(GET_CUSTOMER_COMPANIES_WITH_ROLES, {\n method: 'POST',\n });\n\n if (response.errors?.length) {\n return false;\n }\n\n const customer = response.data?.customer;\n if (!customer) {\n return false;\n }\n\n // Check if user is part of at least one company\n const companies = customer.companies?.items ?? [];\n if (!Array.isArray(companies) || companies.length === 0) {\n return false;\n }\n\n // Check if user has admin role\n const customerRole = customer.role;\n if (!customerRole) {\n return false;\n }\n\n // Check if user is company administrator by role ID or name\n return customerRole.id === '0' || \n (typeof customerRole.id === 'number' && customerRole.id === 0) ||\n customerRole.name === 'Company Administrator';\n } catch (error) {\n console.error('Error checking if customer is company admin:', error);\n return false;\n }\n};\n"],"names":["getCompanyRole","variables","response","fetchGraphQl","GET_COMPANY_ROLE","transformGetCompanyRoleResponse","error","handleNetworkError","flattenPermissionIds","resources","flattenIdsToArray","buildPermissionTree","allResources","selectedIds","selectedSet","filterTree","resource","filteredChildren","_a","child","initialize","config","GET_CUSTOMER_COMPANIES_WITH_ROLES","isCompanyAdmin","customer","_b","companies","_c","customerRole"],"mappings":"gyBA2Ba,MAAAA,EAAiB,MAC5BC,GAC8B,CAC1B,GAAA,CACI,MAAAC,EAAmC,MAAMC,EAAaC,EAAkB,CAC5E,UAAAH,EACA,OAAQ,MACR,MAAO,UAAA,CACR,EAED,OAAOI,EAAgCH,CAAQ,QACxCI,EAAO,CACd,OAAOC,EAAmBD,CAAc,CAAA,CAE5C,EClBaE,EAAwBC,GAC5BC,EAAkBD,CAAS,EAMvBE,EAAsB,CACjCC,EACAC,IAC8B,CACxB,MAAAC,EAAc,IAAI,IAAID,CAAW,EAEjCE,EAAcC,GAAsE,OACxF,MAAMC,IAAmBC,EAAAF,EAAS,WAAT,YAAAE,EACrB,IAAIH,GACL,OAAQI,GAA4CA,IAAU,QAAS,CAAC,EAE3E,OAAIL,EAAY,IAAIE,EAAS,EAAE,GAAKC,EAAiB,OAAS,EACrD,CACL,GAAGD,EACH,SAAUC,CACZ,EAGK,IACT,EAEO,OAAAL,EACJ,IAAIG,CAAU,EACd,OAAQC,GAAkDA,IAAa,IAAI,CAChF,EC7BaI,EAAa,MAAOC,EAA8B,MACtD,CACL,QAAS,GACT,OAAAA,CACF,GCZWC,EAAkD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EC0BlDC,EAAiB,SAA8B,WACtD,GAAA,CACI,MAAArB,EAAW,MAAMC,EAAiDmB,EAAmC,CACzG,OAAQ,MAAA,CACT,EAEG,IAAAJ,EAAAhB,EAAS,SAAT,MAAAgB,EAAiB,OACZ,MAAA,GAGH,MAAAM,GAAWC,EAAAvB,EAAS,OAAT,YAAAuB,EAAe,SAChC,GAAI,CAACD,EACI,MAAA,GAIT,MAAME,IAAYC,EAAAH,EAAS,YAAT,YAAAG,EAAoB,QAAS,CAAC,EAChD,GAAI,CAAC,MAAM,QAAQD,CAAS,GAAKA,EAAU,SAAW,EAC7C,MAAA,GAIT,MAAME,EAAeJ,EAAS,KAC9B,OAAKI,EAKEA,EAAa,KAAO,KACnB,OAAOA,EAAa,IAAO,UAAYA,EAAa,KAAO,GAC5DA,EAAa,OAAS,wBANpB,SAOFtB,EAAO,CACN,eAAA,MAAM,+CAAgDA,CAAK,EAC5D,EAAA,CAEX"}
@@ -0,0 +1,4 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ const i=(n=[])=>{const t=new Set,a=[...n];for(;a.length;){const s=a.pop();if(s&&(typeof s.id=="string"&&t.add(s.id),Array.isArray(s.children)&&s.children.length))for(const o of s.children)a.push(o)}return t},d=(n=[])=>Array.from(i(n)),c=n=>(n==null?void 0:n.id)==="0"||typeof(n==null?void 0:n.id)=="number"&&(n==null?void 0:n.id)===0||(n==null?void 0:n.name)==="Company Administrator",e=n=>{const t=i((n==null?void 0:n.permissions)||[]),a=c(n);return{canViewAccount:a||t.has("Magento_Company::view_account"),canEditAccount:a||t.has("Magento_Company::edit_account"),canViewAddress:a||t.has("Magento_Company::view_address"),canEditAddress:a||t.has("Magento_Company::edit_address"),canViewContacts:a||t.has("Magento_Company::contacts"),canViewPaymentInformation:a||t.has("Magento_Company::payment_information"),canViewShippingInformation:a||t.has("Magento_Company::shipping_information"),canViewRoles:a||t.has("Magento_Company::roles_view"),canManageRoles:a||t.has("Magento_Company::roles_edit")}};export{d as a,e as b,i as f,c as i};
4
+ //# sourceMappingURL=company-permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"company-permissions.js","sources":["/@dropins/storefront-company-management/src/lib/company-permissions.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n/**\n * Permission flags interface for company operations\n */\nexport interface CompanyPermissionFlags {\n canViewAccount: boolean;\n canEditAccount: boolean;\n canViewAddress: boolean;\n canEditAddress: boolean;\n canViewContacts: boolean;\n canViewPaymentInformation: boolean;\n canViewShippingInformation: boolean;\n canViewRoles: boolean;\n canManageRoles: boolean;\n}\n\n/**\n * Flattens a nested permissions tree into a Set of permission IDs\n * This is a pure utility function that can be used across the application\n */\nexport const flattenIds = (nodes: any[] = []): Set<string> => {\n const set = new Set<string>();\n const stack = [...nodes];\n while (stack.length) {\n const node = stack.pop();\n if (!node) continue;\n if (typeof node.id === 'string') set.add(node.id);\n if (Array.isArray(node.children) && node.children.length) {\n for (const child of node.children) stack.push(child);\n }\n }\n return set;\n};\n\n/**\n * Flattens a nested permissions tree into an Array of permission IDs\n * Convenience function that returns an array instead of a Set\n */\nexport const flattenIdsToArray = (nodes: any[] = []): string[] => {\n return Array.from(flattenIds(nodes));\n};\n\n/**\n * Determines if a role is a Company Administrator\n */\nexport const isCompanyAdministrator = (role: any): boolean => {\n return role?.id === '0' || \n (typeof role?.id === 'number' && role?.id === 0) || \n role?.name === 'Company Administrator';\n};\n\n/**\n * Builds permission flags from role data\n */\nexport const buildPermissionFlags = (role: any): CompanyPermissionFlags => {\n const allowedIds = flattenIds(role?.permissions || []);\n const isAdmin = isCompanyAdministrator(role);\n\n return {\n canViewAccount: isAdmin || allowedIds.has('Magento_Company::view_account'),\n canEditAccount: isAdmin || allowedIds.has('Magento_Company::edit_account'),\n canViewAddress: isAdmin || allowedIds.has('Magento_Company::view_address'),\n canEditAddress: isAdmin || allowedIds.has('Magento_Company::edit_address'),\n canViewContacts: isAdmin || allowedIds.has('Magento_Company::contacts'),\n canViewPaymentInformation: isAdmin || allowedIds.has('Magento_Company::payment_information'),\n canViewShippingInformation: isAdmin || allowedIds.has('Magento_Company::shipping_information'),\n canViewRoles: isAdmin || allowedIds.has('Magento_Company::roles_view'),\n canManageRoles: isAdmin || allowedIds.has('Magento_Company::roles_edit'),\n };\n};\n"],"names":["flattenIds","nodes","set","stack","node","child","flattenIdsToArray","isCompanyAdministrator","role","buildPermissionFlags","allowedIds","isAdmin"],"mappings":"AAoCO,MAAMA,EAAa,CAACC,EAAe,KAAoB,CACtD,MAAAC,MAAU,IACVC,EAAQ,CAAC,GAAGF,CAAK,EACvB,KAAOE,EAAM,QAAQ,CACb,MAAAC,EAAOD,EAAM,IAAI,EACvB,GAAKC,IACD,OAAOA,EAAK,IAAO,UAAcF,EAAA,IAAIE,EAAK,EAAE,EAC5C,MAAM,QAAQA,EAAK,QAAQ,GAAKA,EAAK,SAAS,QAChD,UAAWC,KAASD,EAAK,SAAUD,EAAM,KAAKE,CAAK,CACrD,CAEK,OAAAH,CACT,EAMaI,EAAoB,CAACL,EAAe,KACxC,MAAM,KAAKD,EAAWC,CAAK,CAAC,EAMxBM,EAA0BC,IAC9BA,GAAA,YAAAA,EAAM,MAAO,KACZ,OAAOA,GAAA,YAAAA,EAAM,KAAO,WAAYA,GAAA,YAAAA,EAAM,MAAO,IAC9CA,GAAA,YAAAA,EAAM,QAAS,wBAMXC,EAAwBD,GAAsC,CACzE,MAAME,EAAaV,GAAWQ,GAAA,YAAAA,EAAM,cAAe,CAAA,CAAE,EAC/CG,EAAUJ,EAAuBC,CAAI,EAEpC,MAAA,CACL,eAAgBG,GAAWD,EAAW,IAAI,+BAA+B,EACzE,eAAgBC,GAAWD,EAAW,IAAI,+BAA+B,EACzE,eAAgBC,GAAWD,EAAW,IAAI,+BAA+B,EACzE,eAAgBC,GAAWD,EAAW,IAAI,+BAA+B,EACzE,gBAAiBC,GAAWD,EAAW,IAAI,2BAA2B,EACtE,0BAA2BC,GAAWD,EAAW,IAAI,sCAAsC,EAC3F,2BAA4BC,GAAWD,EAAW,IAAI,uCAAuC,EAC7F,aAAcC,GAAWD,EAAW,IAAI,6BAA6B,EACrE,eAAgBC,GAAWD,EAAW,IAAI,6BAA6B,CACzE,CACF"}
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{h as a,a as l}from"./fetch-error.js";import{f as d}from"./fetch-graphql.js";import{t as g}from"./validateCompanyEmail.js";const u=`
3
+ import{h as a,a as l}from"./fetch-error.js";import{f as d}from"./fetch-graphql.js";import{a as g}from"./validateCompanyEmail.js";const u=`
4
4
  query getStoreConfig {
5
5
  storeConfig {
6
6
  default_country
@@ -0,0 +1,27 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import{h as d,a as m}from"./fetch-error.js";import{f as c,i as s}from"./company-permissions.js";import{f as _}from"./fetch-graphql.js";const h=`
4
+ query GET_CUSTOMER_ROLE_PERMISSIONS {
5
+ customer {
6
+ role {
7
+ id
8
+ name
9
+ permissions {
10
+ id
11
+ children {
12
+ id
13
+ children {
14
+ id
15
+ children {
16
+ id
17
+ children { id }
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
23
+ status
24
+ }
25
+ }
26
+ `,C=async()=>await _(h,{method:"GET",cache:"no-cache"}).then(a=>{var i,o,r;if((i=a.errors)!=null&&i.length)return d(a.errors);const t=(r=(o=a==null?void 0:a.data)==null?void 0:o.customer)==null?void 0:r.role,n=c((t==null?void 0:t.permissions)||[]);return s(t)&&["Magento_Company::view_account","Magento_Company::edit_account","Magento_Company::view_address","Magento_Company::edit_address","Magento_Company::contacts","Magento_Company::payment_information","Magento_Company::shipping_information","Magento_Company::roles_view","Magento_Company::roles_edit"].forEach(e=>n.add(e)),{allowedIds:n,roleResponse:a}}).catch(m);export{C as f};
27
+ //# sourceMappingURL=fetchUserPermissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchUserPermissions.js","sources":["/@dropins/storefront-company-management/src/api/fetchUserPermissions/graphql/getCustomerRole.graphql.ts","/@dropins/storefront-company-management/src/api/fetchUserPermissions/fetchUserPermissions.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nexport const GET_CUSTOMER_ROLE_PERMISSIONS = /* GraphQL */ `\n query GET_CUSTOMER_ROLE_PERMISSIONS {\n customer {\n role {\n id\n name\n permissions {\n id\n children {\n id\n children {\n id\n children {\n id\n children { id }\n }\n }\n }\n }\n }\n status\n }\n }\n`;\n\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { handleNetworkError } from '../../lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { GET_CUSTOMER_ROLE_PERMISSIONS } from './graphql/getCustomerRole.graphql';\nimport { flattenIds, isCompanyAdministrator } from '../../lib/company-permissions';\n\n/**\n * Fetches user permissions and returns both the allowed permission IDs and the role response\n * This is a general-purpose API function that can be used across the application\n */\nexport const fetchUserPermissions = async (): Promise<{ allowedIds: Set<string>; roleResponse: any }> => {\n return await fetchGraphQl(GET_CUSTOMER_ROLE_PERMISSIONS, { \n method: 'GET', \n cache: 'no-cache' \n })\n .then((roleResponse: any) => {\n if (roleResponse.errors?.length) {\n return handleFetchError(roleResponse.errors);\n }\n\n const role = roleResponse?.data?.customer?.role;\n const allowedIds = flattenIds(role?.permissions || []);\n \n // Treat Company Administrator as having all permissions even if the permissions tree is empty\n const isAdmin = isCompanyAdministrator(role);\n if (isAdmin) {\n [\n 'Magento_Company::view_account',\n 'Magento_Company::edit_account',\n 'Magento_Company::view_address',\n 'Magento_Company::edit_address',\n 'Magento_Company::contacts',\n 'Magento_Company::payment_information',\n 'Magento_Company::shipping_information',\n 'Magento_Company::roles_view',\n 'Magento_Company::roles_edit',\n ].forEach((id) => allowedIds.add(id));\n }\n\n return { allowedIds, roleResponse };\n })\n .catch(handleNetworkError);\n};\n"],"names":["GET_CUSTOMER_ROLE_PERMISSIONS","fetchUserPermissions","fetchGraphQl","roleResponse","_a","handleFetchError","role","_c","_b","allowedIds","flattenIds","isCompanyAdministrator","id","handleNetworkError"],"mappings":"uIAgBa,MAAAA,EAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECU9CC,EAAuB,SAC3B,MAAMC,EAAaF,EAA+B,CACvD,OAAQ,MACR,MAAO,UAAA,CACR,EACE,KAAMG,GAAsB,WACvB,IAAAC,EAAAD,EAAa,SAAb,MAAAC,EAAqB,OAChB,OAAAC,EAAiBF,EAAa,MAAM,EAGvC,MAAAG,GAAOC,GAAAC,EAAAL,GAAA,YAAAA,EAAc,OAAd,YAAAK,EAAoB,WAApB,YAAAD,EAA8B,KACrCE,EAAaC,GAAWJ,GAAA,YAAAA,EAAM,cAAe,CAAA,CAAE,EAIrD,OADgBK,EAAuBL,CAAI,GAEzC,CACE,gCACA,gCACA,gCACA,gCACA,4BACA,uCACA,wCACA,8BACA,6BAAA,EACA,QAASM,GAAOH,EAAW,IAAIG,CAAE,CAAC,EAG/B,CAAE,WAAAH,EAAY,aAAAN,CAAa,CAAA,CACnC,EACA,MAAMU,CAAkB"}
@@ -0,0 +1,121 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import{a,h as i}from"./fetch-error.js";import{f as n}from"./fetch-graphql.js";const s=`
4
+ fragment CompanyRoleFragment on CompanyRole {
5
+ id
6
+ name
7
+ users_count
8
+ permissions {
9
+ id
10
+ text
11
+ sort_order
12
+ children {
13
+ id
14
+ text
15
+ sort_order
16
+ children {
17
+ id
18
+ text
19
+ sort_order
20
+ children {
21
+ id
22
+ text
23
+ sort_order
24
+ children {
25
+ id
26
+ text
27
+ sort_order
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ `,l=`
35
+ query GetCompanyRoles($pageSize: Int, $currentPage: Int) {
36
+ company {
37
+ roles(pageSize: $pageSize, currentPage: $currentPage) {
38
+ items {
39
+ ...CompanyRoleFragment
40
+ }
41
+ total_count
42
+ page_info {
43
+ current_page
44
+ page_size
45
+ total_pages
46
+ }
47
+ }
48
+ }
49
+ }
50
+ ${s}
51
+ `,P=`
52
+ query GetCompanyRole($id: ID!) {
53
+ company {
54
+ role(id: $id) {
55
+ ...CompanyRoleFragment
56
+ }
57
+ }
58
+ }
59
+ ${s}
60
+ `,d=`
61
+ query GetCompanyAclResources {
62
+ company {
63
+ acl_resources {
64
+ id
65
+ text
66
+ sort_order
67
+ children {
68
+ id
69
+ text
70
+ sort_order
71
+ children {
72
+ id
73
+ text
74
+ sort_order
75
+ children {
76
+ id
77
+ text
78
+ sort_order
79
+ children {
80
+ id
81
+ text
82
+ sort_order
83
+ }
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ `,p=`
91
+ query IsCompanyRoleNameAvailable($name: String!) {
92
+ isCompanyRoleNameAvailable(name: $name) {
93
+ is_role_name_available
94
+ }
95
+ }
96
+ `,m=e=>{var r;return{id:e.id,text:e.text,sortOrder:e.sort_order,children:(r=e.children)==null?void 0:r.map(m)}},c=e=>({id:e.id,name:e.name,usersCount:e.users_count,permissions:e.permissions.map(m)}),u=e=>({currentPage:e.current_page,pageSize:e.page_size,totalPages:e.total_pages}),y=e=>({items:e.items.map(c),totalCount:e.total_count,pageInfo:u(e.page_info)}),C=e=>{var r,o,t;if((r=e.errors)!=null&&r.length)throw new Error(e.errors[0].message);if(!((t=(o=e.data)==null?void 0:o.company)!=null&&t.roles))throw new Error("Invalid response: missing company roles data");return y(e.data.company.roles)},$=e=>{var r,o,t;if((r=e.errors)!=null&&r.length)throw new Error(e.errors[0].message);if(!((t=(o=e.data)==null?void 0:o.company)!=null&&t.role))throw new Error("Invalid response: missing company role data");return c(e.data.company.role)},R=e=>{var r,o,t;if((r=e.errors)!=null&&r.length)throw new Error(e.errors[0].message);if(!((t=(o=e.data)==null?void 0:o.company)!=null&&t.acl_resources))throw new Error("Invalid response: missing ACL resources data");return e.data.company.acl_resources.map(m)},h=e=>{var r,o,t;if((r=e.errors)!=null&&r.length)throw new Error(e.errors[0].message);if(!((t=(o=e.data)==null?void 0:o.createCompanyRole)!=null&&t.role))throw new Error("Invalid response: missing created role data");return c(e.data.createCompanyRole.role)},_=e=>{var r,o,t;if((r=e.errors)!=null&&r.length)throw new Error(e.errors[0].message);if(!((t=(o=e.data)==null?void 0:o.updateCompanyRole)!=null&&t.role))throw new Error("Invalid response: missing updated role data");return c(e.data.updateCompanyRole.role)},g=e=>({name:e.name,permissions:e.permissions}),E=e=>({id:e.id,name:e.name,permissions:e.permissions}),G=async(e={})=>{try{const r=await n(l,{variables:e,method:"GET",cache:"no-cache"});return C(r)}catch(r){return a(r)}},N=async()=>{try{const e=await n(d,{method:"GET",cache:"force-cache"});return R(e)}catch(e){return a(e)}},f=`
97
+ mutation CreateCompanyRole($input: CompanyRoleCreateInput!) {
98
+ createCompanyRole(input: $input) {
99
+ role {
100
+ ...CompanyRoleFragment
101
+ }
102
+ }
103
+ }
104
+ ${s}
105
+ `,w=`
106
+ mutation UpdateCompanyRole($input: CompanyRoleUpdateInput!) {
107
+ updateCompanyRole(input: $input) {
108
+ role {
109
+ ...CompanyRoleFragment
110
+ }
111
+ }
112
+ }
113
+ ${s}
114
+ `,A=`
115
+ mutation DeleteCompanyRole($id: ID!) {
116
+ deleteCompanyRole(id: $id) {
117
+ success
118
+ }
119
+ }
120
+ `,v=async e=>{try{const r={input:g(e)},o=await n(f,{variables:r,method:"POST"});return h(o)}catch(r){return a(r)}},x=async e=>{try{const r={input:E(e)},o=await n(w,{variables:r,method:"POST"});return _(o)}catch(r){return a(r)}},T=async e=>{var r;try{const o=await n(A,{variables:e,method:"POST"});return(r=o.errors)!=null&&r.length?i(o.errors):o.data.deleteCompanyRole.success}catch(o){return a(o)}},L=async e=>{var r;try{const o=await n(p,{variables:e,method:"GET",cache:"no-cache"});return(r=o.errors)!=null&&r.length?i(o.errors):o.data.isCompanyRoleNameAvailable.is_role_name_available}catch(o){return a(o)}};export{P as G,N as a,v as c,T as d,G as g,L as i,$ as t,x as u};
121
+ //# sourceMappingURL=isCompanyRoleNameAvailable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isCompanyRoleNameAvailable.js","sources":["/@dropins/storefront-company-management/src/api/companyRoles/graphql/fragments.ts","/@dropins/storefront-company-management/src/api/companyRoles/graphql/queries.ts","/@dropins/storefront-company-management/src/data/transforms/transform-company-roles.ts","/@dropins/storefront-company-management/src/api/companyRoles/getCompanyRoles.ts","/@dropins/storefront-company-management/src/api/companyRoles/getCompanyAclResources.ts","/@dropins/storefront-company-management/src/api/companyRoles/graphql/mutations.ts","/@dropins/storefront-company-management/src/api/companyRoles/createCompanyRole.ts","/@dropins/storefront-company-management/src/api/companyRoles/updateCompanyRole.ts","/@dropins/storefront-company-management/src/api/companyRoles/deleteCompanyRole.ts","/@dropins/storefront-company-management/src/api/companyRoles/isCompanyRoleNameAvailable.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n// Fragment for company role data\nexport const COMPANY_ROLE_FRAGMENT = /* GraphQL */ `\n fragment CompanyRoleFragment on CompanyRole {\n id\n name\n users_count\n permissions {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n }\n }\n }\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { COMPANY_ROLE_FRAGMENT } from './fragments';\n\nexport const GET_COMPANY_ROLES = /* GraphQL */ `\n query GetCompanyRoles($pageSize: Int, $currentPage: Int) {\n company {\n roles(pageSize: $pageSize, currentPage: $currentPage) {\n items {\n ...CompanyRoleFragment\n }\n total_count\n page_info {\n current_page\n page_size\n total_pages\n }\n }\n }\n }\n ${COMPANY_ROLE_FRAGMENT}\n`;\n\nexport const GET_COMPANY_ROLE = /* GraphQL */ `\n query GetCompanyRole($id: ID!) {\n company {\n role(id: $id) {\n ...CompanyRoleFragment\n }\n }\n }\n ${COMPANY_ROLE_FRAGMENT}\n`;\n\nexport const GET_COMPANY_ACL_RESOURCES = /* GraphQL */ `\n query GetCompanyAclResources {\n company {\n acl_resources {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n children {\n id\n text\n sort_order\n }\n }\n }\n }\n }\n }\n }\n`;\n\nexport const IS_COMPANY_ROLE_NAME_AVAILABLE = /* GraphQL */ `\n query IsCompanyRoleNameAvailable($name: String!) {\n isCompanyRoleNameAvailable(name: $name) {\n is_role_name_available\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n CompanyAclResourceResponse,\n CompanyRoleResponse,\n CompanyRolesResponse,\n PageInfoResponse,\n GetCompanyRolesResponse,\n GetCompanyRoleResponse,\n GetCompanyAclResourcesResponse,\n CreateCompanyRoleResponse,\n UpdateCompanyRoleResponse,\n CompanyRoleCreateInput,\n CompanyRoleUpdateInput,\n} from '../../types/api/companyRoles.types';\nimport {\n CompanyAclResourceModel,\n CompanyRoleModel,\n CompanyRolesResponseModel,\n PageInfoModel,\n CompanyRoleCreateInputModel,\n CompanyRoleUpdateInputModel,\n} from '../models/company-role';\n\nexport const transformCompanyAclResource = (\n response: CompanyAclResourceResponse\n): CompanyAclResourceModel => {\n return {\n id: response.id,\n text: response.text,\n sortOrder: response.sort_order,\n children: response.children?.map(transformCompanyAclResource),\n };\n};\n\nexport const transformCompanyRole = (\n response: CompanyRoleResponse\n): CompanyRoleModel => {\n return {\n id: response.id,\n name: response.name,\n usersCount: response.users_count,\n permissions: response.permissions.map(transformCompanyAclResource),\n };\n};\n\nexport const transformPageInfo = (\n response: PageInfoResponse\n): PageInfoModel => {\n return {\n currentPage: response.current_page,\n pageSize: response.page_size,\n totalPages: response.total_pages,\n };\n};\n\nexport const transformCompanyRolesResponse = (\n response: CompanyRolesResponse\n): CompanyRolesResponseModel => {\n return {\n items: response.items.map(transformCompanyRole),\n totalCount: response.total_count,\n pageInfo: transformPageInfo(response.page_info),\n };\n};\n\nexport const transformGetCompanyRolesResponse = (\n response: GetCompanyRolesResponse\n): CompanyRolesResponseModel => {\n if (response.errors?.length) {\n throw new Error(response.errors[0].message);\n }\n \n if (!response.data?.company?.roles) {\n throw new Error('Invalid response: missing company roles data');\n }\n\n return transformCompanyRolesResponse(response.data.company.roles);\n};\n\nexport const transformGetCompanyRoleResponse = (\n response: GetCompanyRoleResponse\n): CompanyRoleModel => {\n if (response.errors?.length) {\n throw new Error(response.errors[0].message);\n }\n \n if (!response.data?.company?.role) {\n throw new Error('Invalid response: missing company role data');\n }\n\n return transformCompanyRole(response.data.company.role);\n};\n\nexport const transformGetCompanyAclResourcesResponse = (\n response: GetCompanyAclResourcesResponse\n): CompanyAclResourceModel[] => {\n if (response.errors?.length) {\n throw new Error(response.errors[0].message);\n }\n \n if (!response.data?.company?.acl_resources) {\n throw new Error('Invalid response: missing ACL resources data');\n }\n\n return response.data.company.acl_resources.map(transformCompanyAclResource);\n};\n\nexport const transformCreateCompanyRoleResponse = (\n response: CreateCompanyRoleResponse\n): CompanyRoleModel => {\n if (response.errors?.length) {\n throw new Error(response.errors[0].message);\n }\n \n if (!response.data?.createCompanyRole?.role) {\n throw new Error('Invalid response: missing created role data');\n }\n\n return transformCompanyRole(response.data.createCompanyRole.role);\n};\n\nexport const transformUpdateCompanyRoleResponse = (\n response: UpdateCompanyRoleResponse\n): CompanyRoleModel => {\n if (response.errors?.length) {\n throw new Error(response.errors[0].message);\n }\n \n if (!response.data?.updateCompanyRole?.role) {\n throw new Error('Invalid response: missing updated role data');\n }\n\n return transformCompanyRole(response.data.updateCompanyRole.role);\n};\n\nexport const transformCompanyRoleCreateInput = (\n input: CompanyRoleCreateInputModel\n): CompanyRoleCreateInput => {\n return {\n name: input.name,\n permissions: input.permissions,\n };\n};\n\nexport const transformCompanyRoleUpdateInput = (\n input: CompanyRoleUpdateInputModel\n): CompanyRoleUpdateInput => {\n return {\n id: input.id,\n name: input.name,\n permissions: input.permissions,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { GET_COMPANY_ROLES } from './graphql/queries';\nimport { GetCompanyRolesVariables, GetCompanyRolesResponse } from '../../types/api/companyRoles.types';\nimport { CompanyRolesResponseModel } from '../../data/models/company-role';\nimport { transformGetCompanyRolesResponse } from '../../data/transforms/transform-company-roles';\n\n/**\n * Fetch all company roles with pagination\n */\nexport const getCompanyRoles = async (\n variables: GetCompanyRolesVariables = {}\n): Promise<CompanyRolesResponseModel> => {\n try {\n const response: GetCompanyRolesResponse = await fetchGraphQl(GET_COMPANY_ROLES, {\n variables,\n method: 'GET',\n cache: 'no-cache',\n });\n\n return transformGetCompanyRolesResponse(response);\n } catch (error) {\n return handleNetworkError(error as Error);\n }\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { GET_COMPANY_ACL_RESOURCES } from './graphql/queries';\nimport { GetCompanyAclResourcesResponse } from '../../types/api/companyRoles.types';\nimport { CompanyAclResourceModel } from '../../data/models/company-role';\nimport { transformGetCompanyAclResourcesResponse } from '../../data/transforms/transform-company-roles';\n\n/**\n * Fetch all available ACL resources (permissions)\n */\nexport const getCompanyAclResources = async (): Promise<CompanyAclResourceModel[]> => {\n try {\n const response: GetCompanyAclResourcesResponse = await fetchGraphQl(GET_COMPANY_ACL_RESOURCES, {\n method: 'GET',\n cache: 'force-cache', // ACL resources don't change often, so we can cache them\n });\n\n return transformGetCompanyAclResourcesResponse(response);\n } catch (error) {\n return handleNetworkError(error as Error);\n }\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { COMPANY_ROLE_FRAGMENT } from './fragments';\n\nexport const CREATE_COMPANY_ROLE = /* GraphQL */ `\n mutation CreateCompanyRole($input: CompanyRoleCreateInput!) {\n createCompanyRole(input: $input) {\n role {\n ...CompanyRoleFragment\n }\n }\n }\n ${COMPANY_ROLE_FRAGMENT}\n`;\n\nexport const UPDATE_COMPANY_ROLE = /* GraphQL */ `\n mutation UpdateCompanyRole($input: CompanyRoleUpdateInput!) {\n updateCompanyRole(input: $input) {\n role {\n ...CompanyRoleFragment\n }\n }\n }\n ${COMPANY_ROLE_FRAGMENT}\n`;\n\nexport const DELETE_COMPANY_ROLE = /* GraphQL */ `\n mutation DeleteCompanyRole($id: ID!) {\n deleteCompanyRole(id: $id) {\n success\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { CREATE_COMPANY_ROLE } from './graphql/mutations';\nimport { CreateCompanyRoleVariables, CreateCompanyRoleResponse } from '../../types/api/companyRoles.types';\nimport { CompanyRoleModel, CompanyRoleCreateInputModel } from '../../data/models/company-role';\nimport { \n transformCreateCompanyRoleResponse,\n transformCompanyRoleCreateInput \n} from '../../data/transforms/transform-company-roles';\n\n/**\n * Create a new company role\n */\nexport const createCompanyRole = async (\n input: CompanyRoleCreateInputModel\n): Promise<CompanyRoleModel> => {\n try {\n const variables: CreateCompanyRoleVariables = {\n input: transformCompanyRoleCreateInput(input),\n };\n\n const response: CreateCompanyRoleResponse = await fetchGraphQl(CREATE_COMPANY_ROLE, {\n variables,\n method: 'POST',\n });\n\n return transformCreateCompanyRoleResponse(response);\n } catch (error) {\n return handleNetworkError(error as Error);\n }\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { UPDATE_COMPANY_ROLE } from './graphql/mutations';\nimport { UpdateCompanyRoleVariables, UpdateCompanyRoleResponse } from '../../types/api/companyRoles.types';\nimport { CompanyRoleModel, CompanyRoleUpdateInputModel } from '../../data/models/company-role';\nimport { \n transformUpdateCompanyRoleResponse,\n transformCompanyRoleUpdateInput \n} from '../../data/transforms/transform-company-roles';\n\n/**\n * Update an existing company role\n */\nexport const updateCompanyRole = async (\n input: CompanyRoleUpdateInputModel\n): Promise<CompanyRoleModel> => {\n try {\n const variables: UpdateCompanyRoleVariables = {\n input: transformCompanyRoleUpdateInput(input),\n };\n\n const response: UpdateCompanyRoleResponse = await fetchGraphQl(UPDATE_COMPANY_ROLE, {\n variables,\n method: 'POST',\n });\n\n return transformUpdateCompanyRoleResponse(response);\n } catch (error) {\n return handleNetworkError(error as Error);\n }\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { DELETE_COMPANY_ROLE } from './graphql/mutations';\nimport { DeleteCompanyRoleVariables, DeleteCompanyRoleResponse } from '../../types/api/companyRoles.types';\n\n/**\n * Delete a company role\n */\nexport const deleteCompanyRole = async (\n variables: DeleteCompanyRoleVariables\n): Promise<boolean> => {\n try {\n const response: DeleteCompanyRoleResponse = await fetchGraphQl(DELETE_COMPANY_ROLE, {\n variables,\n method: 'POST',\n });\n\n if (response.errors?.length) {\n return handleFetchError(response.errors);\n }\n\n return response.data.deleteCompanyRole.success;\n } catch (error) {\n return handleNetworkError(error as Error);\n }\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { IS_COMPANY_ROLE_NAME_AVAILABLE } from './graphql/queries';\nimport { \n IsCompanyRoleNameAvailableVariables, \n IsCompanyRoleNameAvailableResponse \n} from '../../types/api/companyRoles.types';\n\n/**\n * Check if a role name is available\n */\nexport const isCompanyRoleNameAvailable = async (\n variables: IsCompanyRoleNameAvailableVariables\n): Promise<boolean> => {\n try {\n const response: IsCompanyRoleNameAvailableResponse = await fetchGraphQl(\n IS_COMPANY_ROLE_NAME_AVAILABLE,\n {\n variables,\n method: 'GET',\n cache: 'no-cache',\n }\n );\n\n if (response.errors?.length) {\n return handleFetchError(response.errors);\n }\n\n return response.data.isCompanyRoleNameAvailable.is_role_name_available;\n } catch (error) {\n return handleNetworkError(error as Error);\n }\n};\n"],"names":["COMPANY_ROLE_FRAGMENT","GET_COMPANY_ROLES","GET_COMPANY_ROLE","GET_COMPANY_ACL_RESOURCES","IS_COMPANY_ROLE_NAME_AVAILABLE","transformCompanyAclResource","response","_a","transformCompanyRole","transformPageInfo","transformCompanyRolesResponse","transformGetCompanyRolesResponse","_c","_b","transformGetCompanyRoleResponse","transformGetCompanyAclResourcesResponse","transformCreateCompanyRoleResponse","transformUpdateCompanyRoleResponse","transformCompanyRoleCreateInput","input","transformCompanyRoleUpdateInput","getCompanyRoles","variables","fetchGraphQl","error","handleNetworkError","getCompanyAclResources","CREATE_COMPANY_ROLE","UPDATE_COMPANY_ROLE","DELETE_COMPANY_ROLE","createCompanyRole","updateCompanyRole","deleteCompanyRole","handleFetchError","isCompanyRoleNameAvailable"],"mappings":"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"}
@@ -1,29 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{h as c,a as l}from"./fetch-error.js";import{f as h,i as M,a as A}from"./validateCompanyEmail.js";import{f as g}from"./fetch-graphql.js";const f=`
4
- query GET_CUSTOMER_ROLE_PERMISSIONS {
5
- customer {
6
- role {
7
- id
8
- name
9
- permissions {
10
- id
11
- children {
12
- id
13
- children {
14
- id
15
- children {
16
- id
17
- children { id }
18
- }
19
- }
20
- }
21
- }
22
- }
23
- status
24
- }
25
- }
26
- `,y=async()=>await g(f,{method:"GET",cache:"no-cache"}).then(e=>{var t,d,n;if((t=e.errors)!=null&&t.length)return c(e.errors);const a=(n=(d=e==null?void 0:e.data)==null?void 0:d.customer)==null?void 0:n.role,r=h((a==null?void 0:a.permissions)||[]);return M(a)&&["Magento_Company::view_account","Magento_Company::edit_account","Magento_Company::view_address","Magento_Company::edit_address","Magento_Company::contacts","Magento_Company::payment_information","Magento_Company::shipping_information"].forEach(s=>r.add(s)),{allowedIds:r,roleResponse:e}}).catch(l),E=`
3
+ import{h as _,a as m}from"./fetch-error.js";import{f as A}from"./fetchUserPermissions.js";import{t as c}from"./validateCompanyEmail.js";import{f as y}from"./fetch-graphql.js";const f=`
27
4
  fragment COMPANY_LEGAL_ADDRESS_FRAGMENT on CompanyLegalAddress {
28
5
  street
29
6
  city
@@ -45,20 +22,20 @@ import{h as c,a as l}from"./fetch-error.js";import{f as h,i as M,a as A}from"./v
45
22
  vat_tax_id
46
23
  reseller_id
47
24
  }
48
- `,p=`
25
+ `,h=`
49
26
  fragment COMPANY_SALES_REPRESENTATIVE_FRAGMENT on CompanySalesRepresentative {
50
27
  firstname
51
28
  lastname
52
29
  email
53
30
  }
54
- `,u=`
31
+ `,M=`
55
32
  fragment COMPANY_ADMIN_FRAGMENT on Customer {
56
33
  firstname
57
34
  lastname
58
35
  email
59
36
  job_title
60
37
  }
61
- `,C=e=>{const a=e.has("Magento_Company::view_account"),r=e.has("Magento_Company::view_address"),o=e.has("Magento_Company::contacts"),t=e.has("Magento_Company::payment_information"),d=e.has("Magento_Company::shipping_information"),n=[],s=[];return a&&(n.push("...COMPANY_BASIC_INFO_FRAGMENT"),s.push(N)),r&&(n.push("legal_address { ...COMPANY_LEGAL_ADDRESS_FRAGMENT }"),s.push(E)),o&&(n.push("company_admin { ...COMPANY_ADMIN_FRAGMENT }"),n.push("sales_representative { ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT }"),s.push(u),s.push(p)),t&&n.push("available_payment_methods { code title }"),d&&n.push("available_shipping_methods { code title }"),{fields:n,usedFragments:s}},T=e=>{const{fields:a,usedFragments:r}=C(e);return a.length===0?`
38
+ `,C=e=>{const a=e.has("Magento_Company::view_account"),s=e.has("Magento_Company::view_address"),r=e.has("Magento_Company::contacts"),t=e.has("Magento_Company::payment_information"),l=e.has("Magento_Company::shipping_information"),o=[],d=[];return a&&(o.push("...COMPANY_BASIC_INFO_FRAGMENT"),d.push(N)),s&&(o.push("legal_address { ...COMPANY_LEGAL_ADDRESS_FRAGMENT }"),d.push(f)),r&&(o.push("company_admin { ...COMPANY_ADMIN_FRAGMENT }"),o.push("sales_representative { ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT }"),d.push(M),d.push(h)),t&&o.push("available_payment_methods { code title }"),l&&o.push("available_shipping_methods { code title }"),{fields:o,usedFragments:d}},p=e=>{const{fields:a,usedFragments:s}=C(e);return a.length===0?`
62
39
  query GET_COMPANY_DYNAMIC {
63
40
  company { __typename }
64
41
  }
@@ -70,8 +47,8 @@ import{h as c,a as l}from"./fetch-error.js";import{f as h,i as M,a as A}from"./v
70
47
  }
71
48
  }
72
49
  `}
73
- ${r.join(`
74
- `)}`},I=e=>{const{fields:a,usedFragments:r}=C(e);return a.length===0?`
50
+ ${s.join(`
51
+ `)}`},E=e=>{const{fields:a,usedFragments:s}=C(e);return a.length===0?`
75
52
  mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {
76
53
  updateCompany(input: $input) {
77
54
  company { __typename }
@@ -87,6 +64,6 @@ ${r.join(`
87
64
  }
88
65
  }
89
66
  `}
90
- ${r.join(`
91
- `)}`},Y=async()=>await y().then(async({allowedIds:e,roleResponse:a})=>{var n,s,_;const r=T(e),o=await g(r,{method:"GET",cache:"no-cache"});if((n=o.errors)!=null&&n.length)return c(o.errors);const t=(s=o==null?void 0:o.data)==null?void 0:s.company;return t&&Object.keys(t).some(m=>m!=="__typename")?(o.data.customer=(_=a==null?void 0:a.data)==null?void 0:_.customer,A(o)):null}).catch(l),G=async e=>await y().then(async({allowedIds:a,roleResponse:r})=>{var n,s;const o=I(a),t={};if(e.name!==void 0&&(t.company_name=e.name),e.email!==void 0&&(t.company_email=e.email),e.legalName!==void 0&&(t.legal_name=e.legalName),e.vatTaxId!==void 0&&(t.vat_tax_id=e.vatTaxId),e.resellerId!==void 0&&(t.reseller_id=e.resellerId),e.legalAddress!==void 0&&a.has("Magento_Company::edit_address")){let _;Array.isArray(e.legalAddress.street)?(_=[...e.legalAddress.street],e.legalAddress.street2&&_.push(e.legalAddress.street2)):_=[e.legalAddress.street,e.legalAddress.street2].filter(i=>typeof i=="string"&&i.trim().length>0),_=_.filter(i=>i&&typeof i=="string"&&i.trim().length>0);let m;if(e.legalAddress.region&&typeof e.legalAddress.region=="object"){const i=e.legalAddress.region;i.region===i.regionCode?m={region:i.region,region_code:i.regionCode,region_id:0}:m={region:i.region,region_code:i.regionCode}}else e.legalAddress.regionCode&&e.legalAddress.region!==e.legalAddress.regionCode?m={region:e.legalAddress.region||e.legalAddress.regionCode,region_code:e.legalAddress.regionCode}:e.legalAddress.region&&(m={region:e.legalAddress.region,region_code:e.legalAddress.region,region_id:0});t.legal_address={street:_,city:e.legalAddress.city,region:m,country_id:e.legalAddress.countryCode,postcode:e.legalAddress.postcode,telephone:e.legalAddress.telephone}}const d=await g(o,{method:"POST",variables:{input:t}});return(n=d.errors)!=null&&n.length?c(d.errors):(d.data.customer=(s=r==null?void 0:r.data)==null?void 0:s.customer,A(d))}).catch(l);export{y as f,Y as g,G as u};
67
+ ${s.join(`
68
+ `)}`},O=async()=>await A().then(async({allowedIds:e,roleResponse:a})=>{var o,d,i;const s=p(e),r=await y(s,{method:"GET",cache:"no-cache"});if((o=r.errors)!=null&&o.length)return _(r.errors);const t=(d=r==null?void 0:r.data)==null?void 0:d.company;return t&&Object.keys(t).some(g=>g!=="__typename")?(r.data.customer=(i=a==null?void 0:a.data)==null?void 0:i.customer,c(r)):null}).catch(m),Y=async e=>await A().then(async({allowedIds:a,roleResponse:s})=>{var o,d;const r=E(a),t={};if(e.name!==void 0&&(t.company_name=e.name),e.email!==void 0&&(t.company_email=e.email),e.legalName!==void 0&&(t.legal_name=e.legalName),e.vatTaxId!==void 0&&(t.vat_tax_id=e.vatTaxId),e.resellerId!==void 0&&(t.reseller_id=e.resellerId),e.legalAddress!==void 0&&a.has("Magento_Company::edit_address")){let i;Array.isArray(e.legalAddress.street)?(i=[...e.legalAddress.street],e.legalAddress.street2&&i.push(e.legalAddress.street2)):i=[e.legalAddress.street,e.legalAddress.street2].filter(n=>typeof n=="string"&&n.trim().length>0),i=i.filter(n=>n&&typeof n=="string"&&n.trim().length>0);let g;if(e.legalAddress.region&&typeof e.legalAddress.region=="object"){const n=e.legalAddress.region;n.region===n.regionCode?g={region:n.region,region_code:n.regionCode,region_id:0}:g={region:n.region,region_code:n.regionCode}}else e.legalAddress.regionCode&&e.legalAddress.region!==e.legalAddress.regionCode?g={region:e.legalAddress.region||e.legalAddress.regionCode,region_code:e.legalAddress.regionCode}:e.legalAddress.region&&(g={region:e.legalAddress.region,region_code:e.legalAddress.region,region_id:0});t.legal_address={street:i,city:e.legalAddress.city,region:g,country_id:e.legalAddress.countryCode,postcode:e.legalAddress.postcode,telephone:e.legalAddress.telephone}}const l=await y(r,{method:"POST",variables:{input:t}});return(o=l.errors)!=null&&o.length?_(l.errors):(l.data.customer=(d=s==null?void 0:s.data)==null?void 0:d.customer,c(l))}).catch(m);export{O as g,Y as u};
92
69
  //# sourceMappingURL=updateCompany.js.map