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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/{types/api/checkIsCompanyEnabled.types.d.ts → api/allowCompanyRegistration/allowCompanyRegistration.d.ts} +2 -5
  2. package/api/allowCompanyRegistration/graphql/allowCompanyRegistration.graphql.d.ts +18 -0
  3. package/api/allowCompanyRegistration/index.d.ts +18 -0
  4. package/api/companyEnabled/companyEnabled.d.ts +18 -0
  5. package/api/companyEnabled/graphql/companyEnabled.graphql.d.ts +18 -0
  6. package/api/{checkIsCompanyEnabled → companyEnabled}/index.d.ts +1 -1
  7. package/api/createCompany/createCompany.d.ts +39 -0
  8. package/api/createCompany/graphql/createCompany.graphql.d.ts +18 -0
  9. package/api/createCompany/index.d.ts +18 -0
  10. package/api/getCustomerCompany/getCustomerCompany.d.ts +9 -0
  11. package/api/getCustomerCompany/graphql/getCustomerCompanyInfo.graphql.d.ts +18 -0
  12. package/api/getCustomerCompany/index.d.ts +18 -0
  13. package/api/getStoreConfig/getStoreConfig.d.ts +6 -0
  14. package/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts +18 -0
  15. package/api/getStoreConfig/index.d.ts +18 -0
  16. package/api/index.d.ts +7 -1
  17. package/api/isCompanyAdmin/graphql/isCompanyAdmin.graphql.d.ts +18 -0
  18. package/api/isCompanyAdmin/index.d.ts +18 -0
  19. package/api/isCompanyAdmin/isCompanyAdmin.d.ts +22 -0
  20. package/api/isCompanyUser/graphql/isCompanyUser.graphql.d.ts +18 -0
  21. package/api/isCompanyUser/index.d.ts +18 -0
  22. package/api/isCompanyUser/isCompanyUser.d.ts +22 -0
  23. package/api.js +16 -1
  24. package/api.js.map +1 -1
  25. package/chunks/createCompany.js +44 -0
  26. package/chunks/createCompany.js.map +1 -0
  27. package/chunks/fetch-error.js +4 -0
  28. package/chunks/fetch-error.js.map +1 -0
  29. package/chunks/fetch-graphql.js +4 -0
  30. package/chunks/fetch-graphql.js.map +1 -0
  31. package/chunks/getCustomerCompany.js +26 -0
  32. package/chunks/getCustomerCompany.js.map +1 -0
  33. package/chunks/isCompanyUser.js +21 -0
  34. package/chunks/isCompanyUser.js.map +1 -0
  35. package/chunks/updateCompany.js +92 -0
  36. package/chunks/updateCompany.js.map +1 -0
  37. package/chunks/useCompanyContextListener.js +4 -0
  38. package/chunks/useCompanyContextListener.js.map +1 -0
  39. package/chunks/validateCompanyEmail.js +29 -0
  40. package/chunks/validateCompanyEmail.js.map +1 -0
  41. package/components/CompanyRegistrationForm/CompanyRegistrationForm.d.ts +13 -0
  42. package/components/CompanyRegistrationForm/Form/Form.d.ts +5 -0
  43. package/components/CompanyRegistrationForm/Form/FormInputs/FormInputs.d.ts +5 -0
  44. package/components/CompanyRegistrationForm/Form/FormInputs/index.d.ts +18 -0
  45. package/components/CompanyRegistrationForm/Form/fieldHandlers.d.ts +26 -0
  46. package/components/CompanyRegistrationForm/Form/fieldValidationRules.d.ts +63 -0
  47. package/components/CompanyRegistrationForm/Form/formValidation.d.ts +17 -0
  48. package/components/CompanyRegistrationForm/Form/getCompanyFieldsConfig.d.ts +13 -0
  49. package/components/CompanyRegistrationForm/Form/index.d.ts +18 -0
  50. package/components/CompanyRegistrationForm/index.d.ts +20 -0
  51. package/components/CompanyRegistrationSuccess/CompanyRegistrationSuccess.d.ts +8 -0
  52. package/components/CompanyRegistrationSuccess/index.d.ts +18 -0
  53. package/components/CompanyStructureEmpty/CompanyStructureEmpty.d.ts +9 -0
  54. package/components/CompanyStructureEmpty/index.d.ts +19 -0
  55. package/components/CustomerCompanyInfoCard/CustomerCompanyInfoCard.d.ts +9 -0
  56. package/components/CustomerCompanyInfoCard/index.d.ts +18 -0
  57. package/components/index.d.ts +4 -0
  58. package/containers/CompanyProfile.js +1 -1
  59. package/containers/CompanyProfile.js.map +1 -1
  60. package/containers/CompanyRegistration/CompanyRegistration.d.ts +15 -0
  61. package/containers/CompanyRegistration/index.d.ts +19 -0
  62. package/containers/CompanyRegistration.d.ts +3 -0
  63. package/containers/CompanyRegistration.js +4 -0
  64. package/containers/CompanyRegistration.js.map +1 -0
  65. package/containers/CompanyStructure/CompanyStructure.d.ts +10 -0
  66. package/containers/CompanyStructure/index.d.ts +19 -0
  67. package/containers/CompanyStructure.d.ts +3 -0
  68. package/containers/CompanyStructure.js +4 -0
  69. package/containers/CompanyStructure.js.map +1 -0
  70. package/containers/CustomerCompanyInfo/CustomerCompanyInfo.d.ts +9 -0
  71. package/containers/CustomerCompanyInfo/index.d.ts +19 -0
  72. package/containers/CustomerCompanyInfo.d.ts +1 -0
  73. package/containers/CustomerCompanyInfo.js +4 -0
  74. package/containers/CustomerCompanyInfo.js.map +1 -0
  75. package/containers/index.d.ts +3 -0
  76. package/data/models/company.d.ts +52 -0
  77. package/data/models/customer-company-info.d.ts +23 -0
  78. package/data/models/index.d.ts +1 -0
  79. package/data/transforms/company.d.ts +5 -0
  80. package/data/transforms/index.d.ts +2 -0
  81. package/data/transforms/transform-company.d.ts +5 -1
  82. package/data/transforms/transform-customer-company-info.d.ts +10 -0
  83. package/data/transforms/transform-store-config.d.ts +4 -0
  84. package/hooks/containers/index.d.ts +1 -0
  85. package/hooks/containers/useCustomerCompanyInfo.d.ts +12 -0
  86. package/hooks/index.d.ts +1 -0
  87. package/hooks/useCompanyContextListener.d.ts +62 -0
  88. package/hooks/useCompanyRegistrationForm.d.ts +37 -0
  89. package/hooks/useCountryAndRegionFields.d.ts +20 -0
  90. package/i18n/en_US.json.d.ts +41 -3
  91. package/package.json +1 -1
  92. package/render.js +5 -2
  93. package/render.js.map +1 -1
  94. package/types/api/getCustomerCompanyInfo.types.d.ts +40 -0
  95. package/types/api/getStoreConfig.types.d.ts +33 -0
  96. package/types/customerCompanyInfo.types.d.ts +11 -0
  97. package/types/form.types.d.ts +93 -0
  98. package/types/index.d.ts +4 -1
  99. package/api/checkIsCompanyEnabled/checkIsCompanyEnabled.d.ts +0 -4
  100. package/chunks/getCountries.js +0 -117
  101. package/chunks/getCountries.js.map +0 -1
