@dropins/storefront-company-management 1.0.0-beta4 → 1.0.0-beta6
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.
- package/api/getCustomerCompany/getCustomerCompany.d.ts +9 -0
- package/api/getCustomerCompany/graphql/getCustomerCompanyInfo.graphql.d.ts +18 -0
- package/api/getCustomerCompany/index.d.ts +18 -0
- package/api/index.d.ts +1 -0
- package/api.js +1 -1
- package/api.js.map +1 -1
- package/chunks/getCountries.js +9 -15
- package/chunks/getCountries.js.map +1 -1
- package/chunks/getCustomerCompany.js +20 -0
- package/chunks/getCustomerCompany.js.map +1 -0
- package/chunks/validateCompanyEmail.js +10 -0
- package/chunks/validateCompanyEmail.js.map +1 -0
- package/components/CustomerCompanyInfoCard/CustomerCompanyInfoCard.d.ts +9 -0
- package/components/CustomerCompanyInfoCard/index.d.ts +18 -0
- package/components/EditCompanyProfile/CompanyAccountFields.d.ts +1 -2
- package/components/EditCompanyProfile/LegalAddressFields.d.ts +1 -1
- package/components/Tree/Tree.d.ts +60 -0
- package/components/Tree/index.d.ts +18 -0
- package/components/index.d.ts +1 -0
- package/containers/CompanyProfile.js +1 -1
- package/containers/CompanyProfile.js.map +1 -1
- package/containers/CustomerCompanyInfo/CustomerCompanyInfo.d.ts +9 -0
- package/containers/CustomerCompanyInfo/index.d.ts +19 -0
- package/containers/CustomerCompanyInfo.d.ts +1 -0
- package/containers/CustomerCompanyInfo.js +4 -0
- package/containers/CustomerCompanyInfo.js.map +1 -0
- package/containers/index.d.ts +1 -0
- package/data/models/customer-company-info.d.ts +23 -0
- package/data/models/index.d.ts +1 -0
- package/data/transforms/index.d.ts +1 -0
- package/data/transforms/transform-customer-company-info.d.ts +10 -0
- package/hooks/containers/index.d.ts +1 -0
- package/hooks/containers/useCompanyProfile.d.ts +4 -1
- package/hooks/containers/useCustomerCompanyInfo.d.ts +12 -0
- package/i18n/en_US.json.d.ts +9 -2
- package/package.json +1 -1
- package/render.js +3 -2
- package/render.js.map +1 -1
- package/types/api/getCustomerCompanyInfo.types.d.ts +40 -0
- package/types/customerCompanyInfo.types.d.ts +11 -0
- package/types/index.d.ts +2 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CustomerCompanyInfo } from '../../data/models/customer-company-info';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Gets customer company information for display on account information page
|
|
5
|
+
* This is a simplified API that only returns the essential company info needed
|
|
6
|
+
* for the customer account page, without requiring full company permissions
|
|
7
|
+
*/
|
|
8
|
+
export declare const getCustomerCompany: () => Promise<CustomerCompanyInfo | null>;
|
|
9
|
+
//# sourceMappingURL=getCustomerCompany.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export declare const 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";
|
|
18
|
+
//# sourceMappingURL=getCustomerCompanyInfo.graphql.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export { getCustomerCompany } from './getCustomerCompany';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
package/api/index.d.ts
CHANGED
package/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{
|
|
3
|
+
import{f as p,g as n,r as m,s as i,a as c,b as h,v as f}from"./chunks/validateCompanyEmail.js";import{f as l,a as C,g as d,u}from"./chunks/getCountries.js";import{c as x,g as G}from"./chunks/getCustomerCompany.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";const t=async(e={})=>({success:!0,config:e});export{x as checkIsCompanyEnabled,p as fetchGraphQl,l as fetchUserPermissions,C as getCompany,n as getConfig,d as getCountries,G as getCustomerCompany,t as initialize,m as removeFetchGraphQlHeader,i as setEndpoint,c as setFetchGraphQlHeader,h as setFetchGraphQlHeaders,u as updateCompany,f as validateCompanyEmail};
|
|
4
4
|
//# 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"
|
|
1
|
+
{"version":3,"file":"api.js","sources":["/@dropins/storefront-company-management/src/api/initialize/initialize.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"],"names":["initialize","config"],"mappings":"kSAyBO,MAAMA,EAAa,MAAOC,EAA8B,MACtD,CACL,QAAS,GACT,OAAAA,CACF"}
|
package/chunks/getCountries.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{
|
|
3
|
+
import{f as m,h as _,c as g}from"./validateCompanyEmail.js";const E=`
|
|
4
4
|
query GET_CUSTOMER_ROLE_PERMISSIONS {
|
|
5
5
|
customer {
|
|
6
6
|
role {
|
|
@@ -23,13 +23,7 @@ import{events as E}from"@dropins/tools/event-bus.js";import{FetchGraphQL as v}fr
|
|
|
23
23
|
status
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
`,
|
|
27
|
-
query validateCompanyEmail($email: String!) {
|
|
28
|
-
isCompanyEmailAvailable(email: $email) {
|
|
29
|
-
is_email_available
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
`,j=async e=>{try{const a=await c(b,{variables:{email:e}});return a.errors?{isValid:!1,error:"Unable to validate email"}:{isValid:a.data.isCompanyEmailAvailable.is_email_available,error:a.data.isCompanyEmailAvailable.is_email_available?void 0:"This email is already used by another company"}}catch{return{isValid:!1,error:"Unable to validate email"}}},u=e=>{var s;if(!(e!=null&&e.data))throw new Error("Invalid response: missing data");const a="updateCompany"in e.data?(s=e.data.updateCompany)==null?void 0:s.company:e.data.company;if(!a)throw new Error("Invalid response: missing company data");const t="customer"in e.data?e.data.customer:void 0,i=a.legal_address?{street:Array.isArray(a.legal_address.street)?a.legal_address.street.filter(n=>n&&n.trim()!==""):[],city:(a.legal_address.city||"").trim(),region:a.legal_address.region?{region:(a.legal_address.region.region||"").trim(),regionCode:(a.legal_address.region.region_code||"").trim(),regionId:a.legal_address.region.region_id?Number(a.legal_address.region.region_id):0}:void 0,countryCode:(a.legal_address.country_code||"").toUpperCase().trim(),postcode:(a.legal_address.postcode||"").trim(),telephone:a.legal_address.telephone?a.legal_address.telephone.trim():void 0}:void 0,r=t==null?void 0:t.role,d=N(r),o={id:(a.id||"").toString(),name:(a.name||"").trim(),email:(a.email||"").trim().toLowerCase(),legalName:a.legal_name?a.legal_name.trim():void 0,vatTaxId:a.vat_tax_id?a.vat_tax_id.trim():void 0,resellerId:a.reseller_id?a.reseller_id.trim():void 0,legalAddress:i,companyAdmin:a.company_admin?{id:(a.company_admin.id||"").toString(),firstname:(a.company_admin.firstname||"").trim(),lastname:(a.company_admin.lastname||"").trim(),email:(a.company_admin.email||"").trim().toLowerCase(),jobTitle:a.company_admin.job_title?a.company_admin.job_title.trim():void 0}:void 0,salesRepresentative:a.sales_representative?{firstname:(a.sales_representative.firstname||"").trim(),lastname:(a.sales_representative.lastname||"").trim(),email:(a.sales_representative.email||"").trim().toLowerCase()}:void 0,availablePaymentMethods:Array.isArray(a.available_payment_methods)?a.available_payment_methods.filter(n=>n&&typeof n.code=="string"&&typeof n.title=="string").map(n=>({code:n.code.trim(),title:n.title.trim()})).filter(n=>n.code.length>0&&n.title.length>0):void 0,availableShippingMethods:Array.isArray(a.available_shipping_methods)?a.available_shipping_methods.filter(n=>n&&typeof n.code=="string"&&typeof n.title=="string").map(n=>({code:n.code.trim(),title:n.title.trim()})).filter(n=>n.code.length>0&&n.title.length>0):void 0,canEditAccount:d.canEditAccount,canEditAddress:d.canEditAddress,permissionsFlags:d,customerRole:r,customerStatus:t==null?void 0:t.status};if(d.canViewAccount){if(!o.id)throw new Error("Company ID is required");if(!o.name)throw new Error("Company name is required");if(!o.email)throw new Error("Company email is required")}return o},w=e=>{var o,s;if(!((s=(o=e==null?void 0:e.data)==null?void 0:o.countries)!=null&&s.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:a,storeConfig:t}=e.data,i=t==null?void 0:t.countries_with_required_region.split(","),r=t==null?void 0:t.optional_zip_countries.split(",");return{availableCountries:a.filter(({two_letter_abbreviation:n,full_name_locale:m})=>!!(n&&m)).map(n=>{const{two_letter_abbreviation:m,full_name_locale:l,available_regions:y}=n,f=Array.isArray(y)&&y.length>0;return{value:m,text:l,availableRegions:f?y:void 0}}).sort((n,m)=>n.text.localeCompare(m.text)),countriesWithRequiredRegion:i,optionalZipCountries:r}},I=`
|
|
26
|
+
`,A=(e=[])=>{const a=new Set,t=[...e];for(;t.length;){const i=t.pop();if(i&&(typeof i.id=="string"&&a.add(i.id),Array.isArray(i.children)&&i.children.length))for(const r of i.children)t.push(r)}return a},h=e=>(e==null?void 0:e.id)==="0"||typeof(e==null?void 0:e.id)=="number"&&(e==null?void 0:e.id)===0||(e==null?void 0:e.name)==="Company Administrator",M=e=>{const a=A((e==null?void 0:e.permissions)||[]),t=h(e);return{canViewAccount:t||a.has("Magento_Company::view_account"),canEditAccount:t||a.has("Magento_Company::edit_account"),canViewAddress:t||a.has("Magento_Company::view_address"),canEditAddress:t||a.has("Magento_Company::edit_address"),canViewContacts:t||a.has("Magento_Company::contacts"),canViewPaymentInformation:t||a.has("Magento_Company::payment_information"),canViewShippingInformation:t||a.has("Magento_Company::shipping_information")}},p=async()=>await m(E,{method:"GET",cache:"no-cache"}).then(e=>{var r,d,o;if((r=e.errors)!=null&&r.length)return _(e.errors);const a=(o=(d=e==null?void 0:e.data)==null?void 0:d.customer)==null?void 0:o.role,t=A((a==null?void 0:a.permissions)||[]);return h(a)&&["Magento_Company::view_account","Magento_Company::edit_account","Magento_Company::view_address","Magento_Company::edit_address","Magento_Company::contacts","Magento_Company::payment_information","Magento_Company::shipping_information"].forEach(s=>t.add(s)),{allowedIds:t,roleResponse:e}}).catch(g),u=e=>{var s;if(!(e!=null&&e.data))throw new Error("Invalid response: missing data");const a="updateCompany"in e.data?(s=e.data.updateCompany)==null?void 0:s.company:e.data.company;if(!a)throw new Error("Invalid response: missing company data");const t="customer"in e.data?e.data.customer:void 0,i=a.legal_address?{street:Array.isArray(a.legal_address.street)?a.legal_address.street.filter(n=>n&&n.trim()!==""):[],city:(a.legal_address.city||"").trim(),region:a.legal_address.region?{region:(a.legal_address.region.region||"").trim(),regionCode:(a.legal_address.region.region_code||"").trim(),regionId:a.legal_address.region.region_id?Number(a.legal_address.region.region_id):0}:void 0,countryCode:(a.legal_address.country_code||"").toUpperCase().trim(),postcode:(a.legal_address.postcode||"").trim(),telephone:a.legal_address.telephone?a.legal_address.telephone.trim():void 0}:void 0,r=t==null?void 0:t.role,d=M(r),o={id:(a.id||"").toString(),name:(a.name||"").trim(),email:(a.email||"").trim().toLowerCase(),legalName:a.legal_name?a.legal_name.trim():void 0,vatTaxId:a.vat_tax_id?a.vat_tax_id.trim():void 0,resellerId:a.reseller_id?a.reseller_id.trim():void 0,legalAddress:i,companyAdmin:a.company_admin?{id:(a.company_admin.id||"").toString(),firstname:(a.company_admin.firstname||"").trim(),lastname:(a.company_admin.lastname||"").trim(),email:(a.company_admin.email||"").trim().toLowerCase(),jobTitle:a.company_admin.job_title?a.company_admin.job_title.trim():void 0}:void 0,salesRepresentative:a.sales_representative?{firstname:(a.sales_representative.firstname||"").trim(),lastname:(a.sales_representative.lastname||"").trim(),email:(a.sales_representative.email||"").trim().toLowerCase()}:void 0,availablePaymentMethods:Array.isArray(a.available_payment_methods)?a.available_payment_methods.filter(n=>n&&typeof n.code=="string"&&typeof n.title=="string").map(n=>({code:n.code.trim(),title:n.title.trim()})).filter(n=>n.code.length>0&&n.title.length>0):void 0,availableShippingMethods:Array.isArray(a.available_shipping_methods)?a.available_shipping_methods.filter(n=>n&&typeof n.code=="string"&&typeof n.title=="string").map(n=>({code:n.code.trim(),title:n.title.trim()})).filter(n=>n.code.length>0&&n.title.length>0):void 0,canEditAccount:d.canEditAccount,canEditAddress:d.canEditAddress,permissionsFlags:d,customerRole:r,customerStatus:t==null?void 0:t.status};if(d.canViewAccount){if(!o.id)throw new Error("Company ID is required");if(!o.name)throw new Error("Company name is required");if(!o.email)throw new Error("Company email is required")}return o},v=e=>{var o,s;if(!((s=(o=e==null?void 0:e.data)==null?void 0:o.countries)!=null&&s.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:a,storeConfig:t}=e.data,i=t==null?void 0:t.countries_with_required_region.split(","),r=t==null?void 0:t.optional_zip_countries.split(",");return{availableCountries:a.filter(({two_letter_abbreviation:n,full_name_locale:c})=>!!(n&&c)).map(n=>{const{two_letter_abbreviation:c,full_name_locale:l,available_regions:y}=n,f=Array.isArray(y)&&y.length>0;return{value:c,text:l,availableRegions:f?y:void 0}}).sort((n,c)=>n.text.localeCompare(c.text)),countriesWithRequiredRegion:i,optionalZipCountries:r}},N=`
|
|
33
27
|
fragment COMPANY_LEGAL_ADDRESS_FRAGMENT on CompanyLegalAddress {
|
|
34
28
|
street
|
|
35
29
|
city
|
|
@@ -42,7 +36,7 @@ import{events as E}from"@dropins/tools/event-bus.js";import{FetchGraphQL as v}fr
|
|
|
42
36
|
postcode
|
|
43
37
|
telephone
|
|
44
38
|
}
|
|
45
|
-
`,
|
|
39
|
+
`,I=`
|
|
46
40
|
fragment COMPANY_BASIC_INFO_FRAGMENT on Company {
|
|
47
41
|
id
|
|
48
42
|
name
|
|
@@ -51,20 +45,20 @@ import{events as E}from"@dropins/tools/event-bus.js";import{FetchGraphQL as v}fr
|
|
|
51
45
|
vat_tax_id
|
|
52
46
|
reseller_id
|
|
53
47
|
}
|
|
54
|
-
`,
|
|
48
|
+
`,S=`
|
|
55
49
|
fragment COMPANY_SALES_REPRESENTATIVE_FRAGMENT on CompanySalesRepresentative {
|
|
56
50
|
firstname
|
|
57
51
|
lastname
|
|
58
52
|
email
|
|
59
53
|
}
|
|
60
|
-
`,
|
|
54
|
+
`,w=`
|
|
61
55
|
fragment COMPANY_ADMIN_FRAGMENT on Customer {
|
|
62
56
|
firstname
|
|
63
57
|
lastname
|
|
64
58
|
email
|
|
65
59
|
job_title
|
|
66
60
|
}
|
|
67
|
-
`,C=e=>{const a=e.has("Magento_Company::view_account"),t=e.has("Magento_Company::view_address"),i=e.has("Magento_Company::contacts"),r=e.has("Magento_Company::payment_information"),d=e.has("Magento_Company::shipping_information"),o=[],s=[];return a&&(o.push("...COMPANY_BASIC_INFO_FRAGMENT"),s.push(
|
|
61
|
+
`,C=e=>{const a=e.has("Magento_Company::view_account"),t=e.has("Magento_Company::view_address"),i=e.has("Magento_Company::contacts"),r=e.has("Magento_Company::payment_information"),d=e.has("Magento_Company::shipping_information"),o=[],s=[];return a&&(o.push("...COMPANY_BASIC_INFO_FRAGMENT"),s.push(I)),t&&(o.push("legal_address { ...COMPANY_LEGAL_ADDRESS_FRAGMENT }"),s.push(N)),i&&(o.push("company_admin { ...COMPANY_ADMIN_FRAGMENT }"),o.push("sales_representative { ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT }"),s.push(w),s.push(S)),r&&o.push("available_payment_methods { code title }"),d&&o.push("available_shipping_methods { code title }"),{fields:o,usedFragments:s}},T=e=>{const{fields:a,usedFragments:t}=C(e);return a.length===0?`
|
|
68
62
|
query GET_COMPANY_DYNAMIC {
|
|
69
63
|
company { __typename }
|
|
70
64
|
}
|
|
@@ -77,7 +71,7 @@ import{events as E}from"@dropins/tools/event-bus.js";import{FetchGraphQL as v}fr
|
|
|
77
71
|
}
|
|
78
72
|
`}
|
|
79
73
|
${t.join(`
|
|
80
|
-
`)}`},
|
|
74
|
+
`)}`},b=e=>{const{fields:a,usedFragments:t}=C(e);return a.length===0?`
|
|
81
75
|
mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {
|
|
82
76
|
updateCompany(input: $input) {
|
|
83
77
|
company { __typename }
|
|
@@ -94,7 +88,7 @@ ${t.join(`
|
|
|
94
88
|
}
|
|
95
89
|
`}
|
|
96
90
|
${t.join(`
|
|
97
|
-
`)}`},
|
|
91
|
+
`)}`},G=async()=>await p().then(async({allowedIds:e,roleResponse:a})=>{var o,s,n;const t=T(e),i=await m(t,{method:"GET",cache:"no-cache"});if((o=i.errors)!=null&&o.length)return _(i.errors);const r=(s=i==null?void 0:i.data)==null?void 0:s.company;return r&&Object.keys(r).some(c=>c!=="__typename")?(i.data.customer=(n=a==null?void 0:a.data)==null?void 0:n.customer,u(i)):null}).catch(g),Y=async e=>await p().then(async({allowedIds:a,roleResponse:t})=>{var o,s;const i=b(a),r={};if(e.name!==void 0&&(r.company_name=e.name),e.email!==void 0&&(r.company_email=e.email),e.legalName!==void 0&&(r.legal_name=e.legalName),e.vatTaxId!==void 0&&(r.vat_tax_id=e.vatTaxId),e.resellerId!==void 0&&(r.reseller_id=e.resellerId),e.legalAddress!==void 0&&a.has("Magento_Company::edit_address")){let n;Array.isArray(e.legalAddress.street)?(n=[...e.legalAddress.street],e.legalAddress.street2&&n.push(e.legalAddress.street2)):n=[e.legalAddress.street,e.legalAddress.street2].filter(l=>typeof l=="string"&&l.trim().length>0),n=n.filter(l=>l&&typeof l=="string"&&l.trim().length>0);let c;if(e.legalAddress.region&&typeof e.legalAddress.region=="object"){const l=e.legalAddress.region;l.region===l.regionCode?c={region:l.region,region_code:l.regionCode,region_id:0}:c={region:l.region,region_code:l.regionCode}}else e.legalAddress.regionCode&&e.legalAddress.region!==e.legalAddress.regionCode?c={region:e.legalAddress.region||e.legalAddress.regionCode,region_code:e.legalAddress.regionCode}:e.legalAddress.region&&(c={region:e.legalAddress.region,region_code:e.legalAddress.region,region_id:0});r.legal_address={street:n,city:e.legalAddress.city,region:c,country_id:e.legalAddress.countryCode,postcode:e.legalAddress.postcode,telephone:e.legalAddress.telephone}}const d=await m(i,{method:"POST",variables:{input:r}});return(o=d.errors)!=null&&o.length?_(d.errors):(d.data.customer=(s=t==null?void 0:t.data)==null?void 0:s.customer,u(d))}).catch(g),O=`
|
|
98
92
|
query getCountries {
|
|
99
93
|
countries {
|
|
100
94
|
id
|
|
@@ -113,5 +107,5 @@ ${t.join(`
|
|
|
113
107
|
optional_zip_countries
|
|
114
108
|
}
|
|
115
109
|
}
|
|
116
|
-
`,
|
|
110
|
+
`,F=async()=>{const e="_company_countries",a=sessionStorage.getItem(e);return a?JSON.parse(a):await m(O,{method:"GET"}).then(t=>{var r;if((r=t.errors)!=null&&r.length)return _(t.errors);const i=v(t);return sessionStorage.setItem(e,JSON.stringify(i)),i}).catch(g)};export{G as a,p as f,F as g,Y as u};
|
|
117
111
|
//# sourceMappingURL=getCountries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCountries.js","sources":["/@dropins/storefront-company-management/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-company-management/src/lib/network-error.ts","/@dropins/storefront-company-management/src/lib/fetch-error.ts","/@dropins/storefront-company-management/src/api/fetchUserPermissions/graphql/getCustomerRole.graphql.ts","/@dropins/storefront-company-management/src/lib/company-permissions.ts","/@dropins/storefront-company-management/src/api/fetchUserPermissions/fetchUserPermissions.ts","/@dropins/storefront-company-management/src/api/validateCompanyEmail/graphql/validateCompanyEmail.graphql.ts","/@dropins/storefront-company-management/src/api/validateCompanyEmail/validateCompanyEmail.ts","/@dropins/storefront-company-management/src/data/transforms/transform-company.ts","/@dropins/storefront-company-management/src/data/transforms/transform-countries.ts","/@dropins/storefront-company-management/src/api/graphql/CompanyFragment.graphql.ts","/@dropins/storefront-company-management/src/api/graphql/buildCompanyQueries.ts","/@dropins/storefront-company-management/src/api/getCompany/getCompany.ts","/@dropins/storefront-company-management/src/api/updateCompany/updateCompany.ts","/@dropins/storefront-company-management/src/api/getCountries/graphql/getCountries.graphql.ts","/@dropins/storefront-company-management/src/api/getCountries/getCountries.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 '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\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 { 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","/********************************************************************\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 *******************************************************************/\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}\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 * 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 };\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 ].forEach((id) => allowedIds.add(id));\n }\n\n return { allowedIds, roleResponse };\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 *******************************************************************/\nexport const VALIDATE_COMPANY_EMAIL_QUERY = /* GraphQL */ `\n query validateCompanyEmail($email: String!) {\n isCompanyEmailAvailable(email: $email) {\n is_email_available\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 { fetchGraphQl } from '../fetch-graphql';\nimport { VALIDATE_COMPANY_EMAIL_QUERY } from './graphql/validateCompanyEmail.graphql';\nimport { ValidateCompanyEmailQuery, ValidateCompanyEmailResponse } from '../../types/api/validateCompanyEmail.types';\n\nexport const validateCompanyEmail = async (email: string): Promise<ValidateCompanyEmailResponse> => {\n try {\n const response = await fetchGraphQl<ValidateCompanyEmailQuery>(VALIDATE_COMPANY_EMAIL_QUERY, {\n variables: { email },\n });\n\n if (response.errors) {\n return {\n isValid: false,\n error: 'Unable to validate email'\n };\n }\n\n return {\n isValid: response.data.isCompanyEmailAvailable.is_email_available,\n error: response.data.isCompanyEmailAvailable.is_email_available \n ? undefined \n : 'This email is already used by another company'\n };\n } catch (error) {\n return {\n isValid: false,\n error: 'Unable to validate email'\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 { getCompanyResponse } from '../../types/api/getCompany.types';\nimport { updateCompanyResponse } from '../../types/api/updateCompany.types';\nimport { CompanyModel } from '../models/company';\nimport { buildPermissionFlags } from '../../lib/company-permissions';\n\nexport const transformCompany = (\n response: getCompanyResponse | updateCompanyResponse\n): CompanyModel => {\n // Validate response structure\n if (!response?.data) {\n throw new Error('Invalid response: missing data');\n }\n\n // Handle both getCompany and updateCompany response structures\n const companyData: any = 'updateCompany' in response.data \n ? response.data.updateCompany?.company \n : response.data.company;\n \n if (!companyData) {\n throw new Error('Invalid response: missing company data');\n }\n \n const customerData = 'customer' in response.data ? response.data.customer : undefined;\n\n // Transform legal address with validation\n const legalAddress = companyData.legal_address ? {\n street: Array.isArray(companyData.legal_address.street) \n ? companyData.legal_address.street.filter((line: string) => line && line.trim() !== '') \n : [],\n city: (companyData.legal_address.city || '').trim(),\n region: companyData.legal_address.region ? {\n region: (companyData.legal_address.region.region || '').trim(),\n regionCode: (companyData.legal_address.region.region_code || '').trim(),\n regionId: companyData.legal_address.region.region_id ? Number(companyData.legal_address.region.region_id) : 0,\n } : undefined,\n countryCode: (companyData.legal_address.country_code || '').toUpperCase().trim(),\n postcode: (companyData.legal_address.postcode || '').trim(),\n telephone: companyData.legal_address.telephone ? \n companyData.legal_address.telephone.trim() : undefined,\n } : undefined;\n\n // Determine permissions using shared utility\n const customerRole = customerData?.role;\n const permissionsFlags = buildPermissionFlags(customerRole);\n\n // Build the model with proper validation\n const model: CompanyModel = {\n id: (companyData.id || '').toString(),\n name: (companyData.name || '').trim(),\n email: (companyData.email || '').trim().toLowerCase(),\n legalName: companyData.legal_name ? companyData.legal_name.trim() : undefined,\n vatTaxId: companyData.vat_tax_id ? companyData.vat_tax_id.trim() : undefined,\n resellerId: companyData.reseller_id ? companyData.reseller_id.trim() : undefined,\n legalAddress,\n companyAdmin: companyData.company_admin ? {\n id: (companyData.company_admin.id || '').toString(),\n firstname: (companyData.company_admin.firstname || '').trim(),\n lastname: (companyData.company_admin.lastname || '').trim(),\n email: (companyData.company_admin.email || '').trim().toLowerCase(),\n jobTitle: companyData.company_admin.job_title ? companyData.company_admin.job_title.trim() : undefined,\n } : undefined,\n\n // Transform sales representative\n salesRepresentative: companyData.sales_representative ? {\n firstname: (companyData.sales_representative.firstname || '').trim(),\n lastname: (companyData.sales_representative.lastname || '').trim(),\n email: (companyData.sales_representative.email || '').trim().toLowerCase(),\n } : undefined,\n\n // New comprehensive payment methods with code and title\n availablePaymentMethods: Array.isArray(companyData.available_payment_methods)\n ? companyData.available_payment_methods\n .filter((m: any) => m && typeof m.code === 'string' && typeof m.title === 'string')\n .map((m: any) => ({ code: m.code.trim(), title: m.title.trim() }))\n .filter((m: any) => m.code.length > 0 && m.title.length > 0)\n : undefined,\n\n // New available shipping methods\n availableShippingMethods: Array.isArray(companyData.available_shipping_methods)\n ? companyData.available_shipping_methods\n .filter((m: any) => m && typeof m.code === 'string' && typeof m.title === 'string')\n .map((m: any) => ({ code: m.code.trim(), title: m.title.trim() }))\n .filter((m: any) => m.code.length > 0 && m.title.length > 0)\n : undefined,\n \n // Computed permission flags (single source of truth)\n canEditAccount: permissionsFlags.canEditAccount,\n canEditAddress: permissionsFlags.canEditAddress,\n permissionsFlags,\n customerRole,\n customerStatus: customerData?.status,\n };\n\n // Validate only when profile fields are permitted\n if (permissionsFlags.canViewAccount) {\n if (!model.id) {\n throw new Error('Company ID is required');\n }\n if (!model.name) {\n throw new Error('Company name is required');\n }\n if (!model.email) {\n throw new Error('Company email is required');\n }\n }\n\n return model;\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 { CountriesFormResponse } from '../../types/api/getCountries.types';\nimport { Country } from '../models/country';\n\nexport const transformCountries = (\n response: CountriesFormResponse\n): {\n availableCountries: Country[] | [];\n countriesWithRequiredRegion: string[];\n optionalZipCountries: string[];\n} => {\n if (!response?.data?.countries?.length) {\n return {\n availableCountries: [],\n countriesWithRequiredRegion: [],\n optionalZipCountries: [],\n };\n }\n\n const { countries, storeConfig } = response.data;\n\n const countriesWithRequiredRegion =\n storeConfig?.countries_with_required_region.split(',');\n const optionalZipCountries = storeConfig?.optional_zip_countries.split(',');\n\n const availableCountries = countries\n .filter(({ two_letter_abbreviation, full_name_locale }) =>\n Boolean(two_letter_abbreviation && full_name_locale)\n )\n .map((country) => {\n const { two_letter_abbreviation, full_name_locale, available_regions } = country;\n\n const hasRegions = Array.isArray(available_regions) && available_regions.length > 0;\n return {\n value: two_letter_abbreviation,\n text: full_name_locale,\n availableRegions: hasRegions ? available_regions : undefined,\n };\n })\n .sort((a, b) => a.text.localeCompare(b.text));\n\n return {\n availableCountries,\n countriesWithRequiredRegion,\n optionalZipCountries,\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 *******************************************************************/\nexport const COMPANY_LEGAL_ADDRESS_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_LEGAL_ADDRESS_FRAGMENT on CompanyLegalAddress {\n street\n city\n region {\n region\n region_code\n region_id\n }\n country_code\n postcode\n telephone\n }\n`;\n\nexport const COMPANY_BASIC_INFO_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_BASIC_INFO_FRAGMENT on Company {\n id\n name\n email\n legal_name\n vat_tax_id\n reseller_id\n }\n`;\n\nexport const COMPANY_SALES_REPRESENTATIVE_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_SALES_REPRESENTATIVE_FRAGMENT on CompanySalesRepresentative {\n firstname\n lastname\n email\n }\n`;\n\nexport const COMPANY_ADMIN_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_ADMIN_FRAGMENT on Customer {\n firstname\n lastname\n email\n job_title\n }\n`;\n\nexport const COMPANY_FULL_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_FULL_FRAGMENT on Company {\n ...COMPANY_BASIC_INFO_FRAGMENT\n legal_address {\n ...COMPANY_LEGAL_ADDRESS_FRAGMENT\n }\n company_admin {\n ...COMPANY_ADMIN_FRAGMENT\n }\n sales_representative {\n ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT\n }\n available_payment_methods {\n code\n title\n }\n available_shipping_methods {\n code\n title\n }\n }\n ${COMPANY_BASIC_INFO_FRAGMENT}\n ${COMPANY_LEGAL_ADDRESS_FRAGMENT}\n ${COMPANY_ADMIN_FRAGMENT}\n ${COMPANY_SALES_REPRESENTATIVE_FRAGMENT}\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 {\n COMPANY_BASIC_INFO_FRAGMENT,\n COMPANY_LEGAL_ADDRESS_FRAGMENT,\n COMPANY_ADMIN_FRAGMENT,\n COMPANY_SALES_REPRESENTATIVE_FRAGMENT,\n} from './CompanyFragment.graphql';\n\n/**\n * Builds company fields based on user permissions\n */\nconst buildCompanyFields = (allowed: Set<string>): { fields: string[]; usedFragments: string[] } => {\n const wantProfile = allowed.has('Magento_Company::view_account');\n const wantAddress = allowed.has('Magento_Company::view_address');\n const wantContacts = allowed.has('Magento_Company::contacts');\n const wantPayment = allowed.has('Magento_Company::payment_information');\n const wantShipping = allowed.has('Magento_Company::shipping_information');\n\n const fields: string[] = [];\n const usedFragments: string[] = [];\n\n if (wantProfile) {\n fields.push('...COMPANY_BASIC_INFO_FRAGMENT');\n usedFragments.push(COMPANY_BASIC_INFO_FRAGMENT);\n }\n if (wantAddress) {\n fields.push(`legal_address { ...COMPANY_LEGAL_ADDRESS_FRAGMENT }`);\n usedFragments.push(COMPANY_LEGAL_ADDRESS_FRAGMENT);\n }\n if (wantContacts) {\n fields.push(`company_admin { ...COMPANY_ADMIN_FRAGMENT }`);\n fields.push(`sales_representative { ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT }`);\n usedFragments.push(COMPANY_ADMIN_FRAGMENT);\n usedFragments.push(COMPANY_SALES_REPRESENTATIVE_FRAGMENT);\n }\n if (wantPayment) {\n fields.push(`available_payment_methods { code title }`);\n }\n if (wantShipping) {\n fields.push(`available_shipping_methods { code title }`);\n }\n\n return { fields, usedFragments };\n};\n\n/**\n * Builds a dynamic company query based on user permissions\n */\nexport const buildCompanyQuery = (allowed: Set<string>): string => {\n const { fields, usedFragments } = buildCompanyFields(allowed);\n\n // If no allowed company fields, still query company with __typename to keep response shape\n if (fields.length === 0) {\n return `\n query GET_COMPANY_DYNAMIC {\n company { __typename }\n }\n `;\n }\n\n const query = `\n query GET_COMPANY_DYNAMIC {\n company {\n ${fields.join('\\n ')}\n }\n }\n `;\n\n return `${query}\\n${usedFragments.join('\\n')}`;\n};\n\n/**\n * Builds a dynamic company update mutation based on user permissions\n */\nexport const buildUpdateCompanyMutation = (allowed: Set<string>): string => {\n const { fields, usedFragments } = buildCompanyFields(allowed);\n\n // If no allowed company fields, still query company with __typename to keep response shape\n if (fields.length === 0) {\n return `\n mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {\n updateCompany(input: $input) {\n company { __typename }\n }\n }\n `;\n }\n\n const mutation = `\n mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {\n updateCompany(input: $input) {\n company {\n ${fields.join('\\n ')}\n }\n }\n }\n `;\n\n return `${mutation}\\n${usedFragments.join('\\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 { transformCompany } from '../../data/transforms';\nimport { CompanyModel } from '../../data/models/company';\nimport { getCompanyResponse } from '../../types/api/getCompany.types';\nimport { fetchUserPermissions } from '../fetchUserPermissions';\nimport { buildCompanyQuery } from '../graphql/buildCompanyQueries';\nimport { handleFetchError } from '../../lib/fetch-error';\n\nexport const getCompany = async (): Promise<CompanyModel | null> => {\n return await fetchUserPermissions()\n .then(async ({ allowedIds, roleResponse }) => {\n // Build a company query that requests only allowed fields\n const GET_COMPANY_DYNAMIC = buildCompanyQuery(allowedIds);\n\n // Fetch company with dynamic selection\n const companyResponse: getCompanyResponse = await fetchGraphQl(GET_COMPANY_DYNAMIC, { method: 'GET', cache: 'no-cache' });\n if (companyResponse.errors?.length) return handleFetchError(companyResponse.errors);\n\n const companyNode: any = companyResponse?.data?.company;\n const hasAnyCompanyField = companyNode && Object.keys(companyNode).some((k) => k !== '__typename');\n if (!hasAnyCompanyField) {\n return null;\n }\n\n // Merge back minimal customer role info so transform can compute flags\n (companyResponse as any).data.customer = roleResponse?.data?.customer;\n\n return transformCompany(companyResponse);\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 *******************************************************************/\nimport { handleNetworkError } from '../../lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { transformCompany } from '../../data/transforms';\nimport { CompanyModel } from '../../data/models/company';\nimport { updateCompanyResponse, UpdateCompanyDto } from '../../types';\nimport { fetchUserPermissions } from '../fetchUserPermissions';\nimport { buildUpdateCompanyMutation } from '../graphql/buildCompanyQueries';\n\n\nexport const updateCompany = async (input: UpdateCompanyDto): Promise<CompanyModel> => {\n return await fetchUserPermissions()\n .then(async ({ allowedIds, roleResponse }) => {\n // Build a dynamic mutation that requests only allowed fields in response\n const UPDATE_COMPANY_DYNAMIC = buildUpdateCompanyMutation(allowedIds);\n\n // Transform input (keep original logic for what to send)\n const transformedInput: Record<string, unknown> = {};\n \n // Map frontend field names to GraphQL schema field names\n if (input.name !== undefined) {\n transformedInput.company_name = input.name;\n }\n if (input.email !== undefined) {\n transformedInput.company_email = input.email;\n }\n if (input.legalName !== undefined) {\n transformedInput.legal_name = input.legalName;\n }\n if (input.vatTaxId !== undefined) {\n transformedInput.vat_tax_id = input.vatTaxId;\n }\n if (input.resellerId !== undefined) {\n transformedInput.reseller_id = input.resellerId;\n }\n \n // Transform legal address (only if user has edit_address permission)\n if (input.legalAddress !== undefined && allowedIds.has('Magento_Company::edit_address')) {\n // Handle street field - ensure it's always a flat array of strings\n let streetArray: string[];\n if (Array.isArray(input.legalAddress.street)) {\n // If street is already an array, use it directly and add street_2 if present\n streetArray = [...input.legalAddress.street];\n if (input.legalAddress.street2) {\n streetArray.push(input.legalAddress.street2);\n }\n } else {\n // If street is a string, create array normally with type guard\n streetArray = [input.legalAddress.street, input.legalAddress.street2].filter(\n (s): s is string => typeof s === 'string' && s.trim().length > 0\n );\n }\n \n // Remove any empty strings and ensure all elements are strings\n streetArray = streetArray.filter(street => street && typeof street === 'string' && street.trim().length > 0);\n \n // Handle region - different approaches for dropdown vs custom regions\n let regionValue: { region: string; region_code: string; region_id?: number } | undefined;\n if (input.legalAddress.region && typeof input.legalAddress.region === 'object') {\n const regionObj = input.legalAddress.region;\n \n // Check if this is a custom region (region === regionCode) or predefined region\n if (regionObj.region === regionObj.regionCode) {\n // Custom region - send as object with region_id: 0\n regionValue = {\n region: regionObj.region,\n region_code: regionObj.regionCode,\n region_id: 0\n };\n } else {\n // Predefined region - send as object\n regionValue = {\n region: regionObj.region,\n region_code: regionObj.regionCode,\n };\n }\n } else if (input.legalAddress.regionCode && input.legalAddress.region !== input.legalAddress.regionCode) {\n // If we have different region and regionCode (dropdown case)\n regionValue = {\n region: input.legalAddress.region || input.legalAddress.regionCode,\n region_code: input.legalAddress.regionCode,\n };\n } else if (input.legalAddress.region) {\n // If we only have region string (fallback case)\n regionValue = {\n region: input.legalAddress.region,\n region_code: input.legalAddress.region,\n region_id: 0\n };\n }\n \n transformedInput.legal_address = {\n street: streetArray,\n city: input.legalAddress.city,\n region: regionValue,\n country_id: input.legalAddress.countryCode, // GraphQL expects country_id, not countryCode\n postcode: input.legalAddress.postcode,\n telephone: input.legalAddress.telephone,\n };\n }\n\n // Execute the dynamic mutation\n const response: updateCompanyResponse = await fetchGraphQl(UPDATE_COMPANY_DYNAMIC, {\n method: 'POST',\n variables: { input: transformedInput },\n });\n\n if (response.errors?.length) return handleFetchError(response.errors);\n\n // Merge back minimal customer role info so transform can compute flags\n (response as any).data.customer = roleResponse?.data?.customer;\n\n return transformCompany(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 *******************************************************************/\nexport const GET_COUNTRIES_QUERY = `\n query getCountries {\n countries {\n id\n two_letter_abbreviation\n three_letter_abbreviation\n full_name_locale\n full_name_english\n available_regions {\n id\n code\n name\n }\n }\n storeConfig {\n countries_with_required_region\n optional_zip_countries\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 { GET_COUNTRIES_QUERY } from './graphql/getCountries.graphql';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { transformCountries } from '../../data/transforms/transform-countries';\nimport { CountriesFormResponse } from '../../types/api/getCountries.types';\nimport { Country } from '../../data/models/country';\n\nexport const getCountries = async (): Promise<{\n availableCountries: Country[] | [];\n countriesWithRequiredRegion: string[];\n optionalZipCountries: string[];\n}> => {\n const sessionStorageKey = '_company_countries';\n\n const sessionStorageCache = sessionStorage.getItem(sessionStorageKey);\n\n if (sessionStorageCache) {\n return JSON.parse(sessionStorageCache);\n }\n\n return await fetchGraphQl(GET_COUNTRIES_QUERY, {\n method: 'GET',\n })\n .then((response: CountriesFormResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n const transformedData = transformCountries(response);\n\n sessionStorage.setItem(\n sessionStorageKey,\n JSON.stringify(transformedData)\n );\n\n return transformedData;\n })\n .catch(handleNetworkError);\n};\n"],"names":["setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","handleNetworkError","error","events","handleFetchError","errors","errorMessage","e","GET_CUSTOMER_ROLE_PERMISSIONS","flattenIds","nodes","set","stack","node","child","isCompanyAdministrator","role","buildPermissionFlags","allowedIds","isAdmin","fetchUserPermissions","roleResponse","_a","_c","_b","id","VALIDATE_COMPANY_EMAIL_QUERY","validateCompanyEmail","email","response","transformCompany","companyData","customerData","legalAddress","line","customerRole","permissionsFlags","model","m","transformCountries","countries","storeConfig","countriesWithRequiredRegion","optionalZipCountries","two_letter_abbreviation","full_name_locale","country","available_regions","hasRegions","a","b","COMPANY_LEGAL_ADDRESS_FRAGMENT","COMPANY_BASIC_INFO_FRAGMENT","COMPANY_SALES_REPRESENTATIVE_FRAGMENT","COMPANY_ADMIN_FRAGMENT","buildCompanyFields","allowed","wantProfile","wantAddress","wantContacts","wantPayment","wantShipping","fields","usedFragments","buildCompanyQuery","buildUpdateCompanyMutation","getCompany","GET_COMPANY_DYNAMIC","companyResponse","companyNode","k","updateCompany","input","UPDATE_COMPANY_DYNAMIC","transformedInput","streetArray","s","street","regionValue","regionObj","GET_COUNTRIES_QUERY","getCountries","sessionStorageKey","sessionStorageCache","transformedData"],"mappings":"oHAmBO,KAAM,CACX,YAAAA,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAC,EACA,UAAAC,CACF,EAAI,IAAIC,EAAA,EAAe,WAAA,ECJVC,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,CACtE,MAAMC,EAAeD,EAAO,IAAKE,GAAWA,EAAE,OAAO,EAAE,KAAK,GAAG,EAE/D,MAAM,MAAMD,CAAY,CAC1B,ECLaE,EAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECkB9CC,EAAa,CAACC,EAAe,KAAoB,CAC5D,MAAMC,MAAU,IACVC,EAAQ,CAAC,GAAGF,CAAK,EACvB,KAAOE,EAAM,QAAQ,CACnB,MAAMC,EAAOD,EAAM,IAAA,EACnB,GAAKC,IACD,OAAOA,EAAK,IAAO,UAAUF,EAAI,IAAIE,EAAK,EAAE,EAC5C,MAAM,QAAQA,EA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,aAAa,SAC7B,UAAWA,EAAM,aAAa,SAAA,CAElC,CAGA,MAAM3C,EAAkC,MAAM/B,EAAa2E,EAAwB,CACjF,OAAQ,OACR,UAAW,CAAE,MAAOC,CAAA,CAAiB,CACtC,EAED,OAAIpD,EAAAO,EAAS,SAAT,MAAAP,EAAiB,OAAelB,EAAiByB,EAAS,MAAM,GAGnEA,EAAiB,KAAK,UAAWL,EAAAH,GAAA,YAAAA,EAAc,OAAd,YAAAG,EAAoB,SAE/CM,EAAiBD,CAAQ,EAClC,CAAC,EACA,MAAM5B,CAAkB,EClHhB+E,EAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECQtBC,EAAe,SAItB,CACJ,MAAMC,EAAoB,qBAEpBC,EAAsB,eAAe,QAAQD,CAAiB,EAEpE,OAAIC,EACK,KAAK,MAAMA,CAAmB,EAGhC,MAAMrF,EAAakF,EAAqB,CAC7C,OAAQ,KAAA,CACT,EACE,KAAMnD,GAAoC,OACzC,IAAIP,EAAAO,EAAS,SAAT,MAAAP,EAAiB,OAAQ,OAAOlB,EAAiByB,EAAS,MAAM,EAEpE,MAAMuD,EAAkB7C,EAAmBV,CAAQ,EAEnD,sBAAe,QACbqD,EACA,KAAK,UAAUE,CAAe,CAAA,EAGzBA,CACT,CAAC,EACA,MAAMnF,CAAkB,CAC7B"}
|
|
1
|
+
{"version":3,"file":"getCountries.js","sources":["/@dropins/storefront-company-management/src/api/fetchUserPermissions/graphql/getCustomerRole.graphql.ts","/@dropins/storefront-company-management/src/lib/company-permissions.ts","/@dropins/storefront-company-management/src/api/fetchUserPermissions/fetchUserPermissions.ts","/@dropins/storefront-company-management/src/data/transforms/transform-company.ts","/@dropins/storefront-company-management/src/data/transforms/transform-countries.ts","/@dropins/storefront-company-management/src/api/graphql/CompanyFragment.graphql.ts","/@dropins/storefront-company-management/src/api/graphql/buildCompanyQueries.ts","/@dropins/storefront-company-management/src/api/getCompany/getCompany.ts","/@dropins/storefront-company-management/src/api/updateCompany/updateCompany.ts","/@dropins/storefront-company-management/src/api/getCountries/graphql/getCountries.graphql.ts","/@dropins/storefront-company-management/src/api/getCountries/getCountries.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 *******************************************************************/\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}\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 * 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 };\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 ].forEach((id) => allowedIds.add(id));\n }\n\n return { allowedIds, roleResponse };\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 *******************************************************************/\nimport { getCompanyResponse } from '../../types/api/getCompany.types';\nimport { updateCompanyResponse } from '../../types/api/updateCompany.types';\nimport { CompanyModel } from '../models/company';\nimport { buildPermissionFlags } from '../../lib/company-permissions';\n\nexport const transformCompany = (\n response: getCompanyResponse | updateCompanyResponse\n): CompanyModel => {\n // Validate response structure\n if (!response?.data) {\n throw new Error('Invalid response: missing data');\n }\n\n // Handle both getCompany and updateCompany response structures\n const companyData: any = 'updateCompany' in response.data \n ? response.data.updateCompany?.company \n : response.data.company;\n \n if (!companyData) {\n throw new Error('Invalid response: missing company data');\n }\n \n const customerData = 'customer' in response.data ? response.data.customer : undefined;\n\n // Transform legal address with validation\n const legalAddress = companyData.legal_address ? {\n street: Array.isArray(companyData.legal_address.street) \n ? companyData.legal_address.street.filter((line: string) => line && line.trim() !== '') \n : [],\n city: (companyData.legal_address.city || '').trim(),\n region: companyData.legal_address.region ? {\n region: (companyData.legal_address.region.region || '').trim(),\n regionCode: (companyData.legal_address.region.region_code || '').trim(),\n regionId: companyData.legal_address.region.region_id ? Number(companyData.legal_address.region.region_id) : 0,\n } : undefined,\n countryCode: (companyData.legal_address.country_code || '').toUpperCase().trim(),\n postcode: (companyData.legal_address.postcode || '').trim(),\n telephone: companyData.legal_address.telephone ? \n companyData.legal_address.telephone.trim() : undefined,\n } : undefined;\n\n // Determine permissions using shared utility\n const customerRole = customerData?.role;\n const permissionsFlags = buildPermissionFlags(customerRole);\n\n // Build the model with proper validation\n const model: CompanyModel = {\n id: (companyData.id || '').toString(),\n name: (companyData.name || '').trim(),\n email: (companyData.email || '').trim().toLowerCase(),\n legalName: companyData.legal_name ? companyData.legal_name.trim() : undefined,\n vatTaxId: companyData.vat_tax_id ? companyData.vat_tax_id.trim() : undefined,\n resellerId: companyData.reseller_id ? companyData.reseller_id.trim() : undefined,\n legalAddress,\n companyAdmin: companyData.company_admin ? {\n id: (companyData.company_admin.id || '').toString(),\n firstname: (companyData.company_admin.firstname || '').trim(),\n lastname: (companyData.company_admin.lastname || '').trim(),\n email: (companyData.company_admin.email || '').trim().toLowerCase(),\n jobTitle: companyData.company_admin.job_title ? companyData.company_admin.job_title.trim() : undefined,\n } : undefined,\n\n // Transform sales representative\n salesRepresentative: companyData.sales_representative ? {\n firstname: (companyData.sales_representative.firstname || '').trim(),\n lastname: (companyData.sales_representative.lastname || '').trim(),\n email: (companyData.sales_representative.email || '').trim().toLowerCase(),\n } : undefined,\n\n // New comprehensive payment methods with code and title\n availablePaymentMethods: Array.isArray(companyData.available_payment_methods)\n ? companyData.available_payment_methods\n .filter((m: any) => m && typeof m.code === 'string' && typeof m.title === 'string')\n .map((m: any) => ({ code: m.code.trim(), title: m.title.trim() }))\n .filter((m: any) => m.code.length > 0 && m.title.length > 0)\n : undefined,\n\n // New available shipping methods\n availableShippingMethods: Array.isArray(companyData.available_shipping_methods)\n ? companyData.available_shipping_methods\n .filter((m: any) => m && typeof m.code === 'string' && typeof m.title === 'string')\n .map((m: any) => ({ code: m.code.trim(), title: m.title.trim() }))\n .filter((m: any) => m.code.length > 0 && m.title.length > 0)\n : undefined,\n \n // Computed permission flags (single source of truth)\n canEditAccount: permissionsFlags.canEditAccount,\n canEditAddress: permissionsFlags.canEditAddress,\n permissionsFlags,\n customerRole,\n customerStatus: customerData?.status,\n };\n\n // Validate only when profile fields are permitted\n if (permissionsFlags.canViewAccount) {\n if (!model.id) {\n throw new Error('Company ID is required');\n }\n if (!model.name) {\n throw new Error('Company name is required');\n }\n if (!model.email) {\n throw new Error('Company email is required');\n }\n }\n\n return model;\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 { CountriesFormResponse } from '../../types/api/getCountries.types';\nimport { Country } from '../models/country';\n\nexport const transformCountries = (\n response: CountriesFormResponse\n): {\n availableCountries: Country[] | [];\n countriesWithRequiredRegion: string[];\n optionalZipCountries: string[];\n} => {\n if (!response?.data?.countries?.length) {\n return {\n availableCountries: [],\n countriesWithRequiredRegion: [],\n optionalZipCountries: [],\n };\n }\n\n const { countries, storeConfig } = response.data;\n\n const countriesWithRequiredRegion =\n storeConfig?.countries_with_required_region.split(',');\n const optionalZipCountries = storeConfig?.optional_zip_countries.split(',');\n\n const availableCountries = countries\n .filter(({ two_letter_abbreviation, full_name_locale }) =>\n Boolean(two_letter_abbreviation && full_name_locale)\n )\n .map((country) => {\n const { two_letter_abbreviation, full_name_locale, available_regions } = country;\n\n const hasRegions = Array.isArray(available_regions) && available_regions.length > 0;\n return {\n value: two_letter_abbreviation,\n text: full_name_locale,\n availableRegions: hasRegions ? available_regions : undefined,\n };\n })\n .sort((a, b) => a.text.localeCompare(b.text));\n\n return {\n availableCountries,\n countriesWithRequiredRegion,\n optionalZipCountries,\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 *******************************************************************/\nexport const COMPANY_LEGAL_ADDRESS_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_LEGAL_ADDRESS_FRAGMENT on CompanyLegalAddress {\n street\n city\n region {\n region\n region_code\n region_id\n }\n country_code\n postcode\n telephone\n }\n`;\n\nexport const COMPANY_BASIC_INFO_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_BASIC_INFO_FRAGMENT on Company {\n id\n name\n email\n legal_name\n vat_tax_id\n reseller_id\n }\n`;\n\nexport const COMPANY_SALES_REPRESENTATIVE_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_SALES_REPRESENTATIVE_FRAGMENT on CompanySalesRepresentative {\n firstname\n lastname\n email\n }\n`;\n\nexport const COMPANY_ADMIN_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_ADMIN_FRAGMENT on Customer {\n firstname\n lastname\n email\n job_title\n }\n`;\n\nexport const COMPANY_FULL_FRAGMENT = /* GraphQL */ `\n fragment COMPANY_FULL_FRAGMENT on Company {\n ...COMPANY_BASIC_INFO_FRAGMENT\n legal_address {\n ...COMPANY_LEGAL_ADDRESS_FRAGMENT\n }\n company_admin {\n ...COMPANY_ADMIN_FRAGMENT\n }\n sales_representative {\n ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT\n }\n available_payment_methods {\n code\n title\n }\n available_shipping_methods {\n code\n title\n }\n }\n ${COMPANY_BASIC_INFO_FRAGMENT}\n ${COMPANY_LEGAL_ADDRESS_FRAGMENT}\n ${COMPANY_ADMIN_FRAGMENT}\n ${COMPANY_SALES_REPRESENTATIVE_FRAGMENT}\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 {\n COMPANY_BASIC_INFO_FRAGMENT,\n COMPANY_LEGAL_ADDRESS_FRAGMENT,\n COMPANY_ADMIN_FRAGMENT,\n COMPANY_SALES_REPRESENTATIVE_FRAGMENT,\n} from './CompanyFragment.graphql';\n\n/**\n * Builds company fields based on user permissions\n */\nconst buildCompanyFields = (allowed: Set<string>): { fields: string[]; usedFragments: string[] } => {\n const wantProfile = allowed.has('Magento_Company::view_account');\n const wantAddress = allowed.has('Magento_Company::view_address');\n const wantContacts = allowed.has('Magento_Company::contacts');\n const wantPayment = allowed.has('Magento_Company::payment_information');\n const wantShipping = allowed.has('Magento_Company::shipping_information');\n\n const fields: string[] = [];\n const usedFragments: string[] = [];\n\n if (wantProfile) {\n fields.push('...COMPANY_BASIC_INFO_FRAGMENT');\n usedFragments.push(COMPANY_BASIC_INFO_FRAGMENT);\n }\n if (wantAddress) {\n fields.push(`legal_address { ...COMPANY_LEGAL_ADDRESS_FRAGMENT }`);\n usedFragments.push(COMPANY_LEGAL_ADDRESS_FRAGMENT);\n }\n if (wantContacts) {\n fields.push(`company_admin { ...COMPANY_ADMIN_FRAGMENT }`);\n fields.push(`sales_representative { ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT }`);\n usedFragments.push(COMPANY_ADMIN_FRAGMENT);\n usedFragments.push(COMPANY_SALES_REPRESENTATIVE_FRAGMENT);\n }\n if (wantPayment) {\n fields.push(`available_payment_methods { code title }`);\n }\n if (wantShipping) {\n fields.push(`available_shipping_methods { code title }`);\n }\n\n return { fields, usedFragments };\n};\n\n/**\n * Builds a dynamic company query based on user permissions\n */\nexport const buildCompanyQuery = (allowed: Set<string>): string => {\n const { fields, usedFragments } = buildCompanyFields(allowed);\n\n // If no allowed company fields, still query company with __typename to keep response shape\n if (fields.length === 0) {\n return `\n query GET_COMPANY_DYNAMIC {\n company { __typename }\n }\n `;\n }\n\n const query = `\n query GET_COMPANY_DYNAMIC {\n company {\n ${fields.join('\\n ')}\n }\n }\n `;\n\n return `${query}\\n${usedFragments.join('\\n')}`;\n};\n\n/**\n * Builds a dynamic company update mutation based on user permissions\n */\nexport const buildUpdateCompanyMutation = (allowed: Set<string>): string => {\n const { fields, usedFragments } = buildCompanyFields(allowed);\n\n // If no allowed company fields, still query company with __typename to keep response shape\n if (fields.length === 0) {\n return `\n mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {\n updateCompany(input: $input) {\n company { __typename }\n }\n }\n `;\n }\n\n const mutation = `\n mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {\n updateCompany(input: $input) {\n company {\n ${fields.join('\\n ')}\n }\n }\n }\n `;\n\n return `${mutation}\\n${usedFragments.join('\\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 { transformCompany } from '../../data/transforms';\nimport { CompanyModel } from '../../data/models/company';\nimport { getCompanyResponse } from '../../types/api/getCompany.types';\nimport { fetchUserPermissions } from '../fetchUserPermissions';\nimport { buildCompanyQuery } from '../graphql/buildCompanyQueries';\nimport { handleFetchError } from '../../lib/fetch-error';\n\nexport const getCompany = async (): Promise<CompanyModel | null> => {\n return await fetchUserPermissions()\n .then(async ({ allowedIds, roleResponse }) => {\n // Build a company query that requests only allowed fields\n const GET_COMPANY_DYNAMIC = buildCompanyQuery(allowedIds);\n\n // Fetch company with dynamic selection\n const companyResponse: getCompanyResponse = await fetchGraphQl(GET_COMPANY_DYNAMIC, { method: 'GET', cache: 'no-cache' });\n if (companyResponse.errors?.length) return handleFetchError(companyResponse.errors);\n\n const companyNode: any = companyResponse?.data?.company;\n const hasAnyCompanyField = companyNode && Object.keys(companyNode).some((k) => k !== '__typename');\n if (!hasAnyCompanyField) {\n return null;\n }\n\n // Merge back minimal customer role info so transform can compute flags\n (companyResponse as any).data.customer = roleResponse?.data?.customer;\n\n return transformCompany(companyResponse);\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 *******************************************************************/\nimport { handleNetworkError } from '../../lib/network-error';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { transformCompany } from '../../data/transforms';\nimport { CompanyModel } from '../../data/models/company';\nimport { updateCompanyResponse, UpdateCompanyDto } from '../../types';\nimport { fetchUserPermissions } from '../fetchUserPermissions';\nimport { buildUpdateCompanyMutation } from '../graphql/buildCompanyQueries';\n\n\nexport const updateCompany = async (input: UpdateCompanyDto): Promise<CompanyModel> => {\n return await fetchUserPermissions()\n .then(async ({ allowedIds, roleResponse }) => {\n // Build a dynamic mutation that requests only allowed fields in response\n const UPDATE_COMPANY_DYNAMIC = buildUpdateCompanyMutation(allowedIds);\n\n // Transform input (keep original logic for what to send)\n const transformedInput: Record<string, unknown> = {};\n \n // Map frontend field names to GraphQL schema field names\n if (input.name !== undefined) {\n transformedInput.company_name = input.name;\n }\n if (input.email !== undefined) {\n transformedInput.company_email = input.email;\n }\n if (input.legalName !== undefined) {\n transformedInput.legal_name = input.legalName;\n }\n if (input.vatTaxId !== undefined) {\n transformedInput.vat_tax_id = input.vatTaxId;\n }\n if (input.resellerId !== undefined) {\n transformedInput.reseller_id = input.resellerId;\n }\n \n // Transform legal address (only if user has edit_address permission)\n if (input.legalAddress !== undefined && allowedIds.has('Magento_Company::edit_address')) {\n // Handle street field - ensure it's always a flat array of strings\n let streetArray: string[];\n if (Array.isArray(input.legalAddress.street)) {\n // If street is already an array, use it directly and add street_2 if present\n streetArray = [...input.legalAddress.street];\n if (input.legalAddress.street2) {\n streetArray.push(input.legalAddress.street2);\n }\n } else {\n // If street is a string, create array normally with type guard\n streetArray = [input.legalAddress.street, input.legalAddress.street2].filter(\n (s): s is string => typeof s === 'string' && s.trim().length > 0\n );\n }\n \n // Remove any empty strings and ensure all elements are strings\n streetArray = streetArray.filter(street => street && typeof street === 'string' && street.trim().length > 0);\n \n // Handle region - different approaches for dropdown vs custom regions\n let regionValue: { region: string; region_code: string; region_id?: number } | undefined;\n if (input.legalAddress.region && typeof input.legalAddress.region === 'object') {\n const regionObj = input.legalAddress.region;\n \n // Check if this is a custom region (region === regionCode) or predefined region\n if (regionObj.region === regionObj.regionCode) {\n // Custom region - send as object with region_id: 0\n regionValue = {\n region: regionObj.region,\n region_code: regionObj.regionCode,\n region_id: 0\n };\n } else {\n // Predefined region - send as object\n regionValue = {\n region: regionObj.region,\n region_code: regionObj.regionCode,\n };\n }\n } else if (input.legalAddress.regionCode && input.legalAddress.region !== input.legalAddress.regionCode) {\n // If we have different region and regionCode (dropdown case)\n regionValue = {\n region: input.legalAddress.region || input.legalAddress.regionCode,\n region_code: input.legalAddress.regionCode,\n };\n } else if (input.legalAddress.region) {\n // If we only have region string (fallback case)\n regionValue = {\n region: input.legalAddress.region,\n region_code: input.legalAddress.region,\n region_id: 0\n };\n }\n \n transformedInput.legal_address = {\n street: streetArray,\n city: input.legalAddress.city,\n region: regionValue,\n country_id: input.legalAddress.countryCode, // GraphQL expects country_id, not countryCode\n postcode: input.legalAddress.postcode,\n telephone: input.legalAddress.telephone,\n };\n }\n\n // Execute the dynamic mutation\n const response: updateCompanyResponse = await fetchGraphQl(UPDATE_COMPANY_DYNAMIC, {\n method: 'POST',\n variables: { input: transformedInput },\n });\n\n if (response.errors?.length) return handleFetchError(response.errors);\n\n // Merge back minimal customer role info so transform can compute flags\n (response as any).data.customer = roleResponse?.data?.customer;\n\n return transformCompany(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 *******************************************************************/\nexport const GET_COUNTRIES_QUERY = `\n query getCountries {\n countries {\n id\n two_letter_abbreviation\n three_letter_abbreviation\n full_name_locale\n full_name_english\n available_regions {\n id\n code\n name\n }\n }\n storeConfig {\n countries_with_required_region\n optional_zip_countries\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 { GET_COUNTRIES_QUERY } from './graphql/getCountries.graphql';\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { transformCountries } from '../../data/transforms/transform-countries';\nimport { CountriesFormResponse } from '../../types/api/getCountries.types';\nimport { Country } from '../../data/models/country';\n\nexport const getCountries = async (): Promise<{\n availableCountries: Country[] | [];\n countriesWithRequiredRegion: string[];\n optionalZipCountries: string[];\n}> => {\n const sessionStorageKey = '_company_countries';\n\n const sessionStorageCache = sessionStorage.getItem(sessionStorageKey);\n\n if (sessionStorageCache) {\n return JSON.parse(sessionStorageCache);\n }\n\n return await fetchGraphQl(GET_COUNTRIES_QUERY, {\n method: 'GET',\n })\n .then((response: CountriesFormResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n const transformedData = transformCountries(response);\n\n sessionStorage.setItem(\n sessionStorageKey,\n JSON.stringify(transformedData)\n );\n\n return transformedData;\n })\n .catch(handleNetworkError);\n};\n"],"names":["GET_CUSTOMER_ROLE_PERMISSIONS","flattenIds","nodes","set","stack","node","child","isCompanyAdministrator","role","buildPermissionFlags","allowedIds","isAdmin","fetchUserPermissions","fetchGraphQl","roleResponse","_a","handleFetchError","_c","_b","id","handleNetworkError","transformCompany","response","companyData","customerData","legalAddress","line","customerRole","permissionsFlags","model","m","transformCountries","countries","storeConfig","countriesWithRequiredRegion","optionalZipCountries","two_letter_abbreviation","full_name_locale","country","available_regions","hasRegions","a","b","COMPANY_LEGAL_ADDRESS_FRAGMENT","COMPANY_BASIC_INFO_FRAGMENT","COMPANY_SALES_REPRESENTATIVE_FRAGMENT","COMPANY_ADMIN_FRAGMENT","buildCompanyFields","allowed","wantProfile","wantAddress","wantContacts","wantPayment","wantShipping","fields","usedFragments","buildCompanyQuery","buildUpdateCompanyMutation","getCompany","GET_COMPANY_DYNAMIC","companyResponse","companyNode","k","updateCompany","input","UPDATE_COMPANY_DYNAMIC","transformedInput","streetArray","s","street","regionValue","regionObj","GET_COUNTRIES_QUERY","getCountries","sessionStorageKey","sessionStorageCache","transformedData"],"mappings":"4DAgBa,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,ECkB9CC,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,EAKaI,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,EAAaT,GAAWO,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,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 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{v as l,f as m,h as y,c as i}from"./validateCompanyEmail.js";const h=async()=>{try{return await l("test@test.com"),{companyEnabled:!0}}catch{return{companyEnabled:!1,error:"Company functionality not available"}}},u=t=>{var r,e,c;const a=(r=t==null?void 0:t.data)==null?void 0:r.customer,n=(e=t==null?void 0:t.data)==null?void 0:e.company;if(!a||!n)return null;const o={companyName:(n==null?void 0:n.name)??"",jobTitle:(a==null?void 0:a.job_title)??"",workPhoneNumber:(a==null?void 0:a.telephone)??"",userRole:((c=a==null?void 0:a.role)==null?void 0:c.name)??""};return o.companyName?o:null},d=`
|
|
4
|
+
query GET_CUSTOMER_COMPANY_INFO {
|
|
5
|
+
customer {
|
|
6
|
+
id
|
|
7
|
+
job_title
|
|
8
|
+
telephone
|
|
9
|
+
role {
|
|
10
|
+
id
|
|
11
|
+
name
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
company {
|
|
15
|
+
id
|
|
16
|
+
name
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`,C=async()=>{var t;try{if(!(await h()).companyEnabled)return null;const n=await m(d,{method:"GET",cache:"no-cache"});return(t=n.errors)!=null&&t.length?y(n.errors):u(n)}catch(a){return console.error("Failed to fetch customer company info:",a),i(a)}};export{h as c,C as g};
|
|
20
|
+
//# sourceMappingURL=getCustomerCompany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCustomerCompany.js","sources":["/@dropins/storefront-company-management/src/api/checkIsCompanyEnabled/checkIsCompanyEnabled.ts","/@dropins/storefront-company-management/src/data/transforms/transform-customer-company-info.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 { validateCompanyEmail } from '../validateCompanyEmail';\nimport { CheckIsCompanyEnabledResponse } from '../../types/api/checkIsCompanyEnabled.types';\n\nexport const checkIsCompanyEnabled = async (): Promise<CheckIsCompanyEnabledResponse> => {\n try {\n // Use validateCompanyEmail with a dummy email to check if Company functionality is available\n await validateCompanyEmail('test@test.com');\n \n // If the validation API works (regardless of email availability), Company functionality is enabled\n return {\n companyEnabled: true\n };\n } catch (error) {\n return {\n companyEnabled: false,\n error: 'Company functionality not available'\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 { 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_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 { checkIsCompanyEnabled } from '../checkIsCompanyEnabled';\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 companyCheck = await checkIsCompanyEnabled();\n if (!companyCheck.companyEnabled) {\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":["checkIsCompanyEnabled","validateCompanyEmail","transformCustomerCompanyInfo","response","customer","_a","company","_b","companyInfo","_c","GET_CUSTOMER_COMPANY_INFO","getCustomerCompany","fetchGraphQl","handleFetchError","error","handleNetworkError"],"mappings":"mEAmBO,MAAMA,EAAwB,SAAoD,CACnF,GAAA,CAEF,aAAMC,EAAqB,eAAe,EAGnC,CACL,eAAgB,EAClB,OACc,CACP,MAAA,CACL,eAAgB,GAChB,MAAO,qCACT,CAAA,CAEJ,ECVaC,EAAgCC,GAAyE,WAC9G,MAAAC,GAAWC,EAAAF,GAAA,YAAAA,EAAU,OAAV,YAAAE,EAAgB,SAC3BC,GAAUC,EAAAJ,GAAA,YAAAA,EAAU,OAAV,YAAAI,EAAgB,QAE5B,GAAA,CAACH,GAAY,CAACE,EACT,OAAA,KAGT,MAAME,EAAmC,CACvC,aAAaF,GAAA,YAAAA,EAAS,OAAQ,GAC9B,UAAUF,GAAA,YAAAA,EAAU,YAAa,GACjC,iBAAiBA,GAAA,YAAAA,EAAU,YAAa,GACxC,WAAUK,EAAAL,GAAA,YAAAA,EAAU,OAAV,YAAAK,EAAgB,OAAQ,EACpC,EAGO,OAAAD,EAAY,YAAcA,EAAc,IACjD,ECxBaE,EAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECa5BC,EAAqB,SAAiD,OAC7E,GAAA,CAGE,GAAA,EADiB,MAAMX,EAAsB,GAC/B,eACT,OAAA,KAIH,MAAAG,EAA2C,MAAMS,EAAaF,EAA2B,CAC7F,OAAQ,MACR,MAAO,UAAA,CACR,EAEG,OAAAL,EAAAF,EAAS,SAAT,MAAAE,EAAiB,OACZQ,EAAiBV,EAAS,MAAM,EAIlCD,EAA6BC,CAAQ,QAErCW,EAAO,CACN,eAAA,MAAM,yCAA0CA,CAAK,EACtDC,EAAmBD,CAAc,CAAA,CAE5C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{events as i}from"@dropins/tools/event-bus.js";import{FetchGraphQL as t}from"@dropins/tools/fetch-graphql.js";const{setEndpoint:m,setFetchGraphQlHeader:c,removeFetchGraphQlHeader:h,setFetchGraphQlHeaders:p,fetchGraphQl:s,getConfig:d}=new t().getMethods(),E=a=>{throw a instanceof DOMException&&a.name==="AbortError"||i.emit("error",{source:"company",type:"network",error:a}),a},v=a=>{const e=a.map(r=>r.message).join(" ");throw Error(e)},o=`
|
|
4
|
+
query validateCompanyEmail($email: String!) {
|
|
5
|
+
isCompanyEmailAvailable(email: $email) {
|
|
6
|
+
is_email_available
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
`,b=async a=>{try{const e=await s(o,{variables:{email:a}});return e.errors?{isValid:!1,error:"Unable to validate email"}:{isValid:e.data.isCompanyEmailAvailable.is_email_available,error:e.data.isCompanyEmailAvailable.is_email_available?void 0:"This email is already used by another company"}}catch{return{isValid:!1,error:"Unable to validate email"}}};export{c as a,p as b,E as c,s as f,d as g,v as h,h as r,m as s,b as v};
|
|
10
|
+
//# sourceMappingURL=validateCompanyEmail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateCompanyEmail.js","sources":["/@dropins/storefront-company-management/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-company-management/src/lib/network-error.ts","/@dropins/storefront-company-management/src/lib/fetch-error.ts","/@dropins/storefront-company-management/src/api/validateCompanyEmail/graphql/validateCompanyEmail.graphql.ts","/@dropins/storefront-company-management/src/api/validateCompanyEmail/validateCompanyEmail.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 '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\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 { 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","/********************************************************************\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 VALIDATE_COMPANY_EMAIL_QUERY = /* GraphQL */ `\n query validateCompanyEmail($email: String!) {\n isCompanyEmailAvailable(email: $email) {\n is_email_available\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 { fetchGraphQl } from '../fetch-graphql';\nimport { VALIDATE_COMPANY_EMAIL_QUERY } from './graphql/validateCompanyEmail.graphql';\nimport { ValidateCompanyEmailQuery, ValidateCompanyEmailResponse } from '../../types/api/validateCompanyEmail.types';\n\nexport const validateCompanyEmail = async (email: string): Promise<ValidateCompanyEmailResponse> => {\n try {\n const response = await fetchGraphQl<ValidateCompanyEmailQuery>(VALIDATE_COMPANY_EMAIL_QUERY, {\n variables: { email },\n });\n\n if (response.errors) {\n return {\n isValid: false,\n error: 'Unable to validate email'\n };\n }\n\n return {\n isValid: response.data.isCompanyEmailAvailable.is_email_available,\n error: response.data.isCompanyEmailAvailable.is_email_available \n ? undefined \n : 'This email is already used by another company'\n };\n } catch (error) {\n return {\n isValid: false,\n error: 'Unable to validate email'\n };\n }\n};"],"names":["setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","handleNetworkError","error","events","handleFetchError","errors","errorMessage","e","VALIDATE_COMPANY_EMAIL_QUERY","validateCompanyEmail","email","response"],"mappings":"oHAmBa,KAAA,CACX,YAAAA,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAC,EACA,UAAAC,CACF,EAAI,IAAIC,EAAa,EAAE,WAAW,ECJrBC,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,ECLaE,EAA6C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECI7CC,EAAuB,MAAOC,GAAyD,CAC9F,GAAA,CACI,MAAAC,EAAW,MAAMb,EAAwCU,EAA8B,CAC3F,UAAW,CAAE,MAAAE,CAAM,CAAA,CACpB,EAED,OAAIC,EAAS,OACJ,CACL,QAAS,GACT,MAAO,0BACT,EAGK,CACL,QAASA,EAAS,KAAK,wBAAwB,mBAC/C,MAAOA,EAAS,KAAK,wBAAwB,mBACzC,OACA,+CACN,OACc,CACP,MAAA,CACL,QAAS,GACT,MAAO,0BACT,CAAA,CAEJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FunctionComponent } from 'preact';
|
|
2
|
+
import { CustomerCompanyInfoCardProps } from '../../types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Component for displaying customer company information in a card format
|
|
6
|
+
* Shows company name, job title, and work phone number with loading states
|
|
7
|
+
*/
|
|
8
|
+
export declare const CustomerCompanyInfoCard: FunctionComponent<CustomerCompanyInfoCardProps>;
|
|
9
|
+
//# sourceMappingURL=CustomerCompanyInfoCard.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export { CustomerCompanyInfoCard } from './CustomerCompanyInfoCard';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -11,8 +11,7 @@ interface CompanyAccountFieldsProps {
|
|
|
11
11
|
};
|
|
12
12
|
errors: Record<string, string>;
|
|
13
13
|
touched: Record<string, boolean>;
|
|
14
|
-
|
|
15
|
-
onBlur: (field: string) => void;
|
|
14
|
+
onBlur: (field: string, value?: string) => void;
|
|
16
15
|
/** Optional input name prefix for DOM names (defaults to none) */
|
|
17
16
|
namePrefix?: string;
|
|
18
17
|
/** Optional field path prefix used for change/blur handlers (defaults to none) */
|
|
@@ -16,7 +16,7 @@ interface LegalAddressFieldsProps {
|
|
|
16
16
|
errors: Record<string, string>;
|
|
17
17
|
touched: Record<string, boolean>;
|
|
18
18
|
onChange: (field: string) => (value: string) => void;
|
|
19
|
-
onBlur: (field: string) => void;
|
|
19
|
+
onBlur: (field: string, value?: string) => void;
|
|
20
20
|
countryOptions: {
|
|
21
21
|
text: string;
|
|
22
22
|
value: string;
|