@dropins/storefront-company-management 1.0.0-alpha1002 → 1.0.0-alpha2001
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/checkIsCompanyEnabled/checkIsCompanyEnabled.d.ts +4 -0
- package/api/{isCompanyUser → checkIsCompanyEnabled}/index.d.ts +1 -1
- package/api/deleteCompanyUser/deleteCompanyUser.d.ts +10 -0
- package/api/{companyEnabled/companyEnabled.d.ts → deleteCompanyUser/graphql/deleteCompanyUser.graphql.d.ts} +2 -2
- package/api/{companyEnabled → deleteCompanyUser}/index.d.ts +1 -1
- package/api/getCompanyUsers/getCompanyUsers.d.ts +12 -0
- package/api/getCompanyUsers/graphql/companyUsers.graphql.d.ts +18 -0
- package/api/{createCompany → getCompanyUsers}/index.d.ts +1 -1
- package/api/getCustomerCompany/getCustomerCompany.d.ts +9 -0
- package/api/getCustomerCompany/graphql/getCustomerCompanyInfo.graphql.d.ts +18 -0
- package/api/{allowCompanyRegistration → getCustomerCompany}/index.d.ts +1 -1
- package/api/index.d.ts +5 -6
- package/api/updateCompanyUserStatus/graphql/updateCompanyUserStatus.graphql.d.ts +18 -0
- package/api/{isCompanyAdmin → updateCompanyUserStatus}/index.d.ts +1 -1
- package/api/updateCompanyUserStatus/updateCompanyUserStatus.d.ts +11 -0
- package/api.js +1 -22
- package/api.js.map +1 -1
- package/chunks/fetch-error.js +4 -0
- package/chunks/fetch-error.js.map +1 -0
- package/chunks/fetchUserPermissions.js +27 -0
- package/chunks/fetchUserPermissions.js.map +1 -0
- package/chunks/getCompanyUsers.js +45 -0
- package/chunks/getCompanyUsers.js.map +1 -0
- package/chunks/getCountries.js +65 -6
- package/chunks/getCountries.js.map +1 -1
- package/chunks/getCustomerCompany.js +20 -0
- package/chunks/getCustomerCompany.js.map +1 -0
- package/chunks/useCompanyContextListener.js +4 -0
- package/chunks/useCompanyContextListener.js.map +1 -0
- package/chunks/useInLineAlert.js +4 -0
- package/chunks/useInLineAlert.js.map +1 -0
- package/chunks/validateCompanyEmail.js +10 -0
- package/chunks/validateCompanyEmail.js.map +1 -0
- package/components/CompanyLoaders/CompanyLoaders.d.ts +3 -0
- package/components/CompanyUsersManagementModal/CompanyUsersManagementModal.d.ts +16 -0
- package/components/CompanyUsersManagementModal/index.d.ts +19 -0
- package/components/CustomerCompanyInfoCard/CustomerCompanyInfoCard.d.ts +9 -0
- package/components/CustomerCompanyInfoCard/index.d.ts +18 -0
- package/components/index.d.ts +2 -3
- package/containers/CompanyProfile.js +1 -1
- package/containers/CompanyProfile.js.map +1 -1
- package/containers/CompanyUsers/CompanyUsers.d.ts +7 -0
- package/containers/CompanyUsers/hooks/index.d.ts +19 -0
- package/containers/CompanyUsers/hooks/useCompanyContextListener.d.ts +62 -0
- package/containers/CompanyUsers/hooks.d.ts +1 -0
- package/containers/CompanyUsers/hooks.js +4 -0
- package/containers/CompanyUsers/hooks.js.map +1 -0
- package/containers/CompanyUsers/index.d.ts +19 -0
- package/containers/CompanyUsers.d.ts +3 -0
- package/containers/CompanyUsers.js +4 -0
- package/containers/CompanyUsers.js.map +1 -0
- package/containers/CustomerCompanyInfo/CustomerCompanyInfo.d.ts +9 -0
- package/{api/getStoreConfig → containers/CustomerCompanyInfo}/index.d.ts +2 -1
- 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 +2 -2
- package/data/models/company.d.ts +0 -52
- package/{api/companyEnabled/graphql/companyEnabled.graphql.d.ts → data/models/customer-company-info.d.ts} +7 -2
- package/data/models/index.d.ts +1 -0
- package/data/transforms/index.d.ts +1 -1
- package/data/transforms/transform-company.d.ts +1 -5
- package/data/transforms/transform-customer-company-info.d.ts +10 -0
- package/hooks/containers/index.d.ts +2 -0
- package/hooks/containers/useCompanyUsers.d.ts +33 -0
- package/hooks/containers/useCustomerCompanyInfo.d.ts +12 -0
- package/i18n/en_US.json.d.ts +74 -32
- package/lib/encoding.d.ts +43 -0
- package/lib/index.d.ts +2 -0
- package/lib/userHelpers.d.ts +47 -0
- package/package.json +1 -1
- package/render.js +5 -4
- package/render.js.map +1 -1
- package/{api/allowCompanyRegistration/allowCompanyRegistration.d.ts → types/api/checkIsCompanyEnabled.types.d.ts} +5 -2
- package/types/api/companyUsers.types.d.ts +70 -0
- package/{api/allowCompanyRegistration/graphql/allowCompanyRegistration.graphql.d.ts → types/api/deleteCompanyUser.types.d.ts} +12 -2
- package/types/api/{getStoreConfig.types.d.ts → getCustomerCompanyInfo.types.d.ts} +21 -14
- package/types/api/index.d.ts +26 -0
- package/types/api/updateCompanyUserStatus.types.d.ts +22 -0
- package/types/customerCompanyInfo.types.d.ts +11 -0
- package/types/index.d.ts +3 -7
- package/api/createCompany/createCompany.d.ts +0 -39
- package/api/createCompany/graphql/createCompany.graphql.d.ts +0 -18
- package/api/getStoreConfig/getStoreConfig.d.ts +0 -6
- package/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts +0 -18
- package/api/isCompanyAdmin/graphql/isCompanyAdmin.graphql.d.ts +0 -18
- package/api/isCompanyAdmin/isCompanyAdmin.d.ts +0 -22
- package/api/isCompanyUser/graphql/isCompanyUser.graphql.d.ts +0 -18
- package/api/isCompanyUser/isCompanyUser.d.ts +0 -22
- package/chunks/fetch-graphql.js +0 -4
- package/chunks/fetch-graphql.js.map +0 -1
- package/chunks/getStoreConfig.js +0 -44
- package/chunks/getStoreConfig.js.map +0 -1
- package/chunks/isCompanyUser.js +0 -21
- package/chunks/isCompanyUser.js.map +0 -1
- package/chunks/updateCompany.js +0 -92
- package/chunks/updateCompany.js.map +0 -1
- package/components/CompanyRegistrationForm/CompanyRegistrationForm.d.ts +0 -13
- package/components/CompanyRegistrationForm/Form/Form.d.ts +0 -5
- package/components/CompanyRegistrationForm/Form/FormInputs/FormInputs.d.ts +0 -5
- package/components/CompanyRegistrationForm/Form/FormInputs/index.d.ts +0 -18
- package/components/CompanyRegistrationForm/Form/fieldHandlers.d.ts +0 -26
- package/components/CompanyRegistrationForm/Form/fieldValidationRules.d.ts +0 -60
- package/components/CompanyRegistrationForm/Form/formValidation.d.ts +0 -17
- package/components/CompanyRegistrationForm/Form/getCompanyFieldsConfig.d.ts +0 -13
- package/components/CompanyRegistrationForm/Form/index.d.ts +0 -18
- package/components/CompanyRegistrationForm/index.d.ts +0 -20
- package/components/CompanyRegistrationSuccess/CompanyRegistrationSuccess.d.ts +0 -8
- package/components/CompanyRegistrationSuccess/index.d.ts +0 -18
- package/components/CompanyStructureEmpty/CompanyStructureEmpty.d.ts +0 -9
- package/components/CompanyStructureEmpty/index.d.ts +0 -19
- package/containers/CompanyRegistration/CompanyRegistration.d.ts +0 -15
- package/containers/CompanyRegistration/index.d.ts +0 -19
- package/containers/CompanyRegistration.d.ts +0 -3
- package/containers/CompanyRegistration.js +0 -4
- package/containers/CompanyRegistration.js.map +0 -1
- package/containers/CompanyStructure/CompanyStructure.d.ts +0 -10
- package/containers/CompanyStructure/index.d.ts +0 -19
- package/containers/CompanyStructure.d.ts +0 -3
- package/containers/CompanyStructure.js +0 -4
- package/containers/CompanyStructure.js.map +0 -1
- package/data/transforms/company.d.ts +0 -5
- package/data/transforms/transform-store-config.d.ts +0 -4
- package/hooks/useCompanyRegistrationForm.d.ts +0 -37
- package/hooks/useCountryAndRegionFields.d.ts +0 -20
- package/types/form.types.d.ts +0 -93
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
-
export * from './
|
|
17
|
+
export * from './checkIsCompanyEnabled';
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DeleteCompanyUserParams, DeleteCompanyUserResponse } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Deletes a company user by their ID
|
|
5
|
+
* @param params - The parameters containing user ID
|
|
6
|
+
* @param params.id - The ID of the user to delete (will be base64 encoded)
|
|
7
|
+
* @returns Promise<DeleteCompanyUserResponse> - Object containing success status
|
|
8
|
+
*/
|
|
9
|
+
export declare const deleteCompanyUser: (params: DeleteCompanyUserParams) => Promise<DeleteCompanyUserResponse>;
|
|
10
|
+
//# sourceMappingURL=deleteCompanyUser.d.ts.map
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
-
export declare const
|
|
18
|
-
//# sourceMappingURL=
|
|
17
|
+
export declare const DELETE_COMPANY_USER_MUTATION = "\n mutation DELETE_COMPANY_USER($id: ID!) {\n deleteCompanyUserV2(id: $id) {\n success\n }\n }\n";
|
|
18
|
+
//# sourceMappingURL=deleteCompanyUser.graphql.d.ts.map
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
-
export * from './
|
|
17
|
+
export * from './deleteCompanyUser';
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CompanyUsersParams, CompanyUsersResponse } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Fetches the list of company users with pagination and optional filtering
|
|
5
|
+
* @param params - Query parameters
|
|
6
|
+
* @param params.pageSize - Number of items per page (default: 20)
|
|
7
|
+
* @param params.currentPage - Current page number (default: 1)
|
|
8
|
+
* @param params.filter - Optional filter to apply (e.g., { status: 'ACTIVE' })
|
|
9
|
+
* @returns Promise<CompanyUsersResponse> - Object containing array of company users and pagination info
|
|
10
|
+
*/
|
|
11
|
+
export declare const getCompanyUsers: (params?: CompanyUsersParams) => Promise<CompanyUsersResponse>;
|
|
12
|
+
//# sourceMappingURL=getCompanyUsers.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export declare const COMPANY_USERS_QUERY = "\n query COMPANY_USERS($pageSize: Int!, $currentPage: Int!, $filter: CompanyUsersFilterInput) {\n company {\n users(pageSize: $pageSize, currentPage: $currentPage, filter: $filter) {\n items {\n id\n firstname\n lastname\n email\n role {\n name\n }\n status\n team {\n name\n }\n }\n page_info {\n page_size\n current_page\n total_pages\n }\n total_count\n }\n }\n }\n";
|
|
18
|
+
//# sourceMappingURL=companyUsers.graphql.d.ts.map
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
-
export * from './
|
|
17
|
+
export * from './getCompanyUsers';
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
-
export
|
|
17
|
+
export { getCustomerCompany } from './getCustomerCompany';
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
package/api/index.d.ts
CHANGED
|
@@ -17,14 +17,13 @@
|
|
|
17
17
|
export * from './initialize';
|
|
18
18
|
export * from './fetch-graphql';
|
|
19
19
|
export * from './fetchUserPermissions';
|
|
20
|
+
export * from './checkIsCompanyEnabled';
|
|
21
|
+
export * from './deleteCompanyUser';
|
|
20
22
|
export * from './getCompany';
|
|
21
23
|
export * from './updateCompany';
|
|
24
|
+
export * from './updateCompanyUserStatus';
|
|
22
25
|
export * from './getCountries';
|
|
23
|
-
export * from './getStoreConfig';
|
|
24
26
|
export * from './validateCompanyEmail';
|
|
25
|
-
export * from './
|
|
26
|
-
export * from './
|
|
27
|
-
export * from './createCompany';
|
|
28
|
-
export * from './isCompanyUser';
|
|
29
|
-
export * from './isCompanyAdmin';
|
|
27
|
+
export * from './getCustomerCompany';
|
|
28
|
+
export * from './getCompanyUsers';
|
|
30
29
|
//# sourceMappingURL=index.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 UPDATE_COMPANY_USER_STATUS_MUTATION = "\n mutation UPDATE_COMPANY_USER_STATUS($input: CompanyUserUpdateInput!) {\n updateCompanyUser(input: $input) {\n user {\n id\n status\n }\n }\n }\n";
|
|
18
|
+
//# sourceMappingURL=updateCompanyUserStatus.graphql.d.ts.map
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
-
export * from './
|
|
17
|
+
export * from './updateCompanyUserStatus';
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UpdateCompanyUserStatusParams, UpdateCompanyUserStatusResponse } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Updates a company user's status (Active/Inactive)
|
|
5
|
+
* @param params - The parameters containing user ID and new status
|
|
6
|
+
* @param params.id - The ID of the user to update (will be base64 encoded)
|
|
7
|
+
* @param params.status - The new status for the user (ACTIVE or INACTIVE)
|
|
8
|
+
* @returns Promise<UpdateCompanyUserStatusResponse> - Object containing success status and updated user data
|
|
9
|
+
*/
|
|
10
|
+
export declare const updateCompanyUserStatus: (params: UpdateCompanyUserStatusParams) => Promise<UpdateCompanyUserStatusResponse>;
|
|
11
|
+
//# sourceMappingURL=updateCompanyUserStatus.d.ts.map
|
package/api.js
CHANGED
|
@@ -1,25 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{f as
|
|
4
|
-
query GET_COMPANY_ENABLED {
|
|
5
|
-
storeConfig {
|
|
6
|
-
company_enabled
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
`,u=async()=>{var t,r,o;const e=await i(m,{method:"POST"});if((t=e==null?void 0:e.errors)!=null&&t.length)throw new Error(((r=e.errors[0])==null?void 0:r.message)||"Failed to load store configuration");const a=(o=e==null?void 0:e.data)==null?void 0:o.storeConfig;if(!a)throw new Error("Invalid response: missing storeConfig");return!!a.company_enabled},c=`
|
|
10
|
-
query GET_CUSTOMER_COMPANIES_WITH_ROLES {
|
|
11
|
-
customer {
|
|
12
|
-
companies(input: {}) {
|
|
13
|
-
items {
|
|
14
|
-
id
|
|
15
|
-
name
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
role {
|
|
19
|
-
id
|
|
20
|
-
name
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`,E=async()=>{var e,a,t;try{const r=await i(c,{method:"POST"});if((e=r.errors)!=null&&e.length)return!1;const o=(a=r.data)==null?void 0:a.customer;if(!o)return!1;const n=((t=o.companies)==null?void 0:t.items)??[];if(!Array.isArray(n)||n.length===0)return!1;const s=o.role;return s?s.id==="0"||typeof s.id=="number"&&s.id===0||s.name==="Company Administrator":!1}catch(r){return console.error("Error checking if customer is company admin:",r),!1}};export{U as DEFAULT_COUNTRY,x as STORE_CONFIG_DEFAULTS,b as allowCompanyRegistration,u as companyEnabled,I as createCompany,i as fetchGraphQl,S as fetchUserPermissions,G as getCompany,y as getConfig,w as getCountries,L as getStoreConfig,d as initialize,E as isCompanyAdmin,D as isCompanyUser,h as removeFetchGraphQlHeader,_ as setEndpoint,T as setFetchGraphQlHeader,O as setFetchGraphQlHeaders,N as updateCompany,F as validateCompanyEmail};
|
|
3
|
+
import{f as p,g as m,r as n,s as i,a as c,b as f}from"./chunks/fetch-error.js";import{f as d}from"./chunks/fetchUserPermissions.js";import{c as h,g as u}from"./chunks/getCustomerCompany.js";import{d as y,g as x,u as G}from"./chunks/getCompanyUsers.js";import{g as U,a as v,u as E}from"./chunks/getCountries.js";import{v as H}from"./chunks/validateCompanyEmail.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/event-bus.js";const t=async(e={})=>({success:!0,config:e});export{h as checkIsCompanyEnabled,y as deleteCompanyUser,p as fetchGraphQl,d as fetchUserPermissions,U as getCompany,x as getCompanyUsers,m as getConfig,v as getCountries,u as getCustomerCompany,t as initialize,n as removeFetchGraphQlHeader,i as setEndpoint,c as setFetchGraphQlHeader,f as setFetchGraphQlHeaders,E as updateCompany,G as updateCompanyUserStatus,H as validateCompanyEmail};
|
|
25
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":"wbAyBO,MAAMA,EAAa,MAAOC,EAA8B,MACtD,CACL,QAAS,GACT,OAAAA,CACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{FetchGraphQL as o}from"@dropins/tools/fetch-graphql.js";import{events as s}from"@dropins/tools/event-bus.js";const{setEndpoint:h,setFetchGraphQlHeader:c,removeFetchGraphQlHeader:p,setFetchGraphQlHeaders:i,fetchGraphQl:m,getConfig:E}=new o().getMethods(),d=r=>{throw r instanceof DOMException&&r.name==="AbortError"||s.emit("error",{source:"company",type:"network",error:r}),r},f=r=>{const e=r.map(t=>t.message).join(" ");throw Error(e)};export{c as a,i as b,d as c,m as f,E as g,f as h,p as r,h as s};
|
|
4
|
+
//# sourceMappingURL=fetch-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-error.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"],"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"],"names":["setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","handleNetworkError","error","events","handleFetchError","errors","errorMessage","e"],"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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{f as r,h,c as _}from"./fetch-error.js";const p=`
|
|
4
|
+
query GET_CUSTOMER_ROLE_PERMISSIONS {
|
|
5
|
+
customer {
|
|
6
|
+
role {
|
|
7
|
+
id
|
|
8
|
+
name
|
|
9
|
+
permissions {
|
|
10
|
+
id
|
|
11
|
+
children {
|
|
12
|
+
id
|
|
13
|
+
children {
|
|
14
|
+
id
|
|
15
|
+
children {
|
|
16
|
+
id
|
|
17
|
+
children { id }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
status
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`,d=(n=[])=>{const a=new Set,t=[...n];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 s of i.children)t.push(s)}return a},e=n=>(n==null?void 0:n.id)==="0"||typeof(n==null?void 0:n.id)=="number"&&(n==null?void 0:n.id)===0||(n==null?void 0:n.name)==="Company Administrator",g=n=>{const a=d((n==null?void 0:n.permissions)||[]),t=e(n);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")}},f=async()=>await r(p,{method:"GET",cache:"no-cache"}).then(n=>{var s,c,o;if((s=n.errors)!=null&&s.length)return h(n.errors);const a=(o=(c=n==null?void 0:n.data)==null?void 0:c.customer)==null?void 0:o.role,t=d((a==null?void 0:a.permissions)||[]);return e(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","Magento_Company::users_view","Magento_Company::users_edit"].forEach(m=>t.add(m)),{allowedIds:t,roleResponse:n}}).catch(_);export{g as b,f};
|
|
27
|
+
//# sourceMappingURL=fetchUserPermissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchUserPermissions.js","sources":["/@dropins/storefront-company-management/src/api/fetchUserPermissions/graphql/getCustomerRole.graphql.ts","/@dropins/storefront-company-management/src/lib/company-permissions.ts","/@dropins/storefront-company-management/src/api/fetchUserPermissions/fetchUserPermissions.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nexport const GET_CUSTOMER_ROLE_PERMISSIONS = /* GraphQL */ `\n query GET_CUSTOMER_ROLE_PERMISSIONS {\n customer {\n role {\n id\n name\n permissions {\n id\n children {\n id\n children {\n id\n children {\n id\n children { id }\n }\n }\n }\n }\n }\n status\n }\n }\n`;\n\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\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 'Magento_Company::users_view',\n 'Magento_Company::users_edit',\n ].forEach((id) => allowedIds.add(id));\n }\n\n return { allowedIds, roleResponse };\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"],"mappings":"8CAgBa,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,eAAgBC,GAAWD,EAAW,IAAI,+BAA+B,EACzE,eAAgBC,GAAWD,EAAW,IAAI,+BAA+B,EACzE,gBAAiBC,GAAWD,EAAW,IAAI,2BAA2B,EACtE,0BAA2BC,GAAWD,EAAW,IAAI,sCAAsC,EAC3F,2BAA4BC,GAAWD,EAAW,IAAI,uCAAuC,CAC/F,CACF,EC/CaE,EAAuB,SAC3B,MAAMC,EAAab,EAA+B,CACvD,OAAQ,MACR,MAAO,UAAA,CACR,EACE,KAAMc,GAAsB,WACvB,IAAAC,EAAAD,EAAa,SAAb,MAAAC,EAAqB,OAChB,OAAAC,EAAiBF,EAAa,MAAM,EAGvC,MAAAN,GAAOS,GAAAC,EAAAJ,GAAA,YAAAA,EAAc,OAAd,YAAAI,EAAoB,WAApB,YAAAD,EAA8B,KACrCP,EAAaT,GAAWO,GAAA,YAAAA,EAAM,cAAe,CAAA,CAAE,EAIrD,OADgBD,EAAuBC,CAAI,GAEzC,CACE,gCACA,gCACA,gCACA,gCACA,4BACA,uCACA,wCACA,8BACA,6BAAA,EACA,QAASW,GAAOT,EAAW,IAAIS,CAAE,CAAC,EAG/B,CAAE,WAAAT,EAAY,aAAAI,CAAa,CAAA,CACnC,EACA,MAAMM,CAAkB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{f as p,c as d,h as m}from"./fetch-error.js";const f=e=>{try{return btoa(e)}catch(t){throw new Error(`Failed to encode base64: ${t}`)}},g=e=>{try{return atob(e)}catch{return e}},l=e=>{if(!e||typeof e!="string")throw new Error("User ID must be a non-empty string");return f(e)},y=e=>!e||typeof e!="string"?e:g(e),h=`
|
|
4
|
+
mutation DELETE_COMPANY_USER($id: ID!) {
|
|
5
|
+
deleteCompanyUserV2(id: $id) {
|
|
6
|
+
success
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
`,S=async e=>{var r,u;const{id:t}=e;if(!t)throw new Error("User ID is required to delete a company user");try{const n=l(t),a=await p(h,{method:"POST",cache:"no-cache",variables:{id:n}}).catch(d);return(r=a.errors)!=null&&r.length&&m(a.errors),(u=a.data)!=null&&u.deleteCompanyUserV2?{success:a.data.deleteCompanyUserV2.success}:{success:!1}}catch{return{success:!1}}},U=`
|
|
10
|
+
mutation UPDATE_COMPANY_USER_STATUS($input: CompanyUserUpdateInput!) {
|
|
11
|
+
updateCompanyUser(input: $input) {
|
|
12
|
+
user {
|
|
13
|
+
id
|
|
14
|
+
status
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`,T=async e=>{var u,n,a;const{id:t,status:r}=e;if(!t)throw new Error("User ID is required to update company user status");if(!r||r!=="ACTIVE"&&r!=="INACTIVE")throw new Error("Valid status (ACTIVE or INACTIVE) is required to update company user status");try{const i=l(t),o=await p(U,{method:"POST",cache:"no-cache",variables:{input:{id:i,status:r}}}).catch(d);return(u=o.errors)!=null&&u.length&&m(o.errors),(a=(n=o.data)==null?void 0:n.updateCompanyUser)!=null&&a.user?{success:!0,user:{id:o.data.updateCompanyUser.user.id,status:o.data.updateCompanyUser.user.status}}:{success:!1}}catch{return{success:!1}}},E=`
|
|
19
|
+
query COMPANY_USERS($pageSize: Int!, $currentPage: Int!, $filter: CompanyUsersFilterInput) {
|
|
20
|
+
company {
|
|
21
|
+
users(pageSize: $pageSize, currentPage: $currentPage, filter: $filter) {
|
|
22
|
+
items {
|
|
23
|
+
id
|
|
24
|
+
firstname
|
|
25
|
+
lastname
|
|
26
|
+
email
|
|
27
|
+
role {
|
|
28
|
+
name
|
|
29
|
+
}
|
|
30
|
+
status
|
|
31
|
+
team {
|
|
32
|
+
name
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
page_info {
|
|
36
|
+
page_size
|
|
37
|
+
current_page
|
|
38
|
+
total_pages
|
|
39
|
+
}
|
|
40
|
+
total_count
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`,I=async(e={})=>{var n,a,i,o;const{pageSize:t=20,currentPage:r=1,filter:u}=e;try{const s=await p(E,{method:"GET",cache:"no-cache",variables:{pageSize:t,currentPage:r,filter:u}}).catch(d);return(n=s.errors)!=null&&n.length&&m(s.errors),(o=(i=(a=s.data)==null?void 0:a.company)==null?void 0:i.users)!=null&&o.items?{users:s.data.company.users.items.map(c=>({id:y(c.id),firstName:c.firstname,lastName:c.lastname,email:c.email,role:c.role.name,status:c.status,...c.team&&{team:c.team.name}})),pageInfo:{pageSize:s.data.company.users.page_info.page_size,currentPage:s.data.company.users.page_info.current_page,totalPages:s.data.company.users.page_info.total_pages},totalCount:s.data.company.users.total_count}:{users:[],pageInfo:{pageSize:t,currentPage:r,totalPages:1}}}catch{return{users:[],pageInfo:{pageSize:t,currentPage:r,totalPages:1}}}};export{S as d,I as g,T as u};
|
|
45
|
+
//# sourceMappingURL=getCompanyUsers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCompanyUsers.js","sources":["/@dropins/storefront-company-management/src/lib/encoding.ts","/@dropins/storefront-company-management/src/api/deleteCompanyUser/graphql/deleteCompanyUser.graphql.ts","/@dropins/storefront-company-management/src/api/deleteCompanyUser/deleteCompanyUser.ts","/@dropins/storefront-company-management/src/api/updateCompanyUserStatus/graphql/updateCompanyUserStatus.graphql.ts","/@dropins/storefront-company-management/src/api/updateCompanyUserStatus/updateCompanyUserStatus.ts","/@dropins/storefront-company-management/src/api/getCompanyUsers/graphql/companyUsers.graphql.ts","/@dropins/storefront-company-management/src/api/getCompanyUsers/getCompanyUsers.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n/**\n * Encodes a string to base64\n * @param value - The string to encode\n * @returns The base64 encoded string\n * @throws Error if encoding fails\n */\nexport const encodeBase64 = (value: string): string => {\n try {\n return btoa(value);\n } catch (error) {\n throw new Error(`Failed to encode base64: ${error}`);\n }\n};\n\n/**\n * Decodes a base64 encoded string\n * @param encoded - The base64 encoded string to decode\n * @returns The decoded string, or the original string if decoding fails\n */\nexport const decodeBase64 = (encoded: string): string => {\n try {\n return atob(encoded);\n } catch {\n // Return original if decoding fails (graceful fallback)\n return encoded;\n }\n};\n\n/**\n * Safely encodes a user ID to base64 for API transmission\n * @param userId - The user ID to encode\n * @returns The base64 encoded user ID\n * @throws Error if userId is empty or encoding fails\n */\nexport const encodeUserId = (userId: string): string => {\n if (!userId || typeof userId !== 'string') {\n throw new Error('User ID must be a non-empty string');\n }\n \n return encodeBase64(userId);\n};\n\n/**\n * Safely decodes a base64 encoded user ID from API response\n * @param encodedUserId - The base64 encoded user ID\n * @returns The decoded user ID, or the original string if decoding fails\n */\nexport const decodeUserId = (encodedUserId: string): string => {\n if (!encodedUserId || typeof encodedUserId !== 'string') {\n return encodedUserId;\n }\n \n return decodeBase64(encodedUserId);\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 DELETE_COMPANY_USER_MUTATION = /* GraphQL */ `\n mutation DELETE_COMPANY_USER($id: ID!) {\n deleteCompanyUserV2(id: $id) {\n success\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { fetchGraphQl } from '@/company-management/api';\nimport { handleNetworkError, handleFetchError, encodeUserId } from '@/company-management/lib';\nimport { DELETE_COMPANY_USER_MUTATION } from './graphql/deleteCompanyUser.graphql';\nimport { DeleteCompanyUserMutation, DeleteCompanyUserParams, DeleteCompanyUserResponse } from '@/company-management/types';\n\n/**\n * Deletes a company user by their ID\n * @param params - The parameters containing user ID\n * @param params.id - The ID of the user to delete (will be base64 encoded)\n * @returns Promise<DeleteCompanyUserResponse> - Object containing success status\n */\nexport const deleteCompanyUser = async (params: DeleteCompanyUserParams): Promise<DeleteCompanyUserResponse> => {\n const { id } = params;\n \n if (!id) {\n throw new Error('User ID is required to delete a company user');\n }\n\n try {\n const encodedId = encodeUserId(id);\n \n const response = await fetchGraphQl<DeleteCompanyUserMutation>(\n DELETE_COMPANY_USER_MUTATION,\n {\n method: 'POST',\n cache: 'no-cache',\n variables: {\n id: encodedId\n }\n }\n ).catch(handleNetworkError);\n\n if (response.errors?.length) {\n handleFetchError(response.errors);\n }\n\n if (!response.data?.deleteCompanyUserV2) {\n return {\n success: false\n };\n }\n\n return {\n success: response.data.deleteCompanyUserV2.success\n };\n } catch (error) {\n // Both handleNetworkError and handleFetchError throw errors\n // We return failure status as fallback\n return {\n success: false\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 *******************************************************************/\nexport const UPDATE_COMPANY_USER_STATUS_MUTATION = /* GraphQL */ `\n mutation UPDATE_COMPANY_USER_STATUS($input: CompanyUserUpdateInput!) {\n updateCompanyUser(input: $input) {\n user {\n id\n status\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { fetchGraphQl } from '@/company-management/api';\nimport { handleNetworkError, handleFetchError, encodeUserId } from '@/company-management/lib';\nimport { UPDATE_COMPANY_USER_STATUS_MUTATION } from './graphql/updateCompanyUserStatus.graphql';\nimport {\n UpdateCompanyUserStatusMutation,\n UpdateCompanyUserStatusParams,\n UpdateCompanyUserStatusResponse,\n} from '@/company-management/types';\n\n/**\n * Updates a company user's status (Active/Inactive)\n * @param params - The parameters containing user ID and new status\n * @param params.id - The ID of the user to update (will be base64 encoded)\n * @param params.status - The new status for the user (ACTIVE or INACTIVE)\n * @returns Promise<UpdateCompanyUserStatusResponse> - Object containing success status and updated user data\n */\nexport const updateCompanyUserStatus = async (params: UpdateCompanyUserStatusParams): Promise<UpdateCompanyUserStatusResponse> => {\n const { id, status } = params;\n \n if (!id) {\n throw new Error('User ID is required to update company user status');\n }\n \n if (!status || (status !== 'ACTIVE' && status !== 'INACTIVE')) {\n throw new Error('Valid status (ACTIVE or INACTIVE) is required to update company user status');\n }\n\n try {\n const encodedId = encodeUserId(id);\n \n const response = await fetchGraphQl<UpdateCompanyUserStatusMutation>(\n UPDATE_COMPANY_USER_STATUS_MUTATION,\n {\n method: 'POST',\n cache: 'no-cache',\n variables: {\n input: {\n id: encodedId,\n status\n }\n }\n }\n ).catch(handleNetworkError);\n\n if (response.errors?.length) {\n handleFetchError(response.errors);\n }\n\n if (!response.data?.updateCompanyUser?.user) {\n return {\n success: false\n };\n }\n\n return {\n success: true,\n user: {\n id: response.data.updateCompanyUser.user.id,\n status: response.data.updateCompanyUser.user.status\n }\n };\n } catch (error) {\n // Both handleNetworkError and handleFetchError throw errors\n // We return failure status as fallback\n return {\n success: false\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 *******************************************************************/\nexport const COMPANY_USERS_QUERY = /* GraphQL */ `\n query COMPANY_USERS($pageSize: Int!, $currentPage: Int!, $filter: CompanyUsersFilterInput) {\n company {\n users(pageSize: $pageSize, currentPage: $currentPage, filter: $filter) {\n items {\n id\n firstname\n lastname\n email\n role {\n name\n }\n status\n team {\n name\n }\n }\n page_info {\n page_size\n current_page\n total_pages\n }\n total_count\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { fetchGraphQl } from '@/company-management/api';\nimport { handleNetworkError, handleFetchError, decodeUserId } from '@/company-management/lib';\nimport { COMPANY_USERS_QUERY } from './graphql/companyUsers.graphql';\nimport { CompanyUsersQuery, CompanyUser, CompanyUsersParams, CompanyUsersResponse } from '@/company-management/types';\n\n/**\n * Fetches the list of company users with pagination and optional filtering\n * @param params - Query parameters\n * @param params.pageSize - Number of items per page (default: 20)\n * @param params.currentPage - Current page number (default: 1)\n * @param params.filter - Optional filter to apply (e.g., { status: 'ACTIVE' })\n * @returns Promise<CompanyUsersResponse> - Object containing array of company users and pagination info\n */\nexport const getCompanyUsers = async (params: CompanyUsersParams = {}): Promise<CompanyUsersResponse> => {\n const { pageSize = 20, currentPage = 1, filter } = params;\n\n try {\n const response = await fetchGraphQl<CompanyUsersQuery>(\n COMPANY_USERS_QUERY,\n {\n method: 'GET',\n cache: 'no-cache',\n variables: {\n pageSize,\n currentPage,\n filter\n }\n }\n ).catch(handleNetworkError);\n\n if (response.errors?.length) {\n handleFetchError(response.errors);\n }\n\n if (!response.data?.company?.users?.items) {\n return {\n users: [],\n pageInfo: {\n pageSize,\n currentPage,\n totalPages: 1\n }\n };\n }\n\n // Transform the GraphQL response to CompanyUser interface\n const users: CompanyUser[] = response.data.company.users.items.map((item) => {\n return {\n id: decodeUserId(item.id),\n firstName: item.firstname,\n lastName: item.lastname,\n email: item.email,\n role: item.role.name,\n status: item.status,\n ...(item.team && { team: item.team.name })\n };\n });\n\n return {\n users,\n pageInfo: {\n pageSize: response.data.company.users.page_info.page_size,\n currentPage: response.data.company.users.page_info.current_page,\n totalPages: response.data.company.users.page_info.total_pages\n },\n totalCount: response.data.company.users.total_count\n };\n } catch (error) {\n // Both handleNetworkError and handleFetchError throw errors\n // We return empty users array with default page info as fallback\n return {\n users: [],\n pageInfo: {\n pageSize,\n currentPage,\n totalPages: 1\n }\n };\n }\n};\n"],"names":["encodeBase64","value","error","decodeBase64","encoded","encodeUserId","userId","decodeUserId","encodedUserId","DELETE_COMPANY_USER_MUTATION","deleteCompanyUser","params","id","encodedId","response","fetchGraphQl","handleNetworkError","_a","handleFetchError","_b","UPDATE_COMPANY_USER_STATUS_MUTATION","updateCompanyUserStatus","status","_c","COMPANY_USERS_QUERY","getCompanyUsers","pageSize","currentPage","filter","_d","item"],"mappings":"mDAuBa,MAAAA,EAAgBC,GAA0B,CACjD,GAAA,CACF,OAAO,KAAKA,CAAK,QACVC,EAAO,CACd,MAAM,IAAI,MAAM,4BAA4BA,CAAK,EAAE,CAAA,CAEvD,EAOaC,EAAgBC,GAA4B,CACnD,GAAA,CACF,OAAO,KAAKA,CAAO,CAAA,MACb,CAEC,OAAAA,CAAA,CAEX,EAQaC,EAAgBC,GAA2B,CACtD,GAAI,CAACA,GAAU,OAAOA,GAAW,SACzB,MAAA,IAAI,MAAM,oCAAoC,EAGtD,OAAON,EAAaM,CAAM,CAC5B,EAOaC,EAAgBC,GACvB,CAACA,GAAiB,OAAOA,GAAkB,SACtCA,EAGFL,EAAaK,CAAa,ECrDtBC,EAA6C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECW7CC,EAAoB,MAAOC,GAAwE,SACxG,KAAA,CAAE,GAAAC,GAAOD,EAEf,GAAI,CAACC,EACG,MAAA,IAAI,MAAM,8CAA8C,EAG5D,GAAA,CACI,MAAAC,EAAYR,EAAaO,CAAE,EAE3BE,EAAW,MAAMC,EACrBN,EACA,CACE,OAAQ,OACR,MAAO,WACP,UAAW,CACT,GAAII,CAAA,CACN,CACF,EACA,MAAMG,CAAkB,EAMtB,OAJAC,EAAAH,EAAS,SAAT,MAAAG,EAAiB,QACnBC,EAAiBJ,EAAS,MAAM,GAG7BK,EAAAL,EAAS,OAAT,MAAAK,EAAe,oBAMb,CACL,QAASL,EAAS,KAAK,oBAAoB,OAC7C,EAPS,CACL,QAAS,EACX,OAMY,CAGP,MAAA,CACL,QAAS,EACX,CAAA,CAEJ,ECpDaM,EAAoD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECgBpDC,EAA0B,MAAOV,GAAoF,WAC1H,KAAA,CAAE,GAAAC,EAAI,OAAAU,CAAA,EAAWX,EAEvB,GAAI,CAACC,EACG,MAAA,IAAI,MAAM,mDAAmD,EAGrE,GAAI,CAACU,GAAWA,IAAW,UAAYA,IAAW,WAC1C,MAAA,IAAI,MAAM,6EAA6E,EAG3F,GAAA,CACI,MAAAT,EAAYR,EAAaO,CAAE,EAE3BE,EAAW,MAAMC,EACrBK,EACA,CACE,OAAQ,OACR,MAAO,WACP,UAAW,CACT,MAAO,CACL,GAAIP,EACJ,OAAAS,CAAA,CACF,CACF,CACF,EACA,MAAMN,CAAkB,EAM1B,OAJIC,EAAAH,EAAS,SAAT,MAAAG,EAAiB,QACnBC,EAAiBJ,EAAS,MAAM,GAG7BS,GAAAJ,EAAAL,EAAS,OAAT,YAAAK,EAAe,oBAAf,MAAAI,EAAkC,KAMhC,CACL,QAAS,GACT,KAAM,CACJ,GAAIT,EAAS,KAAK,kBAAkB,KAAK,GACzC,OAAQA,EAAS,KAAK,kBAAkB,KAAK,MAAA,CAEjD,EAXS,CACL,QAAS,EACX,OAUY,CAGP,MAAA,CACL,QAAS,EACX,CAAA,CAEJ,ECpEaU,EAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECapCC,EAAkB,MAAOd,EAA6B,KAAsC,aACvG,KAAM,CAAE,SAAAe,EAAW,GAAI,YAAAC,EAAc,EAAG,OAAAC,GAAWjB,EAE/C,GAAA,CACF,MAAMG,EAAW,MAAMC,EACrBS,EACA,CACE,OAAQ,MACR,MAAO,WACP,UAAW,CACT,SAAAE,EACA,YAAAC,EACA,OAAAC,CAAA,CACF,CACF,EACA,MAAMZ,CAAkB,EAM1B,OAJIC,EAAAH,EAAS,SAAT,MAAAG,EAAiB,QACnBC,EAAiBJ,EAAS,MAAM,GAG7Be,GAAAN,GAAAJ,EAAAL,EAAS,OAAT,YAAAK,EAAe,UAAf,YAAAI,EAAwB,QAAxB,MAAAM,EAA+B,MAwB7B,CACL,MAb2Bf,EAAS,KAAK,QAAQ,MAAM,MAAM,IAAKgB,IAC3D,CACL,GAAIvB,EAAauB,EAAK,EAAE,EACxB,UAAWA,EAAK,UAChB,SAAUA,EAAK,SACf,MAAOA,EAAK,MACZ,KAAMA,EAAK,KAAK,KAChB,OAAQA,EAAK,OACb,GAAIA,EAAK,MAAQ,CAAE,KAAMA,EAAK,KAAK,IAAK,CAC1C,EACD,EAIC,SAAU,CACR,SAAUhB,EAAS,KAAK,QAAQ,MAAM,UAAU,UAChD,YAAaA,EAAS,KAAK,QAAQ,MAAM,UAAU,aACnD,WAAYA,EAAS,KAAK,QAAQ,MAAM,UAAU,WACpD,EACA,WAAYA,EAAS,KAAK,QAAQ,MAAM,WAC1C,EA/BS,CACL,MAAO,CAAC,EACR,SAAU,CACR,SAAAY,EACA,YAAAC,EACA,WAAY,CAAA,CAEhB,OAyBY,CAGP,MAAA,CACL,MAAO,CAAC,EACR,SAAU,CACR,SAAAD,EACA,YAAAC,EACA,WAAY,CAAA,CAEhB,CAAA,CAEJ"}
|
package/chunks/getCountries.js
CHANGED
|
@@ -1,12 +1,71 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{f as c}from"./fetch-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import{f as c,h as g,c as A}from"./fetch-error.js";import{b as C,f as y}from"./fetchUserPermissions.js";const p=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 r="customer"in e.data?e.data.customer:void 0,o=a.legal_address?{street:Array.isArray(a.legal_address.street)?a.legal_address.street.filter(t=>t&&t.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,n=r==null?void 0:r.role,l=C(n),i={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:o,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(t=>t&&typeof t.code=="string"&&typeof t.title=="string").map(t=>({code:t.code.trim(),title:t.title.trim()})).filter(t=>t.code.length>0&&t.title.length>0):void 0,availableShippingMethods:Array.isArray(a.available_shipping_methods)?a.available_shipping_methods.filter(t=>t&&typeof t.code=="string"&&typeof t.title=="string").map(t=>({code:t.code.trim(),title:t.title.trim()})).filter(t=>t.code.length>0&&t.title.length>0):void 0,canEditAccount:l.canEditAccount,canEditAddress:l.canEditAddress,permissionsFlags:l,customerRole:n,customerStatus:r==null?void 0:r.status};if(l.canViewAccount){if(!i.id)throw new Error("Company ID is required");if(!i.name)throw new Error("Company name is required");if(!i.email)throw new Error("Company email is required")}return i},f=e=>{var i,s;if(!((s=(i=e==null?void 0:e.data)==null?void 0:i.countries)!=null&&s.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:a,storeConfig:r}=e.data,o=r==null?void 0:r.countries_with_required_region.split(","),n=r==null?void 0:r.optional_zip_countries.split(",");return{availableCountries:a.filter(({two_letter_abbreviation:t,full_name_locale:m})=>!!(t&&m)).map(t=>{const{two_letter_abbreviation:m,full_name_locale:d,available_regions:_}=t,u=Array.isArray(_)&&_.length>0;return{value:m,text:d,availableRegions:u?_:void 0}}).sort((t,m)=>t.text.localeCompare(m.text)),countriesWithRequiredRegion:o,optionalZipCountries:n}},v=`
|
|
4
|
+
fragment COMPANY_LEGAL_ADDRESS_FRAGMENT on CompanyLegalAddress {
|
|
5
|
+
street
|
|
6
|
+
city
|
|
7
|
+
region {
|
|
8
|
+
region
|
|
9
|
+
region_code
|
|
10
|
+
region_id
|
|
7
11
|
}
|
|
12
|
+
country_code
|
|
13
|
+
postcode
|
|
14
|
+
telephone
|
|
8
15
|
}
|
|
9
|
-
`,
|
|
16
|
+
`,E=`
|
|
17
|
+
fragment COMPANY_BASIC_INFO_FRAGMENT on Company {
|
|
18
|
+
id
|
|
19
|
+
name
|
|
20
|
+
email
|
|
21
|
+
legal_name
|
|
22
|
+
vat_tax_id
|
|
23
|
+
reseller_id
|
|
24
|
+
}
|
|
25
|
+
`,N=`
|
|
26
|
+
fragment COMPANY_SALES_REPRESENTATIVE_FRAGMENT on CompanySalesRepresentative {
|
|
27
|
+
firstname
|
|
28
|
+
lastname
|
|
29
|
+
email
|
|
30
|
+
}
|
|
31
|
+
`,M=`
|
|
32
|
+
fragment COMPANY_ADMIN_FRAGMENT on Customer {
|
|
33
|
+
firstname
|
|
34
|
+
lastname
|
|
35
|
+
email
|
|
36
|
+
job_title
|
|
37
|
+
}
|
|
38
|
+
`,h=e=>{const a=e.has("Magento_Company::view_account"),r=e.has("Magento_Company::view_address"),o=e.has("Magento_Company::contacts"),n=e.has("Magento_Company::payment_information"),l=e.has("Magento_Company::shipping_information"),i=[],s=[];return a&&(i.push("...COMPANY_BASIC_INFO_FRAGMENT"),s.push(E)),r&&(i.push("legal_address { ...COMPANY_LEGAL_ADDRESS_FRAGMENT }"),s.push(v)),o&&(i.push("company_admin { ...COMPANY_ADMIN_FRAGMENT }"),i.push("sales_representative { ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT }"),s.push(M),s.push(N)),n&&i.push("available_payment_methods { code title }"),l&&i.push("available_shipping_methods { code title }"),{fields:i,usedFragments:s}},b=e=>{const{fields:a,usedFragments:r}=h(e);return a.length===0?`
|
|
39
|
+
query GET_COMPANY_DYNAMIC {
|
|
40
|
+
company { __typename }
|
|
41
|
+
}
|
|
42
|
+
`:`${`
|
|
43
|
+
query GET_COMPANY_DYNAMIC {
|
|
44
|
+
company {
|
|
45
|
+
${a.join(`
|
|
46
|
+
`)}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`}
|
|
50
|
+
${r.join(`
|
|
51
|
+
`)}`},I=e=>{const{fields:a,usedFragments:r}=h(e);return a.length===0?`
|
|
52
|
+
mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {
|
|
53
|
+
updateCompany(input: $input) {
|
|
54
|
+
company { __typename }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`:`${`
|
|
58
|
+
mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {
|
|
59
|
+
updateCompany(input: $input) {
|
|
60
|
+
company {
|
|
61
|
+
${a.join(`
|
|
62
|
+
`)}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`}
|
|
67
|
+
${r.join(`
|
|
68
|
+
`)}`},O=async()=>await y().then(async({allowedIds:e,roleResponse:a})=>{var i,s,t;const r=b(e),o=await c(r,{method:"GET",cache:"no-cache"});if((i=o.errors)!=null&&i.length)return g(o.errors);const n=(s=o==null?void 0:o.data)==null?void 0:s.company;return n&&Object.keys(n).some(m=>m!=="__typename")?(o.data.customer=(t=a==null?void 0:a.data)==null?void 0:t.customer,p(o)):null}).catch(A),w=async e=>await y().then(async({allowedIds:a,roleResponse:r})=>{var i,s;const o=I(a),n={};if(e.name!==void 0&&(n.company_name=e.name),e.email!==void 0&&(n.company_email=e.email),e.legalName!==void 0&&(n.legal_name=e.legalName),e.vatTaxId!==void 0&&(n.vat_tax_id=e.vatTaxId),e.resellerId!==void 0&&(n.reseller_id=e.resellerId),e.legalAddress!==void 0&&a.has("Magento_Company::edit_address")){let t;Array.isArray(e.legalAddress.street)?(t=[...e.legalAddress.street],e.legalAddress.street2&&t.push(e.legalAddress.street2)):t=[e.legalAddress.street,e.legalAddress.street2].filter(d=>typeof d=="string"&&d.trim().length>0),t=t.filter(d=>d&&typeof d=="string"&&d.trim().length>0);let m;if(e.legalAddress.region&&typeof e.legalAddress.region=="object"){const d=e.legalAddress.region;d.region===d.regionCode?m={region:d.region,region_code:d.regionCode,region_id:0}:m={region:d.region,region_code:d.regionCode}}else e.legalAddress.regionCode&&e.legalAddress.region!==e.legalAddress.regionCode?m={region:e.legalAddress.region||e.legalAddress.regionCode,region_code:e.legalAddress.regionCode}:e.legalAddress.region&&(m={region:e.legalAddress.region,region_code:e.legalAddress.region,region_id:0});n.legal_address={street:t,city:e.legalAddress.city,region:m,country_id:e.legalAddress.countryCode,postcode:e.legalAddress.postcode,telephone:e.legalAddress.telephone}}const l=await c(o,{method:"POST",variables:{input:n}});return(i=l.errors)!=null&&i.length?g(l.errors):(l.data.customer=(s=r==null?void 0:r.data)==null?void 0:s.customer,p(l))}).catch(A),T=`
|
|
10
69
|
query getCountries {
|
|
11
70
|
countries {
|
|
12
71
|
id
|
|
@@ -25,5 +84,5 @@ import{f as c}from"./fetch-graphql.js";import{events as p}from"@dropins/tools/ev
|
|
|
25
84
|
optional_zip_countries
|
|
26
85
|
}
|
|
27
86
|
}
|
|
28
|
-
`,
|
|
87
|
+
`,Y=async()=>{const e="_company_countries",a=sessionStorage.getItem(e);return a?JSON.parse(a):await c(T,{method:"GET"}).then(r=>{var n;if((n=r.errors)!=null&&n.length)return g(r.errors);const o=f(r);return sessionStorage.setItem(e,JSON.stringify(o)),o}).catch(A)};export{Y as a,O as g,w as u};
|
|
29
88
|
//# sourceMappingURL=getCountries.js.map
|