@@ -14,8 +14,5 @@
14
14
  * is strictly forbidden unless prior written permission is obtained
15
15
  * from Adobe.
16
16
  *******************************************************************/
17
- export interface CheckIsCompanyEnabledResponse {
18
- companyEnabled: boolean;
19
- error?: string;
20
- }
21
- //# sourceMappingURL=checkIsCompanyEnabled.types.d.ts.map
17
+ export declare const allowCompanyRegistration: () => Promise<boolean>;
18
+ //# sourceMappingURL=allowCompanyRegistration.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export declare const GET_ALLOW_COMPANY_REGISTRATION = "\n query GET_ALLOW_COMPANY_REGISTRATION {\n storeConfig {\n allow_company_registration\n }\n }\n";
18
+ //# sourceMappingURL=allowCompanyRegistration.graphql.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export * from './allowCompanyRegistration';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export declare const companyEnabled: () => Promise<boolean>;
18
+ //# sourceMappingURL=companyEnabled.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export declare const GET_COMPANY_ENABLED = "\n query GET_COMPANY_ENABLED {\n storeConfig {\n company_enabled\n }\n }\n";
18
+ //# sourceMappingURL=companyEnabled.graphql.d.ts.map
@@ -14,5 +14,5 @@
14
14
  * is strictly forbidden unless prior written permission is obtained
15
15
  * from Adobe.
16
16
  *******************************************************************/
17
- export * from './checkIsCompanyEnabled';
17
+ export * from './companyEnabled';
18
18
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,39 @@
1
+ import { CompanyRegistrationModel } from '../../data/models/company';
2
+
3
+ export interface CompanyCreateInput {
4
+ company_name: string;
5
+ company_email: string;
6
+ legal_name?: string;
7
+ vat_tax_id?: string;
8
+ reseller_id?: string;
9
+ legal_address: {
10
+ street: string[];
11
+ city: string;
12
+ region: {
13
+ region_code: string;
14
+ region?: string;
15
+ region_id?: number;
16
+ };
17
+ postcode: string;
18
+ country_id: string;
19
+ telephone?: string;
20
+ };
21
+ company_admin: {
22
+ email: string;
23
+ firstname: string;
24
+ lastname: string;
25
+ job_title?: string;
26
+ telephone?: string;
27
+ gender?: number;
28
+ custom_attributes?: Array<{
29
+ attribute_code: string;
30
+ value: string;
31
+ }>;
32
+ };
33
+ }
34
+ export declare const createCompany: (formData: any) => Promise<{
35
+ success: boolean;
36
+ company?: CompanyRegistrationModel;
37
+ errors?: string[];
38
+ }>;
39
+ //# sourceMappingURL=createCompany.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export declare const CREATE_COMPANY_MUTATION = "\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";
18
+ //# sourceMappingURL=createCompany.graphql.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export * from './createCompany';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { CustomerCompanyInfo } from '../../data/models/customer-company-info';
2
+
3
+ /**
4
+ * Gets customer company information for display on account information page
5
+ * This is a simplified API that only returns the essential company info needed
6
+ * for the customer account page, without requiring full company permissions
7
+ */
8
+ export declare const getCustomerCompany: () => Promise<CustomerCompanyInfo | null>;
9
+ //# sourceMappingURL=getCustomerCompany.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export declare const GET_CUSTOMER_COMPANY_INFO = "\n query GET_CUSTOMER_COMPANY_INFO {\n customer {\n id\n job_title\n telephone\n role {\n id\n name\n }\n }\n company {\n id\n name\n }\n }\n";
18
+ //# sourceMappingURL=getCustomerCompanyInfo.graphql.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export { getCustomerCompany } from './getCustomerCompany';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { StoreConfigModel } from '../../types';
2
+
3
+ export declare const DEFAULT_COUNTRY = "US";
4
+ export declare const STORE_CONFIG_DEFAULTS: StoreConfigModel;
5
+ export declare const getStoreConfig: () => Promise<StoreConfigModel>;
6
+ //# sourceMappingURL=getStoreConfig.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export declare const GET_STORE_CONFIG_QUERY = "\n query getStoreConfig {\n storeConfig {\n default_country\n store_code\n }\n }\n";
18
+ //# sourceMappingURL=getStoreConfig.graphql.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export { getStoreConfig, STORE_CONFIG_DEFAULTS, DEFAULT_COUNTRY } from './getStoreConfig';
18
+ //# sourceMappingURL=index.d.ts.map
package/api/index.d.ts CHANGED
@@ -17,9 +17,15 @@
17
17
  export * from './initialize';
