@dropins/storefront-company-management 1.0.0-beta8 → 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 (105) 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/{getCompanyCredit/graphql/getCompanyCredit.graphql.d.ts → companyRoles/graphql/fragments.d.ts} +2 -2
  7. package/api/{checkCompanyCreditEnabled → companyRoles/graphql}/index.d.ts +3 -1
  8. package/api/{checkCompanyCreditEnabled/graphql/checkCompanyCreditEnabled.graphql.d.ts → companyRoles/graphql/mutations.d.ts} +4 -2
  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 -3
  15. package/api.js +2 -8
  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 +3 -3
  20. package/chunks/createCompany.js.map +1 -1
  21. package/chunks/fetch-error.js +1 -1
  22. package/chunks/fetch-error.js.map +1 -1
  23. package/chunks/fetchUserPermissions.js +27 -0
  24. package/chunks/fetchUserPermissions.js.map +1 -0
  25. package/chunks/getCustomerCompany.js +3 -3
  26. package/chunks/getCustomerCompany.js.map +1 -1
  27. package/chunks/isCompanyRoleNameAvailable.js +121 -0
  28. package/chunks/isCompanyRoleNameAvailable.js.map +1 -0
  29. package/chunks/updateCompany.js +8 -31
  30. package/chunks/updateCompany.js.map +1 -1
  31. package/chunks/useCompanyContextListener.js +4 -0
  32. package/chunks/useCompanyContextListener.js.map +1 -0
  33. package/chunks/useCompanyContextListener2.js +4 -0
  34. package/chunks/useCompanyContextListener2.js.map +1 -0
  35. package/chunks/useInLineAlert.js +4 -0
  36. package/chunks/useInLineAlert.js.map +1 -0
  37. package/chunks/validateCompanyEmail.js +3 -3
  38. package/chunks/validateCompanyEmail.js.map +1 -1
  39. package/components/CompanyLoaders/CompanyLoaders.d.ts +0 -10
  40. package/components/DeleteRoleModal/DeleteRoleModal.d.ts +9 -0
  41. package/{api/getCompanyCreditHistory → components/DeleteRoleModal}/index.d.ts +2 -2
  42. package/components/EditRoleAndPermission/EditRoleAndPermission.d.ts +24 -0
  43. package/components/{CompanyCreditDisplay → EditRoleAndPermission}/index.d.ts +2 -2
  44. package/components/RoleAndPermissionTable/RoleAndPermissionTable.d.ts +20 -0
  45. package/{api/getCompanyCredit → components/RoleAndPermissionTable}/index.d.ts +2 -1
  46. package/components/Tree/Tree.d.ts +2 -0
  47. package/components/index.d.ts +3 -2
  48. package/containers/CompanyProfile.js +1 -1
  49. package/containers/CompanyProfile.js.map +1 -1
  50. package/containers/CompanyRegistration.js +1 -1
  51. package/containers/CompanyRegistration.js.map +1 -1
  52. package/containers/CompanyUsers/hooks/index.d.ts +19 -0
  53. package/containers/CompanyUsers/hooks/useCompanyContextListener.d.ts +62 -0
  54. package/containers/CompanyUsers/hooks.d.ts +1 -0
  55. package/containers/CompanyUsers/hooks.js +4 -0
  56. package/containers/CompanyUsers/hooks.js.map +1 -0
  57. package/containers/CustomerCompanyInfo.js +1 -1
  58. package/containers/CustomerCompanyInfo.js.map +1 -1
  59. package/containers/RolesAndPermissions/RolesAndPermissions.d.ts +8 -0
  60. package/containers/RolesAndPermissions/index.d.ts +19 -0
  61. package/containers/RolesAndPermissions.d.ts +3 -0
  62. package/containers/RolesAndPermissions.js +4 -0
  63. package/containers/RolesAndPermissions.js.map +1 -0
  64. package/containers/index.d.ts +1 -1
  65. package/data/models/{company-credit-history.d.ts → company-role.d.ts} +25 -31
  66. package/data/models/company.d.ts +4 -17
  67. package/data/models/index.d.ts +1 -2
  68. package/data/transforms/index.d.ts +1 -2
  69. package/data/transforms/transform-company-roles.d.ts +15 -0
  70. package/hooks/containers/index.d.ts +0 -1
  71. package/hooks/index.d.ts +3 -0
  72. package/hooks/useCompanyRoles.d.ts +28 -0
  73. package/hooks/useUserPermissions.d.ts +12 -0
  74. package/i18n/en_US.json.d.ts +70 -44
  75. package/lib/company-permissions.d.ts +7 -0
  76. package/package.json +1 -1
  77. package/render.js +5 -6
  78. package/render.js.map +1 -1
  79. package/types/api/companyRoles.types.d.ts +137 -0
  80. package/api/checkCompanyCreditEnabled/checkCompanyCreditEnabled.d.ts +0 -4
  81. package/api/getCompanyCredit/getCompanyCredit.d.ts +0 -4
  82. package/api/getCompanyCreditHistory/getCompanyCreditHistory.d.ts +0 -5
  83. package/api/getCompanyCreditHistory/graphql/getCompanyCreditHistory.graphql.d.ts +0 -18
  84. package/chunks/CompanyLoaders.js +0 -4
  85. package/chunks/CompanyLoaders.js.map +0 -1
  86. package/chunks/getCompanyCreditHistory.js +0 -68
  87. package/chunks/getCompanyCreditHistory.js.map +0 -1
  88. package/chunks/network-error.js +0 -4
  89. package/chunks/network-error.js.map +0 -1
  90. package/components/CompanyCreditDisplay/CompanyCreditDisplay.d.ts +0 -7
  91. package/components/CompanyCreditHistoryDisplay/CompanyCreditHistoryDisplay.d.ts +0 -15
  92. package/components/CompanyCreditHistoryDisplay/index.d.ts +0 -19
  93. package/containers/CompanyCredit/CompanyCredit.d.ts +0 -16
  94. package/containers/CompanyCredit/index.d.ts +0 -19
  95. package/containers/CompanyCredit.d.ts +0 -3
  96. package/containers/CompanyCredit.js +0 -4
  97. package/containers/CompanyCredit.js.map +0 -1
  98. package/data/models/company-credit-info.d.ts +0 -33
  99. package/data/transforms/transform-company-credit-history.d.ts +0 -5
  100. package/data/transforms/transform-company-credit.d.ts +0 -5
  101. package/hooks/containers/useCompanyCreditHistory.d.ts +0 -32
  102. package/types/api/checkCompanyCreditEnabled.types.d.ts +0 -21
  103. package/types/api/getCompanyCredit.types.d.ts +0 -40
  104. package/types/api/getCompanyCreditHistory.types.d.ts +0 -61
  105. package/types/api/getCompanyCreditHistoryParams.types.d.ts +0 -53
