@dropins/storefront-company-management 1.0.0-beta2 → 1.0.0-beta21
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/allowCompanyRegistration/allowCompanyRegistration.d.ts +18 -0
- package/api/allowCompanyRegistration/graphql/allowCompanyRegistration.graphql.d.ts +18 -0
- package/api/allowCompanyRegistration/index.d.ts +18 -0
- package/api/checkCompanyCreditEnabled/checkCompanyCreditEnabled.d.ts +4 -0
- package/api/checkCompanyCreditEnabled/graphql/checkCompanyCreditEnabled.graphql.d.ts +18 -0
- package/api/checkCompanyCreditEnabled/index.d.ts +18 -0
- package/api/companyEnabled/companyEnabled.d.ts +18 -0
- package/api/companyEnabled/graphql/companyEnabled.graphql.d.ts +18 -0
- package/api/{checkIsCompanyEnabled → companyEnabled}/index.d.ts +1 -1
- package/api/companyRoles/createCompanyRole.d.ts +7 -0
- package/api/companyRoles/deleteCompanyRole.d.ts +7 -0
- package/api/companyRoles/getCompanyAclResources.d.ts +7 -0
- package/api/companyRoles/getCompanyRole.d.ts +8 -0
- package/api/companyRoles/getCompanyRoles.d.ts +8 -0
- package/api/companyRoles/graphql/fragments.d.ts +18 -0
- package/api/companyRoles/graphql/index.d.ts +20 -0
- package/api/companyRoles/graphql/mutations.d.ts +20 -0
- package/api/companyRoles/graphql/queries.d.ts +21 -0
- package/api/companyRoles/index.d.ts +27 -0
- package/api/companyRoles/isCompanyRoleNameAvailable.d.ts +7 -0
- package/api/companyRoles/updateCompanyRole.d.ts +7 -0
- package/api/companyRoles/utils.d.ts +11 -0
- package/api/createCompany/createCompany.d.ts +39 -0
- package/api/createCompany/graphql/createCompany.graphql.d.ts +18 -0
- package/api/createCompany/index.d.ts +18 -0
- package/api/createCompanyTeam/createCompanyTeam.d.ts +11 -0
- package/api/createCompanyTeam/graphql/createCompanyTeam.graphql.d.ts +18 -0
- package/api/createCompanyTeam/index.d.ts +18 -0
- package/api/createCompanyUser/createCompanyUser.d.ts +9 -0
- package/api/createCompanyUser/graphql/createCompanyUser.graphql.d.ts +18 -0
- package/api/createCompanyUser/index.d.ts +18 -0
- package/api/deleteCompanyTeam/deleteCompanyTeam.d.ts +9 -0
- package/api/deleteCompanyTeam/graphql/deleteCompanyTeam.graphql.d.ts +18 -0
- package/api/deleteCompanyTeam/index.d.ts +18 -0
- package/api/deleteCompanyUser/deleteCompanyUser.d.ts +10 -0
- package/api/deleteCompanyUser/graphql/deleteCompanyUser.graphql.d.ts +18 -0
- package/api/deleteCompanyUser/index.d.ts +18 -0
- package/api/fetchUserPermissions/fetchUserPermissions.d.ts +11 -0
- package/api/{getCompany → fetchUserPermissions}/graphql/getCustomerRole.graphql.d.ts +1 -1
- package/api/fetchUserPermissions/index.d.ts +18 -0
- package/api/getCompany/getCompany.d.ts +9 -3
- package/api/getCompanyCredit/getCompanyCredit.d.ts +4 -0
- package/api/getCompanyCredit/graphql/getCompanyCredit.graphql.d.ts +18 -0
- package/api/getCompanyCredit/index.d.ts +18 -0
- package/api/getCompanyCreditHistory/getCompanyCreditHistory.d.ts +5 -0
- package/api/getCompanyCreditHistory/graphql/getCompanyCreditHistory.graphql.d.ts +18 -0
- package/api/getCompanyCreditHistory/index.d.ts +19 -0
- package/api/getCompanyStructure/getCompanyStructure.d.ts +10 -0
- package/api/getCompanyStructure/graphql/getCompanyStructure.graphql.d.ts +18 -0
- package/api/getCompanyStructure/index.d.ts +18 -0
- package/api/getCompanyTeam/getCompanyTeam.d.ts +11 -0
- package/api/getCompanyTeam/graphql/getCompanyTeam.graphql.d.ts +18 -0
- package/api/getCompanyTeam/index.d.ts +18 -0
- package/api/getCompanyUser/getCompanyUser.d.ts +9 -0
- package/api/getCompanyUser/graphql/getCompanyUser.graphql.d.ts +18 -0
- package/api/getCompanyUser/index.d.ts +18 -0
- package/api/getCompanyUsers/getCompanyUsers.d.ts +12 -0
- package/api/getCompanyUsers/graphql/companyUsers.graphql.d.ts +18 -0
- package/api/getCompanyUsers/index.d.ts +18 -0
- package/api/getCustomerCompany/getCustomerCompany.d.ts +12 -0
- package/api/getCustomerCompany/graphql/getCustomerCompanyInfo.graphql.d.ts +18 -0
- package/api/getCustomerCompany/index.d.ts +18 -0
- package/api/getStoreConfig/getStoreConfig.d.ts +6 -0
- package/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts +18 -0
- package/api/getStoreConfig/index.d.ts +18 -0
- package/api/graphql/buildCompanyQueries.d.ts +9 -0
- package/api/index.d.ts +26 -2
- package/api/initialize/initialize.d.ts +2 -20
- package/api/isCompanyAdmin/graphql/isCompanyAdmin.graphql.d.ts +18 -0
- package/api/isCompanyAdmin/index.d.ts +18 -0
- package/api/isCompanyAdmin/isCompanyAdmin.d.ts +22 -0
- package/api/isCompanyUser/graphql/isCompanyUser.graphql.d.ts +18 -0
- package/api/isCompanyUser/index.d.ts +18 -0
- package/api/isCompanyUser/isCompanyUser.d.ts +22 -0
- package/api/isCompanyUserEmailAvailable/graphql/isCompanyUserEmailAvailable.graphql.d.ts +18 -0
- package/api/isCompanyUserEmailAvailable/index.d.ts +18 -0
- package/api/isCompanyUserEmailAvailable/isCompanyUserEmailAvailable.d.ts +7 -0
- package/api/updateCompanyStructure/graphql/updateCompanyStructure.graphql.d.ts +18 -0
- package/api/updateCompanyStructure/index.d.ts +18 -0
- package/api/updateCompanyStructure/updateCompanyStructure.d.ts +11 -0
- package/api/updateCompanyTeam/graphql/updateCompanyTeam.graphql.d.ts +18 -0
- package/api/updateCompanyTeam/index.d.ts +18 -0
- package/api/updateCompanyTeam/updateCompanyTeam.d.ts +11 -0
- package/api/updateCompanyUser/graphql/updateCompanyUser.graphql.d.ts +18 -0
- package/api/updateCompanyUser/index.d.ts +18 -0
- package/api/updateCompanyUser/updateCompanyUser.d.ts +9 -0
- package/api/updateCompanyUserStatus/graphql/updateCompanyUserStatus.graphql.d.ts +18 -0
- package/api/updateCompanyUserStatus/index.d.ts +18 -0
- package/api/updateCompanyUserStatus/updateCompanyUserStatus.d.ts +11 -0
- package/api.js +22 -1
- package/api.js.map +1 -1
- package/chunks/CompanyLoaders.js +4 -0
- package/chunks/CompanyLoaders.js.map +1 -0
- package/chunks/CompanyUserForm.js +4 -0
- package/chunks/CompanyUserForm.js.map +1 -0
- package/chunks/Tree.js +4 -0
- package/chunks/Tree.js.map +1 -0
- package/chunks/acdl.js +4 -0
- package/chunks/acdl.js.map +1 -0
- package/chunks/company-permissions.js +4 -0
- package/chunks/company-permissions.js.map +1 -0
- package/chunks/fetch-error.js +4 -0
- package/chunks/fetch-error.js.map +1 -0
- package/chunks/fetchUserPermissions.js +34 -0
- package/chunks/fetchUserPermissions.js.map +1 -0
- package/chunks/getCompanyCreditHistory.js +68 -0
- package/chunks/getCompanyCreditHistory.js.map +1 -0
- package/chunks/getCustomerCompany.js +26 -0
- package/chunks/getCustomerCompany.js.map +1 -0
- package/chunks/isCompanyRoleNameAvailable.js +121 -0
- package/chunks/isCompanyRoleNameAvailable.js.map +1 -0
- package/chunks/isCompanyUser.js +21 -0
- package/chunks/isCompanyUser.js.map +1 -0
- package/chunks/network-error.js +4 -0
- package/chunks/network-error.js.map +1 -0
- package/chunks/transform-store-config.js +44 -0
- package/chunks/transform-store-config.js.map +1 -0
- package/chunks/updateCompany.js +70 -0
- package/chunks/updateCompany.js.map +1 -0
- package/chunks/updateCompanyTeam.js +42 -0
- package/chunks/updateCompanyTeam.js.map +1 -0
- package/chunks/updateCompanyUser.js +37 -0
- package/chunks/updateCompanyUser.js.map +1 -0
- package/chunks/updateCompanyUserStatus.js +39 -0
- package/chunks/updateCompanyUserStatus.js.map +1 -0
- package/chunks/useCompanyContextListener.js +4 -0
- package/chunks/useCompanyContextListener.js.map +1 -0
- package/chunks/useCompanyRoles.js +4 -0
- package/chunks/useCompanyRoles.js.map +1 -0
- package/chunks/useCustomerCompanyInfo.js +4 -0
- package/chunks/useCustomerCompanyInfo.js.map +1 -0
- package/chunks/useInLineAlert.js +4 -0
- package/chunks/useInLineAlert.js.map +1 -0
- package/chunks/useUserPermissions.js +4 -0
- package/chunks/useUserPermissions.js.map +1 -0
- package/chunks/validateCompanyEmail.js +29 -0
- package/chunks/validateCompanyEmail.js.map +1 -0
- package/components/CompanyCreditDisplay/CompanyCreditDisplay.d.ts +7 -0
- package/components/CompanyCreditDisplay/index.d.ts +19 -0
- package/components/CompanyCreditHistoryDisplay/CompanyCreditHistoryDisplay.d.ts +15 -0
- package/components/CompanyCreditHistoryDisplay/index.d.ts +19 -0
- package/components/CompanyLoaders/CompanyLoaders.d.ts +14 -0
- package/components/CompanyRegistrationForm/CompanyRegistrationForm.d.ts +13 -0
- package/components/CompanyRegistrationForm/Form/Form.d.ts +5 -0
- package/components/CompanyRegistrationForm/Form/FormInputs/FormInputs.d.ts +5 -0
- package/components/CompanyRegistrationForm/Form/FormInputs/index.d.ts +18 -0
- package/components/CompanyRegistrationForm/Form/fieldHandlers.d.ts +26 -0
- package/components/CompanyRegistrationForm/Form/fieldValidationRules.d.ts +63 -0
- package/components/CompanyRegistrationForm/Form/formValidation.d.ts +17 -0
- package/components/CompanyRegistrationForm/Form/getCompanyFieldsConfig.d.ts +13 -0
- package/components/CompanyRegistrationForm/Form/index.d.ts +18 -0
- package/components/CompanyRegistrationForm/index.d.ts +20 -0
- package/components/CompanyRegistrationSuccess/CompanyRegistrationSuccess.d.ts +8 -0
- package/components/CompanyRegistrationSuccess/index.d.ts +18 -0
- package/components/CompanyStructureCard/CompanyStructureCard.d.ts +12 -0
- package/components/CompanyStructureCard/index.d.ts +18 -0
- package/components/CompanyStructureEmpty/CompanyStructureEmpty.d.ts +9 -0
- package/components/CompanyStructureEmpty/index.d.ts +19 -0
- package/components/CompanyTeamForm/CompanyTeamForm.d.ts +17 -0
- package/components/CompanyTeamForm/index.d.ts +18 -0
- package/components/CompanyUserForm/CompanyUserForm.d.ts +10 -0
- package/components/CompanyUserForm/index.d.ts +18 -0
- package/components/CompanyUsersFilters/CompanyUsersFilters.d.ts +29 -0
- package/components/CompanyUsersFilters/index.d.ts +18 -0
- package/components/CompanyUsersManagementModal/CompanyUsersManagementModal.d.ts +18 -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/DeleteRoleModal/DeleteRoleModal.d.ts +9 -0
- package/components/DeleteRoleModal/index.d.ts +19 -0
- package/components/EditCompanyProfile/CompanyAccountFields.d.ts +1 -2
- package/components/EditCompanyProfile/LegalAddressFields.d.ts +1 -1
- package/components/EditRoleAndPermission/EditRoleAndPermission.d.ts +24 -0
- package/components/EditRoleAndPermission/index.d.ts +19 -0
- package/components/RoleAndPermissionTable/RoleAndPermissionTable.d.ts +23 -0
- package/components/RoleAndPermissionTable/index.d.ts +19 -0
- package/components/Tree/Tree.d.ts +62 -0
- package/components/Tree/index.d.ts +18 -0
- package/components/index.d.ts +15 -0
- package/containers/CompanyCredit/CompanyCredit.d.ts +16 -0
- package/containers/CompanyCredit/index.d.ts +19 -0
- package/containers/CompanyCredit.d.ts +3 -0
- package/containers/CompanyCredit.js +4 -0
- package/containers/CompanyCredit.js.map +1 -0
- package/containers/CompanyProfile.js +1 -1
- package/containers/CompanyProfile.js.map +1 -1
- package/containers/CompanyRegistration/CompanyRegistration.d.ts +15 -0
- package/containers/CompanyRegistration/index.d.ts +19 -0
- package/containers/CompanyRegistration.d.ts +3 -0
- package/containers/CompanyRegistration.js +4 -0
- package/containers/CompanyRegistration.js.map +1 -0
- package/containers/CompanyStructure/CompanyStructure.d.ts +5 -0
- package/containers/CompanyStructure/index.d.ts +19 -0
- package/containers/CompanyStructure.d.ts +3 -0
- package/containers/CompanyStructure.js +4 -0
- package/containers/CompanyStructure.js.map +1 -0
- package/containers/CompanyUsers/CompanyUsers.d.ts +7 -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/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/RolesAndPermissions/RolesAndPermissions.d.ts +8 -0
- package/containers/RolesAndPermissions/index.d.ts +19 -0
- package/containers/RolesAndPermissions.d.ts +3 -0
- package/containers/RolesAndPermissions.js +4 -0
- package/containers/RolesAndPermissions.js.map +1 -0
- package/containers/index.d.ts +7 -0
- package/data/models/company-credit-history.d.ts +54 -0
- package/data/models/company-credit-info.d.ts +33 -0
- package/data/models/company-role.d.ts +48 -0
- package/data/models/company-structure.d.ts +26 -0
- package/data/models/company-team.d.ts +24 -0
- package/data/models/company-user.d.ts +33 -0
- package/data/models/company.d.ts +58 -17
- package/data/models/customer-company-info.d.ts +23 -0
- package/data/models/index.d.ts +7 -0
- package/data/transforms/company.d.ts +5 -0
- package/data/transforms/index.d.ts +8 -0
- package/data/transforms/transform-company-credit-history.d.ts +5 -0
- package/data/transforms/transform-company-credit.d.ts +5 -0
- package/data/transforms/transform-company-roles.d.ts +15 -0
- package/data/transforms/transform-company-structure.d.ts +22 -0
- package/data/transforms/transform-company-team.d.ts +10 -0
- package/data/transforms/transform-company-user.d.ts +18 -0
- package/data/transforms/transform-company.d.ts +5 -1
- package/data/transforms/transform-customer-company-info.d.ts +10 -0
- package/data/transforms/transform-store-config.d.ts +4 -0
- package/hooks/containers/index.d.ts +3 -0
- package/hooks/containers/useCompanyCreditHistory.d.ts +32 -0
- package/hooks/containers/useCompanyProfile.d.ts +2 -8
- package/hooks/containers/useCompanyUsers.d.ts +34 -0
- package/hooks/containers/useCustomerCompanyInfo.d.ts +12 -0
- package/hooks/index.d.ts +9 -0
- package/hooks/useCompanyContextListener.d.ts +62 -0
- package/hooks/useCompanyRegistrationForm.d.ts +37 -0
- package/hooks/useCompanyRoles.d.ts +28 -0
- package/hooks/useCompanyStructureCard.d.ts +36 -0
- package/hooks/useCompanyTeamForm.d.ts +30 -0
- package/hooks/useCompanyUserForm.d.ts +37 -0
- package/hooks/useCountryAndRegionFields.d.ts +20 -0
- package/hooks/useModal.d.ts +24 -0
- package/hooks/usePermissions.d.ts +31 -0
- package/hooks/useUserPermissions.d.ts +26 -0
- package/i18n/en_US.json.d.ts +345 -4
- package/lib/acdl.d.ts +2 -1
- package/lib/company-permissions.d.ts +25 -0
- package/lib/encoding.d.ts +43 -0
- package/lib/fetch-error.d.ts +6 -1
- package/lib/index.d.ts +3 -0
- package/lib/network-error.d.ts +4 -0
- package/lib/userHelpers.d.ts +47 -0
- package/lib/validationFields.d.ts +16 -0
- package/package.json +1 -1
- package/render.js +12 -2
- package/render.js.map +1 -1
- package/types/api/{checkIsCompanyEnabled.types.d.ts → checkCompanyCreditEnabled.types.d.ts} +3 -3
- package/types/api/companyRoles.types.d.ts +137 -0
- package/types/api/companyUsers.types.d.ts +70 -0
- package/types/api/createCompanyTeam.types.d.ts +27 -0
- package/types/api/createCompanyUser.types.d.ts +31 -0
- package/types/api/deleteCompanyTeam.types.d.ts +20 -0
- package/types/api/deleteCompanyUser.types.d.ts +28 -0
- package/types/api/fetchUserPermissions.types.d.ts +43 -0
- package/types/api/getCompany.types.d.ts +1 -1
- package/types/api/getCompanyCredit.types.d.ts +40 -0
- package/types/api/getCompanyCreditHistory.types.d.ts +61 -0
- package/types/api/getCompanyCreditHistoryParams.types.d.ts +53 -0
- package/types/api/getCompanyStructure.types.d.ts +33 -0
- package/types/api/getCompanyTeam.types.d.ts +20 -0
- package/types/api/getCompanyUser.types.d.ts +20 -0
- package/types/api/getCustomerCompanyInfo.types.d.ts +40 -0
- package/types/api/getStoreConfig.types.d.ts +33 -0
- package/types/api/index.d.ts +29 -0
- package/types/api/initialize.types.d.ts +21 -0
- package/types/api/isCompanyUserEmailAvailable.types.d.ts +20 -0
- package/types/api/updateCompany.types.d.ts +1 -1
- package/types/api/updateCompanyStructure.types.d.ts +21 -0
- package/types/api/updateCompanyTeam.types.d.ts +22 -0
- package/types/api/updateCompanyUser.types.d.ts +27 -0
- package/types/api/updateCompanyUserStatus.types.d.ts +22 -0
- package/types/companyForm.types.d.ts +33 -0
- package/types/companyPermission.types.d.ts +33 -0
- package/types/companyProfile.types.d.ts +43 -0
- package/types/companyStructure.types.d.ts +28 -0
- package/types/customerCompanyInfo.types.d.ts +11 -0
- package/types/events.d.ts +21 -0
- package/types/form.types.d.ts +93 -0
- package/types/hook.types.d.ts +18 -0
- package/types/index.d.ts +25 -2
- package/api/checkIsCompanyEnabled/checkIsCompanyEnabled.d.ts +0 -4
- package/api/updateCompany/graphql/updateCompany.graphql.d.ts +0 -2
- package/chunks/getCountries.js +0 -135
- package/chunks/getCountries.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCompanyUser.js","sources":["/@dropins/storefront-company-management/src/api/allowCompanyRegistration/graphql/allowCompanyRegistration.graphql.ts","/@dropins/storefront-company-management/src/api/allowCompanyRegistration/allowCompanyRegistration.ts","/@dropins/storefront-company-management/src/api/isCompanyUser/graphql/isCompanyUser.graphql.ts","/@dropins/storefront-company-management/src/api/isCompanyUser/isCompanyUser.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_ALLOW_COMPANY_REGISTRATION = /* GraphQL */ `\n query GET_ALLOW_COMPANY_REGISTRATION {\n storeConfig {\n allow_company_registration\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n \nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_ALLOW_COMPANY_REGISTRATION } from './graphql/allowCompanyRegistration.graphql';\n\nexport const allowCompanyRegistration = async (): Promise<boolean> => { \n const response = await fetchGraphQl(GET_ALLOW_COMPANY_REGISTRATION, { method: 'POST' });\n\n if ((response as any)?.errors?.length) {\n throw new Error((response as any).errors[0]?.message || 'Failed to load store configuration');\n }\n\n const node = (response as any)?.data?.storeConfig;\n if (!node) {\n throw new Error('Invalid response: missing storeConfig');\n }\n\n // Backend guarantees that companyEnabled is true if allowCompanyRegistration is true\n return Boolean(node.allow_company_registration);\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_CUSTOMER_COMPANIES = /* GraphQL */ `\n query GET_CUSTOMER_COMPANIES {\n customer {\n companies(input: {}) {\n items {\n id\n name\n }\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n \nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_CUSTOMER_COMPANIES } from './graphql/isCompanyUser.graphql';\n\ninterface CompanyItem {\n id: string;\n name: string;\n}\n\ninterface CustomerCompaniesResponse {\n customer: {\n companies: {\n items: CompanyItem[];\n };\n } | null;\n}\n\n/**\n * Check if the current authenticated customer belongs to any company\n * @returns Promise<boolean> - true if customer belongs to one or more companies, false otherwise\n */\nexport const isCompanyUser = async (): Promise<boolean> => {\n try {\n const response = await fetchGraphQl<CustomerCompaniesResponse>(GET_CUSTOMER_COMPANIES, {\n method: 'POST',\n });\n\n if (response.errors?.length) {\n return false;\n }\n\n const companies = (response as any)?.data?.customer?.companies?.items ?? [];\n return Array.isArray(companies) && companies.length > 0;\n } catch (error) {\n return false;\n }\n};\n"],"names":["GET_ALLOW_COMPANY_REGISTRATION","allowCompanyRegistration","response","fetchGraphQl","_a","_b","node","_c","GET_CUSTOMER_COMPANIES","isCompanyUser","companies","_d"],"mappings":"uCAiBO,MAAMA,EAA+C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECG/CC,EAA2B,SAA8B,WACpE,MAAMC,EAAW,MAAMC,EAAaH,EAAgC,CAAE,OAAQ,OAAQ,EAEtF,IAAKI,EAAAF,GAAA,YAAAA,EAAkB,SAAlB,MAAAE,EAA0B,OAC7B,MAAM,IAAI,QAAOC,EAAAH,EAAiB,OAAO,CAAC,IAAzB,YAAAG,EAA4B,UAAW,oCAAoC,EAG9F,MAAMC,GAAQC,EAAAL,GAAA,YAAAA,EAAkB,OAAlB,YAAAK,EAAwB,YACtC,GAAI,CAACD,EACH,MAAM,IAAI,MAAM,uCAAuC,EAIzD,MAAO,EAAQA,EAAK,0BACtB,ECjBaE,EAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECoBvCC,EAAgB,SAA8B,aACzD,GAAI,CACF,MAAMP,EAAW,MAAMC,EAAwCK,EAAwB,CACrF,OAAQ,MAAA,CACT,EAED,IAAIJ,EAAAF,EAAS,SAAT,MAAAE,EAAiB,OACnB,MAAO,GAGT,MAAMM,IAAaC,GAAAJ,GAAAF,EAAAH,GAAA,YAAAA,EAAkB,OAAlB,YAAAG,EAAwB,WAAxB,YAAAE,EAAkC,YAAlC,YAAAI,EAA6C,QAAS,CAAA,EACzE,OAAO,MAAM,QAAQD,CAAS,GAAKA,EAAU,OAAS,CACxD,MAAgB,CACd,MAAO,EACT,CACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{FetchGraphQL as t}from"@dropins/tools/fetch-graphql.js";import{events as r}from"@dropins/tools/event-bus.js";const{setEndpoint:n,setFetchGraphQlHeader:h,removeFetchGraphQlHeader:c,setFetchGraphQlHeaders:p,fetchGraphQl:i,getConfig:m}=new t().getMethods(),f=e=>{throw e instanceof DOMException&&e.name==="AbortError"||r.emit("error",{source:"company",type:"network",error:e}),e};export{h as a,p as b,i as f,m as g,f as h,c as r,n as s};
|
|
4
|
+
//# sourceMappingURL=network-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-error.js","sources":["/@dropins/storefront-company-management/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-company-management/src/lib/network-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 * Handles network errors by emitting error events and re-throwing the error\n * A function which can be attached to fetchGraphQL to handle thrown errors in\n * a generic way.\n * \n * @param error - The error that occurred during network operations\n * @throws {Error} Re-throws the original error after emitting event\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"],"names":["setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","handleNetworkError","error","events"],"mappings":"oHAmBO,KAAM,CACX,YAAAA,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAC,EACA,UAAAC,CACF,EAAI,IAAIC,EAAA,EAAe,WAAA,ECAVC,EAAsBC,GAAiB,CAIlD,MAFEA,aAAiB,cAAgBA,EAAM,OAAS,cAIhDC,EAAO,KAAK,QAAS,CACnB,OAAQ,UACR,KAAM,UACN,MAAAD,CAAA,CACD,EAEGA,CACR"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{t as a}from"./validateCompanyEmail.js";import{f as d,h as l}from"./network-error.js";import{h as g}from"./fetch-error.js";const u=`
|
|
4
|
+
mutation CreateCompany($input: CompanyCreateInput!) {
|
|
5
|
+
createCompany(input: $input) {
|
|
6
|
+
company {
|
|
7
|
+
id
|
|
8
|
+
name
|
|
9
|
+
email
|
|
10
|
+
legal_name
|
|
11
|
+
vat_tax_id
|
|
12
|
+
reseller_id
|
|
13
|
+
legal_address {
|
|
14
|
+
street
|
|
15
|
+
city
|
|
16
|
+
region {
|
|
17
|
+
region_code
|
|
18
|
+
region
|
|
19
|
+
region_id
|
|
20
|
+
}
|
|
21
|
+
postcode
|
|
22
|
+
country_code
|
|
23
|
+
telephone
|
|
24
|
+
}
|
|
25
|
+
company_admin {
|
|
26
|
+
id
|
|
27
|
+
firstname
|
|
28
|
+
lastname
|
|
29
|
+
email
|
|
30
|
+
job_title
|
|
31
|
+
telephone
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`,p=e=>{var o,t,i;const r={};if(e.regionCode&&e.regionCode.trim())r.region_code=e.regionCode.trim(),e.regionId&&(r.region_id=typeof e.regionId=="string"?parseInt(e.regionId,10):e.regionId);else if(e.region&&typeof e.region=="string"&&e.region.includes(",")){const[n,c]=e.region.split(",");r.region_code=n.trim(),r.region_id=parseInt(c.trim(),10)}else if(e.region&&e.region.trim()){const n=e.region.trim();if(/^\d+$/.test(n))throw new Error("Region selection error: Missing region code. Please ensure regions are properly loaded.");r.region=n,r.region_code=n}if(!r.region_code)throw new Error("Region code is required. Please select a state/province or enter a region name.");return{company_name:e.companyName,company_email:e.companyEmail,legal_name:e.legalName,vat_tax_id:e.vatTaxId,reseller_id:e.resellerId,legal_address:{street:Array.isArray(e.street)?e.street.filter(n=>n&&n.trim()!==""):[e.street].filter(n=>n&&n.trim()!==""),city:e.city,region:r,postcode:e.postcode,country_id:e.countryCode,telephone:e.addressTelephone},company_admin:{email:e.adminEmail,firstname:((o=e.adminFirstname)==null?void 0:o.trim())||"",lastname:((t=e.adminLastname)==null?void 0:t.trim())||"",job_title:e.adminJobTitle,telephone:e.adminWorkTelephone,gender:e.adminGender?typeof e.adminGender=="string"?parseInt(e.adminGender,10):e.adminGender:void 0,custom_attributes:((i=e.adminCustomAttributes)==null?void 0:i.map(n=>({attribute_code:n.attribute_code,value:n.value})))||[]}}},T=async e=>{var r;try{const o=p(e),t=await d(u,{method:"POST",variables:{input:o}});return(r=t.errors)!=null&&r.length?{success:!1,errors:t.errors.map(n=>n.message)}:{success:!0,company:a(t)}}catch(o){return console.error("Failed to create company:",o),{success:!1,errors:["Failed to create company. Please try again."]}}},m=`
|
|
37
|
+
query getStoreConfig {
|
|
38
|
+
storeConfig {
|
|
39
|
+
default_country
|
|
40
|
+
store_code
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`,_="US",s={defaultCountry:_,storeCode:""},E=async()=>await d(m,{method:"GET"}).then(e=>{var r;return(r=e.errors)!=null&&r.length?g(e.errors):y(e)}).catch(l),y=e=>{var t;if(!((t=e==null?void 0:e.data)!=null&&t.storeConfig))return s;const{default_country:r,store_code:o}=e.data.storeConfig;return{defaultCountry:r||s.defaultCountry,storeCode:o||s.storeCode}};export{_ as D,s as S,T as c,E as g};
|
|
44
|
+
//# sourceMappingURL=transform-store-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-store-config.js","sources":["/@dropins/storefront-company-management/src/api/createCompany/graphql/createCompany.graphql.ts","/@dropins/storefront-company-management/src/data/transforms/company.ts","/@dropins/storefront-company-management/src/api/createCompany/createCompany.ts","/@dropins/storefront-company-management/src/api/getStoreConfig/graphql/getStoreConfig.graphql.ts","/@dropins/storefront-company-management/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-company-management/src/data/transforms/transform-store-config.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const CREATE_COMPANY_MUTATION = /* GraphQL */ `\n mutation CreateCompany($input: CompanyCreateInput!) {\n createCompany(input: $input) {\n company {\n id\n name\n email\n legal_name\n vat_tax_id\n reseller_id\n legal_address {\n street\n city\n region {\n region_code\n region\n region_id\n }\n postcode\n country_code\n telephone\n }\n company_admin {\n id\n firstname\n lastname\n email\n job_title\n telephone\n }\n }\n }\n }\n`;","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CompanyFormData } from '../models/company';\nimport { CompanyCreateInput } from '@/company-management/api/createCompany';\n\nexport const transformFormDataToCreateInput = (formData: CompanyFormData): CompanyCreateInput => {\n // Build region object - ensure we have at least one region field\n const regionInput: any = {};\n \n // Handle region data based on what we receive from the form\n if (formData.regionCode && formData.regionCode.trim()) {\n // We have regionCode (preferred path)\n regionInput.region_code = formData.regionCode.trim();\n if (formData.regionId) {\n regionInput.region_id = typeof formData.regionId === 'string' ? parseInt(formData.regionId, 10) : formData.regionId;\n }\n } else if (formData.region && typeof formData.region === 'string' && formData.region.includes(',')) {\n // Dropdown selection: parse \"AL,4\" format as fallback\n const [regionCode, regionId] = formData.region.split(',');\n regionInput.region_code = regionCode.trim();\n regionInput.region_id = parseInt(regionId.trim(), 10);\n } else if (formData.region && formData.region.trim()) {\n const regionValue = formData.region.trim();\n // Check if this is a numeric regionId (from dropdown) or text region name\n if (/^\\d+$/.test(regionValue)) {\n // This is likely a regionId from dropdown, but we only have the ID\n // We need both region_code and region_id for GraphQL, but we can't proceed without region_code\n throw new Error('Region selection error: Missing region code. Please ensure regions are properly loaded.');\n } else {\n // Text input: free-form region name (countries without predefined regions)\n regionInput.region = regionValue;\n regionInput.region_code = regionValue;\n }\n }\n \n // Ensure we have at least region_code (required by GraphQL)\n if (!regionInput.region_code) {\n throw new Error('Region code is required. Please select a state/province or enter a region name.');\n }\n\n return {\n company_name: formData.companyName,\n company_email: formData.companyEmail,\n legal_name: formData.legalName,\n vat_tax_id: formData.vatTaxId,\n reseller_id: formData.resellerId,\n legal_address: {\n street: Array.isArray(formData.street) \n ? formData.street.filter((line: string) => line && line.trim() !== '') // Remove empty lines\n : [formData.street].filter((line: string) => line && line.trim() !== ''), // Handle case where street is not an array\n city: formData.city,\n region: regionInput,\n postcode: formData.postcode,\n country_id: formData.countryCode,\n telephone: formData.addressTelephone,\n },\n company_admin: {\n email: formData.adminEmail,\n firstname: formData.adminFirstname?.trim() || '',\n lastname: formData.adminLastname?.trim() || '',\n job_title: formData.adminJobTitle,\n telephone: formData.adminWorkTelephone,\n gender: formData.adminGender ? (typeof formData.adminGender === 'string' ? parseInt(formData.adminGender, 10) : formData.adminGender) : undefined,\n custom_attributes: formData.adminCustomAttributes?.map(attr => ({\n attribute_code: attr.attribute_code,\n value: attr.value,\n })) || [],\n },\n };\n};","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/company-management/api/fetch-graphql';\nimport { CREATE_COMPANY_MUTATION } from './graphql/createCompany.graphql';\nimport { CompanyRegistrationModel } from '@/company-management/data/models/company';\nimport { transformFormDataToCreateInput } from '@/company-management/data/transforms/company';\nimport { transformCreateCompanyResponse } from '@/company-management/data/transforms/transform-company';\n\nexport interface CompanyCreateInput {\n company_name: string;\n company_email: string;\n legal_name?: string;\n vat_tax_id?: string;\n reseller_id?: string;\n legal_address: {\n street: string[];\n city: string;\n region: {\n region_code: string;\n region?: string;\n region_id?: number;\n };\n postcode: string;\n country_id: string;\n telephone?: string;\n };\n company_admin: {\n email: string;\n firstname: string;\n lastname: string;\n job_title?: string;\n telephone?: string;\n gender?: number;\n custom_attributes?: Array<{\n attribute_code: string;\n value: string;\n }>;\n };\n}\n\n\nexport const createCompany = async (formData: any): Promise<{ success: boolean; company?: CompanyRegistrationModel; errors?: string[] }> => {\n try {\n const input = transformFormDataToCreateInput(formData);\n const response = await fetchGraphQl(CREATE_COMPANY_MUTATION, {\n method: 'POST',\n variables: { input },\n });\n\n if (response.errors?.length) {\n return {\n success: false,\n errors: response.errors.map((error: any) => error.message),\n };\n }\n\n // Transform the GraphQL response using the dedicated transformer\n const transformedCompany = transformCreateCompanyResponse(response);\n\n return {\n success: true,\n company: transformedCompany,\n };\n } catch (error) {\n console.error('Failed to create company:', error);\n return {\n success: false,\n errors: ['Failed to create company. Please try again.'],\n };\n }\n};","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_STORE_CONFIG_QUERY = /* GraphQL */ `\n query getStoreConfig {\n storeConfig {\n default_country\n store_code\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_STORE_CONFIG_QUERY } from './graphql/getStoreConfig.graphql';\nimport { handleNetworkError } from '@/company-management/lib/network-error';\nimport { handleFetchError } from '@/company-management/lib/fetch-error';\nimport { GetStoreConfigResponse, StoreConfigModel } from '@/company-management/types';\nimport { transformStoreConfig } from '@/company-management/data/transforms';\n\nexport const DEFAULT_COUNTRY = 'US';\n\nexport const STORE_CONFIG_DEFAULTS: StoreConfigModel = {\n defaultCountry: DEFAULT_COUNTRY,\n storeCode: '',\n};\n\nexport const getStoreConfig = async (): Promise<StoreConfigModel> => {\n return await fetchGraphQl(GET_STORE_CONFIG_QUERY, {\n method: 'GET',\n })\n .then((response: GetStoreConfigResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n return transformStoreConfig(response);\n })\n .catch(handleNetworkError);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { GetStoreConfigResponse, StoreConfigModel } from '@/company-management/types';\nimport { STORE_CONFIG_DEFAULTS } from '@/company-management/api/getStoreConfig/getStoreConfig';\n\nexport const transformStoreConfig = (\n response: GetStoreConfigResponse\n): StoreConfigModel => {\n if (!response?.data?.storeConfig) return STORE_CONFIG_DEFAULTS;\n\n const { default_country, store_code } = response.data.storeConfig;\n\n return {\n defaultCountry: default_country || STORE_CONFIG_DEFAULTS.defaultCountry,\n storeCode: store_code || STORE_CONFIG_DEFAULTS.storeCode,\n };\n};\n"],"names":["CREATE_COMPANY_MUTATION","transformFormDataToCreateInput","formData","regionInput","regionCode","regionId","regionValue","line","_a","_b","_c","attr","createCompany","input","response","fetchGraphQl","error","transformCreateCompanyResponse","GET_STORE_CONFIG_QUERY","DEFAULT_COUNTRY","STORE_CONFIG_DEFAULTS","getStoreConfig","handleFetchError","transformStoreConfig","handleNetworkError","default_country","store_code"],"mappings":"iIAiBO,MAAMA,EAAwC;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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECGxCC,EAAkCC,GAAkD,WAE/F,MAAMC,EAAmB,CAAA,EAGzB,GAAID,EAAS,YAAcA,EAAS,WAAW,OAE7CC,EAAY,YAAcD,EAAS,WAAW,KAAA,EAC1CA,EAAS,WACXC,EAAY,UAAY,OAAOD,EAAS,UAAa,SAAW,SAASA,EAAS,SAAU,EAAE,EAAIA,EAAS,kBAEpGA,EAAS,QAAU,OAAOA,EAAS,QAAW,UAAYA,EAAS,OAAO,SAAS,GAAG,EAAG,CAElG,KAAM,CAACE,EAAYC,CAAQ,EAAIH,EAAS,OAAO,MAAM,GAAG,EACxDC,EAAY,YAAcC,EAAW,KAAA,EACrCD,EAAY,UAAY,SAASE,EAAS,KAAA,EAAQ,EAAE,CACtD,SAAWH,EAAS,QAAUA,EAAS,OAAO,OAAQ,CACpD,MAAMI,EAAcJ,EAAS,OA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,OAAQM,EAAS,OAAO,IAAKE,GAAeA,EAAM,OAAO,CAAA,EAOtD,CACL,QAAS,GACT,QAJyBC,EAA+BH,CAAQ,CAIvD,CAEb,OAASE,EAAO,CACd,eAAQ,MAAM,4BAA6BA,CAAK,EACzC,CACL,QAAS,GACT,OAAQ,CAAC,6CAA6C,CAAA,CAE1D,CACF,ECpEaE,EAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECOvCC,EAAkB,KAElBC,EAA0C,CACrD,eAAgBD,EAChB,UAAW,EACb,EAEaE,EAAiB,SACrB,MAAMN,EAAaG,EAAwB,CAChD,OAAQ,KAAA,CACT,EACE,KAAMJ,GAAqC,OAC1C,OAAIN,EAAAM,EAAS,SAAT,MAAAN,EAAiB,OAAec,EAAiBR,EAAS,MAAM,EAE7DS,EAAqBT,CAAQ,CACtC,CAAC,EACA,MAAMU,CAAkB,ECpBhBD,EACXT,GACqB,OACrB,GAAI,GAACN,EAAAM,GAAA,YAAAA,EAAU,OAAV,MAAAN,EAAgB,aAAa,OAAOY,EAEzC,KAAM,CAAE,gBAAAK,EAAiB,WAAAC,CAAA,EAAeZ,EAAS,KAAK,YAEtD,MAAO,CACL,eAAgBW,GAAmBL,EAAsB,eACzD,UAAWM,GAAcN,EAAsB,SAAA,CAEnD"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{f as _}from"./fetchUserPermissions.js";import{f as m,h as A}from"./network-error.js";import{h as c}from"./fetch-error.js";import{a as C}from"./validateCompanyEmail.js";const f=`
|
|
4
|
+
fragment COMPANY_LEGAL_ADDRESS_FRAGMENT on CompanyLegalAddress {
|
|
5
|
+
street
|
|
6
|
+
city
|
|
7
|
+
region {
|
|
8
|
+
region
|
|
9
|
+
region_code
|
|
10
|
+
region_id
|
|
11
|
+
}
|
|
12
|
+
country_code
|
|
13
|
+
postcode
|
|
14
|
+
telephone
|
|
15
|
+
}
|
|
16
|
+
`,h=`
|
|
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
|
+
id
|
|
34
|
+
firstname
|
|
35
|
+
lastname
|
|
36
|
+
email
|
|
37
|
+
job_title
|
|
38
|
+
}
|
|
39
|
+
`,y=e=>{const r=e.has("Magento_Company::view_account"),s=e.has("Magento_Company::view_address"),a=e.has("Magento_Company::contacts"),o=e.has("Magento_Company::payment_information"),l=e.has("Magento_Company::shipping_information"),t=[],d=[];return r&&(t.push("...COMPANY_BASIC_INFO_FRAGMENT"),d.push(h)),s&&(t.push("legal_address { ...COMPANY_LEGAL_ADDRESS_FRAGMENT }"),d.push(f)),a&&(t.push("company_admin { ...COMPANY_ADMIN_FRAGMENT }"),t.push("sales_representative { ...COMPANY_SALES_REPRESENTATIVE_FRAGMENT }"),d.push(M),d.push(N)),o&&t.push("available_payment_methods { code title }"),l&&t.push("available_shipping_methods { code title }"),{fields:t,usedFragments:d}},E=e=>{const{fields:r,usedFragments:s}=y(e);return r.length===0?`
|
|
40
|
+
query GET_COMPANY_DYNAMIC {
|
|
41
|
+
company { __typename }
|
|
42
|
+
}
|
|
43
|
+
`:`${`
|
|
44
|
+
query GET_COMPANY_DYNAMIC {
|
|
45
|
+
company {
|
|
46
|
+
${r.join(`
|
|
47
|
+
`)}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`}
|
|
51
|
+
${s.join(`
|
|
52
|
+
`)}`},p=e=>{const{fields:r,usedFragments:s}=y(e);return r.length===0?`
|
|
53
|
+
mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {
|
|
54
|
+
updateCompany(input: $input) {
|
|
55
|
+
company { __typename }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`:`${`
|
|
59
|
+
mutation UPDATE_COMPANY_DYNAMIC($input: CompanyUpdateInput!) {
|
|
60
|
+
updateCompany(input: $input) {
|
|
61
|
+
company {
|
|
62
|
+
${r.join(`
|
|
63
|
+
`)}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`}
|
|
68
|
+
${s.join(`
|
|
69
|
+
`)}`};async function O(){return await _().then(async({allowedIds:e,roleResponse:r})=>{var t,d,i;const s=E(e),a=await m(s,{method:"GET",cache:"no-cache"});if((t=a.errors)!=null&&t.length)return c(a.errors);const o=(d=a==null?void 0:a.data)==null?void 0:d.company;return o&&Object.keys(o).some(g=>g!=="__typename")?(a!=null&&a.data&&((i=r==null?void 0:r.data)!=null&&i.customer)&&(a.data.customer=r.data.customer),C(a)):null}).catch(A)}const Y=async e=>await _().then(async({allowedIds:r,roleResponse:s})=>{var t,d;const a=p(r),o={};if(e.name!==void 0&&(o.company_name=e.name),e.email!==void 0&&(o.company_email=e.email),e.legalName!==void 0&&(o.legal_name=e.legalName),e.vatTaxId!==void 0&&(o.vat_tax_id=e.vatTaxId),e.resellerId!==void 0&&(o.reseller_id=e.resellerId),e.legalAddress!==void 0&&r.has("Magento_Company::edit_address")){let i;Array.isArray(e.legalAddress.street)?(i=[...e.legalAddress.street],e.legalAddress.street2&&i.push(e.legalAddress.street2)):i=[e.legalAddress.street,e.legalAddress.street2].filter(n=>typeof n=="string"&&n.trim().length>0),i=i.filter(n=>n&&typeof n=="string"&&n.trim().length>0);let g;if(e.legalAddress.region&&typeof e.legalAddress.region=="object"){const n=e.legalAddress.region;n.region===n.regionCode?g={region:n.region,region_code:n.regionCode,region_id:0}:g={region:n.region,region_code:n.regionCode}}else e.legalAddress.regionCode&&e.legalAddress.region!==e.legalAddress.regionCode?g={region:e.legalAddress.region||e.legalAddress.regionCode,region_code:e.legalAddress.regionCode}:e.legalAddress.region&&(g={region:e.legalAddress.region,region_code:e.legalAddress.region,region_id:0});o.legal_address={street:i,city:e.legalAddress.city,region:g,country_id:e.legalAddress.countryCode,postcode:e.legalAddress.postcode,telephone:e.legalAddress.telephone}}const l=await m(a,{method:"POST",variables:{input:o}});return(t=l.errors)!=null&&t.length?c(l.errors):(l.data.customer=(d=s==null?void 0:s.data)==null?void 0:d.customer,C(l))}).catch(A);export{O as g,Y as u};
|
|
70
|
+
//# sourceMappingURL=updateCompany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCompany.js","sources":["/@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"],"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 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 id\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 { fetchGraphQl } from '../fetch-graphql';\nimport { fetchUserPermissions } from '../fetchUserPermissions/fetchUserPermissions';\nimport { buildCompanyQuery } from '../graphql/buildCompanyQueries';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { CompanyModel } from '../../data/models';\nimport { transformCompany } from '../../data/transforms';\nimport { getCompanyResponse } from '../../types/api/getCompany.types';\n\n/**\n * Retrieves company information with permissions-aware field selection\n * Only returns fields that the current user has permission to view\n * \n * @returns Promise resolving to CompanyModel or null if no company data available\n * @throws {Error} When network errors or GraphQL errors occur\n */\nexport async function getCompany(): 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 = 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 if (companyResponse?.data && roleResponse?.data?.customer) {\n companyResponse.data.customer = roleResponse.data.customer;\n }\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/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"],"names":["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","fetchUserPermissions","allowedIds","roleResponse","GET_COMPANY_DYNAMIC","companyResponse","fetchGraphQl","_a","handleFetchError","companyNode","_b","k","_c","transformCompany","handleNetworkError","updateCompany","input","UPDATE_COMPANY_DYNAMIC","transformedInput","streetArray","s","street","regionValue","regionObj","response"],"mappings":"+KAgBO,MAAMA,EAA+C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAe/CC,EAA4C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAW5CC,EAAsD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQtDC,EAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECxB9CC,EAAsBC,GAAwE,CAClG,MAAMC,EAAcD,EAAQ,IAAI,+BAA+B,EACzDE,EAAcF,EAAQ,IAAI,+BAA+B,EACzDG,EAAeH,EAAQ,IAAI,2BAA2B,EACtDI,EAAcJ,EAAQ,IAAI,sCAAsC,EAChEK,EAAeL,EAAQ,IAAI,uCAAuC,EAElEM,EAAmB,CAAA,EACnBC,EAA0B,CAAA,EAEhC,OAAIN,IACFK,EAAO,KAAK,gCAAgC,EAC5CC,EAAc,KAAKX,CAA2B,GAE5CM,IACFI,EAAO,KAAK,qDAAqD,EACjEC,EAAc,KAAKZ,CAA8B,GAE/CQ,IACFG,EAAO,KAAK,6CAA6C,EACzDA,EAA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,OAClB,YAAaA,EAAU,UAAA,CAG7B,MAAWP,EAAM,aAAa,YAAcA,EAAM,aAAa,SAAWA,EAAM,aAAa,WAE3FM,EAAc,CACZ,OAAQN,EAAM,aAAa,QAAUA,EAAM,aAAa,WACxD,YAAaA,EAAM,aAAa,UAAA,EAEzBA,EAAM,aAAa,SAE5BM,EAAc,CACZ,OAAQN,EAAM,aAAa,OAC3B,YAAaA,EAAM,aAAa,OAChC,UAAW,CAAA,GAIfE,EAAiB,cAAgB,CAC/B,OAAQC,EACR,KAAMH,EAAM,aAAa,KACzB,OAAQM,EACR,WAAYN,EAAM,aAAa,YAC/B,SAAUA,EAAM,aAAa,SAC7B,UAAWA,EAAM,aAAa,SAAA,CAElC,CAGA,MAAMQ,EAAkC,MAAMlB,EAAaW,EAAwB,CACjF,OAAQ,OACR,UAAW,CAAE,MAAOC,CAAA,CAAiB,CACtC,EAED,OAAIX,EAAAiB,EAAS,SAAT,MAAAjB,EAAiB,OAAeC,EAAiBgB,EAAS,MAAM,GAGnEA,EAAiB,KAAK,UAAWd,EAAAP,GAAA,YAAAA,EAAc,OAAd,YAAAO,EAAoB,SAE/CG,EAAiBW,CAAQ,EAClC,CAAC,EACA,MAAMV,CAAkB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{f as o,h as u}from"./network-error.js";import{h as i}from"./fetch-error.js";const d=`
|
|
4
|
+
mutation createCompanyTeam($input: CompanyTeamCreateInput!) {
|
|
5
|
+
createCompanyTeam(input: $input) { __typename team { id structure_id name } }
|
|
6
|
+
}
|
|
7
|
+
`;async function f(a){const n={name:a.name,description:a.description,target_id:a.targetId};return await o(d,{variables:{input:n}}).then(e=>{var r,m,p;if((r=e.errors)!=null&&r.length)return i(e.errors);const t=(p=(m=e==null?void 0:e.data)==null?void 0:m.createCompanyTeam)==null?void 0:p.team;return t?{id:t.id,structureId:t.structure_id,name:t.name}:null}).catch(u)}const c=`
|
|
8
|
+
mutation deleteCompanyTeam($id: ID!) {
|
|
9
|
+
deleteCompanyTeam(id: $id) { __typename }
|
|
10
|
+
}
|
|
11
|
+
`;async function E(a){return await o(c,{variables:{id:a}}).then(n=>{var e,t;return(e=n.errors)!=null&&e.length?i(n.errors):!!((t=n==null?void 0:n.data)!=null&&t.deleteCompanyTeam)}).catch(u)}function y(a){return a.items.map(t=>({structureId:t.entity.structure_id,parentStructureId:t.parent_id||null,label:t.entity.__typename==="CompanyTeam"?t.entity.name||"":`${t.entity.firstname||""} ${t.entity.lastname||""}`.trim(),type:t.entity.__typename==="CompanyTeam"?"team":"user",entityId:(t.entity.__typename==="CompanyTeam"?t.entity.companyTeamId:t.entity.customerId)||"",description:t.entity.__typename==="CompanyTeam"&&t.entity.description||null})).map(t=>{const r=t.parentStructureId||null,m=!r||r==="MA=="?null:r;return{id:t.structureId,parentId:m,label:t.label,type:t.type,entityId:t.entityId,description:t.description}})}const s=a=>{if(!a)throw new Error("Invalid response: missing team data");return{id:a.id,name:a.name,description:a.description}},T=`
|
|
12
|
+
query getCompanyStructure {
|
|
13
|
+
company {
|
|
14
|
+
structure {
|
|
15
|
+
items {
|
|
16
|
+
id
|
|
17
|
+
parent_id
|
|
18
|
+
entity {
|
|
19
|
+
__typename
|
|
20
|
+
... on CompanyTeam { companyTeamId: id structure_id name description }
|
|
21
|
+
... on Customer { customerId: id structure_id firstname lastname }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`;async function g(){return await o(T,{method:"GET",cache:"no-cache"}).then(a=>{var e;if((e=a.errors)!=null&&e.length)return i(a.errors);const n=a.data.company.structure;return y(n)}).catch(u)}const l=`
|
|
28
|
+
query getCompanyTeam($id: ID!) {
|
|
29
|
+
company { team(id: $id) { id name description } }
|
|
30
|
+
}
|
|
31
|
+
`;async function A(a){return await o(l,{variables:{id:a}}).then(n=>{var t,r,m;if((t=n.errors)!=null&&t.length)return i(n.errors);const e=(m=(r=n==null?void 0:n.data)==null?void 0:r.company)==null?void 0:m.team;return e?s(e):null}).catch(u)}const _=`
|
|
32
|
+
mutation updateCompanyStructure($treeId: ID!, $parentTreeId: ID!) {
|
|
33
|
+
updateCompanyStructure(input: { tree_id: $treeId, parent_tree_id: $parentTreeId }) {
|
|
34
|
+
__typename
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`;async function $(a){const n={treeId:a.id,parentTreeId:a.parentId};return await o(_,{variables:n}).then(e=>{var t,r;return(t=e.errors)!=null&&t.length?i(e.errors):!!((r=e==null?void 0:e.data)!=null&&r.updateCompanyStructure)}).catch(u)}const C=`
|
|
38
|
+
mutation updateCompanyTeam($input: CompanyTeamUpdateInput!) {
|
|
39
|
+
updateCompanyTeam(input: $input) { __typename team { id name } }
|
|
40
|
+
}
|
|
41
|
+
`;async function M(a){const n={id:a.id,name:a.name,description:a.description};return await o(C,{variables:{input:n}}).then(e=>{var t,r,m,p;return(t=e.errors)!=null&&t.length?i(e.errors):!!((p=(m=(r=e==null?void 0:e.data)==null?void 0:r.updateCompanyTeam)==null?void 0:m.team)!=null&&p.id)}).catch(u)}export{g as a,$ as b,f as c,E as d,A as g,M as u};
|
|
42
|
+
//# sourceMappingURL=updateCompanyTeam.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCompanyTeam.js","sources":["/@dropins/storefront-company-management/src/api/createCompanyTeam/graphql/createCompanyTeam.graphql.ts","/@dropins/storefront-company-management/src/api/createCompanyTeam/createCompanyTeam.ts","/@dropins/storefront-company-management/src/api/deleteCompanyTeam/graphql/deleteCompanyTeam.graphql.ts","/@dropins/storefront-company-management/src/api/deleteCompanyTeam/deleteCompanyTeam.ts","/@dropins/storefront-company-management/src/data/transforms/transform-company-structure.ts","/@dropins/storefront-company-management/src/data/transforms/transform-company-team.ts","/@dropins/storefront-company-management/src/api/getCompanyStructure/graphql/getCompanyStructure.graphql.ts","/@dropins/storefront-company-management/src/api/getCompanyStructure/getCompanyStructure.ts","/@dropins/storefront-company-management/src/api/getCompanyTeam/graphql/getCompanyTeam.graphql.ts","/@dropins/storefront-company-management/src/api/getCompanyTeam/getCompanyTeam.ts","/@dropins/storefront-company-management/src/api/updateCompanyStructure/graphql/updateCompanyStructure.graphql.ts","/@dropins/storefront-company-management/src/api/updateCompanyStructure/updateCompanyStructure.ts","/@dropins/storefront-company-management/src/api/updateCompanyTeam/graphql/updateCompanyTeam.graphql.ts","/@dropins/storefront-company-management/src/api/updateCompanyTeam/updateCompanyTeam.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const CREATE_COMPANY_TEAM = /* GraphQL */ `\n mutation createCompanyTeam($input: CompanyTeamCreateInput!) {\n createCompanyTeam(input: $input) { __typename team { id structure_id name } }\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 { handleNetworkError } from '../../lib/network-error';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { CreateCompanyTeamInput, CreateCompanyTeamResult } from '../../types/api/createCompanyTeam.types';\nimport { CREATE_COMPANY_TEAM } from './graphql/createCompanyTeam.graphql';\n\n/**\n * Creates a new company team with the provided information\n * \n * @param input - Team information including name, description, and target location\n * @returns Promise resolving to created team result or null if creation failed\n * @throws {Error} When network errors or GraphQL errors occur\n */\nexport async function createCompanyTeam(input: CreateCompanyTeamInput): Promise<CreateCompanyTeamResult | null> {\n // Transform camelCase input to GraphQL snake_case format\n const transformedInput = {\n name: input.name,\n description: input.description,\n target_id: input.targetId,\n };\n\n return await fetchGraphQl<{ createCompanyTeam?: { team?: { id: string; structure_id?: string; name: string } } }>(CREATE_COMPANY_TEAM, { variables: { input: transformedInput } })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n const team = res?.data?.createCompanyTeam?.team;\n if (!team) return null;\n \n // Transform GraphQL snake_case response to camelCase\n return {\n id: team.id,\n structureId: team.structure_id,\n name: team.name,\n };\n })\n .catch(handleNetworkError);\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const DELETE_COMPANY_TEAM = /* GraphQL */ `\n mutation deleteCompanyTeam($id: ID!) {\n deleteCompanyTeam(id: $id) { __typename }\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 { handleNetworkError, handleFetchError } from '@/company-management/lib';\nimport { DELETE_COMPANY_TEAM } from './graphql/deleteCompanyTeam.graphql';\n\n/**\n * Deletes a company team by their ID\n * \n * @param id - The ID of the company team to delete (base64 encoded UID from GraphQL)\n * @returns Promise resolving to boolean indicating success\n * @throws {Error} When network errors or GraphQL errors occur\n */\nexport async function deleteCompanyTeam(id: string): Promise<boolean> {\n return await fetchGraphQl<{ deleteCompanyTeam?: { __typename: string } }>(DELETE_COMPANY_TEAM, { variables: { id } })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n return !!res?.data?.deleteCompanyTeam;\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 type { CompanyStructureNode } from '../models/company-structure';\n\n// Internal GraphQL response interface (snake_case for direct GraphQL mapping)\ninterface CompanyStructureResponse {\n items: CompanyStructureItemResponse[];\n}\n\ninterface CompanyStructureItemResponse {\n id: string;\n parent_id: string | null;\n entity: {\n __typename: 'CompanyTeam' | 'Customer';\n companyTeamId?: string;\n customerId?: string;\n structure_id: string;\n firstname?: string;\n lastname?: string;\n name?: string;\n description?: string | null;\n };\n}\n\nexport function transformCompanyStructure(response: CompanyStructureResponse): CompanyStructureNode[] {\n const typed = response.items.map((i) => ({\n structureId: i.entity.structure_id,\n parentStructureId: i.parent_id || null,\n label: i.entity.__typename === 'CompanyTeam' ? (i.entity.name || '') : `${i.entity.firstname || ''} ${i.entity.lastname || ''}`.trim(),\n type: i.entity.__typename === 'CompanyTeam' ? ('team' as const) : ('user' as const),\n entityId: (i.entity.__typename === 'CompanyTeam' ? i.entity.companyTeamId : i.entity.customerId) || '',\n description: i.entity.__typename === 'CompanyTeam' ? i.entity.description || null : null,\n }));\n\n const mapped: CompanyStructureNode[] = typed.map((t) => {\n const parentRaw = t.parentStructureId || null;\n const parentTyped = !parentRaw || parentRaw === 'MA==' ? null : parentRaw;\n return { id: t.structureId, parentId: parentTyped, label: t.label, type: t.type, entityId: t.entityId, description: t.description };\n });\n return mapped;\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CompanyTeamModel } from '../models/company-team';\n\n// GraphQL response interface (snake_case for direct GraphQL mapping)\ninterface CompanyTeamResponse {\n id: string;\n name: string;\n description?: string | null;\n}\n\nexport const transformCompanyTeam = (response: CompanyTeamResponse): CompanyTeamModel => {\n // Validate response structure\n if (!response) {\n throw new Error('Invalid response: missing team data');\n }\n\n // Transform GraphQL snake_case response to camelCase model\n return {\n id: response.id,\n name: response.name,\n description: response.description,\n // Extended properties for UI and business logic\n // Note: memberCount should be calculated from structure data in components when needed\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_COMPANY_STRUCTURE = /* GraphQL */ `\n query getCompanyStructure {\n company {\n structure {\n items {\n id\n parent_id\n entity {\n __typename\n ... on CompanyTeam { companyTeamId: id structure_id name description }\n ... on Customer { customerId: id structure_id firstname lastname }\n }\n }\n }\n }\n }\n`;\n\n\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { CompanyStructureNode } from '../../data/models';\nimport { transformCompanyStructure } from '../../data/transforms';\nimport { CompanyStructureResponse } from '../../types/api/getCompanyStructure.types';\nimport { GET_COMPANY_STRUCTURE } from './graphql/getCompanyStructure.graphql';\n\n/**\n * Retrieves the company organizational structure as a tree of nodes\n * \n * @returns Promise resolving to array of CompanyStructureNode representing the company hierarchy\n * @throws {Error} When network errors or GraphQL errors occur\n */\nexport async function getCompanyStructure(): Promise<CompanyStructureNode[]> {\n return await fetchGraphQl<{ company: { structure: CompanyStructureResponse } }>(GET_COMPANY_STRUCTURE, { method: 'GET', cache: 'no-cache' })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n const structure = res.data.company.structure;\n \n // Use transformer to convert GraphQL response to model\n return transformCompanyStructure(structure);\n })\n .catch(handleNetworkError);\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_COMPANY_TEAM = /* GraphQL */ `\n query getCompanyTeam($id: ID!) {\n company { team(id: $id) { id name description } }\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 { handleNetworkError, handleFetchError } from '@/company-management/lib';\nimport { CompanyTeamModel } from '../../data/models';\nimport { transformCompanyTeam } from '../../data/transforms';\nimport { GET_COMPANY_TEAM } from './graphql/getCompanyTeam.graphql';\n\n/**\n * Retrieves a specific company team by their ID\n * \n * @param id - The ID of the company team to retrieve (base64 encoded UID from GraphQL)\n * @returns Promise resolving to CompanyTeamModel or null if team not found\n * @throws {Error} When network errors or GraphQL errors occur\n */\nexport async function getCompanyTeam(id: string): Promise<CompanyTeamModel | null> {\n return await fetchGraphQl<{ company: { team?: { id: string; name: string; description?: string | null } } }>(GET_COMPANY_TEAM, { variables: { id } })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n const team = res?.data?.company?.team;\n if (!team) return null;\n \n // Pure data transformation (no permissions)\n return transformCompanyTeam(team);\n })\n .catch(handleNetworkError);\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const UPDATE_COMPANY_STRUCTURE = /* GraphQL */ `\n mutation updateCompanyStructure($treeId: ID!, $parentTreeId: ID!) {\n updateCompanyStructure(input: { tree_id: $treeId, parent_tree_id: $parentTreeId }) {\n __typename\n }\n }\n`;\n\n\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { handleFetchError } from '../../lib/fetch-error';\nimport { UpdateCompanyStructureInput } from '../../types/api/updateCompanyStructure.types';\nimport { UPDATE_COMPANY_STRUCTURE } from './graphql/updateCompanyStructure.graphql';\n\n/**\n * Updates the company structure by moving a node to a new parent\n * \n * @param input - Object containing the node ID and new parent ID\n * @returns Promise resolving to boolean indicating success\n * @throws {Error} When network errors or GraphQL errors occur\n */\nexport async function updateCompanyStructure(input: UpdateCompanyStructureInput): Promise<boolean> {\n // Transform camelCase input to GraphQL snake_case format\n const transformedInput = {\n treeId: input.id,\n parentTreeId: input.parentId,\n };\n\n return await fetchGraphQl<{ updateCompanyStructure?: { __typename: string } }>(UPDATE_COMPANY_STRUCTURE, {\n variables: transformedInput,\n })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n return !!res?.data?.updateCompanyStructure;\n })\n .catch(handleNetworkError);\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const UPDATE_COMPANY_TEAM = /* GraphQL */ `\n mutation updateCompanyTeam($input: CompanyTeamUpdateInput!) {\n updateCompanyTeam(input: $input) { __typename team { id name } }\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 { handleNetworkError, handleFetchError } from '@/company-management/lib';\nimport { UpdateCompanyTeamInput } from '../../types/api/updateCompanyTeam.types';\nimport { UPDATE_COMPANY_TEAM } from './graphql/updateCompanyTeam.graphql';\n\n/**\n * Updates an existing company team with the provided information\n * \n * @param input - Team information including ID (base64 encoded UID) and fields to update\n * @returns Promise resolving to boolean indicating success\n * @throws {Error} When network errors or GraphQL errors occur\n */\nexport async function updateCompanyTeam(input: UpdateCompanyTeamInput): Promise<boolean> {\n // Transform camelCase input to GraphQL snake_case format\n const transformedInput = {\n id: input.id,\n name: input.name,\n description: input.description,\n };\n\n return await fetchGraphQl<{ updateCompanyTeam?: { team?: { id: string } } }>(UPDATE_COMPANY_TEAM, { variables: { input: transformedInput } })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n return !!res?.data?.updateCompanyTeam?.team?.id;\n })\n .catch(handleNetworkError);\n}\n"],"names":["CREATE_COMPANY_TEAM","createCompanyTeam","input","transformedInput","fetchGraphQl","res","_a","handleFetchError","team","_c","_b","handleNetworkError","DELETE_COMPANY_TEAM","deleteCompanyTeam","id","transformCompanyStructure","response","i","parentRaw","parentTyped","transformCompanyTeam","GET_COMPANY_STRUCTURE","getCompanyStructure","structure","GET_COMPANY_TEAM","getCompanyTeam","UPDATE_COMPANY_STRUCTURE","updateCompanyStructure","UPDATE_COMPANY_TEAM","updateCompanyTeam","_d"],"mappings":"mFAiBO,MAAMA,EAAoC;AAAA;AAAA;AAAA;AAAA,ECYjD,eAAsBC,EAAkBC,EAAwE,CAE9G,MAAMC,EAAmB,CACvB,KAAMD,EAAM,KACZ,YAAaA,EAAM,YACnB,UAAWA,EAAM,QAAA,EAGnB,OAAO,MAAME,EAAqGJ,EAAqB,CAAE,UAAW,CAAE,MAAOG,EAAiB,CAAG,EAC9K,KAAME,GAAQ,WACb,IAAIC,EAAAD,EAAI,SAAJ,MAAAC,EAAY,OAAQ,OAAOC,EAAiBF,EAAI,MAAM,EAC1D,MAAMG,GAAOC,GAAAC,EAAAL,GAAA,YAAAA,EAAK,OAAL,YAAAK,EAAW,oBAAX,YAAAD,EAA8B,KAC3C,OAAKD,EAGE,CACL,GAAIA,EAAK,GACT,YAAaA,EAAK,aAClB,KAAMA,EAAK,IAAA,EANK,IAQpB,CAAC,EACA,MAAMG,CAAkB,CAC7B,CClCO,MAAMC,EAAoC;AAAA;AAAA;AAAA;AAAA,ECUjD,eAAsBC,EAAkBC,EAA8B,CACpE,OAAO,MAAMV,EAA6DQ,EAAqB,CAAE,UAAW,CAAE,GAAAE,CAAA,EAAM,EACjH,KAAMT,GAAQ,SACb,OAAIC,EAAAD,EAAI,SAAJ,MAAAC,EAAY,OAAeC,EAAiBF,EAAI,MAAM,EACnD,CAAC,GAACK,EAAAL,GAAA,YAAAA,EAAK,OAAL,MAAAK,EAAW,kBACtB,CAAC,EACA,MAAMC,CAAkB,CAC7B,CCIO,SAASI,EAA0BC,EAA4D,CAepG,OAdcA,EAAS,MAAM,IAAKC,IA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AW,oBAAX,YAAAD,EAA8B,OAA9B,MAAAqB,EAAoC,GAC/C,CAAC,EACA,MAAMnB,CAAkB,CAC7B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{h as o}from"./fetch-error.js";import{f as l,h as m}from"./network-error.js";import{i as u}from"./company-permissions.js";const c=`
|
|
4
|
+
mutation createCompanyUser($input: CompanyUserCreateInput!) {
|
|
5
|
+
createCompanyUser(input: $input) { __typename user { id structure_id email firstname lastname } }
|
|
6
|
+
}
|
|
7
|
+
`;async function E(a){const t={email:a.email,firstname:a.firstName,lastname:a.lastName,job_title:a.jobTitle,telephone:a.telephone,role_id:a.roleId,status:a.status,target_id:a.targetId};return await l(c,{variables:{input:t}}).then(e=>{var n,i,s;if((n=e.errors)!=null&&n.length)return o(e.errors);const r=(s=(i=e==null?void 0:e.data)==null?void 0:i.createCompanyUser)==null?void 0:s.user;return r?{id:r.id,structureId:r.structure_id}:null}).catch(m)}const d=`
|
|
8
|
+
mutation DELETE_COMPANY_USER($id: ID!) {
|
|
9
|
+
deleteCompanyUserV2(id: $id) {
|
|
10
|
+
success
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
`,A=async a=>{var r,n;const{id:t}=a;if(!t)throw new Error("User ID is required to delete a company user");const e=await l(d,{method:"POST",cache:"no-cache",variables:{id:t}}).catch(m);return(r=e.errors)!=null&&r.length&&o(e.errors),(n=e.data)!=null&&n.deleteCompanyUserV2?{success:e.data.deleteCompanyUserV2.success}:{success:!1}},p=a=>{if(!a)throw new Error("Invalid response: missing user data");return{id:a.id,email:a.email,firstName:a.firstname,lastName:a.lastname,jobTitle:a.job_title,telephone:a.telephone,status:a.status,role:a.role,isCompanyAdmin:u(a.role)}},y=`
|
|
14
|
+
query getCompanyUser($id: ID!) {
|
|
15
|
+
company {
|
|
16
|
+
user(id: $id) {
|
|
17
|
+
id
|
|
18
|
+
email
|
|
19
|
+
firstname
|
|
20
|
+
lastname
|
|
21
|
+
job_title
|
|
22
|
+
telephone
|
|
23
|
+
status
|
|
24
|
+
role { id name }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;async function b(a){return await l(y,{variables:{id:a}}).then(t=>{var r,n,i;if((r=t.errors)!=null&&r.length)return o(t.errors);const e=(i=(n=t==null?void 0:t.data)==null?void 0:n.company)==null?void 0:i.user;return e?p(e):null}).catch(m)}const h=`
|
|
29
|
+
query isCompanyUserEmailAvailable($email: String!) {
|
|
30
|
+
isCompanyUserEmailAvailable(email: $email) { is_email_available }
|
|
31
|
+
}
|
|
32
|
+
`;async function I(a){return await l(h,{variables:{email:a}}).then(t=>{var e,r,n;return(e=t.errors)!=null&&e.length?o(t.errors):((n=(r=t==null?void 0:t.data)==null?void 0:r.isCompanyUserEmailAvailable)==null?void 0:n.is_email_available)??null}).catch(m)}const _=`
|
|
33
|
+
mutation updateCompanyUser($input: CompanyUserUpdateInput!) {
|
|
34
|
+
updateCompanyUser(input: $input) { __typename user { id } }
|
|
35
|
+
}
|
|
36
|
+
`;async function N(a){const t={id:a.id,email:a.email,firstname:a.firstName,lastname:a.lastName,job_title:a.jobTitle,telephone:a.telephone,role_id:a.roleId,status:a.status};return await l(_,{variables:{input:t}}).then(e=>{var r,n,i,s;return(r=e.errors)!=null&&r.length?o(e.errors):!!((s=(i=(n=e==null?void 0:e.data)==null?void 0:n.updateCompanyUser)==null?void 0:i.user)!=null&&s.id)}).catch(m)}export{E as c,A as d,b as g,I as i,N as u};
|
|
37
|
+
//# sourceMappingURL=updateCompanyUser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCompanyUser.js","sources":["/@dropins/storefront-company-management/src/api/createCompanyUser/graphql/createCompanyUser.graphql.ts","/@dropins/storefront-company-management/src/api/createCompanyUser/createCompanyUser.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/data/transforms/transform-company-user.ts","/@dropins/storefront-company-management/src/api/getCompanyUser/graphql/getCompanyUser.graphql.ts","/@dropins/storefront-company-management/src/api/getCompanyUser/getCompanyUser.ts","/@dropins/storefront-company-management/src/api/isCompanyUserEmailAvailable/graphql/isCompanyUserEmailAvailable.graphql.ts","/@dropins/storefront-company-management/src/api/isCompanyUserEmailAvailable/isCompanyUserEmailAvailable.ts","/@dropins/storefront-company-management/src/api/updateCompanyUser/graphql/updateCompanyUser.graphql.ts","/@dropins/storefront-company-management/src/api/updateCompanyUser/updateCompanyUser.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const CREATE_COMPANY_USER = /* GraphQL */ `\n mutation createCompanyUser($input: CompanyUserCreateInput!) {\n createCompanyUser(input: $input) { __typename user { id structure_id email firstname lastname } }\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 } from '@/company-management/lib';\nimport { CreateCompanyUserInput, CreateCompanyUserResult } from '@/company-management/types';\nimport { CREATE_COMPANY_USER } from './graphql/createCompanyUser.graphql';\n\n/**\n * Creates a new company user with the provided information\n * @param input - User information including email, name, job title, and role\n * @returns Promise resolving to created user result or null if creation failed\n */\nexport async function createCompanyUser(input: CreateCompanyUserInput): Promise<CreateCompanyUserResult | null> {\n const transformedInput = {\n email: input.email,\n firstname: input.firstName,\n lastname: input.lastName,\n job_title: input.jobTitle,\n telephone: input.telephone,\n role_id: input.roleId,\n status: input.status,\n target_id: input.targetId,\n };\n\n return await fetchGraphQl<{ createCompanyUser?: { user?: { id: string; structure_id?: string } } }>(CREATE_COMPANY_USER, { variables: { input: transformedInput } })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n const user = res?.data?.createCompanyUser?.user;\n if (!user) return null;\n\n return {\n id: user.id,\n structureId: user.structure_id,\n };\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 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 } 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 (base64 encoded UID from GraphQL)\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 const response = await fetchGraphQl<DeleteCompanyUserMutation>(\n DELETE_COMPANY_USER_MUTATION,\n {\n method: 'POST',\n cache: 'no-cache',\n variables: {\n id\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};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CompanyUserModel } from '@/company-management/data/models/company-user';\nimport { isCompanyAdministrator } from '@/company-management/lib';\n\ninterface CompanyUserResponse {\n id: string;\n email: string;\n firstname: string;\n lastname: string;\n job_title?: string | null;\n telephone?: string | null;\n status?: string | null;\n role?: {\n id: string;\n name: string;\n } | null;\n}\n\nexport const transformCompanyUser = (response: CompanyUserResponse): CompanyUserModel => {\n if (!response) {\n throw new Error('Invalid response: missing user data');\n }\n\n return {\n id: response.id,\n email: response.email,\n firstName: response.firstname,\n lastName: response.lastname,\n jobTitle: response.job_title,\n telephone: response.telephone,\n status: response.status,\n role: response.role,\n isCompanyAdmin: isCompanyAdministrator(response.role),\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_COMPANY_USER = /* GraphQL */ `\n query getCompanyUser($id: ID!) {\n company {\n user(id: $id) {\n id\n email\n firstname\n lastname\n job_title\n telephone\n status\n role { id name }\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { fetchGraphQl } from '@/company-management/api';\nimport { handleNetworkError, handleFetchError } from '@/company-management/lib';\nimport { CompanyUserModel } from '@/company-management/data/models';\nimport { transformCompanyUser } from '@/company-management/data/transforms';\nimport { GET_COMPANY_USER } from './graphql/getCompanyUser.graphql';\n\n/**\n * Retrieves a specific company user by their ID\n * @param id - The ID of the company user to retrieve (base64 encoded UID from GraphQL)\n * @returns Promise resolving to CompanyUserModel or null if user not found\n */\nexport async function getCompanyUser(id: string): Promise<CompanyUserModel | null> {\n return await fetchGraphQl<{ company: { user?: { id: string; email: string; firstname: string; lastname: string; job_title?: string | null; telephone?: string | null; status?: string | null; role?: { id: string; name: string } | null } } }>(GET_COMPANY_USER, { variables: { id } })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n const user = res?.data?.company?.user;\n if (!user) return null;\n\n return transformCompanyUser(user);\n })\n .catch(handleNetworkError);\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const IS_COMPANY_USER_EMAIL_AVAILABLE = /* GraphQL */ `\n query isCompanyUserEmailAvailable($email: String!) {\n isCompanyUserEmailAvailable(email: $email) { 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 '@/company-management/api';\nimport { handleNetworkError, handleFetchError } from '@/company-management/lib';\nimport { IS_COMPANY_USER_EMAIL_AVAILABLE } from './graphql/isCompanyUserEmailAvailable.graphql';\n\n/**\n * Checks if an email address is available for use by a new company user\n * @param email - The email address to check for availability\n * @returns Promise resolving to boolean indicating availability or null if check failed\n */\nexport async function isCompanyUserEmailAvailable(email: string): Promise<boolean | null> {\n return await fetchGraphQl<{ isCompanyUserEmailAvailable?: { is_email_available: boolean } }>(IS_COMPANY_USER_EMAIL_AVAILABLE, { variables: { email } })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n return res?.data?.isCompanyUserEmailAvailable?.is_email_available ?? null;\n })\n .catch(handleNetworkError);\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const UPDATE_COMPANY_USER = /* GraphQL */ `\n mutation updateCompanyUser($input: CompanyUserUpdateInput!) {\n updateCompanyUser(input: $input) { __typename user { id } }\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 } from '@/company-management/lib';\nimport { UpdateCompanyUserInput } from '@/company-management/types';\nimport { UPDATE_COMPANY_USER } from './graphql/updateCompanyUser.graphql';\n\n/**\n * Updates an existing company user with the provided information\n * @param input - User information including ID (base64 encoded UID) and fields to update\n * @returns Promise resolving to boolean indicating success\n */\nexport async function updateCompanyUser(input: UpdateCompanyUserInput): Promise<boolean> {\n const transformedInput = {\n id: input.id,\n email: input.email,\n firstname: input.firstName,\n lastname: input.lastName,\n job_title: input.jobTitle,\n telephone: input.telephone,\n role_id: input.roleId,\n status: input.status,\n };\n\n return await fetchGraphQl<{ updateCompanyUser?: { user?: { id: string } } }>(UPDATE_COMPANY_USER, { variables: { input: transformedInput } })\n .then((res) => {\n if (res.errors?.length) return handleFetchError(res.errors);\n return !!res?.data?.updateCompanyUser?.user?.id;\n })\n .catch(handleNetworkError);\n}\n"],"names":["CREATE_COMPANY_USER","createCompanyUser","input","transformedInput","fetchGraphQl","res","_a","handleFetchError","user","_c","_b","handleNetworkError","DELETE_COMPANY_USER_MUTATION","deleteCompanyUser","params","id","response","transformCompanyUser","isCompanyAdministrator","GET_COMPANY_USER","getCompanyUser","IS_COMPANY_USER_EMAIL_AVAILABLE","isCompanyUserEmailAvailable","email","UPDATE_COMPANY_USER","updateCompanyUser","_d"],"mappings":"gIAiBO,MAAMA,EAAoC;AAAA;AAAA;AAAA;AAAA,ECSjD,eAAsBC,EAAkBC,EAAwE,CAC9G,MAAMC,EAAmB,CACvB,MAAOD,EAAM,MACb,UAAWA,EAAM,UACjB,SAAUA,EAAM,SAChB,UAAWA,EAAM,SACjB,UAAWA,EAAM,UACjB,QAASA,EAAM,OACf,OAAQA,EAAM,OACd,UAAWA,EAAM,QAAA,EAGnB,OAAO,MAAME,EAAuFJ,EAAqB,CAAE,UAAW,CAAE,MAAOG,EAAiB,CAAG,EAChK,KAAME,GAAQ,WACb,IAAIC,EAAAD,EAAI,SAAJ,MAAAC,EAAY,OAAQ,OAAOC,EAAiBF,EAAI,MAAM,EAC1D,MAAMG,GAAOC,GAAAC,EAAAL,GAAA,YAAAA,EAAK,OAAL,YAAAK,EAAW,oBAAX,YAAAD,EAA8B,KAC3C,OAAKD,EAEE,CACL,GAAIA,EAAK,GACT,YAAaA,EAAK,YAAA,EAJF,IAMpB,CAAC,EACA,MAAMG,CAAkB,CAC7B,CClCO,MAAMC,EAA6C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECW7CC,EAAoB,MAAOC,GAAwE,SAC9G,KAAM,CAAE,GAAAC,GAAOD,EAEf,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,8CAA8C,EAGhE,MAAMC,EAAW,MA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Q,WACb,OAAIC,EAAAD,EAAI,SAAJ,MAAAC,EAAY,OAAeC,EAAiBF,EAAI,MAAM,IACnDI,GAAAC,EAAAL,GAAA,YAAAA,EAAK,OAAL,YAAAK,EAAW,8BAAX,YAAAD,EAAwC,qBAAsB,IACvE,CAAC,EACA,MAAME,CAAkB,CAC7B,CCfO,MAAMa,EAAoC;AAAA;AAAA;AAAA;AAAA,ECSjD,eAAsBC,EAAkBvB,EAAiD,CACvF,MAAMC,EAAmB,CACvB,GAAID,EAAM,GACV,MAAOA,EAAM,MACb,UAAWA,EAAM,UACjB,SAAUA,EAAM,SAChB,UAAWA,EAAM,SACjB,UAAWA,EAAM,UACjB,QAASA,EAAM,OACf,OAAQA,EAAM,MAAA,EAGhB,OAAO,MAAME,EAAgEoB,EAAqB,CAAE,UAAW,CAAE,MAAOrB,EAAiB,CAAG,EACzI,KAAME,GAAQ,aACb,OAAIC,EAAAD,EAAI,SAAJ,MAAAC,EAAY,OAAeC,EAAiBF,EAAI,MAAM,EACnD,CAAC,GAACqB,GAAAjB,GAAAC,EAAAL,GAAA,YAAAA,EAAK,OAAL,YAAAK,EAAW,oBAAX,YAAAD,EAA8B,OAA9B,MAAAiB,EAAoC,GAC/C,CAAC,EACA,MAAMf,CAAkB,CAC7B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{h as i}from"./fetch-error.js";import{f as m,h as d}from"./network-error.js";const l=`
|
|
4
|
+
query COMPANY_USERS($pageSize: Int!, $currentPage: Int!, $filter: CompanyUsersFilterInput) {
|
|
5
|
+
company {
|
|
6
|
+
users(pageSize: $pageSize, currentPage: $currentPage, filter: $filter) {
|
|
7
|
+
items {
|
|
8
|
+
id
|
|
9
|
+
firstname
|
|
10
|
+
lastname
|
|
11
|
+
email
|
|
12
|
+
role {
|
|
13
|
+
name
|
|
14
|
+
}
|
|
15
|
+
status
|
|
16
|
+
team {
|
|
17
|
+
name
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
page_info {
|
|
21
|
+
page_size
|
|
22
|
+
current_page
|
|
23
|
+
total_pages
|
|
24
|
+
}
|
|
25
|
+
total_count
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`,h=async(p={})=>{var n,o,u,c;const{pageSize:s=20,currentPage:a=1,filter:r}=p;try{const e=await m(l,{method:"GET",cache:"no-cache",variables:{pageSize:s,currentPage:a,filter:r}}).catch(d);return(n=e.errors)!=null&&n.length&&i(e.errors),(c=(u=(o=e.data)==null?void 0:o.company)==null?void 0:u.users)!=null&&c.items?{users:e.data.company.users.items.map(t=>({id:t.id,firstName:t.firstname,lastName:t.lastname,email:t.email,role:t.role.name,status:t.status,...t.team&&{team:t.team.name}})),pageInfo:{pageSize:e.data.company.users.page_info.page_size,currentPage:e.data.company.users.page_info.current_page,totalPages:e.data.company.users.page_info.total_pages},totalCount:e.data.company.users.total_count}:{users:[],pageInfo:{pageSize:s,currentPage:a,totalPages:1}}}catch{return{users:[],pageInfo:{pageSize:s,currentPage:a,totalPages:1}}}},g=`
|
|
30
|
+
mutation UPDATE_COMPANY_USER_STATUS($input: CompanyUserUpdateInput!) {
|
|
31
|
+
updateCompanyUser(input: $input) {
|
|
32
|
+
user {
|
|
33
|
+
id
|
|
34
|
+
status
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
`,U=async p=>{var n,o,u;const{id:s,status:a}=p;if(!s)throw new Error("User ID is required to update company user status");if(!a||a!=="ACTIVE"&&a!=="INACTIVE")throw new Error("Valid status (ACTIVE or INACTIVE) is required to update company user status");const r=await m(g,{method:"POST",cache:"no-cache",variables:{input:{id:s,status:a}}}).catch(d);return(n=r.errors)!=null&&n.length&&i(r.errors),(u=(o=r.data)==null?void 0:o.updateCompanyUser)!=null&&u.user?{success:!0,user:{id:r.data.updateCompanyUser.user.id,status:r.data.updateCompanyUser.user.status}}:{success:!1}};export{h as g,U as u};
|
|
39
|
+
//# sourceMappingURL=updateCompanyUserStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCompanyUserStatus.js","sources":["/@dropins/storefront-company-management/src/api/getCompanyUsers/graphql/companyUsers.graphql.ts","/@dropins/storefront-company-management/src/api/getCompanyUsers/getCompanyUsers.ts","/@dropins/storefront-company-management/src/api/updateCompanyUserStatus/graphql/updateCompanyUserStatus.graphql.ts","/@dropins/storefront-company-management/src/api/updateCompanyUserStatus/updateCompanyUserStatus.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 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 } 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 with base64-encoded IDs 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 // Keep IDs base64-encoded for consistency with other APIs\n const users: CompanyUser[] = response.data.company.users.items.map((item) => {\n return {\n id: 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","/********************************************************************\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 } 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 (base64 encoded UID from GraphQL)\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 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,\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};\n"],"names":["COMPANY_USERS_QUERY","getCompanyUsers","params","pageSize","currentPage","filter","response","fetchGraphQl","handleNetworkError","_a","handleFetchError","_d","_c","_b","item","UPDATE_COMPANY_USER_STATUS_MUTATION","updateCompanyUserStatus","id","status"],"mappings":"mFAgBO,MAAMA,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,MAAOC,EAA6B,KAAsC,aACvG,KAAM,CAAE,SAAAC,EAAW,GAAI,YAAAC,EAAc,EAAG,OAAAC,GAAWH,EAEnD,GAAI,CACF,MAAMI,EAAW,MAAMC,EACrBP,EACA,CACE,OAAQ,MACR,MAAO,WACP,UAAW,CACT,SAAAG,EACA,YAAAC,EACA,OAAAC,CAAA,CACF,CACF,EACA,MAAMG,CAAkB,EAM1B,OAJIC,EAAAH,EAAS,SAAT,MAAAG,EAAiB,QACnBC,EAAiBJ,EAAS,MAAM,GAG7BK,GAAAC,GAAAC,EAAAP,EAAS,OAAT,YAAAO,EAAe,UAAf,YAAAD,EAAwB,QAAxB,MAAAD,EAA+B,MAyB7B,CACL,MAb2BL,EAAS,KAAK,QAAQ,MAAM,MAAM,IAAKQ,IAC3D,CACL,GAAIA,EAAK,GACT,UAAWA,EAAK,UAChB,SAAUA,EAAK,SACf,MA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EAAA,CAWf"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{useRef as m,useEffect as u}from"@dropins/tools/preact-hooks.js";import{events as C}from"@dropins/tools/event-bus.js";const d=(t,f={})=>{const{eager:n=!0,enabled:o=!0}=f,r=m(t);r.current=t,u(()=>{if(!o)return;const c=()=>{r.current()},e=C.on("companyContext/changed",c,{eager:n});return()=>{var a;(a=e==null?void 0:e.off)==null||a.call(e)}},[n,o])};export{d as u};
|
|
4
|
+
//# sourceMappingURL=useCompanyContextListener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCompanyContextListener.js","sources":["/@dropins/storefront-company-management/src/hooks/useCompanyContextListener.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 { useEffect, useRef } from 'preact/hooks';\nimport { events } from '@adobe-commerce/event-bus';\n\n/**\n * Configuration options for company context event handling\n */\nexport interface CompanyContextListenerOptions {\n /** Whether to enable eager listening (subscribe immediately on mount) */\n eager?: boolean;\n /** Whether the hook is enabled (allows conditional subscription) */\n enabled?: boolean;\n}\n\n/**\n * Custom hook that listens to company context changes and executes a callback\n * \n * This hook provides a reusable pattern for components that need to respond to\n * company context changes (e.g., user switching companies, company data updates).\n * \n * @param callback - Function to execute when company context changes\n * @param options - Configuration options for the event listener\n * \n * @example\n * ```typescript\n * const MyComponent = () => {\n * const [data, setData] = useState(null);\n * \n * const refreshData = useCallback(async () => {\n * const newData = await fetchMyData();\n * setData(newData);\n * }, []);\n * \n * // Listen for company context changes and refresh data\n * useCompanyContextListener(refreshData);\n * \n * return <div>{data}</div>;\n * };\n * ```\n * \n * @example\n * ```typescript\n * // With options\n * useCompanyContextListener(refreshData, {\n * eager: true, // Subscribe immediately on mount\n * enabled: true // Conditionally enable/disable\n * });\n * ```\n */\nexport const useCompanyContextListener = (\n callback: () => void,\n options: CompanyContextListenerOptions = {}\n) => {\n const { eager = true, enabled = true } = options;\n \n // Use ref to maintain stable reference to callback across re-renders\n const callbackRef = useRef(callback);\n callbackRef.current = callback;\n\n useEffect(() => {\n // Skip subscription if disabled\n if (!enabled) {\n return;\n }\n\n const handleCompanyContextChange = () => {\n callbackRef.current();\n };\n\n const subscription = events.on(\n 'companyContext/changed',\n handleCompanyContextChange,\n { eager }\n );\n\n return () => {\n subscription?.off?.();\n };\n }, [eager, enabled]);\n};\n\n"],"names":["useCompanyContextListener","callback","options","eager","enabled","callbackRef","useRef","useEffect","handleCompanyContextChange","subscription","events","_a"],"mappings":"4HAiEO,MAAMA,EAA4B,CACvCC,EACAC,EAAyC,KACtC,CACH,KAAM,CAAE,MAAAC,EAAQ,GAAM,QAAAC,EAAU,IAASF,EAGnCG,EAAcC,EAAOL,CAAQ,EACnCI,EAAY,QAAUJ,EAEtBM,EAAU,IAAM,CAEd,GAAI,CAACH,EACH,OAGF,MAAMI,EAA6B,IAAM,CACvCH,EAAY,QAAA,CACd,EAEMI,EAAeC,EAAO,GAC1B,yBACAF,EACA,CAAE,MAAAL,CAAA,CAAM,EAGV,MAAO,IAAM,QACXQ,EAAAF,GAAA,YAAAA,EAAc,MAAd,MAAAE,EAAA,KAAAF,EACF,CACF,EAAG,CAACN,EAAOC,CAAO,CAAC,CACrB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{useState as a,useCallback as r,useEffect as w}from"@dropins/tools/preact-hooks.js";import{u as q}from"./useCompanyContextListener.js";import{g as A,a as B,c as J,u as K,d as M,i as Q}from"./isCompanyRoleNameAvailable.js";const V=10,$=(I=V,u=!0,C=!1)=>{const[S,n]=a([]),[z,R]=a([]),[L,f]=a(0),[m,l]=a(1),[y,D]=a(I),[F,p]=a(1),[N,d]=a(!1),[T,P]=a(!1),[b,E]=a(!1),[k,h]=a(!1),[U,s]=a(null),o=r(async(t={})=>{d(!0),s(null);try{if(C){const e=await A({pageSize:1e3,currentPage:1,...t});n(e.items),f(e.totalCount),p(1),l(1)}else{const e=await A({pageSize:y,currentPage:m,...t});n(e.items),f(e.totalCount),p(e.pageInfo.totalPages),l(e.pageInfo.currentPage)}}catch(e){s(e instanceof Error?e.message:"Failed to fetch roles")}finally{d(!1)}},[C,y,m]),c=r(async()=>{try{const t=await B();R(t)}catch(t){s(t instanceof Error?t.message:"Failed to fetch ACL resources")}},[]),v=r(async t=>{P(!0),s(null);try{const e=await J(t);return await o(),e}catch(e){return s(e instanceof Error?e.message:"Failed to create role"),null}finally{P(!1)}},[o]),x=r(async t=>{E(!0),s(null);try{const e=await K(t);return n(i=>i.map(g=>g.id===e.id?e:g)),e}catch(e){return s(e instanceof Error?e.message:"Failed to update role"),null}finally{E(!1)}},[]),_=r(async t=>{h(!0),s(null);try{const e=await M({id:t});return e&&(n(i=>i.filter(g=>g.id!==t)),f(i=>i-1)),e}catch(e){return s(e instanceof Error?e.message:"Failed to delete role"),!1}finally{h(!1)}},[]),G=r(async t=>{try{return await Q({name:t})}catch(e){return s(e instanceof Error?e.message:"Failed to check role name availability"),!1}},[]),H=r(t=>{l(t)},[]),O=r(t=>{D(t),l(1)},[]),Z=r(async()=>{await Promise.all([o(),c()])},[o,c]),j=r(()=>{s(null)},[]);return w(()=>{u&&o()},[o,u]),w(()=>{u&&c()},[c,u]),q(r(()=>{l(1),n([]),R([]),f(0),p(0),d(!0)},[]),{eager:!0}),{roles:S,aclResources:z,totalCount:L,currentPage:m,pageSize:y,totalPages:F,isLoading:N,isCreating:T,isUpdating:b,isDeleting:k,error:U,fetchRoles:o,fetchAclResources:c,createRole:v,updateRole:x,deleteRole:_,checkRoleNameAvailability:G,setPage:H,setPageSize:O,refresh:Z,clearError:j}};export{V as D,$ as u};
|
|
4
|
+
//# sourceMappingURL=useCompanyRoles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCompanyRoles.js","sources":["/@dropins/storefront-company-management/src/hooks/useCompanyRoles.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 { useState, useEffect, useCallback } from 'preact/hooks';\nimport {\n getCompanyRoles,\n getCompanyAclResources,\n createCompanyRole,\n updateCompanyRole,\n deleteCompanyRole,\n isCompanyRoleNameAvailable,\n CompanyRoleModel,\n CompanyAclResourceModel,\n CompanyRoleCreateInputModel,\n CompanyRoleUpdateInputModel,\n GetCompanyRolesVariables,\n} from '../api/companyRoles';\nimport { useCompanyContextListener } from './useCompanyContextListener';\n\nexport const DEFAULT_PAGINATION_SIZE = 10;\n\nexport interface UseCompanyRolesReturn {\n roles: CompanyRoleModel[];\n aclResources: CompanyAclResourceModel[];\n totalCount: number;\n currentPage: number;\n pageSize: number;\n totalPages: number;\n \n isLoading: boolean;\n isCreating: boolean;\n isUpdating: boolean;\n isDeleting: boolean;\n \n error: string | null;\n \n fetchRoles: (variables?: GetCompanyRolesVariables) => Promise<void>;\n fetchAclResources: () => Promise<void>;\n createRole: (input: CompanyRoleCreateInputModel) => Promise<CompanyRoleModel | null>;\n updateRole: (input: CompanyRoleUpdateInputModel) => Promise<CompanyRoleModel | null>;\n deleteRole: (id: string) => Promise<boolean>;\n checkRoleNameAvailability: (name: string) => Promise<boolean>;\n \n setPage: (page: number) => void;\n setPageSize: (size: number) => void;\n \n refresh: () => Promise<void>;\n clearError: () => void;\n}\n\nexport const useCompanyRoles = (\n initialPageSize: number = DEFAULT_PAGINATION_SIZE,\n autoFetch: boolean = true,\n clientSidePagination: boolean = false\n): UseCompanyRolesReturn => {\n const [roles, setRoles] = useState<CompanyRoleModel[]>([]);\n const [aclResources, setAclResources] = useState<CompanyAclResourceModel[]>([]);\n const [totalCount, setTotalCount] = useState(0);\n const [currentPage, setCurrentPage] = useState(1);\n const [pageSize, setPageSize] = useState(initialPageSize);\n const [totalPages, setTotalPages] = useState(1);\n \n const [isLoading, setIsLoading] = useState(false);\n const [isCreating, setIsCreating] = useState(false);\n const [isUpdating, setIsUpdating] = useState(false);\n const [isDeleting, setIsDeleting] = useState(false);\n \n const [error, setError] = useState<string | null>(null);\n\n const fetchRoles = useCallback(async (variables: GetCompanyRolesVariables = {}) => {\n setIsLoading(true);\n setError(null);\n \n try {\n if (clientSidePagination) {\n // For client-side pagination, fetch all roles at once\n const response = await getCompanyRoles({\n pageSize: 1000,\n currentPage: 1,\n ...variables,\n });\n \n setRoles(response.items);\n setTotalCount(response.totalCount);\n setTotalPages(1);\n setCurrentPage(1);\n } else {\n // Server-side pagination\n const response = await getCompanyRoles({\n pageSize,\n currentPage,\n ...variables,\n });\n \n setRoles(response.items);\n setTotalCount(response.totalCount);\n setTotalPages(response.pageInfo.totalPages);\n setCurrentPage(response.pageInfo.currentPage);\n }\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to fetch roles');\n } finally {\n setIsLoading(false);\n }\n }, [clientSidePagination, pageSize, currentPage]);\n\n const fetchAclResources = useCallback(async () => {\n try {\n const resources = await getCompanyAclResources();\n setAclResources(resources);\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to fetch ACL resources');\n }\n }, []);\n\n const createRole = useCallback(async (input: CompanyRoleCreateInputModel): Promise<CompanyRoleModel | null> => {\n setIsCreating(true);\n setError(null);\n \n try {\n const newRole = await createCompanyRole(input);\n await fetchRoles();\n return newRole;\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to create role');\n return null;\n } finally {\n setIsCreating(false);\n }\n }, [fetchRoles]);\n\n const updateRole = useCallback(async (input: CompanyRoleUpdateInputModel): Promise<CompanyRoleModel | null> => {\n setIsUpdating(true);\n setError(null);\n \n try {\n const updatedRole = await updateCompanyRole(input);\n \n // Update the role in the local state\n setRoles(prevRoles => \n prevRoles.map(role => \n role.id === updatedRole.id ? updatedRole : role\n )\n );\n \n return updatedRole;\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to update role');\n return null;\n } finally {\n setIsUpdating(false);\n }\n }, []);\n\n const deleteRole = useCallback(async (id: string): Promise<boolean> => {\n setIsDeleting(true);\n setError(null);\n \n try {\n const success = await deleteCompanyRole({ id });\n \n if (success) {\n // Remove the role from local state\n setRoles(prevRoles => prevRoles.filter(role => role.id !== id));\n setTotalCount(prev => prev - 1);\n }\n \n return success;\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to delete role');\n return false;\n } finally {\n setIsDeleting(false);\n }\n }, []);\n\n const checkRoleNameAvailability = useCallback(async (name: string): Promise<boolean> => {\n try {\n return await isCompanyRoleNameAvailable({ name });\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to check role name availability');\n return false;\n }\n }, []);\n\n const setPage = useCallback((page: number) => {\n setCurrentPage(page);\n }, []);\n\n const setPageSizeHandler = useCallback((size: number) => {\n setPageSize(size);\n setCurrentPage(1); // Reset to first page when changing page size\n }, []);\n\n const refresh = useCallback(async () => {\n await Promise.all([\n fetchRoles(),\n fetchAclResources(),\n ]);\n }, [fetchRoles, fetchAclResources]);\n\n const clearError = useCallback(() => {\n setError(null);\n }, []);\n\n // Auto-fetch on mount and when pagination changes\n useEffect(() => {\n if (autoFetch) {\n fetchRoles();\n }\n }, [fetchRoles, autoFetch]);\n\n // Fetch ACL resources on mount\n useEffect(() => {\n if (autoFetch) {\n fetchAclResources();\n }\n }, [fetchAclResources, autoFetch]);\n\n // Listen for company context changes to clear stale data\n // Note: We don't call refresh() here to avoid race conditions with permission updates.\n // The parent component (RolesAndPermissions) will call refresh() after permissions update.\n useCompanyContextListener(\n useCallback(() => {\n setCurrentPage(1);\n setRoles([]);\n setAclResources([]);\n setTotalCount(0);\n setTotalPages(0);\n setIsLoading(true);\n }, []),\n { eager: true }\n );\n\n return {\n roles,\n aclResources,\n totalCount,\n currentPage,\n pageSize,\n totalPages,\n isLoading,\n isCreating,\n isUpdating,\n isDeleting,\n error,\n fetchRoles,\n fetchAclResources,\n createRole,\n updateRole,\n deleteRole,\n checkRoleNameAvailability,\n setPage,\n setPageSize: setPageSizeHandler,\n refresh,\n clearError,\n };\n};\n"],"names":["DEFAULT_PAGINATION_SIZE","useCompanyRoles","initialPageSize","autoFetch","clientSidePagination","roles","setRoles","useState","aclResources","setAclResources","totalCount","setTotalCount","currentPage","setCurrentPage","pageSize","setPageSize","totalPages","setTotalPages","isLoading","setIsLoading","isCreating","setIsCreating","isUpdating","setIsUpdating","isDeleting","setIsDeleting","error","setError","fetchRoles","useCallback","variables","response","getCompanyRoles","err","fetchAclResources","resources","getCompanyAclResources","createRole","input","newRole","createCompanyRole","updateRole","updatedRole","updateCompanyRole","prevRoles","role","deleteRole","id","success","deleteCompanyRole","prev","checkRoleNameAvailability","name","isCompanyRoleNameAvailable","setPage","page","setPageSizeHandler","size","refresh","clearError","useEffect","useCompanyContextListener"],"mappings":"oOAiCO,MAAMA,EAA0B,GA+B1BC,EAAkB,CAC7BC,EAA0BF,EAC1BG,EAAqB,GACrBC,EAAgC,KACN,CAC1B,KAAM,CAACC,EAAOC,CAAQ,EAAIC,EAA6B,CAAA,CAAE,EACnD,CAACC,EAAcC,CAAe,EAAIF,EAAoC,CAAA,CAAE,EACxE,CAACG,EAAYC,CAAa,EAAIJ,EAAS,CAAC,EACxC,CAACK,EA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AE,EAECqB,EAAUzB,EAAa0B,GAAiB,CAC5C1C,EAAe0C,CAAI,CACrB,EAAG,CAAA,CAAE,EAECC,EAAqB3B,EAAa4B,GAAiB,CACvD1C,EAAY0C,CAAI,EAChB5C,EAAe,CAAC,CAClB,EAAG,CAAA,CAAE,EAEC6C,EAAU7B,EAAY,SAAY,CACtC,MAAM,QAAQ,IAAI,CAChBD,EAAA,EACAM,EAAA,CAAkB,CACnB,CACH,EAAG,CAACN,EAAYM,CAAiB,CAAC,EAE5ByB,EAAa9B,EAAY,IAAM,CACnCF,EAAS,IAAI,CACf,EAAG,CAAA,CAAE,EAGL,OAAAiC,EAAU,IAAM,CACVzD,GACFyB,EAAA,CAEJ,EAAG,CAACA,EAAYzB,CAAS,CAAC,EAG1ByD,EAAU,IAAM,CACVzD,GACF+B,EAAA,CAEJ,EAAG,CAACA,EAAmB/B,CAAS,CAAC,EAKjC0D,EACEhC,EAAY,IAAM,CAChBhB,EAAe,CAAC,EAChBP,EAAS,CAAA,CAAE,EACXG,EAAgB,CAAA,CAAE,EAClBE,EAAc,CAAC,EACfM,EAAc,CAAC,EACfE,EAAa,EAAI,CACnB,EAAG,CAAA,CAAE,EACL,CAAE,MAAO,EAAA,CAAK,EAGT,CACL,MAAAd,EACA,aAAAG,EACA,WAAAE,EACA,YAAAE,EACA,SAAAE,EACA,WAAAE,EACA,UAAAE,EACA,WAAAE,EACA,WAAAE,EACA,WAAAE,EACA,MAAAE,EACA,WAAAE,EACA,kBAAAM,EACA,WAAAG,EACA,WAAAI,EACA,WAAAK,EACA,0BAAAK,EACA,QAAAG,EACA,YAAaE,EACb,QAAAE,EACA,WAAAC,CAAA,CAEJ"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{useState as a,useEffect as m}from"@dropins/tools/preact-hooks.js";import{u}from"./useCompanyContextListener.js";import{g as f}from"./getCustomerCompany.js";const i=()=>{const[s,o]=a(null),[r,t]=a(!0),n=async()=>{try{t(!0);const e=await f();o(e)}catch{o(null)}finally{t(!1)}};return m(()=>{n()},[]),u(n),{companyInfo:s,loading:r}};export{i as u};
|
|
4
|
+
//# sourceMappingURL=useCustomerCompanyInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCustomerCompanyInfo.js","sources":["/@dropins/storefront-company-management/src/hooks/containers/useCustomerCompanyInfo.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 { useState, useEffect } from 'preact/hooks';\nimport { getCustomerCompany } from '@/company-management/api/getCustomerCompany';\nimport { CustomerCompanyInfo } from '@/company-management/data/models/customer-company-info';\nimport { useCompanyContextListener } from '@/company-management/hooks/useCompanyContextListener';\n\n/**\n * Custom hook for fetching and managing customer company information\n * Listens to companyContext/changed events to refetch data when company context changes\n * @returns Object containing company info and loading state\n */\nexport const useCustomerCompanyInfo = () => {\n const [companyInfo, setCompanyInfo] = useState<CustomerCompanyInfo | null>(null);\n const [loading, setLoading] = useState<boolean>(true);\n\n const fetchCompanyInfo = async () => {\n try {\n setLoading(true);\n const data = await getCustomerCompany();\n setCompanyInfo(data);\n } catch (error) {\n setCompanyInfo(null);\n } finally {\n setLoading(false);\n }\n };\n\n useEffect(() => {\n fetchCompanyInfo();\n }, []);\n\n // Re-fetch customer company info when company context changes (e.g., user switches company)\n useCompanyContextListener(fetchCompanyInfo);\n\n return {\n companyInfo,\n loading,\n };\n};\n"],"names":["useCustomerCompanyInfo","companyInfo","setCompanyInfo","useState","loading","setLoading","fetchCompanyInfo","data","getCustomerCompany","useEffect","useCompanyContextListener"],"mappings":"mKA0BO,MAAMA,EAAyB,IAAM,CAC1C,KAAM,CAACC,EAAaC,CAAc,EAAIC,EAAqC,IAAI,EACzE,CAACC,EAASC,CAAU,EAAIF,EAAkB,EAAI,EAE9CG,EAAmB,SAAY,CACnC,GAAI,CACFD,EAAW,EAAI,EACf,MAAME,EAAO,MAAMC,EAAA,EACnBN,EAAeK,CAAI,CACrB,MAAgB,CACdL,EAAe,IAAI,CACrB,QAAA,CACEG,EAAW,EAAK,CAClB,CACF,EAEA,OAAAI,EAAU,IAAM,CACdH,EAAA,CACF,EAAG,CAAA,CAAE,EAGLI,EAA0BJ,CAAgB,EAEnC,CACL,YAAAL,EACA,QAAAG,CAAA,CAEJ"}
|