18
18
  export * from './fetch-graphql';
19
19
  export * from './fetchUserPermissions';
20
- export * from './checkIsCompanyEnabled';
21
20
  export * from './getCompany';
22
21
  export * from './updateCompany';
23
22
  export * from './getCountries';
23
+ export * from './getStoreConfig';
24
24
  export * from './validateCompanyEmail';
25
+ export * from './getCustomerCompany';
26
+ export * from './companyEnabled';
27
+ export * from './allowCompanyRegistration';
28
+ export * from './createCompany';
29
+ export * from './isCompanyUser';
30
+ export * from './isCompanyAdmin';
25
31
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export declare const GET_CUSTOMER_COMPANIES_WITH_ROLES = "\n query GET_CUSTOMER_COMPANIES_WITH_ROLES {\n customer {\n companies(input: {}) {\n items {\n id\n name\n }\n }\n role {\n id\n name\n }\n }\n }\n";
18
+ //# sourceMappingURL=isCompanyAdmin.graphql.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export * from './isCompanyAdmin';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,22 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ /**
18
+ * Check if the current authenticated customer is a company administrator in any company
19
+ * @returns Promise<boolean> - true if customer is a company admin in at least one company, false otherwise
20
+ */
21
+ export declare const isCompanyAdmin: () => Promise<boolean>;
22
+ //# sourceMappingURL=isCompanyAdmin.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export declare const GET_CUSTOMER_COMPANIES = "\n query GET_CUSTOMER_COMPANIES {\n customer {\n companies(input: {}) {\n items {\n id\n name\n }\n }\n }\n }\n";
18
+ //# sourceMappingURL=isCompanyUser.graphql.d.ts.map
@@ -0,0 +1,18 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export * from './isCompanyUser';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,22 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ /**
18
+ * Check if the current authenticated customer belongs to any company
19
+ * @returns Promise<boolean> - true if customer belongs to one or more companies, false otherwise
20
+ */
21
+ export declare const isCompanyUser: () => Promise<boolean>;
22
+ //# sourceMappingURL=isCompanyUser.d.ts.map
package/api.js CHANGED
@@ -1,4 +1,19 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{v as e}from"./chunks/getCountries.js";import{f as p,e as m,a as l,d as h,g as y,r as d,s as u,b as f,c as C,u as b}from"./chunks/getCountries.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";const n=async(a={})=>({success:!0,config:a}),o=async()=>{try{return await e("test@test.com"),{companyEnabled:!0}}catch{return{companyEnabled:!1,error:"Company functionality not available"}}};export{o as checkIsCompanyEnabled,p as fetchGraphQl,m as fetchUserPermissions,l as getCompany,h as getConfig,y as getCountries,n as initialize,d as removeFetchGraphQlHeader,u as setEndpoint,f as setFetchGraphQlHeader,C as setFetchGraphQlHeaders,b as updateCompany,e as validateCompanyEmail};
3
+ import{f as i}from"./chunks/fetch-graphql.js";import{g,r as E,s as h,a as S,b as T}from"./chunks/fetch-graphql.js";import{f as O,g as A,u as R}from"./chunks/updateCompany.js";import{g as G,v as U}from"./chunks/validateCompanyEmail.js";import{D as H,S as I,c as L,g as M}from"./chunks/createCompany.js";import{c as P,g as Q}from"./chunks/getCustomerCompany.js";import{a as v,i as D}from"./chunks/isCompanyUser.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/fetch-error.js";import"@dropins/tools/event-bus.js";const u=async(r={})=>({success:!0,config:r}),m=`
4
+ query GET_CUSTOMER_COMPANIES_WITH_ROLES {
5
+ customer {
6
+ companies(input: {}) {
7
+ items {
8
+ id
9
+ name
10
+ }
11
+ }
12
+ role {
13
+ id
14
+ name
15
+ }
16
+ }
17
+ }
18
+ `,C=async()=>{var r,o,t;try{const a=await i(m,{method:"POST"});if((r=a.errors)!=null&&r.length)return!1;const s=(o=a.data)==null?void 0:o.customer;if(!s)return!1;const n=((t=s.companies)==null?void 0:t.items)??[];if(!Array.isArray(n)||n.length===0)return!1;const e=s.role;return e?e.id==="0"||typeof e.id=="number"&&e.id===0||e.name==="Company Administrator":!1}catch(a){return console.error("Error checking if customer is company admin:",a),!1}};export{H as DEFAULT_COUNTRY,I as STORE_CONFIG_DEFAULTS,v as allowCompanyRegistration,P as companyEnabled,L as createCompany,i as fetchGraphQl,O as fetchUserPermissions,A as getCompany,g as getConfig,G as getCountries,Q as getCustomerCompany,M as getStoreConfig,u as initialize,C as isCompanyAdmin,D as isCompanyUser,E as removeFetchGraphQlHeader,h as setEndpoint,S as setFetchGraphQlHeader,T as setFetchGraphQlHeaders,R as updateCompany,U as validateCompanyEmail};
4
19
  //# sourceMappingURL=api.js.map