@@ -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
@@ -14,5 +14,5 @@
14
14
  * is strictly forbidden unless prior written permission is obtained
15
15
  * from Adobe.
16
16
  *******************************************************************/
17
- export declare const GET_COMPANY_CREDIT = "\n query GET_COMPANY_CREDIT \n {\n company {\n credit {\n available_credit {\n currency\n value\n }\n credit_limit {\n currency\n value\n }\n outstanding_balance {\n currency\n value\n }\n }\n }\n }\n";
18
- //# sourceMappingURL=getCompanyCredit.graphql.d.ts.map
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
@@ -14,5 +14,7 @@
14
14
  * is strictly forbidden unless prior written permission is obtained
15
15
  * from Adobe.
16
16
  *******************************************************************/
17
- export * from './checkCompanyCreditEnabled';
17
+ export * from './fragments';
18
+ export * from './queries';
19
+ export * from './mutations';
18
20
  //# sourceMappingURL=index.d.ts.map
@@ -14,5 +14,7 @@
14
14
  * is strictly forbidden unless prior written permission is obtained
15
15
  * from Adobe.
16
16
  *******************************************************************/
17
- export declare const CHECK_COMPANY_CREDIT_ENABLED = "\n query CHECK_COMPANY_CREDIT_ENABLED {\n storeConfig{\n company_credit_enabled\n }\n }\n";
18
- //# sourceMappingURL=checkCompanyCreditEnabled.graphql.d.ts.map
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,7 +28,5 @@ export * from './allowCompanyRegistration';
28
28
  export * from './createCompany';
29
29
  export * from './isCompanyUser';
30
30
  export * from './isCompanyAdmin';
31
- export * from './getCompanyCredit';
32
- export * from './getCompanyCreditHistory';
33
- export * from './checkCompanyCreditEnabled';
31
+ export * from './companyRoles';
34
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 as A,r as T,s as R,a as b,b as S}from"./chunks/fetch-graphql.js";import{f as O,g as N,u as I}from"./chunks/updateCompany.js";import{g as L,v as M}from"./chunks/validateCompanyEmail.js";import{D,S as x,c as G,g as F}from"./chunks/createCompany.js";import{c as B,g as Q}from"./chunks/getCustomerCompany.js";import{a as w,i as Y}from"./chunks/isCompanyUser.js";import{g as K,a as W}from"./chunks/getCompanyCreditHistory.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/network-error.js";import"@dropins/tools/event-bus.js";import"./chunks/fetch-error.js";const u=async(e={})=>({success:!0,config:e}),c=`
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,11 +15,5 @@ import{f as i}from"./chunks/fetch-graphql.js";import{g as A,r as T,s as R,a as b
15
15
  }
16
16
  }
17
17
  }
18
- `,y=async()=>{var e,t,a;try{const r=await i(c,{method:"POST"});if((e=r.errors)!=null&&e.length)return!1;const n=(t=r.data)==null?void 0:t.customer;if(!n)return!1;const s=((a=n.companies)==null?void 0:a.items)??[];if(!Array.isArray(s)||s.length===0)return!1;const o=n.role;return o?o.id==="0"||typeof o.id=="number"&&o.id===0||o.name==="Company Administrator":!1}catch(r){return console.error("Error checking if customer is company admin:",r),!1}};var m=(e=>(e.ALLOCATION="ALLOCATION",e.UPDATE="UPDATE",e.PURCHASE="PURCHASE",e.REIMBURSEMENT="REIMBURSEMENT",e))(m||{});const E=`
19
- query CHECK_COMPANY_CREDIT_ENABLED {
20
- storeConfig{
21
- company_credit_enabled
22
- }
23
- }
24
- `,g=async()=>{var e,t,a;try{const r=await i(E,{method:"GET",cache:"no-cache"});return(e=r.errors)!=null&&e.length?{creditEnabled:!1,error:"Unable to check company credit configuration"}:((a=(t=r.data)==null?void 0:t.storeConfig)==null?void 0:a.company_credit_enabled)===!0?{creditEnabled:!0}:{creditEnabled:!1,error:"Company credit is not enabled in store configuration"}}catch{return{creditEnabled:!1,error:"Company credit functionality not available"}}};export{m as CompanyCreditOperationType,D as DEFAULT_COUNTRY,x as STORE_CONFIG_DEFAULTS,w as allowCompanyRegistration,g as checkCompanyCreditEnabled,B as companyEnabled,G as createCompany,i as fetchGraphQl,O as fetchUserPermissions,N as getCompany,K as getCompanyCredit,W as getCompanyCreditHistory,A as getConfig,L as getCountries,Q as getCustomerCompany,F as getStoreConfig,u as initialize,y as isCompanyAdmin,Y as isCompanyUser,T as removeFetchGraphQlHeader,R as setEndpoint,b as setFetchGraphQlHeader,S as setFetchGraphQlHeaders,I as updateCompany,M 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};
25
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","/@dropins/storefront-company-management/src/types/api/getCompanyCreditHistoryParams.types.ts","/@dropins/storefront-company-management/src/api/checkCompanyCreditEnabled/graphql/checkCompanyCreditEnabled.graphql.ts","/@dropins/storefront-company-management/src/api/checkCompanyCreditEnabled/checkCompanyCreditEnabled.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","/********************************************************************\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 enum CompanyCreditOperationType {\n ALLOCATION = 'ALLOCATION',\n UPDATE = 'UPDATE',\n PURCHASE = 'PURCHASE',\n REIMBURSEMENT = 'REIMBURSEMENT'\n}\n\nexport interface CompanyCreditHistoryFilterInput {\n /**\n * The purchase order number associated with the company credit operation.\n */\n customReferenceNumber?: string;\n\n /**\n * The type of the company credit operation.\n */\n operationType?: CompanyCreditOperationType;\n\n /**\n * The name of the person submitting the company credit operation.\n */\n updatedBy?: string;\n}\n\nexport interface GetCompanyCreditHistoryParams {\n /**\n * Filter criteria for narrowing the results of a credit history search.\n */\n filter?: CompanyCreditHistoryFilterInput;\n\n /**\n * Number of items to return per page.\n * @default 20\n */\n pageSize?: number;\n\n /**\n * Current page number.\n * @default 1\n */\n currentPage?: number;\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 CHECK_COMPANY_CREDIT_ENABLED = /* GraphQL */ `\n query CHECK_COMPANY_CREDIT_ENABLED {\n storeConfig{\n company_credit_enabled\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 { CHECK_COMPANY_CREDIT_ENABLED } from \"./graphql/checkCompanyCreditEnabled.graphql\";\nimport { CheckCompanyCreditEnabledResponse } from '../../types/api/checkCompanyCreditEnabled.types';\nimport { fetchGraphQl } from '../fetch-graphql';\n\nexport const checkCompanyCreditEnabled = async (): Promise<CheckCompanyCreditEnabledResponse> => {\n try {\n const response = await fetchGraphQl(CHECK_COMPANY_CREDIT_ENABLED, {\n method: 'GET',\n cache: 'no-cache',\n });\n\n // If there are errors, return false with error message\n if (response.errors?.length) {\n return {\n creditEnabled: false,\n error: 'Unable to check company credit configuration'\n };\n }\n\n // Check if company credit is enabled in store config\n const companyCreditEnabled = response.data?.storeConfig?.company_credit_enabled;\n \n if (companyCreditEnabled === true) {\n return {\n creditEnabled: true\n };\n }\n\n // If company credit is disabled or not configured\n return {\n creditEnabled: false,\n error: 'Company credit is not enabled in store configuration'\n };\n\n } catch (error) {\n return {\n creditEnabled: false,\n error: 'Company credit functionality not available'\n };\n }\n};\n"],"names":["initialize","config","GET_CUSTOMER_COMPANIES_WITH_ROLES","isCompanyAdmin","response","fetchGraphQl","_a","customer","_b","companies","_c","customerRole","error","CompanyCreditOperationType","CHECK_COMPANY_CREDIT_ENABLED","checkCompanyCreditEnabled"],"mappings":"0mBAyBO,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,EC7DY,IAAAC,GAAAA,IACVA,EAAA,WAAa,aACbA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,cAAgB,gBAJNA,IAAAA,GAAA,CAAA,CAAA,ECAC,MAAAC,EAA6C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECI7CC,EAA4B,SAAwD,WAC3F,GAAA,CACI,MAAAX,EAAW,MAAMC,EAAaS,EAA8B,CAChE,OAAQ,MACR,MAAO,UAAA,CACR,EAGG,OAAAR,EAAAF,EAAS,SAAT,MAAAE,EAAiB,OACZ,CACL,cAAe,GACf,MAAO,8CACT,IAI2BI,GAAAF,EAAAJ,EAAS,OAAT,YAAAI,EAAe,cAAf,YAAAE,EAA4B,0BAE5B,GACpB,CACL,cAAe,EACjB,EAIK,CACL,cAAe,GACf,MAAO,sDACT,OAEc,CACP,MAAA,CACL,cAAe,GACf,MAAO,4CACT,CAAA,CAEJ"}
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,13 +1,13 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{h as c}from"./network-error.js";import{h as a}from"./fetch-error.js";import{f as s}from"./fetch-graphql.js";import{t as l}from"./validateCompanyEmail.js";const g=`
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
7
7
  store_code
8
8
  }