package/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sources":["/@dropins/storefront-company-management/src/api/initialize/initialize.ts","/@dropins/storefront-company-management/src/api/checkIsCompanyEnabled/checkIsCompanyEnabled.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n// import { events } from '@adobe-commerce/event-bus';\n\n\nexport interface CompanyDropinConfig {\n langDefinitions?: Record<string, Record<string, string>>;\n models?: Record<string, any>;\n}\n\nexport const initialize = async (config: CompanyDropinConfig = {}) => {\n return {\n success: true,\n config,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { validateCompanyEmail } from '../validateCompanyEmail';\nimport { CheckIsCompanyEnabledResponse } from '../../types/api/checkIsCompanyEnabled.types';\n\nexport const checkIsCompanyEnabled = async (): Promise<CheckIsCompanyEnabledResponse> => {\n try {\n // Use validateCompanyEmail with a dummy email to check if Company functionality is available\n await validateCompanyEmail('test@test.com');\n \n // If the validation API works (regardless of email availability), Company functionality is enabled\n return {\n companyEnabled: true\n };\n } catch (error) {\n return {\n companyEnabled: false,\n error: 'Company functionality not available'\n };\n }\n};"],"names":["initialize","config","checkIsCompanyEnabled","validateCompanyEmail"],"mappings":"qOAyBO,MAAMA,EAAa,MAAOC,EAA8B,MACtD,CACL,QAAS,GACT,OAAAA,CACF,GCVWC,EAAwB,SAAoD,CACnF,GAAA,CAEF,aAAMC,EAAqB,eAAe,EAGnC,CACL,eAAgB,EAClB,OACc,CACP,MAAA,CACL,eAAgB,GAChB,MAAO,qCACT,CAAA,CAEJ"}
1
+ {"version":3,"file":"api.js","sources":["/@dropins/storefront-company-management/src/api/initialize/initialize.ts","/@dropins/storefront-company-management/src/api/isCompanyAdmin/graphql/isCompanyAdmin.graphql.ts","/@dropins/storefront-company-management/src/api/isCompanyAdmin/isCompanyAdmin.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n// import { events } from '@adobe-commerce/event-bus';\n\n\nexport interface CompanyDropinConfig {\n langDefinitions?: Record<string, Record<string, string>>;\n models?: Record<string, any>;\n}\n\nexport const initialize = async (config: CompanyDropinConfig = {}) => {\n return {\n success: true,\n config,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_CUSTOMER_COMPANIES_WITH_ROLES = /* GraphQL */ `\n query GET_CUSTOMER_COMPANIES_WITH_ROLES {\n customer {\n companies(input: {}) {\n items {\n id\n name\n }\n }\n role {\n id\n name\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n \nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_CUSTOMER_COMPANIES_WITH_ROLES } from './graphql/isCompanyAdmin.graphql';\n\ninterface CompanyRole {\n id: string;\n name: string;\n}\n\ninterface CompanyBasicInfo {\n id: string;\n name: string;\n}\n\ninterface CustomerCompaniesWithRolesResponse {\n customer: {\n companies: {\n items: CompanyBasicInfo[];\n };\n role: CompanyRole | null;\n } | null;\n}\n\n/**\n * Check if the current authenticated customer is a company administrator in any company\n * @returns Promise<boolean> - true if customer is a company admin in at least one company, false otherwise\n */\nexport const isCompanyAdmin = async (): Promise<boolean> => {\n try {\n const response = await fetchGraphQl<CustomerCompaniesWithRolesResponse>(GET_CUSTOMER_COMPANIES_WITH_ROLES, {\n method: 'POST',\n });\n\n if (response.errors?.length) {\n return false;\n }\n\n const customer = response.data?.customer;\n if (!customer) {\n return false;\n }\n\n // Check if user is part of at least one company\n const companies = customer.companies?.items ?? [];\n if (!Array.isArray(companies) || companies.length === 0) {\n return false;\n }\n\n // Check if user has admin role\n const customerRole = customer.role;\n if (!customerRole) {\n return false;\n }\n\n // Check if user is company administrator by role ID or name\n return customerRole.id === '0' || \n (typeof customerRole.id === 'number' && customerRole.id === 0) ||\n customerRole.name === 'Company Administrator';\n } catch (error) {\n console.error('Error checking if customer is company admin:', error);\n return false;\n }\n};\n"],"names":["initialize","config","GET_CUSTOMER_COMPANIES_WITH_ROLES","isCompanyAdmin","response","fetchGraphQl","_a","customer","_b","companies","_c","customerRole","error"],"mappings":"ygBAyBO,MAAMA,EAAa,MAAOC,EAA8B,MACtD,CACL,QAAS,GACT,OAAAA,CACF,GCZWC,EAAkD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EC0BlDC,EAAiB,SAA8B,WACtD,GAAA,CACI,MAAAC,EAAW,MAAMC,EAAiDH,EAAmC,CACzG,OAAQ,MAAA,CACT,EAEG,IAAAI,EAAAF,EAAS,SAAT,MAAAE,EAAiB,OACZ,MAAA,GAGH,MAAAC,GAAWC,EAAAJ,EAAS,OAAT,YAAAI,EAAe,SAChC,GAAI,CAACD,EACI,MAAA,GAIT,MAAME,IAAYC,EAAAH,EAAS,YAAT,YAAAG,EAAoB,QAAS,CAAC,EAChD,GAAI,CAAC,MAAM,QAAQD,CAAS,GAAKA,EAAU,SAAW,EAC7C,MAAA,GAIT,MAAME,EAAeJ,EAAS,KAC9B,OAAKI,EAKEA,EAAa,KAAO,KACnB,OAAOA,EAAa,IAAO,UAAYA,EAAa,KAAO,GAC5DA,EAAa,OAAS,wBANpB,SAOFC,EAAO,CACN,eAAA,MAAM,+CAAgDA,CAAK,EAC5D,EAAA,CAEX"}
@@ -0,0 +1,44 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import{h as a,a as l}from"./fetch-error.js";import{f as d}from"./fetch-graphql.js";import{t as g}from"./validateCompanyEmail.js";const u=`
4
+ query getStoreConfig {
5
+ storeConfig {
6
+ default_country
7
+ store_code
8
+ }
9
+ }
10
+ `,p="US",s={defaultCountry:p,storeCode:""},T=async()=>await d(u,{method:"GET"}).then(e=>{var r;return(r=e.errors)!=null&&r.length?a(e.errors):m(e)}).catch(l),m=e=>{var t;if(!((t=e==null?void 0:e.data)!=null&&t.storeConfig))return s;const{default_country:r,store_code:o}=e.data.storeConfig;return{defaultCountry:r||s.defaultCountry,storeCode:o||s.storeCode}},_=`
11
+ mutation CreateCompany($input: CompanyCreateInput!) {
12
+ createCompany(input: $input) {
13
+ company {
14
+ id
15
+ name
16
+ email
17
+ legal_name
18
+ vat_tax_id
19
+ reseller_id
20
+ legal_address {
21
+ street
22
+ city
23
+ region {
24
+ region_code
25
+ region
26
+ region_id
27
+ }
28
+ postcode
29
+ country_code
30
+ telephone
31
+ }
32
+ company_admin {
33
+ id
34
+ firstname
35
+ lastname
36
+ email
37
+ job_title
38
+ telephone
39
+ }
40
+ }
41
+ }
42
+ }
43
+ `,y=e=>{var o,t,i;const r={};if(e.regionCode&&e.regionCode.trim())r.region_code=e.regionCode.trim(),e.regionId&&(r.region_id=typeof e.regionId=="string"?parseInt(e.regionId,10):e.regionId);else if(e.region&&typeof e.region=="string"&&e.region.includes(",")){const[n,c]=e.region.split(",");r.region_code=n.trim(),r.region_id=parseInt(c.trim(),10)}else if(e.region&&e.region.trim()){const n=e.region.trim();if(/^\d+$/.test(n))throw new Error("Region selection error: Missing region code. Please ensure regions are properly loaded.");r.region=n,r.region_code=n}if(!r.region_code)throw new Error("Region code is required. Please select a state/province or enter a region name.");return{company_name:e.companyName,company_email:e.companyEmail,legal_name:e.legalName,vat_tax_id:e.vatTaxId,reseller_id:e.resellerId,legal_address:{street:Array.isArray(e.street)?e.street.filter(n=>n&&n.trim()!==""):[e.street].filter(n=>n&&n.trim()!==""),city:e.city,region:r,postcode:e.postcode,country_id:e.countryCode,telephone:e.addressTelephone},company_admin:{email:e.adminEmail,firstname:((o=e.adminFirstname)==null?void 0:o.trim())||"",lastname:((t=e.adminLastname)==null?void 0:t.trim())||"",job_title:e.adminJobTitle,telephone:e.adminWorkTelephone,gender:e.adminGender?typeof e.adminGender=="string"?parseInt(e.adminGender,10):e.adminGender:void 0,custom_attributes:((i=e.adminCustomAttributes)==null?void 0:i.map(n=>({attribute_code:n.attribute_code,value:n.value})))||[]}}},E=async e=>{var r;try{const o=y(e),t=await d(_,{method:"POST",variables:{input:o}});return(r=t.errors)!=null&&r.length?{success:!1,errors:t.errors.map(n=>n.message)}:{success:!0,company:g(t)}}catch(o){return console.error("Failed to create company:",o),{success:!1,errors:["Failed to create company. Please try again."]}}};export{p as D,s as S,E as c,T as g};
44
+ //# sourceMappingURL=createCompany.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCompany.js","sources":["/@dropins/storefront-company-management/src/api/getStoreConfig/graphql/getStoreConfig.graphql.ts","/@dropins/storefront-company-management/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-company-management/src/data/transforms/transform-store-config.ts","/@dropins/storefront-company-management/src/api/createCompany/graphql/createCompany.graphql.ts","/@dropins/storefront-company-management/src/data/transforms/company.ts","/@dropins/storefront-company-management/src/api/createCompany/createCompany.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_STORE_CONFIG_QUERY = /* GraphQL */ `\n query getStoreConfig {\n storeConfig {\n default_country\n store_code\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_STORE_CONFIG_QUERY } from './graphql/getStoreConfig.graphql';\nimport { handleNetworkError } from '@/company-management/lib/network-error';\nimport { handleFetchError } from '@/company-management/lib/fetch-error';\nimport { GetStoreConfigResponse, StoreConfigModel } from '@/company-management/types';\nimport { transformStoreConfig } from '@/company-management/data/transforms';\n\nexport const DEFAULT_COUNTRY = 'US';\n\nexport const STORE_CONFIG_DEFAULTS: StoreConfigModel = {\n defaultCountry: DEFAULT_COUNTRY,\n storeCode: '',\n};\n\nexport const getStoreConfig = async (): Promise<StoreConfigModel> => {\n return await fetchGraphQl(GET_STORE_CONFIG_QUERY, {\n method: 'GET',\n })\n .then((response: GetStoreConfigResponse) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n return transformStoreConfig(response);\n })\n .catch(handleNetworkError);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { GetStoreConfigResponse, StoreConfigModel } from '@/company-management/types';\nimport { STORE_CONFIG_DEFAULTS } from '@/company-management/api/getStoreConfig/getStoreConfig';\n\nexport const transformStoreConfig = (\n response: GetStoreConfigResponse\n): StoreConfigModel => {\n if (!response?.data?.storeConfig) return STORE_CONFIG_DEFAULTS;\n\n const { default_country, store_code } = response.data.storeConfig;\n\n return {\n defaultCountry: default_country || STORE_CONFIG_DEFAULTS.defaultCountry,\n storeCode: store_code || STORE_CONFIG_DEFAULTS.storeCode,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const CREATE_COMPANY_MUTATION = /* GraphQL */ `\n mutation CreateCompany($input: CompanyCreateInput!) {\n createCompany(input: $input) {\n company {\n id\n name\n email\n legal_name\n vat_tax_id\n reseller_id\n legal_address {\n street\n city\n region {\n region_code\n region\n region_id\n }\n postcode\n country_code\n telephone\n }\n company_admin {\n id\n firstname\n lastname\n email\n job_title\n telephone\n }\n }\n }\n }\n`;","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CompanyFormData } from '../models/company';\nimport { CompanyCreateInput } from '@/company-management/api/createCompany';\n\nexport const transformFormDataToCreateInput = (formData: CompanyFormData): CompanyCreateInput => {\n // Build region object - ensure we have at least one region field\n const regionInput: any = {};\n \n // Handle region data based on what we receive from the form\n if (formData.regionCode && formData.regionCode.trim()) {\n // We have regionCode (preferred path)\n regionInput.region_code = formData.regionCode.trim();\n if (formData.regionId) {\n regionInput.region_id = typeof formData.regionId === 'string' ? parseInt(formData.regionId, 10) : formData.regionId;\n }\n } else if (formData.region && typeof formData.region === 'string' && formData.region.includes(',')) {\n // Dropdown selection: parse \"AL,4\" format as fallback\n const [regionCode, regionId] = formData.region.split(',');\n regionInput.region_code = regionCode.trim();\n regionInput.region_id = parseInt(regionId.trim(), 10);\n } else if (formData.region && formData.region.trim()) {\n const regionValue = formData.region.trim();\n // Check if this is a numeric regionId (from dropdown) or text region name\n if (/^\\d+$/.test(regionValue)) {\n // This is likely a regionId from dropdown, but we only have the ID\n // We need both region_code and region_id for GraphQL, but we can't proceed without region_code\n throw new Error('Region selection error: Missing region code. Please ensure regions are properly loaded.');\n } else {\n // Text input: free-form region name (countries without predefined regions)\n regionInput.region = regionValue;\n regionInput.region_code = regionValue;\n }\n }\n \n // Ensure we have at least region_code (required by GraphQL)\n if (!regionInput.region_code) {\n throw new Error('Region code is required. Please select a state/province or enter a region name.');\n }\n\n return {\n company_name: formData.companyName,\n company_email: formData.companyEmail,\n legal_name: formData.legalName,\n vat_tax_id: formData.vatTaxId,\n reseller_id: formData.resellerId,\n legal_address: {\n street: Array.isArray(formData.street) \n ? formData.street.filter((line: string) => line && line.trim() !== '') // Remove empty lines\n : [formData.street].filter((line: string) => line && line.trim() !== ''), // Handle case where street is not an array\n city: formData.city,\n region: regionInput,\n postcode: formData.postcode,\n country_id: formData.countryCode,\n telephone: formData.addressTelephone,\n },\n company_admin: {\n email: formData.adminEmail,\n firstname: formData.adminFirstname?.trim() || '',\n lastname: formData.adminLastname?.trim() || '',\n job_title: formData.adminJobTitle,\n telephone: formData.adminWorkTelephone,\n gender: formData.adminGender ? (typeof formData.adminGender === 'string' ? parseInt(formData.adminGender, 10) : formData.adminGender) : undefined,\n custom_attributes: formData.adminCustomAttributes?.map(attr => ({\n attribute_code: attr.attribute_code,\n value: attr.value,\n })) || [],\n },\n };\n};","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/company-management/api/fetch-graphql';\nimport { CREATE_COMPANY_MUTATION } from './graphql/createCompany.graphql';\nimport { CompanyRegistrationModel } from '@/company-management/data/models/company';\nimport { transformFormDataToCreateInput } from '@/company-management/data/transforms/company';\nimport { transformCreateCompanyResponse } from '@/company-management/data/transforms/transform-company';\n\nexport interface CompanyCreateInput {\n company_name: string;\n company_email: string;\n legal_name?: string;\n vat_tax_id?: string;\n reseller_id?: string;\n legal_address: {\n street: string[];\n city: string;\n region: {\n region_code: string;\n region?: string;\n region_id?: number;\n };\n postcode: string;\n country_id: string;\n telephone?: string;\n };\n company_admin: {\n email: string;\n firstname: string;\n lastname: string;\n job_title?: string;\n telephone?: string;\n gender?: number;\n custom_attributes?: Array<{\n attribute_code: string;\n value: string;\n }>;\n };\n}\n\n\nexport const createCompany = async (formData: any): Promise<{ success: boolean; company?: CompanyRegistrationModel; errors?: string[] }> => {\n try {\n const input = transformFormDataToCreateInput(formData);\n const response = await fetchGraphQl(CREATE_COMPANY_MUTATION, {\n method: 'POST',\n variables: { input },\n });\n\n if (response.errors?.length) {\n return {\n success: false,\n errors: response.errors.map((error: any) => error.message),\n };\n }\n\n // Transform the GraphQL response using the dedicated transformer\n const transformedCompany = transformCreateCompanyResponse(response);\n\n return {\n success: true,\n company: transformedCompany,\n };\n } catch (error) {\n console.error('Failed to create company:', error);\n return {\n success: false,\n errors: ['Failed to create company. Please try again.'],\n };\n }\n};"],"names":["GET_STORE_CONFIG_QUERY","DEFAULT_COUNTRY","STORE_CONFIG_DEFAULTS","getStoreConfig","fetchGraphQl","response","_a","handleFetchError","transformStoreConfig","handleNetworkError","default_country","store_code","CREATE_COMPANY_MUTATION","transformFormDataToCreateInput","formData","regionInput","regionCode","regionId","regionValue","line","_b","_c","attr","createCompany","input","error","transformCreateCompanyResponse"],"mappings":"iIAiBa,MAAAA,EAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECOvCC,EAAkB,KAElBC,EAA0C,CACrD,eAAgBD,EAChB,UAAW,EACb,EAEaE,EAAiB,SACrB,MAAMC,EAAaJ,EAAwB,CAChD,OAAQ,KAAA,CACT,EACE,KAAMK,GAAqC,OAC1C,OAAIC,EAAAD,EAAS,SAAT,MAAAC,EAAiB,OAAeC,EAAiBF,EAAS,MAAM,EAE7DG,EAAqBH,CAAQ,CAAA,CACrC,EACA,MAAMI,CAAkB,ECpBhBD,EACXH,GACqB,OACrB,GAAI,GAACC,EAAAD,GAAA,YAAAA,EAAU,OAAV,MAAAC,EAAgB,aAAoB,OAAAJ,EAEzC,KAAM,CAAE,gBAAAQ,EAAiB,WAAAC,CAAW,EAAIN,EAAS,KAAK,YAE/C,MAAA,CACL,eAAgBK,GAAmBR,EAAsB,eACzD,UAAWS,GAAcT,EAAsB,SACjD,CACF,ECdaU,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,CAAC,EAG1B,GAAID,EAAS,YAAcA,EAAS,WAAW,OAEjCC,EAAA,YAAcD,EAAS,WAAW,KAAK,EAC/CA,EAAS,WACCC,EAAA,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,EAC5CC,EAAA,YAAcC,EAAW,KAAK,EAC1CD,EAAY,UAAY,SAASE,EAAS,KAAA,EAAQ,EAAE,CAAA,SAC3CH,EAAS,QAAUA,EAAS,OAAO,OAAQ,CAC9C,MAAAI,EAAcJ,EAAS,OAAO,KAAK,EAErC,GAAA,QAAQ,KAAKI,CAAW,EAGpB,MAAA,IAAI,MAAM,yFAAyF,EAGzGH,EAAY,OAASG,EACrBH,EAAY,YAAcG,CAC5B,CAIE,GAAA,CAACH,EAAY,YACT,MAAA,IAAI,MAAM,iFAAiF,EAG5F,MAAA,CACL,aAAcD,EAAS,YACvB,cAAeA,EAAS,aACxB,WAAYA,EAAS,UACrB,WAAYA,EAAS,SACrB,YAAaA,EAAS,WACtB,cAAe,CACb,OAAQ,MAAM,QAAQA,EAAS,MAAM,EACjCA,EAAS,OAAO,OAAQK,GAAiBA,GAAQA,EAAK,KAAW,IAAA,EAAE,EACnE,CAACL,EAAS,MAAM,EAAE,OAAQK,GAAiBA,GAAQA,EAAK,KAAK,IAAM,EAAE,EACzE,KAAML,EAAS,KACf,OAAQC,EACR,SAAUD,EAAS,SACnB,WAAYA,EAAS,YACrB,UAAWA,EAAS,gBACtB,EACA,cAAe,CACb,MAAOA,EAAS,WAChB,YAAWR,EAAAQ,EAAS,iBAAT,YAAAR,EAAyB,SAAU,GAC9C,WAAUc,EAAAN,EAAS,gBAAT,YAAAM,EAAwB,SAAU,GAC5C,UAAWN,EAAS,cACpB,UAAWA,EAAS,mBACpB,OAAQA,EAAS,YAAe,OAAOA,EAAS,aAAgB,SAAW,SAASA,EAAS,YAAa,EAAE,EAAIA,EAAS,YAAe,OACxI,oBAAmBO,EAAAP,EAAS,wBAAT,YAAAO,EAAgC,IAAaC,IAAA,CAC9D,eAAgBA,EAAK,eACrB,MAAOA,EAAK,KACd,MAAO,CAAA,CAAC,CAEZ,CACF,EC5BaC,EAAgB,MAAOT,GAAwG,OACtI,GAAA,CACI,MAAAU,EAAQX,EAA+BC,CAAQ,EAC/CT,EAAW,MAAMD,EAAaQ,EAAyB,CAC3D,OAAQ,OACR,UAAW,CAAE,MAAAY,CAAM,CAAA,CACpB,EAEG,OAAAlB,EAAAD,EAAS,SAAT,MAAAC,EAAiB,OACZ,CACL,QAAS,GACT,OAAQD,EAAS,OAAO,IAAKoB,GAAeA,EAAM,OAAO,CAC3D,EAMK,CACL,QAAS,GACT,QAJyBC,EAA+BrB,CAAQ,CAKlE,QACOoB,EAAO,CACN,eAAA,MAAM,4BAA6BA,CAAK,EACzC,CACL,QAAS,GACT,OAAQ,CAAC,6CAA6C,CACxD,CAAA,CAEJ"}
@@ -0,0 +1,4 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import{events as e}from"@dropins/tools/event-bus.js";const n=r=>{throw r instanceof DOMException&&r.name==="AbortError"||e.emit("error",{source:"company",type:"network",error:r}),r},a=r=>{const o=r.map(t=>t.message).join(" ");throw Error(o)};export{n as a,a as h};
4
+ //# sourceMappingURL=fetch-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-error.js","sources":["/@dropins/storefront-company-management/src/lib/network-error.ts","/@dropins/storefront-company-management/src/lib/fetch-error.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { events } from '@adobe-commerce/event-bus';\n\n/**\n * A function which can be attached to fetchGraphQL to handle thrown errors in\n * a generic way.\n */\nexport const handleNetworkError = (error: Error) => {\n const isAbortError =\n error instanceof DOMException && error.name === 'AbortError';\n\n if (!isAbortError) {\n // @ts-ignore\n events.emit('error', {\n source: 'company',\n type: 'network',\n error,\n });\n }\n throw error;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n/** Actions */\nexport const handleFetchError = (errors: Array<{ message: string }>) => {\n const errorMessage = errors.map((e: any) => e.message).join(' ');\n\n throw Error(errorMessage);\n};\n"],"names":["handleNetworkError","error","events","handleFetchError","errors","errorMessage","e"],"mappings":"qDAsBa,MAAAA,EAAsBC,GAAiB,CAIlD,MAFEA,aAAiB,cAAgBA,EAAM,OAAS,cAIhDC,EAAO,KAAK,QAAS,CACnB,OAAQ,UACR,KAAM,UACN,MAAAD,CAAA,CACD,EAEGA,CACR,EClBaE,EAAoBC,GAAuC,CAChE,MAAAC,EAAeD,EAAO,IAAKE,GAAWA,EAAE,OAAO,EAAE,KAAK,GAAG,EAE/D,MAAM,MAAMD,CAAY,CAC1B"}
@@ -0,0 +1,4 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import{FetchGraphQL as e}from"@dropins/tools/fetch-graphql.js";const{setEndpoint:t,setFetchGraphQlHeader:r,removeFetchGraphQlHeader:s,setFetchGraphQlHeaders:h,fetchGraphQl:o,getConfig:p}=new e().getMethods();export{r as a,h as b,o as f,p as g,s as r,t as s};
4
+ //# sourceMappingURL=fetch-graphql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-graphql.js","sources":["/@dropins/storefront-company-management/src/api/fetch-graphql/fetch-graphql.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"],"names":["setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL"],"mappings":"+DAmBa,KAAA,CACX,YAAAA,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAC,EACA,UAAAC,CACF,EAAI,IAAIC,EAAa,EAAE,WAAW"}
@@ -0,0 +1,26 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import{h as i,a as m}from"./fetch-error.js";import{f as l}from"./fetch-graphql.js";const d=o=>{var t,e,c;const n=(t=o==null?void 0:o.data)==null?void 0:t.customer,r=(e=o==null?void 0:o.data)==null?void 0:e.company;if(!n||!r)return null;const a={companyName:(r==null?void 0:r.name)??"",jobTitle:(n==null?void 0:n.job_title)??"",workPhoneNumber:(n==null?void 0:n.telephone)??"",userRole:((c=n==null?void 0:n.role)==null?void 0:c.name)??""};return a.companyName?a:null},h=`
4
+ query GET_COMPANY_ENABLED {
5
+ storeConfig {
6
+ company_enabled
7
+ }
8
+ }
9
+ `,f=async()=>{var r,a,t;const o=await l(h,{method:"POST"});if((r=o==null?void 0:o.errors)!=null&&r.length)throw new Error(((a=o.errors[0])==null?void 0:a.message)||"Failed to load store configuration");const n=(t=o==null?void 0:o.data)==null?void 0:t.storeConfig;if(!n)throw new Error("Invalid response: missing storeConfig");return!!n.company_enabled},E=`
10
+ query GET_CUSTOMER_COMPANY_INFO {
11
+ customer {
12
+ id
13
+ job_title
14
+ telephone
15
+ role {
16
+ id
17
+ name
18
+ }
19
+ }
20
+ company {
21
+ id
22
+ name
23
+ }
24
+ }
25
+ `,u=async()=>{var o;try{if(!await f())return null;const r=await l(E,{method:"GET",cache:"no-cache"});return(o=r.errors)!=null&&o.length?i(r.errors):d(r)}catch(n){return console.error("Failed to fetch customer company info:",n),m(n)}};export{f as c,u as g};
26
+ //# sourceMappingURL=getCustomerCompany.js.map