9
9
  }
10
- `,u="US",o={defaultCountry:u,storeCode:""},T=async()=>await s(g,{method:"GET"}).then(e=>{var n;return(n=e.errors)!=null&&n.length?a(e.errors):p(e)}).catch(c),p=e=>{var r;if(!((r=e==null?void 0:e.data)!=null&&r.storeConfig))return o;const{default_country:n,store_code:t}=e.data.storeConfig;return{defaultCountry:n||o.defaultCountry,storeCode:t||o.storeCode}},m=`
10
+ `,p="US",s={defaultCountry:p,storeCode:""},T=async()=>await d(u,{method:"GET"}).then(e=>{var r;return(r=e.errors)!=null&&r.length?a(e.errors):m(e)}).catch(l),m=e=>{var t;if(!((t=e==null?void 0:e.data)!=null&&t.storeConfig))return s;const{default_country:r,store_code:o}=e.data.storeConfig;return{defaultCountry:r||s.defaultCountry,storeCode:o||s.storeCode}},_=`
11
11
  mutation CreateCompany($input: CompanyCreateInput!) {
12
12
  createCompany(input: $input) {
13
13
  company {
@@ -40,5 +40,5 @@ import{h as c}from"./network-error.js";import{h as a}from"./fetch-error.js";impo
40
40
  }
41
41
  }
42
42
  }
43
- `,_=e=>{var t;const n={};if(e.regionCode&&e.regionCode.trim())n.region_code=e.regionCode.trim(),e.regionId&&(n.region_id=typeof e.regionId=="string"?parseInt(e.regionId,10):e.regionId);else if(e.region&&typeof e.region=="string"&&e.region.includes(",")){const[r,i]=e.region.split(",");n.region_code=r.trim(),n.region_id=parseInt(i.trim(),10)}else if(e.region&&e.region.trim()){const r=e.region.trim();if(/^\d+$/.test(r))throw new Error("Region selection error: Missing region code. Please ensure regions are properly loaded.");n.region=r,n.region_code=r}if(!n.region_code)throw new Error("Region code is required. Please select a state/province or enter a region name.");return{company_name:e.companyName,company_email:e.companyEmail,legal_name:e.legalName,vat_tax_id:e.vatTaxId,reseller_id:e.resellerId,legal_address:{street:Array.isArray(e.street)?e.street.filter(r=>r&&r.trim()!==""):[e.street].filter(r=>r&&r.trim()!==""),city:e.city,region:n,postcode:e.postcode,country_id:e.countryCode,telephone:e.addressTelephone},company_admin:{email:e.adminEmail,firstname:e.adminFirstname,lastname:e.adminLastname,job_title:e.adminJobTitle,telephone:e.adminWorkTelephone,gender:e.adminGender?typeof e.adminGender=="string"?parseInt(e.adminGender,10):e.adminGender:void 0,custom_attributes:((t=e.adminCustomAttributes)==null?void 0:t.map(r=>({attribute_code:r.attribute_code,value:r.value})))||[]}}},E=async e=>{var n;try{const t=_(e),r=await s(m,{method:"POST",variables:{input:t}});return(n=r.errors)!=null&&n.length?{success:!1,errors:r.errors.map(d=>d.message)}:{success:!0,company:l(r)}}catch(t){return console.error("Failed to create company:",t),{success:!1,errors:["Failed to create company. Please try again."]}}};export{u as D,o as S,E as c,T as g};
43
+ `,y=e=>{var o,t,i;const r={};if(e.regionCode&&e.regionCode.trim())r.region_code=e.regionCode.trim(),e.regionId&&(r.region_id=typeof e.regionId=="string"?parseInt(e.regionId,10):e.regionId);else if(e.region&&typeof e.region=="string"&&e.region.includes(",")){const[n,c]=e.region.split(",");r.region_code=n.trim(),r.region_id=parseInt(c.trim(),10)}else if(e.region&&e.region.trim()){const n=e.region.trim();if(/^\d+$/.test(n))throw new Error("Region selection error: Missing region code. Please ensure regions are properly loaded.");r.region=n,r.region_code=n}if(!r.region_code)throw new Error("Region code is required. Please select a state/province or enter a region name.");return{company_name:e.companyName,company_email:e.companyEmail,legal_name:e.legalName,vat_tax_id:e.vatTaxId,reseller_id:e.resellerId,legal_address:{street:Array.isArray(e.street)?e.street.filter(n=>n&&n.trim()!==""):[e.street].filter(n=>n&&n.trim()!==""),city:e.city,region:r,postcode:e.postcode,country_id:e.countryCode,telephone:e.addressTelephone},company_admin:{email:e.adminEmail,firstname:((o=e.adminFirstname)==null?void 0:o.trim())||"",lastname:((t=e.adminLastname)==null?void 0:t.trim())||"",job_title:e.adminJobTitle,telephone:e.adminWorkTelephone,gender:e.adminGender?typeof e.adminGender=="string"?parseInt(e.adminGender,10):e.adminGender:void 0,custom_attributes:((i=e.adminCustomAttributes)==null?void 0:i.map(n=>({attribute_code:n.attribute_code,value:n.value})))||[]}}},E=async e=>{var r;try{const o=y(e),t=await d(_,{method:"POST",variables:{input:o}});return(r=t.errors)!=null&&r.length?{success:!1,errors:t.errors.map(n=>n.message)}:{success:!0,company:g(t)}}catch(o){return console.error("Failed to create company:",o),{success:!1,errors:["Failed to create company. Please try again."]}}};export{p as D,s as S,E as c,T as g};
44
44
  //# sourceMappingURL=createCompany.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createCompany.js","sources":["/@dropins/storefront-company-management/src/api/getStoreConfig/graphql/getStoreConfig.graphql.ts","/@dropins/storefront-company-management/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-company-management/src/data/transforms/transform-store-config.ts","/@dropins/storefront-company-management/src/api/createCompany/graphql/createCompany.graphql.ts","/@dropins/storefront-company-management/src/data/transforms/company.ts","/@dropins/storefront-company-management/src/api/createCompany/createCompany.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\nexport const GET_STORE_CONFIG_QUERY = /* GraphQL */ `\n query getStoreConfig {\n storeConfig {\n default_country\n store_code\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_STORE_CONFIG_QUERY } from './graphql/getStoreConfig.graphql';\nimport { handleNetworkError } from '@/company-management/lib/network-error';\nimport { handleFetchError } from '@/company-management/lib/fetch-error';\nimport { GetStoreConfigResponse, StoreConfigModel } from '@/company-management/types';\nimport { transformStoreConfig } from '@/company-management/data/transforms';\n\nexport const DEFAULT_COUNTRY = 'US';\n\nexport const STORE_CONFIG_DEFAULTS: StoreConfigModel = {\n defaultCountry: DEFAULT_COUNTRY,\n storeCode: '',\n};\n\nexport const getStoreConfig = async (): Promise<StoreConfigModel> => {\n return await fetchGraphQl(GET_STORE_CONFIG_QUERY, {\n method: 'GET',\n })\n .then((response: GetStoreConfigResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n return transformStoreConfig(response);\n })\n .catch(handleNetworkError);\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 { GetStoreConfigResponse, StoreConfigModel } from '@/company-management/types';\nimport { STORE_CONFIG_DEFAULTS } from '@/company-management/api/getStoreConfig/getStoreConfig';\n\nexport const transformStoreConfig = (\n response: GetStoreConfigResponse\n): StoreConfigModel => {\n if (!response?.data?.storeConfig) return STORE_CONFIG_DEFAULTS;\n\n const { default_country, store_code } = response.data.storeConfig;\n\n return {\n defaultCountry: default_country || STORE_CONFIG_DEFAULTS.defaultCountry,\n storeCode: store_code || STORE_CONFIG_DEFAULTS.storeCode,\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 CREATE_COMPANY_MUTATION = /* GraphQL */ `\n mutation CreateCompany($input: CompanyCreateInput!) {\n createCompany(input: $input) {\n company {\n id\n name\n email\n legal_name\n vat_tax_id\n reseller_id\n legal_address {\n street\n city\n region {\n region_code\n region\n region_id\n }\n postcode\n country_code\n telephone\n }\n company_admin {\n id\n firstname\n lastname\n email\n job_title\n telephone\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 { CompanyFormData } from '../models/company';\nimport { CompanyCreateInput } from '@/company-management/api/createCompany';\n\nexport const transformFormDataToCreateInput = (formData: CompanyFormData): CompanyCreateInput => {\n // Build region object - ensure we have at least one region field\n const regionInput: any = {};\n \n // Handle region data based on what we receive from the form\n if (formData.regionCode && formData.regionCode.trim()) {\n // We have regionCode (preferred path)\n regionInput.region_code = formData.regionCode.trim();\n if (formData.regionId) {\n regionInput.region_id = typeof formData.regionId === 'string' ? parseInt(formData.regionId, 10) : formData.regionId;\n }\n } else if (formData.region && typeof formData.region === 'string' && formData.region.includes(',')) {\n // Dropdown selection: parse \"AL,4\" format as fallback\n const [regionCode, regionId] = formData.region.split(',');\n regionInput.region_code = regionCode.trim();\n regionInput.region_id = parseInt(regionId.trim(), 10);\n } else if (formData.region && formData.region.trim()) {\n const regionValue = formData.region.trim();\n // Check if this is a numeric regionId (from dropdown) or text region name\n if (/^\\d+$/.test(regionValue)) {\n // This is likely a regionId from dropdown, but we only have the ID\n // We need both region_code and region_id for GraphQL, but we can't proceed without region_code\n throw new Error('Region selection error: Missing region code. Please ensure regions are properly loaded.');\n } else {\n // Text input: free-form region name (countries without predefined regions)\n regionInput.region = regionValue;\n regionInput.region_code = regionValue;\n }\n }\n \n // Ensure we have at least region_code (required by GraphQL)\n if (!regionInput.region_code) {\n throw new Error('Region code is required. Please select a state/province or enter a region name.');\n }\n\n return {\n company_name: formData.companyName,\n company_email: formData.companyEmail,\n legal_name: formData.legalName,\n vat_tax_id: formData.vatTaxId,\n reseller_id: formData.resellerId,\n legal_address: {\n street: Array.isArray(formData.street) \n ? formData.street.filter((line: string) => line && line.trim() !== '') // Remove empty lines\n : [formData.street].filter((line: string) => line && line.trim() !== ''), // Handle case where street is not an array\n city: formData.city,\n region: regionInput,\n postcode: formData.postcode,\n country_id: formData.countryCode,\n telephone: formData.addressTelephone,\n },\n company_admin: {\n email: formData.adminEmail,\n firstname: formData.adminFirstname,\n lastname: formData.adminLastname,\n job_title: formData.adminJobTitle,\n telephone: formData.adminWorkTelephone,\n gender: formData.adminGender ? (typeof formData.adminGender === 'string' ? parseInt(formData.adminGender, 10) : formData.adminGender) : undefined,\n custom_attributes: formData.adminCustomAttributes?.map(attr => ({\n attribute_code: attr.attribute_code,\n value: attr.value,\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 '@/company-management/api/fetch-graphql';\nimport { CREATE_COMPANY_MUTATION } from './graphql/createCompany.graphql';\nimport { CompanyRegistrationModel } from '@/company-management/data/models/company';\nimport { transformFormDataToCreateInput } from '@/company-management/data/transforms/company';\nimport { transformCreateCompanyResponse } from '@/company-management/data/transforms/transform-company';\n\nexport interface CompanyCreateInput {\n company_name: string;\n company_email: string;\n legal_name?: string;\n vat_tax_id?: string;\n reseller_id?: string;\n legal_address: {\n street: string[];\n city: string;\n region: {\n region_code: string;\n region?: string;\n region_id?: number;\n };\n postcode: string;\n country_id: string;\n telephone?: string;\n };\n company_admin: {\n email: string;\n firstname: string;\n lastname: string;\n job_title?: string;\n telephone?: string;\n gender?: number;\n custom_attributes?: Array<{\n attribute_code: string;\n value: string;\n }>;\n };\n}\n\n\nexport const createCompany = async (formData: any): Promise<{ success: boolean; company?: CompanyRegistrationModel; errors?: string[] }> => {\n try {\n const input = transformFormDataToCreateInput(formData);\n const response = await fetchGraphQl(CREATE_COMPANY_MUTATION, {\n method: 'POST',\n variables: { input },\n });\n\n if (response.errors?.length) {\n return {\n success: false,\n errors: response.errors.map((error: any) => error.message),\n };\n }\n\n // Transform the GraphQL response using the dedicated transformer\n const transformedCompany = transformCreateCompanyResponse(response);\n\n return {\n success: true,\n company: transformedCompany,\n };\n } catch (error) {\n console.error('Failed to create company:', error);\n return {\n success: false,\n errors: ['Failed to create company. Please try again.'],\n };\n }\n};"],"names":["GET_STORE_CONFIG_QUERY","DEFAULT_COUNTRY","STORE_CONFIG_DEFAULTS","getStoreConfig","fetchGraphQl","response","_a","handleFetchError","transformStoreConfig","handleNetworkError","default_country","store_code","CREATE_COMPANY_MUTATION","transformFormDataToCreateInput","formData","regionInput","regionCode","regionId","regionValue","line","attr","createCompany","input","error","transformCreateCompanyResponse"],"mappings":"iKAiBa,MAAAA,EAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECOvCC,EAAkB,KAElBC,EAA0C,CACrD,eAAgBD,EAChB,UAAW,EACb,EAEaE,EAAiB,SACrB,MAAMC,EAAaJ,EAAwB,CAChD,OAAQ,KAAA,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zC,CACL,QAAS,GACT,OAAQ,CAAC,6CAA6C,CACxD,CAAA,CAEJ"}
1
+ {"version":3,"file":"createCompany.js","sources":["/@dropins/storefront-company-management/src/api/getStoreConfig/graphql/getStoreConfig.graphql.ts","/@dropins/storefront-company-management/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-company-management/src/data/transforms/transform-store-config.ts","/@dropins/storefront-company-management/src/api/createCompany/graphql/createCompany.graphql.ts","/@dropins/storefront-company-management/src/data/transforms/company.ts","/@dropins/storefront-company-management/src/api/createCompany/createCompany.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\nexport const GET_STORE_CONFIG_QUERY = /* GraphQL */ `\n query getStoreConfig {\n storeConfig {\n default_country\n store_code\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_STORE_CONFIG_QUERY } from './graphql/getStoreConfig.graphql';\nimport { handleNetworkError } from '@/company-management/lib/network-error';\nimport { handleFetchError } from '@/company-management/lib/fetch-error';\nimport { GetStoreConfigResponse, StoreConfigModel } from '@/company-management/types';\nimport { transformStoreConfig } from '@/company-management/data/transforms';\n\nexport const DEFAULT_COUNTRY = 'US';\n\nexport const STORE_CONFIG_DEFAULTS: StoreConfigModel = {\n defaultCountry: DEFAULT_COUNTRY,\n storeCode: '',\n};\n\nexport const getStoreConfig = async (): Promise<StoreConfigModel> => {\n return await fetchGraphQl(GET_STORE_CONFIG_QUERY, {\n method: 'GET',\n })\n .then((response: GetStoreConfigResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n return transformStoreConfig(response);\n })\n .catch(handleNetworkError);\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 { GetStoreConfigResponse, StoreConfigModel } from '@/company-management/types';\nimport { STORE_CONFIG_DEFAULTS } from '@/company-management/api/getStoreConfig/getStoreConfig';\n\nexport const transformStoreConfig = (\n response: GetStoreConfigResponse\n): StoreConfigModel => {\n if (!response?.data?.storeConfig) return STORE_CONFIG_DEFAULTS;\n\n const { default_country, store_code } = response.data.storeConfig;\n\n return {\n defaultCountry: default_country || STORE_CONFIG_DEFAULTS.defaultCountry,\n storeCode: store_code || STORE_CONFIG_DEFAULTS.storeCode,\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 CREATE_COMPANY_MUTATION = /* GraphQL */ `\n mutation CreateCompany($input: CompanyCreateInput!) {\n createCompany(input: $input) {\n company {\n id\n name\n email\n legal_name\n vat_tax_id\n reseller_id\n legal_address {\n street\n city\n region {\n region_code\n region\n region_id\n }\n postcode\n country_code\n telephone\n }\n company_admin {\n id\n firstname\n lastname\n email\n job_title\n telephone\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 { CompanyFormData } from '../models/company';\nimport { CompanyCreateInput } from '@/company-management/api/createCompany';\n\nexport const transformFormDataToCreateInput = (formData: CompanyFormData): CompanyCreateInput => {\n // Build region object - ensure we have at least one region field\n const regionInput: any = {};\n \n // Handle region data based on what we receive from the form\n if (formData.regionCode && formData.regionCode.trim()) {\n // We have regionCode (preferred path)\n regionInput.region_code = formData.regionCode.trim();\n if (formData.regionId) {\n regionInput.region_id = typeof formData.regionId === 'string' ? parseInt(formData.regionId, 10) : formData.regionId;\n }\n } else if (formData.region && typeof formData.region === 'string' && formData.region.includes(',')) {\n // Dropdown selection: parse \"AL,4\" format as fallback\n const [regionCode, regionId] = formData.region.split(',');\n regionInput.region_code = regionCode.trim();\n regionInput.region_id = parseInt(regionId.trim(), 10);\n } else if (formData.region && formData.region.trim()) {\n const regionValue = formData.region.trim();\n // Check if this is a numeric regionId (from dropdown) or text region name\n if (/^\\d+$/.test(regionValue)) {\n // This is likely a regionId from dropdown, but we only have the ID\n // We need both region_code and region_id for GraphQL, but we can't proceed without region_code\n throw new Error('Region selection error: Missing region code. Please ensure regions are properly loaded.');\n } else {\n // Text input: free-form region name (countries without predefined regions)\n regionInput.region = regionValue;\n regionInput.region_code = regionValue;\n }\n }\n \n // Ensure we have at least region_code (required by GraphQL)\n if (!regionInput.region_code) {\n throw new Error('Region code is required. Please select a state/province or enter a region name.');\n }\n\n return {\n company_name: formData.companyName,\n company_email: formData.companyEmail,\n legal_name: formData.legalName,\n vat_tax_id: formData.vatTaxId,\n reseller_id: formData.resellerId,\n legal_address: {\n street: Array.isArray(formData.street) \n ? formData.street.filter((line: string) => line && line.trim() !== '') // Remove empty lines\n : [formData.street].filter((line: string) => line && line.trim() !== ''), // Handle case where street is not an array\n city: formData.city,\n region: regionInput,\n postcode: formData.postcode,\n country_id: formData.countryCode,\n telephone: formData.addressTelephone,\n },\n company_admin: {\n email: formData.adminEmail,\n firstname: formData.adminFirstname?.trim() || '',\n lastname: formData.adminLastname?.trim() || '',\n job_title: formData.adminJobTitle,\n telephone: formData.adminWorkTelephone,\n gender: formData.adminGender ? (typeof formData.adminGender === 'string' ? parseInt(formData.adminGender, 10) : formData.adminGender) : undefined,\n custom_attributes: formData.adminCustomAttributes?.map(attr => ({\n attribute_code: attr.attribute_code,\n value: attr.value,\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 '@/company-management/api/fetch-graphql';\nimport { CREATE_COMPANY_MUTATION } from './graphql/createCompany.graphql';\nimport { CompanyRegistrationModel } from '@/company-management/data/models/company';\nimport { transformFormDataToCreateInput } from '@/company-management/data/transforms/company';\nimport { transformCreateCompanyResponse } from '@/company-management/data/transforms/transform-company';\n\nexport interface CompanyCreateInput {\n company_name: string;\n company_email: string;\n legal_name?: string;\n vat_tax_id?: string;\n reseller_id?: string;\n legal_address: {\n street: string[];\n city: string;\n region: {\n region_code: string;\n region?: string;\n region_id?: number;\n };\n postcode: string;\n country_id: string;\n telephone?: string;\n };\n company_admin: {\n email: string;\n firstname: string;\n lastname: string;\n job_title?: string;\n telephone?: string;\n gender?: number;\n custom_attributes?: Array<{\n attribute_code: string;\n value: string;\n }>;\n };\n}\n\n\nexport const createCompany = async (formData: any): Promise<{ success: boolean; company?: CompanyRegistrationModel; errors?: string[] }> => {\n try {\n const input = transformFormDataToCreateInput(formData);\n const response = await fetchGraphQl(CREATE_COMPANY_MUTATION, {\n method: 'POST',\n variables: { input },\n });\n\n if (response.errors?.length) {\n return {\n success: false,\n errors: response.errors.map((error: any) => error.message),\n };\n }\n\n // Transform the GraphQL response using the dedicated transformer\n const transformedCompany = transformCreateCompanyResponse(response);\n\n return {\n success: true,\n company: transformedCompany,\n };\n } catch (error) {\n console.error('Failed to create company:', error);\n return {\n success: false,\n errors: ['Failed to create company. Please try again.'],\n };\n }\n};"],"names":["GET_STORE_CONFIG_QUERY","DEFAULT_COUNTRY","STORE_CONFIG_DEFAULTS","getStoreConfig","fetchGraphQl","response","_a","handleFetchError","transformStoreConfig","handleNetworkError","default_country","store_code","CREATE_COMPANY_MUTATION","transformFormDataToCreateInput","formData","regionInput","regionCode","regionId","regionValue","line","_b","_c","attr","createCompany","input","error","transformCreateCompanyResponse"],"mappings":"iIAiBa,MAAAA,EAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECOvCC,EAAkB,KAElBC,EAA0C,CACrD,eAAgBD,EAChB,UAAW,EACb,EAEaE,EAAiB,SACrB,MAAMC,EAAaJ,EAAwB,CAChD,OAAQ,KAAA,CACT,EACE,KAAMK,GAAqC,OAC1C,OAAIC,EAAAD,EAAS,SAAT,MAAAC,EAAiB,OAAeC,EAAiBF,EAAS,MAAM,EAE7DG,EAAqBH,CAAQ,CAAA,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"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- const s=r=>{const e=r.map(o=>o.message).join(" ");throw Error(e)};export{s as h};
3
+ import{events as e}from"@dropins/tools/event-bus.js";const n=r=>{throw r instanceof DOMException&&r.name==="AbortError"||e.emit("error",{source:"company",type:"network",error:r}),r},a=r=>{const o=r.map(t=>t.message).join(" ");throw Error(o)};export{n as a,a as h};
4
4
  //# sourceMappingURL=fetch-error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-error.js","sources":["/@dropins/storefront-company-management/src/lib/fetch-error.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/** Actions */\nexport const handleFetchError = (errors: Array<{ message: string }>) => {\n const errorMessage = errors.map((e: any) => e.message).join(' ');\n\n throw Error(errorMessage);\n};\n"],"names":["handleFetchError","errors","errorMessage","e"],"mappings":"AAiBa,MAAAA,EAAoBC,GAAuC,CAChE,MAAAC,EAAeD,EAAO,IAAKE,GAAWA,EAAE,OAAO,EAAE,KAAK,GAAG,EAE/D,MAAM,MAAMD,CAAY,CAC1B"}
1
+ {"version":3,"file":"fetch-error.js","sources":["/@dropins/storefront-company-management/src/lib/network-error.ts","/@dropins/storefront-company-management/src/lib/fetch-error.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 *******************************************************************/\nimport { events } from '@adobe-commerce/event-bus';\n\n/**\n * A function which can be attached to fetchGraphQL to handle thrown errors in\n * a generic way.\n */\nexport const handleNetworkError = (error: Error) => {\n const isAbortError =\n error instanceof DOMException && error.name === 'AbortError';\n\n if (!isAbortError) {\n // @ts-ignore\n events.emit('error', {\n source: 'company',\n type: 'network',\n error,\n });\n }\n throw error;\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/** Actions */\nexport const handleFetchError = (errors: Array<{ message: string }>) => {\n const errorMessage = errors.map((e: any) => e.message).join(' ');\n\n throw Error(errorMessage);\n};\n"],"names":["handleNetworkError","error","events","handleFetchError","errors","errorMessage","e"],"mappings":"qDAsBa,MAAAA,EAAsBC,GAAiB,CAIlD,MAFEA,aAAiB,cAAgBA,EAAM,OAAS,cAIhDC,EAAO,KAAK,QAAS,CACnB,OAAQ,UACR,KAAM,UACN,MAAAD,CAAA,CACD,EAEGA,CACR,EClBaE,EAAoBC,GAAuC,CAChE,MAAAC,EAAeD,EAAO,IAAKE,GAAWA,EAAE,OAAO,EAAE,KAAK,GAAG,EAE/D,MAAM,MAAMD,CAAY,CAC1B"}
@@ -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"}
@@ -1,12 +1,12 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{h as l}from"./network-error.js";import{h as m}from"./fetch-error.js";import{f as i}from"./fetch-graphql.js";const d=o=>{var a,e,c;const r=(a=o==null?void 0:o.data)==null?void 0:a.customer,n=(e=o==null?void 0:o.data)==null?void 0:e.company;if(!r||!n)return null;const t={companyName:(n==null?void 0:n.name)??"",jobTitle:(r==null?void 0:r.job_title)??"",workPhoneNumber:(r==null?void 0:r.telephone)??"",userRole:((c=r==null?void 0:r.role)==null?void 0:c.name)??""};return t.companyName?t:null},h=`
3
+ import{h as i,a as m}from"./fetch-error.js";import{f as l}from"./fetch-graphql.js";const d=o=>{var t,e,c;const n=(t=o==null?void 0:o.data)==null?void 0:t.customer,r=(e=o==null?void 0:o.data)==null?void 0:e.company;if(!n||!r)return null;const a={companyName:(r==null?void 0:r.name)??"",jobTitle:(n==null?void 0:n.job_title)??"",workPhoneNumber:(n==null?void 0:n.telephone)??"",userRole:((c=n==null?void 0:n.role)==null?void 0:c.name)??""};return a.companyName?a:null},h=`
4
4
  query GET_COMPANY_ENABLED {
5
5
  storeConfig {
6
6
  company_enabled
7
7
  }
8
8
  }
9
- `,f=async()=>{var n,t,a;const o=await i(h,{method:"POST"});if((n=o==null?void 0:o.errors)!=null&&n.length)throw new Error(((t=o.errors[0])==null?void 0:t.message)||"Failed to load store configuration");const r=(a=o==null?void 0:o.data)==null?void 0:a.storeConfig;if(!r)throw new Error("Invalid response: missing storeConfig");return!!r.company_enabled},E=`
9
+ `,f=async()=>{var r,a,t;const o=await l(h,{method:"POST"});if((r=o==null?void 0:o.errors)!=null&&r.length)throw new Error(((a=o.errors[0])==null?void 0:a.message)||"Failed to load store configuration");const n=(t=o==null?void 0:o.data)==null?void 0:t.storeConfig;if(!n)throw new Error("Invalid response: missing storeConfig");return!!n.company_enabled},E=`
10
10
  query GET_CUSTOMER_COMPANY_INFO {
11
11
  customer {
12
12
  id
@@ -22,5 +22,5 @@ import{h as l}from"./network-error.js";import{h as m}from"./fetch-error.js";impo
22
22
  name
23
23
  }
24
24
  }
25
- `,C=async()=>{var o;try{if(!await f())return null;const n=await i(E,{method:"GET",cache:"no-cache"});return(o=n.errors)!=null&&o.length?m(n.errors):d(n)}catch(r){return console.error("Failed to fetch customer company info:",r),l(r)}};export{f as c,C as g};
25
+ `,u=async()=>{var o;try{if(!await f())return null;const r=await l(E,{method:"GET",cache:"no-cache"});return(o=r.errors)!=null&&o.length?i(r.errors):d(r)}catch(n){return console.error("Failed to fetch customer company info:",n),m(n)}};export{f as c,u as g};
26
26
  //# sourceMappingURL=getCustomerCompany.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getCustomerCompany.js","sources":["/@dropins/storefront-company-management/src/data/transforms/transform-customer-company-info.ts","/@dropins/storefront-company-management/src/api/companyEnabled/graphql/companyEnabled.graphql.ts","/@dropins/storefront-company-management/src/api/companyEnabled/companyEnabled.ts","/@dropins/storefront-company-management/src/api/getCustomerCompany/graphql/getCustomerCompanyInfo.graphql.ts","/@dropins/storefront-company-management/src/api/getCustomerCompany/getCustomerCompany.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 *******************************************************************/\nimport { CustomerCompanyInfo } from '../models/customer-company-info';\nimport { GetCustomerCompanyInfoResponse } from '../../types/api/getCustomerCompanyInfo.types';\n\n/**\n * Transforms GraphQL response to CustomerCompanyInfo model\n * @param response - GraphQL response containing customer and company data\n * @returns Transformed customer company info or null if data is incomplete\n */\nexport const transformCustomerCompanyInfo = (response: GetCustomerCompanyInfoResponse): CustomerCompanyInfo | null => {\n const customer = response?.data?.customer;\n const company = response?.data?.company;\n \n if (!customer || !company) {\n return null;\n }\n\n const companyInfo: CustomerCompanyInfo = {\n companyName: company?.name ?? '',\n jobTitle: customer?.job_title ?? '',\n workPhoneNumber: customer?.telephone ?? '',\n userRole: customer?.role?.name ?? '',\n };\n\n // Only return data if we have at least a company name\n return companyInfo.companyName ? companyInfo : 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\nexport const GET_COMPANY_ENABLED = /* GraphQL */ `\n query GET_COMPANY_ENABLED {\n storeConfig {\n company_enabled\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_COMPANY_ENABLED } from './graphql/companyEnabled.graphql';\n\nexport const companyEnabled = async (): Promise<boolean> => { \n const response = await fetchGraphQl(GET_COMPANY_ENABLED, { method: 'POST' });\n\n if ((response as any)?.errors?.length) {\n throw new Error((response as any).errors[0]?.message || 'Failed to load store configuration');\n }\n\n const node = (response as any)?.data?.storeConfig;\n if (!node) {\n throw new Error('Invalid response: missing storeConfig');\n }\n\n return Boolean(node.company_enabled);\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_COMPANY_INFO = `\n query GET_CUSTOMER_COMPANY_INFO {\n customer {\n id\n job_title\n telephone\n role {\n id\n name\n }\n }\n company {\n id\n name\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 { companyEnabled } from '../companyEnabled';\nimport { GET_CUSTOMER_COMPANY_INFO } from './graphql/getCustomerCompanyInfo.graphql';\nimport { CustomerCompanyInfo } from '../../data/models/customer-company-info';\nimport { GetCustomerCompanyInfoResponse } from '../../types/api/getCustomerCompanyInfo.types';\nimport { transformCustomerCompanyInfo } from '../../data/transforms/transform-customer-company-info';\n\n/**\n * Gets customer company information for display on account information page\n * This is a simplified API that only returns the essential company info needed\n * for the customer account page, without requiring full company permissions\n */\nexport const getCustomerCompany = async (): Promise<CustomerCompanyInfo | null> => {\n try {\n // First check if company functionality is enabled\n const isCompanyEnabled = await companyEnabled();\n if (!isCompanyEnabled) {\n return null;\n }\n\n // Fetch customer company information\n const response: GetCustomerCompanyInfoResponse = await fetchGraphQl(GET_CUSTOMER_COMPANY_INFO, { \n method: 'GET', \n cache: 'no-cache' \n });\n\n if (response.errors?.length) {\n return handleFetchError(response.errors);\n }\n\n // Transform the response using the transformer\n return transformCustomerCompanyInfo(response);\n\n } catch (error) {\n console.error('Failed to fetch customer company info:', error);\n return handleNetworkError(error as Error);\n }\n};\n"],"names":["transformCustomerCompanyInfo","response","customer","_a","company","_b","companyInfo","_c","GET_COMPANY_ENABLED","companyEnabled","fetchGraphQl","node","GET_CUSTOMER_COMPANY_INFO","getCustomerCompany","handleFetchError","error","handleNetworkError"],"mappings":"mHAwBa,MAAAA,EAAgCC,GAAyE,WAC9G,MAAAC,GAAWC,EAAAF,GAAA,YAAAA,EAAU,OAAV,YAAAE,EAAgB,SAC3BC,GAAUC,EAAAJ,GAAA,YAAAA,EAAU,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Company.js","sources":["/@dropins/storefront-company-management/src/data/transforms/transform-customer-company-info.ts","/@dropins/storefront-company-management/src/api/companyEnabled/graphql/companyEnabled.graphql.ts","/@dropins/storefront-company-management/src/api/companyEnabled/companyEnabled.ts","/@dropins/storefront-company-management/src/api/getCustomerCompany/graphql/getCustomerCompanyInfo.graphql.ts","/@dropins/storefront-company-management/src/api/getCustomerCompany/getCustomerCompany.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 *******************************************************************/\nimport { CustomerCompanyInfo } from '../models/customer-company-info';\nimport { GetCustomerCompanyInfoResponse } from '../../types/api/getCustomerCompanyInfo.types';\n\n/**\n * Transforms GraphQL response to CustomerCompanyInfo model\n * @param response - GraphQL response containing customer and company data\n * @returns Transformed customer company info or null if data is incomplete\n */\nexport const transformCustomerCompanyInfo = (response: GetCustomerCompanyInfoResponse): CustomerCompanyInfo | null => {\n const customer = response?.data?.customer;\n const company = response?.data?.company;\n \n if (!customer || !company) {\n return null;\n }\n\n const companyInfo: CustomerCompanyInfo = {\n companyName: company?.name ?? '',\n jobTitle: customer?.job_title ?? '',\n workPhoneNumber: customer?.telephone ?? '',\n userRole: customer?.role?.name ?? '',\n };\n\n // Only return data if we have at least a company name\n return companyInfo.companyName ? companyInfo : 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\nexport const GET_COMPANY_ENABLED = /* GraphQL */ `\n query GET_COMPANY_ENABLED {\n storeConfig {\n company_enabled\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_COMPANY_ENABLED } from './graphql/companyEnabled.graphql';\n\nexport const companyEnabled = async (): Promise<boolean> => { \n const response = await fetchGraphQl(GET_COMPANY_ENABLED, { method: 'POST' });\n\n if ((response as any)?.errors?.length) {\n throw new Error((response as any).errors[0]?.message || 'Failed to load store configuration');\n }\n\n const node = (response as any)?.data?.storeConfig;\n if (!node) {\n throw new Error('Invalid response: missing storeConfig');\n }\n\n return Boolean(node.company_enabled);\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_COMPANY_INFO = `\n query GET_CUSTOMER_COMPANY_INFO {\n customer {\n id\n job_title\n telephone\n role {\n id\n name\n }\n }\n company {\n id\n name\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 { companyEnabled } from '../companyEnabled';\nimport { GET_CUSTOMER_COMPANY_INFO } from './graphql/getCustomerCompanyInfo.graphql';\nimport { CustomerCompanyInfo } from '../../data/models/customer-company-info';\nimport { GetCustomerCompanyInfoResponse } from '../../types/api/getCustomerCompanyInfo.types';\nimport { transformCustomerCompanyInfo } from '../../data/transforms/transform-customer-company-info';\n\n/**\n * Gets customer company information for display on account information page\n * This is a simplified API that only returns the essential company info needed\n * for the customer account page, without requiring full company permissions\n */\nexport const getCustomerCompany = async (): Promise<CustomerCompanyInfo | null> => {\n try {\n // First check if company functionality is enabled\n const isCompanyEnabled = await companyEnabled();\n if (!isCompanyEnabled) {\n return null;\n }\n\n // Fetch customer company information\n const response: GetCustomerCompanyInfoResponse = await fetchGraphQl(GET_CUSTOMER_COMPANY_INFO, { \n method: 'GET', \n cache: 'no-cache' \n });\n\n if (response.errors?.length) {\n return handleFetchError(response.errors);\n }\n\n // Transform the response using the transformer\n return transformCustomerCompanyInfo(response);\n\n } catch (error) {\n console.error('Failed to fetch customer company info:', error);\n return handleNetworkError(error as Error);\n }\n};\n"],"names":["transformCustomerCompanyInfo","response","customer","_a","company","_b","companyInfo","_c","GET_COMPANY_ENABLED","companyEnabled","fetchGraphQl","node","GET_CUSTOMER_COMPANY_INFO","getCustomerCompany","handleFetchError","error","handleNetworkError"],"mappings":"mFAwBa,MAAAA,EAAgCC,GAAyE,WAC9G,MAAAC,GAAWC,EAAAF,GAAA,Y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