@dropins/storefront-quote-management 0.0.1-alpha31 → 0.0.1-alpha33
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/LICENSE.md +25 -26
- package/api/getStoreConfig/graphql/StoreConfigQuery.d.ts +1 -1
- package/api.js +5 -3
- package/api.js.map +1 -1
- package/chunks/state.js +1 -1
- package/chunks/state.js.map +1 -1
- package/chunks/transform-quote.js +1 -1
- package/chunks/transform-quote.js.map +1 -1
- package/containers/ManageNegotiableQuote.js +1 -1
- package/containers/ManageNegotiableQuote.js.map +1 -1
- package/containers/ManageNegotiableQuoteTemplate.js +2 -2
- package/containers/ManageNegotiableQuoteTemplate.js.map +1 -1
- package/containers/QuoteTemplatesListTable.js +1 -1
- package/containers/QuoteTemplatesListTable.js.map +1 -1
- package/containers/QuotesListTable.js +1 -1
- package/containers/QuotesListTable.js.map +1 -1
- package/data/models/store-config-model.d.ts +2 -0
- package/data/transforms/__fixtures__/storeConfigData.d.ts +4 -0
- package/i18n/en_US.json.d.ts +0 -10
- package/package.json +1 -1
- package/render.js +1 -1
- package/render.js.map +1 -1
package/LICENSE.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Last Updated: 28 October 2024
|
|
1
|
+
Last Updated: 8 December 2025
|
|
3
2
|
|
|
4
|
-
ADOBE COMMERCE DROP-IN LICENSE AGREEMENT
|
|
3
|
+
**ADOBE COMMERCE DROP-IN LICENSE AGREEMENT**
|
|
5
4
|
|
|
6
|
-
applicable to Adobe Commerce Customers
|
|
5
|
+
applicable to Adobe Commerce as a Cloud Service and Adobe Commerce Optimizer Customers
|
|
7
6
|
|
|
8
7
|
**Effective Date:** first date you download or use the Drop-in
|
|
9
8
|
|
|
10
|
-
NOTICE TO USER: The Adobe Commerce Drop-in (
|
|
9
|
+
NOTICE TO USER: The Adobe Commerce Drop-ins are licensed only for use with Adobe Commerce as a Cloud Service and Adobe Commerce Optimizer. The Adobe Commerce Drop-in ("Drop-in") is licensed to you subject to the terms and conditions below which form a binding agreement between you and Adobe. **By downloading, installing, or making use of any portion of the Drop-in, you are agreeing to the following terms and conditions. If you do not agree to the terms and conditions below, do not use the Drop-in**. If you agree to be bound by this agreement on behalf of your employer or other entity, you must have the legal authority to do so. If you are not authorized to so bind your employer or such entity, do not download and do not use the Drop-in.
|
|
11
10
|
|
|
12
11
|
Your access to and use of the Drop-in is governed by the Adobe Enterprise Licensing Terms previously agreed to by you and Adobe or an authorized Adobe Reseller in a separate agreement. If you have not previously agreed to licensing terms then your installation and use of the Drop-in is subject to the current applicable Adobe Enterprise Licensing Terms available at <http://www.adobe.com/legal/terms/enterprise-licensing.html>. You agree that this agreement will have the same effect as any written negotiated agreement signed by you.
|
|
13
12
|
|
|
@@ -15,7 +14,7 @@ By downloading, installing or making use of any portion of the Drop-in, you acce
|
|
|
15
14
|
|
|
16
15
|
This agreement is enforceable against any person or entity that installs and uses the Drop-in and any person or entity (e.g., system integrator, consultant or contractor) that installs or uses the drop-in on another person's or entity's behalf (e.g., Adobe Customer).
|
|
17
16
|
|
|
18
|
-
Notice to U.S. Government End Users: Products and services are
|
|
17
|
+
Notice to U.S. Government End Users: Products and services are "Commercial Product(s)," and "Commercial Service(s)" as those terms are defined at 48 C.F.R. section 2.101, consisting of "Commercial Computer Software" and "Commercial Computer Software Documentation," as the terms are used in 48 C.F.R. section 12.212 or 48 C.F.R. section 227.7202, as applicable. Customer agrees, consistent with 48 C.F.R. section 12.212 or 48 C.F.R. sections 227.7202-1 through 227.72024, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (A) only as Commercial Products and Services; and (B) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished rights are reserved under the copyright laws of the United States.
|
|
19
18
|
|
|
20
19
|
**ADOBE COMMERCE DROP-IN LICENSE AGREEMENT**
|
|
21
20
|
|
|
@@ -23,21 +22,21 @@ applicable to Developers
|
|
|
23
22
|
|
|
24
23
|
**Effective Date:** first date you download or use the Drop-in
|
|
25
24
|
|
|
26
|
-
The Adobe Commerce Drop-in (
|
|
25
|
+
The Adobe Commerce Drop-ins are licensed only for use with Adobe Commerce as a Cloud Service and Adobe Commerce Optimizer. The Adobe Commerce Drop-in ("Drop-in") is licensed to you subject to the terms and conditions below which form a binding agreement between you and Adobe. **By downloading, installing, or making use of any portion of the Drop-in, you are agreeing to the following terms and conditions. If you do not agree to the terms and conditions below, do not use the Drop-in**. If you agree to be bound by this agreement on behalf of your employer or other entity, you must have the legal authority to do so. If you are not authorized to so bind your employer or such entity, do not download and do not use the Drop-in.
|
|
27
26
|
|
|
28
27
|
**AGREED TERMS AND CONDITIONS**
|
|
29
28
|
|
|
30
29
|
1. **DEFINITIONS**.
|
|
31
30
|
|
|
32
|
-
1.1
|
|
31
|
+
1.1 "**Adobe**" means collectively, Adobe Inc., a company incorporated in Delaware, U.S.A., having a place of business at 345 Park Avenue, San Jose, California USA 95110-2704, U.S.A. ("**Adobe US**") and Adobe Systems Software Ireland, company incorporated in Ireland, having a place of business 4-6 Riverwalk, City West Business Campus, Saggart, Dublin 24, Ireland ("**Adobe Ireland**").
|
|
33
32
|
|
|
34
|
-
1.2
|
|
33
|
+
1.2 "**Adobe Product(s)**" means software applications, programs and other technologies not included in or with the Drop-in which are or may be made available by Adobe for licensing to the general public. This agreement does not govern use of Adobe Products. See the end user license agreement accompanying an Adobe Product for terms governing its use.
|
|
35
34
|
|
|
36
|
-
1.3
|
|
35
|
+
1.3 "**Developer Product(s)**" means any software application(s), program(s) and other technolog(y/ies) you develop with use of the Drop-in to function or interoperate with Adobe Products.
|
|
37
36
|
|
|
38
|
-
1.4
|
|
37
|
+
1.4 "**Intellectual Property Rights**" means copyright, moral rights, trademark, trade dress, patent, trade secret, unfair competition, and any other intellectual and proprietary rights.
|
|
39
38
|
|
|
40
|
-
1.5
|
|
39
|
+
1.5 "**Adobe Commerce Drop-in**" or "Drop-in" means all items comprising the application and all associated materials licensed to you by Adobe as part of the Drop-in, including all Drop-in system files, tools, programs and utilities, as well as any plug-ins or other application programming interfaces, header or JAR files ("**API**"), sample images, sounds, or similar assets ("**Content** **Files**"), software code samples, runtimes and libraries, including any portion(s) that is modified by you, or merged or incorporated with your Developer Products ("**Sample Code**"), and any related documentation, technical specifications, notes and explanatory materials, as well any modifications, updates, upgrades, or copies of, any of the foregoing items, that may be made available by Adobe, whether online or recorded on media, or manually downloaded by you.
|
|
41
40
|
|
|
42
41
|
2. **LICENSES GRANTED TO YOU**.
|
|
43
42
|
|
|
@@ -51,23 +50,23 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
|
|
|
51
50
|
|
|
52
51
|
3. **SCOPE OF LICENSE; LIMITATIONS AND RESTRICTIONS**
|
|
53
52
|
|
|
54
|
-
3.1 You may not distribute the Drop-ins or any of its component parts to interoperate with or to run on a platform other than
|
|
53
|
+
3.1 You may not distribute the Drop-ins or any of its component parts to interoperate with or to run on a platform other than Adobe Commerce as a Cloud Service and Adobe Commerce Optimizer.
|
|
55
54
|
|
|
56
55
|
3.2 Third-Party Software. The Drop-ins may contain third-party software, subject to additional terms and conditions, available at <http://www.adobe.com/go/thirdparty>; and
|
|
57
56
|
|
|
58
|
-
3.3 You may not modify, port, adapt,
|
|
57
|
+
3.3 You may not modify, port, adapt, create derivate works, redistribute, or translate any portion of this Drop-in; or add or delete any Drop-in program files that would in any way result in modifying the functionality or appearance of any element of the Adobe Products.
|
|
59
58
|
|
|
60
|
-
3.4 You may not reverse engineer, decompile, disassemble, or otherwise attempt to discover the source code of, any portion of the Drop-in, except and only to the extent that applicable laws of the jurisdiction where you are located grant you the right to decompile the Drop-in in order to obtain information necessary to render the Drop-in interoperable with other software; in which case you must first request the information from Adobe in writing and Adobe may, in its discretion, either provide such information to you or impose reasonable conditions, including reasonable fees, on your use of the Drop-in to ensure that Adobe
|
|
59
|
+
3.4 You may not reverse engineer, decompile, disassemble, or otherwise attempt to discover the source code of, any portion of the Drop-in, except and only to the extent that applicable laws of the jurisdiction where you are located grant you the right to decompile the Drop-in in order to obtain information necessary to render the Drop-in interoperable with other software; in which case you must first request the information from Adobe in writing and Adobe may, in its discretion, either provide such information to you or impose reasonable conditions, including reasonable fees, on your use of the Drop-in to ensure that Adobe's and its licensors' Intellectual Proprietary Rights in the Drop-in are protected.
|
|
61
60
|
|
|
62
|
-
3.5 You may not unbundle, repackage, distribute, rent, lease, offer, sell, resale, sublicense, assign or transfer all, or any component parts of the Drop-in, or any of your rights in the Drop-in, nor authorize any portion of the Drop-in to be copied onto another
|
|
61
|
+
3.5 You may not unbundle, repackage, distribute, rent, lease, offer, sell, resale, sublicense, assign or transfer all, or any component parts of the Drop-in, or any of your rights in the Drop-in, nor authorize any portion of the Drop-in to be copied onto another's device, computer or platform, including on a service bureau basis to other providers (i.e., volume printing, banking, payroll service providers, etc) who provide you free or fee-based business services.
|
|
63
62
|
|
|
64
63
|
4. **VIRAL OPEN SOURCE SOFTWARE AND SERVICES**
|
|
65
64
|
|
|
66
|
-
You are not
|
|
65
|
+
You are not licensed to (and you agree that you will not) merge, integrate or use the Drop-in with any Viral Open Source Software or Viral Service, or otherwise take any action that could require disclosure, distribution, or licensing of all or any part of the Drop-in in source code form for any purpose whatsoever. For purposes of this Section, "**Viral Open Source Software**" means software licensed under the GNU General Public License, the GNU Affero General Public License (AGPL), the GNU Lesser General Public License (LGPL), or any other license terms that would require, or condition your use, modification, or distribution of such licensed software on the disclosure, distribution, or licensing of any other software in source code form, for the purpose of making derivative works, or at no charge, and "**Viral Service**" means any service that contains any viruses, Trojan horses, worms, time bombs, cancelbots or other computer programming routines that are intended to damage, detrimentally interfere with, surreptitiously intercept, expropriate or deprive owners' possession of any system, data or personal information, or that in any way violates any law, statute, ordinance, regulation or rights (including any law, regulations or rights respecting intellectual property, computer spyware, privacy, export control, unfair competition, antidiscrimination or false advertising), or otherwise interferes with the operability of Adobe Products or third-party programs or software.
|
|
67
66
|
|
|
68
67
|
5. **NON-BLOCKING OF ADOBE DEVELOPMENT**
|
|
69
68
|
|
|
70
|
-
You acknowledge that Adobe is currently developing or may develop technologies and Adobe Products in the future that have, or may have, design or functionality similar to Developer Products that you may develop based on the license granted to you in this agreement. Nothing in this agreement will impair, limit or curtail Adobe
|
|
69
|
+
You acknowledge that Adobe is currently developing or may develop technologies and Adobe Products in the future that have, or may have, design or functionality similar to Developer Products that you may develop based on the license granted to you in this agreement. Nothing in this agreement will impair, limit or curtail Adobe's right to continue with its development, maintenance or distribution of Adobe Products. You agree that you will not assert in any way any patent owned by you arising out of or in connection with your use of the Drop-in, or any Drop-in modifications made by you, against Adobe, its customers, subsidiaries or affiliates, or any of their customers, direct or indirect, agents and contractors for the manufacture, use, import, license, offer for sale, or sale of any Adobe Products.
|
|
71
70
|
|
|
72
71
|
6. **OWNERSHIP; INTELLECTUAL PROPERTY RIGHTS**
|
|
73
72
|
|
|
@@ -75,13 +74,13 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
|
|
|
75
74
|
|
|
76
75
|
6.2 The Drop-in, or any of its component parts, may be supplied to you with certain accompanying proprietary notices, including patent, copyright and trademark notices. You agree to protect all copyright and other ownership interests of Adobe and its licensors in the Drop-in supplied to you under this agreement; to preserve exactly (and not remove or alter) all proprietary notices displayed in or on the Drop-in; to reproduce the same proprietary notices in all copies you make of any portion of the Drop-in.
|
|
77
76
|
|
|
78
|
-
6.3 You agree to include in your Developer Products Adobe
|
|
77
|
+
6.3 You agree to include in your Developer Products Adobe's copyright notices, wherever such notices are customarily posted, in substantially the following form: _Portions of software used to develop this product copyrighted by Adobe and its licensors. All Rights Reserved_.
|
|
79
78
|
|
|
80
79
|
6.4 Nothing in this agreement gives you a right to use the name, logo or trademarks of Adobe or its licensors to market your Developer Products.
|
|
81
80
|
|
|
82
81
|
7. **CONFIDENTIAL INFORMATION**
|
|
83
82
|
|
|
84
|
-
With respect to the API, and any portion, included in the Drop-in (for purposes of this Section,
|
|
83
|
+
With respect to the API, and any portion, included in the Drop-in (for purposes of this Section, "**Adobe Confidential Information**"), you will treat the Adobe Confidential Information, and exercise the same degree of care to protect it, as you afford to your own confidential information. Your obligations under this Section will terminate when you can document that (a) the Adobe Confidential Information was in the public domain at or subsequent to the time Adobe communicated or provided it to you with no fault of your own; (b) your employees or agents developed independently without reference to any Adobe Confidential Information Adobe communicated or provided to you; or (c) your communication of Adobe Confidential Information was in response to a valid order by a court or other governmental body, was otherwise required by law, or was necessary to establish the rights of a party under this agreement.
|
|
85
84
|
|
|
86
85
|
8. **TERM; TERMINATION**
|
|
87
86
|
|
|
@@ -91,13 +90,13 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
|
|
|
91
90
|
|
|
92
91
|
You expressly understand and agree that, to the maximum extent permitted by applicable law:
|
|
93
92
|
|
|
94
|
-
9.1 **Use
|
|
93
|
+
9.1 **Use of the DROP-IN is entirely at your own risk. The Drop-in is provided by Adobe "AS-IS" and with all faults. Adobe and its licensors are not liable to you or anyone else for any special, incidental, indirect, consequential, or punitive damages whatsoever (even if Adobe has been advised of the possibility of such damages), including (a) damages resulting from loss of use, data, or profits, whether or not foreseeable, (b) damages based on any theory of liability, including breach of contract or warranty, negligence or other tortious action, or (c) damages arising from any other claim arising out of or in connection with your use of the Drop-in.**
|
|
95
94
|
|
|
96
|
-
9.2 **Adobe
|
|
95
|
+
9.2 **Adobe's total liability in any matter arising out of or related to these terms is limited to US $100. This limitation will apply even if Adobe has been advised of the possibility of such damages and regardless of any failure of the essential purpose of any limited remedy.**
|
|
97
96
|
|
|
98
97
|
10. **INDEMNIFICATION**
|
|
99
98
|
|
|
100
|
-
To the maximum extent permitted by law, you agree to indemnify Adobe, its subsidiaries, affiliates, officers, agents, employees, partners, licensors, or suppliers from any claim or demand, including reasonable attorneys
|
|
99
|
+
To the maximum extent permitted by law, you agree to indemnify Adobe, its subsidiaries, affiliates, officers, agents, employees, partners, licensors, or suppliers from any claim or demand, including reasonable attorneys' fees, that arise from the use and distribution of your Developer Products that contain or are based upon any portion of the Drop-in, or from your violation of the terms of this agreement.
|
|
101
100
|
|
|
102
101
|
11. **DISPUTE RESOLUTION**
|
|
103
102
|
|
|
@@ -105,7 +104,7 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
|
|
|
105
104
|
|
|
106
105
|
11.2 **Venue.** You agree that any claim or dispute you may have against Adobe must be resolved by a court located in Santa Clara County, California, United States of America. You agree to submit to the personal jurisdiction of the courts located in Santa Clara County, California, United States of America when the laws of California apply, and the courts of Dublin, Ireland, when the laws of Ireland applies, for the purpose of litigating such claims or disputes. The parties specifically disclaim the U.N. Convention on Contracts for the International Sale of Goods.
|
|
107
106
|
|
|
108
|
-
11.3 **Injunctive Relief.** Notwithstanding the foregoing, in the event of your or others
|
|
107
|
+
11.3 **Injunctive Relief.** Notwithstanding the foregoing, in the event of your or others' unauthorized access to or use of the Drop-in in violation of this Agreement, you agree that Adobe is entitled to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.
|
|
109
108
|
|
|
110
109
|
12. **EXPORT RULES**
|
|
111
110
|
|
|
@@ -113,7 +112,7 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
|
|
|
113
112
|
|
|
114
113
|
13. **NOTICE TO U.S. GOVERNMENT END USERS**
|
|
115
114
|
|
|
116
|
-
Products and services are
|
|
115
|
+
Products and services are "Commercial Product(s)," and "Commercial Service(s)" as those terms are defined at 48 C.F.R. section 2.101, consisting of "Commercial Computer Software" and "Commercial Computer Software Documentation," as the terms are used in 48 C.F.R. section 12.212 or 48 C.F.R. section 227.7202, as applicable. Customer agrees, consistent with 48 C.F.R. section 12.212 or 48 C.F.R. sections 227.7202-1 through 227.72024, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (A) only as Commercial Products and Services; and (B) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished rights are reserved under the copyright laws of the United States.
|
|
117
116
|
|
|
118
117
|
14. **GENERAL PROVISIONS**
|
|
119
118
|
|
|
@@ -125,4 +124,4 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
|
|
|
125
124
|
|
|
126
125
|
14.4 **Entire Agreement.** This Agreement is the entire agreement, superseding any prior written or oral agreements, between you and Adobe relating to the Drop-in.
|
|
127
126
|
|
|
128
|
-
Adobe Commerce Drop-in License Agreement_en_US-
|
|
127
|
+
Adobe Commerce Drop-in License Agreement_en_US-20251208_v1
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* file in accordance with the terms of the Adobe license agreement
|
|
7
7
|
* accompanying it.
|
|
8
8
|
*******************************************************************/
|
|
9
|
-
export declare const STORE_CONFIG_QUERY = "\n query STORE_CONFIG_QUERY {\n storeConfig {\n cart_summary_display_quantity\n max_items_in_order_summary\n shopping_cart_display_full_summary\n shopping_cart_display_grand_total\n shopping_cart_display_price\n shopping_cart_display_shipping\n shopping_cart_display_subtotal\n shopping_cart_display_zero_tax\n configurable_thumbnail_source\n }\n }\n";
|
|
9
|
+
export declare const STORE_CONFIG_QUERY = "\n query STORE_CONFIG_QUERY {\n storeConfig {\n cart_summary_display_quantity\n max_items_in_order_summary\n shopping_cart_display_full_summary\n shopping_cart_display_grand_total\n shopping_cart_display_price\n shopping_cart_display_shipping\n shopping_cart_display_subtotal\n shopping_cart_display_zero_tax\n configurable_thumbnail_source\n quote_minimum_amount\n quote_minimum_amount_message\n }\n }\n";
|
|
10
10
|
//# sourceMappingURL=StoreConfigQuery.d.ts.map
|
package/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{r as J}from"./chunks/requestNegotiableQuote.js";import{g as I}from"./chunks/duplicateNegotiableQuote.js";import{c as V,a as W,d as Z,b as ee,r as te,s as se}from"./chunks/duplicateNegotiableQuote.js";import{F as re,N as ae,S as ie,n as ne}from"./chunks/negotiableQuotes.js";import{events as a}from"@dropins/tools/event-bus.js";import{s as r,D as f,a as h,Q as n}from"./chunks/state.js";import{f as d,t as q}from"./chunks/transform-quote.js";import{i as ue,r as
|
|
3
|
+
import{r as J}from"./chunks/requestNegotiableQuote.js";import{g as I}from"./chunks/duplicateNegotiableQuote.js";import{c as V,a as W,d as Z,b as ee,r as te,s as se}from"./chunks/duplicateNegotiableQuote.js";import{F as re,N as ae,S as ie,n as ne}from"./chunks/negotiableQuotes.js";import{events as a}from"@dropins/tools/event-bus.js";import{s as r,D as f,a as h,Q as n}from"./chunks/state.js";import{f as d,t as q}from"./chunks/transform-quote.js";import{i as ue,r as me,s as pe,e as le,h as ge}from"./chunks/transform-quote.js";import{N as D}from"./chunks/NegotiableQuoteFragment.js";import{u as _e}from"./chunks/uploadFile.js";import{a as T}from"./chunks/transform-quote-template.js";import{N as Q}from"./chunks/NegotiableQuoteTemplateFragment.js";import{Q as he,a as Te,S as Qe,g as Ae}from"./chunks/getQuoteTemplates.js";import{a as Ie,c as qe,d as De,o as Ne,s as ye}from"./chunks/openQuoteTemplate.js";import{a as Se,r as we,u as Fe}from"./chunks/addQuoteTemplateLineItemNote.js";import{g as ve}from"./chunks/generateQuoteFromTemplate.js";import{r as Me,s as Oe,u as xe}from"./chunks/setLineItemNote.js";import{Initializer as N}from"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";function y(e){if(!e||typeof e!="object")return{requestQuote:!1,editQuote:!1,deleteQuote:!1,checkoutQuote:!1,viewQuoteTemplates:!1,manageQuoteTemplates:!1,generateQuoteFromTemplate:!1};if(e.all===!0)return{requestQuote:!0,editQuote:!0,deleteQuote:!0,checkoutQuote:!0,viewQuoteTemplates:!0,manageQuoteTemplates:!0,generateQuoteFromTemplate:!0};const s=e["Magento_NegotiableQuote::all"]===!0,t=e["Magento_NegotiableQuoteTemplate::all"]===!0,o=s||e["Magento_NegotiableQuote::manage"]===!0;return{requestQuote:o,editQuote:o,deleteQuote:o,checkoutQuote:s||e["Magento_NegotiableQuote::checkout"]===!0,viewQuoteTemplates:t||e["Magento_NegotiableQuoteTemplate::view_template"]===!0,manageQuoteTemplates:t||e["Magento_NegotiableQuoteTemplate::manage"]===!0,generateQuoteFromTemplate:t||e["Magento_NegotiableQuoteTemplate::generate_quote"]===!0}}function m(e){if(r.quoteDataLoaded)return;const s=p.config.getConfig(),{quoteId:t,quoteTemplateId:o}=s;!e.editQuote||!t&&!o||(r.quoteDataLoaded=!0,t&&I(t).then(i=>{r.quoteDataInitialized||a.emit("quote-management/quote-data/initialized",{quote:i,permissions:e}),r.quoteDataInitialized=!0}).catch(i=>{r.quoteDataLoaded=!1,a.emit("quote-management/quote-data/error",{error:i})}),o&&L(o).catch(i=>{r.quoteDataLoaded=!1,a.emit("quote-management/quote-template-data/error",{error:i})}))}const p=new N({init:async e=>{const s={};p.config.setConfig({...s,...e}),await w().then(t=>{r.config=t}).catch(t=>{console.error("Failed to fetch store config: ",t),r.config=h}),r.initialized=!0,a.emit("quote-management/initialized",{config:r.config})},listeners:()=>[a.on("authenticated",async e=>{r.authenticated=!!e,e||(r.permissions=f,r.quoteDataLoaded=!1,a.emit("quote-management/permissions",f))},{eager:!0}),a.on("auth/permissions",async e=>{const s=y(e);r.permissions=s,r.quoteDataLoaded=!1,a.emit("quote-management/permissions",r.permissions)},{eager:!0}),a.on("quote-management/permissions",async e=>{r.initialized&&m(e)},{eager:!0}),a.on("quote-management/initialized",async()=>{m(r.permissions)},{eager:!0}),a.on("checkout/updated",async e=>{r.initialized&&(e==null?void 0:e.type)==="quote"&&(r.quoteDataLoaded=!1,m(r.permissions))},{eager:!0})]}),B=p.config;function b(e){if(!e)return h;const s=t=>[n.TAX_EXCLUDED,n.TAX_INCLUDED,n.TAX_INCLUDED_AND_EXCLUDED].includes(t)?t:n.TAX_EXCLUDED;return{quoteSummaryDisplayTotal:e.cart_summary_display_quantity,quoteSummaryMaxItems:e.max_items_in_order_summary,quoteDisplaySettings:{zeroTax:e.shopping_cart_display_zero_tax,subtotal:s(e.shopping_cart_display_subtotal),price:s(e.shopping_cart_display_price),shipping:s(e.shopping_cart_display_shipping),fullSummary:e.shopping_cart_display_full_summary,grandTotal:e.shopping_cart_display_grand_total},useConfigurableParentThumbnail:e.configurable_thumbnail_source==="parent",quoteMinimumAmount:e.quote_minimum_amount??null,quoteMinimumAmountMessage:e.quote_minimum_amount_message??null}}const S=`
|
|
4
4
|
query STORE_CONFIG_QUERY {
|
|
5
5
|
storeConfig {
|
|
6
6
|
cart_summary_display_quantity
|
|
@@ -12,6 +12,8 @@ import{r as J}from"./chunks/requestNegotiableQuote.js";import{g as I}from"./chun
|
|
|
12
12
|
shopping_cart_display_subtotal
|
|
13
13
|
shopping_cart_display_zero_tax
|
|
14
14
|
configurable_thumbnail_source
|
|
15
|
+
quote_minimum_amount
|
|
16
|
+
quote_minimum_amount_message
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
`,w=async()=>d(S,{method:"GET",cache:"force-cache"}).then(({errors:e,data:s})=>{if(e){const t=e.map(o=>o.message).join(", ");throw new Error(`Failed to get store config: ${t}`)}return b(s.storeConfig)}),F=`
|
|
@@ -35,7 +37,7 @@ import{r as J}from"./chunks/requestNegotiableQuote.js";import{g as I}from"./chun
|
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
${D}
|
|
38
|
-
`;function U(e){const{additionalInput:s,...t}=e,o={city:t.city,company:t.company,country_code:t.countryCode,firstname:t.firstname,lastname:t.lastname,postcode:t.postcode,region:t.region,region_id:t.regionId,save_in_address_book:t.saveInAddressBook,street:t.street,telephone:t.telephone};return{...s||{},...o}}const H=async e=>{const{quoteUid:s,addressId:t,addressData:o}=e;if(!s)throw new Error("Quote UID is required");if(t===void 0&&!o)throw new Error("Either addressId or addressData must be provided");if(t!==void 0&&o)throw new Error("Cannot provide both addressId and addressData");const i=o?U(o):null;return d(F,{variables:{quoteUid:s,addressId:t||null,addressData:i}}).then(l=>{var c,_;const{errors:g}=l;if(g){const
|
|
40
|
+
`;function U(e){const{additionalInput:s,...t}=e,o={city:t.city,company:t.company,country_code:t.countryCode,firstname:t.firstname,lastname:t.lastname,postcode:t.postcode,region:t.region,region_id:t.regionId,save_in_address_book:t.saveInAddressBook,street:t.street,telephone:t.telephone};return{...s||{},...o}}const H=async e=>{const{quoteUid:s,addressId:t,addressData:o}=e;if(!s)throw new Error("Quote UID is required");if(t===void 0&&!o)throw new Error("Either addressId or addressData must be provided");if(t!==void 0&&o)throw new Error("Cannot provide both addressId and addressData");const i=o?U(o):null;return d(F,{variables:{quoteUid:s,addressId:t||null,addressData:i}}).then(l=>{var c,_;const{errors:g}=l;if(g){const A=g.map(E=>E.message).join("; ");throw new Error(`Failed to set shipping address: ${A}`)}const u=q((_=(c=l.data)==null?void 0:c.setNegotiableQuoteShippingAddress)==null?void 0:_.quote);if(!u)throw new Error("Failed to transform quote data: Invalid response structure");return a.emit("quote-management/shipping-address-set",{quote:u,input:{quoteUid:s,addressId:t,addressData:o}}),u})},v=`
|
|
39
41
|
query QUOTE_TEMPLATE_DATA_QUERY($templateId: ID!) {
|
|
40
42
|
negotiableQuoteTemplate(templateId: $templateId) {
|
|
41
43
|
...NegotiableQuoteTemplateFragment
|
|
@@ -59,5 +61,5 @@ import{r as J}from"./chunks/requestNegotiableQuote.js";import{g as I}from"./chun
|
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
${Q}
|
|
62
|
-
`,X=async e=>{var s;if(!e.templateId)throw new Error("Template ID is required");if(!e.shippingAddress)throw new Error("Shipping address is required");if(!r.authenticated)throw new Error("Unauthorized");if(!e.shippingAddress.address&&!e.shippingAddress.customerAddressUid)throw new Error("Either address or customerAddressUid must be provided");try{const t=await d(M,{variables:{templateId:e.templateId,shippingAddress:{address:e.shippingAddress.address?{city:e.shippingAddress.address.city,company:e.shippingAddress.address.company,country_code:e.shippingAddress.address.countryCode,fax:e.shippingAddress.address.fax,firstname:e.shippingAddress.address.firstname,lastname:e.shippingAddress.address.lastname,middlename:e.shippingAddress.address.middlename,postcode:e.shippingAddress.address.postcode,prefix:e.shippingAddress.address.prefix,region:e.shippingAddress.address.region,region_id:e.shippingAddress.address.regionId,save_in_address_book:e.shippingAddress.address.saveInAddressBook,street:e.shippingAddress.address.street,suffix:e.shippingAddress.address.suffix,telephone:e.shippingAddress.address.telephone,vat_id:e.shippingAddress.address.vatId}:void 0,customer_address_uid:e.shippingAddress.customerAddressUid,customer_notes:e.shippingAddress.customerNotes}}});if(!((s=t==null?void 0:t.data)!=null&&s.setNegotiableQuoteTemplateShippingAddress))throw new Error("No quote template data received");const o=T(t.data.setNegotiableQuoteTemplateShippingAddress);if(!o)throw new Error("Failed to transform quote template data");return a.emit("quote-management/quote-template-data",{quoteTemplate:o,permissions:r.permissions}),o}catch(t){return Promise.reject(t)}};export{re as FilterMatchTypeEnum,ae as NegotiableQuoteSortableField,he as QuoteTemplateFilterStatus,Te as QuoteTemplateSortField,Qe as SortDirection,ie as SortEnum,Ie as acceptQuoteTemplate,Se as addQuoteTemplateLineItemNote,X as addQuoteTemplateShippingAddress,qe as cancelQuoteTemplate,V as closeNegotiableQuote,B as config,W as createQuoteTemplate,Z as deleteQuote,De as deleteQuoteTemplate,ee as duplicateQuote,d as fetchGraphQl,ve as generateQuoteFromTemplate,ue as getConfig,I as getQuoteData,L as getQuoteTemplateData,
|
|
64
|
+
`,X=async e=>{var s;if(!e.templateId)throw new Error("Template ID is required");if(!e.shippingAddress)throw new Error("Shipping address is required");if(!r.authenticated)throw new Error("Unauthorized");if(!e.shippingAddress.address&&!e.shippingAddress.customerAddressUid)throw new Error("Either address or customerAddressUid must be provided");try{const t=await d(M,{variables:{templateId:e.templateId,shippingAddress:{address:e.shippingAddress.address?{city:e.shippingAddress.address.city,company:e.shippingAddress.address.company,country_code:e.shippingAddress.address.countryCode,fax:e.shippingAddress.address.fax,firstname:e.shippingAddress.address.firstname,lastname:e.shippingAddress.address.lastname,middlename:e.shippingAddress.address.middlename,postcode:e.shippingAddress.address.postcode,prefix:e.shippingAddress.address.prefix,region:e.shippingAddress.address.region,region_id:e.shippingAddress.address.regionId,save_in_address_book:e.shippingAddress.address.saveInAddressBook,street:e.shippingAddress.address.street,suffix:e.shippingAddress.address.suffix,telephone:e.shippingAddress.address.telephone,vat_id:e.shippingAddress.address.vatId}:void 0,customer_address_uid:e.shippingAddress.customerAddressUid,customer_notes:e.shippingAddress.customerNotes}}});if(!((s=t==null?void 0:t.data)!=null&&s.setNegotiableQuoteTemplateShippingAddress))throw new Error("No quote template data received");const o=T(t.data.setNegotiableQuoteTemplateShippingAddress);if(!o)throw new Error("Failed to transform quote template data");return a.emit("quote-management/quote-template-data",{quoteTemplate:o,permissions:r.permissions}),o}catch(t){return Promise.reject(t)}};export{re as FilterMatchTypeEnum,ae as NegotiableQuoteSortableField,he as QuoteTemplateFilterStatus,Te as QuoteTemplateSortField,Qe as SortDirection,ie as SortEnum,Ie as acceptQuoteTemplate,Se as addQuoteTemplateLineItemNote,X as addQuoteTemplateShippingAddress,qe as cancelQuoteTemplate,V as closeNegotiableQuote,B as config,W as createQuoteTemplate,Z as deleteQuote,De as deleteQuoteTemplate,ee as duplicateQuote,d as fetchGraphQl,ve as generateQuoteFromTemplate,ue as getConfig,I as getQuoteData,L as getQuoteTemplateData,Ae as getQuoteTemplates,w as getStoreConfig,p as initialize,ne as negotiableQuotes,Ne as openQuoteTemplate,me as removeFetchGraphQlHeader,Me as removeNegotiableQuoteItems,we as removeQuoteTemplateItems,te as renameNegotiableQuote,J as requestNegotiableQuote,se as sendForReview,ye as sendQuoteTemplateForReview,pe as setEndpoint,le as setFetchGraphQlHeader,ge as setFetchGraphQlHeaders,Oe as setLineItemNote,H as setShippingAddress,xe as updateQuantities,Fe as updateQuoteTemplateItemQuantities,_e as uploadFile};
|
|
63
65
|
//# sourceMappingURL=api.js.map
|
package/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sources":["/@dropins/storefront-quote-management/src/utils/mapAuthPermissions.ts","/@dropins/storefront-quote-management/src/api/initialize/initialize.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-store-config.ts","/@dropins/storefront-quote-management/src/api/getStoreConfig/graphql/StoreConfigQuery.ts","/@dropins/storefront-quote-management/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-quote-management/src/api/setShippingAddress/graphql/SetNegotiableQuoteShippingAddressMutation.ts","/@dropins/storefront-quote-management/src/api/setShippingAddress/setShippingAddress.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplateData/graphql/getQuoteTemplateData.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplateData/getQuoteTemplateData.ts","/@dropins/storefront-quote-management/src/api/addQuoteTemplateShippingAddress/graphql/setNegotiableQuoteTemplateShippingAddress.ts","/@dropins/storefront-quote-management/src/api/addQuoteTemplateShippingAddress/addQuoteTemplateShippingAddress.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { State } from '@/quote-management/types/state.types';\n\n/**\n * Type definition for the auth/permissions event payload\n * Contains flat Adobe Commerce permission keys with boolean values\n */\nexport type AuthPermissionsPayload = {\n all?: boolean;\n 'Magento_NegotiableQuote::all'?: boolean;\n 'Magento_NegotiableQuote::manage'?: boolean;\n 'Magento_NegotiableQuote::checkout'?: boolean;\n 'Magento_NegotiableQuoteTemplate::all'?: boolean;\n 'Magento_NegotiableQuoteTemplate::view_template'?: boolean;\n 'Magento_NegotiableQuoteTemplate::manage'?: boolean;\n 'Magento_NegotiableQuoteTemplate::generate_quote'?: boolean;\n [key: string]: boolean | undefined;\n};\n\n/**\n * Maps the auth/permissions event payload to internal permissions structure.\n * \n * Implements hierarchical permission checking:\n * 1. Top-level \"all\": If true, grants all permissions\n * 2. Module-level \"::all\": Grants all permissions for that module\n * 3. Specific permissions: Maps individual keys to internal flags\n * \n * @param payload - The raw auth/permissions event payload\n * @returns Typed permissions object matching the state structure\n * \n * @example\n * ```typescript\n * const permissions = mapAuthPermissions({\n * \"Magento_NegotiableQuote::manage\": true,\n * \"Magento_NegotiableQuote::checkout\": true\n * });\n * // Returns: { requestQuote: true, editQuote: true, deleteQuote: true, checkoutQuote: true, ... }\n * ```\n */\nexport function mapAuthPermissions(\n payload: AuthPermissionsPayload | null | undefined\n): State['permissions'] {\n // Handle null/undefined payload - return all false\n if (!payload || typeof payload !== 'object') {\n return {\n requestQuote: false,\n editQuote: false,\n deleteQuote: false,\n checkoutQuote: false,\n viewQuoteTemplates: false,\n manageQuoteTemplates: false,\n generateQuoteFromTemplate: false,\n };\n }\n\n // If top-level \"all\" is true, grant all permissions\n if (payload.all === true) {\n return {\n requestQuote: true,\n editQuote: true,\n deleteQuote: true,\n checkoutQuote: true,\n viewQuoteTemplates: true,\n manageQuoteTemplates: true,\n generateQuoteFromTemplate: true,\n };\n }\n\n // Check module-level \"all\" permissions\n const hasAllQuotePermissions = payload['Magento_NegotiableQuote::all'] === true;\n const hasAllTemplatePermissions = payload['Magento_NegotiableQuoteTemplate::all'] === true;\n\n // Map specific permissions with fallback to module-level \"all\"\n const hasManagePermission = \n hasAllQuotePermissions || payload['Magento_NegotiableQuote::manage'] === true;\n\n return {\n // Magento_NegotiableQuote::manage maps to request, edit, and delete\n requestQuote: hasManagePermission,\n editQuote: hasManagePermission,\n deleteQuote: hasManagePermission,\n \n // Magento_NegotiableQuote::checkout maps to checkoutQuote\n checkoutQuote: \n hasAllQuotePermissions || payload['Magento_NegotiableQuote::checkout'] === true,\n \n // Template permissions\n viewQuoteTemplates: \n hasAllTemplatePermissions || payload['Magento_NegotiableQuoteTemplate::view_template'] === true,\n manageQuoteTemplates: \n hasAllTemplatePermissions || payload['Magento_NegotiableQuoteTemplate::manage'] === true,\n generateQuoteFromTemplate: \n hasAllTemplatePermissions || payload['Magento_NegotiableQuoteTemplate::generate_quote'] === true,\n };\n}\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { Initializer } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport {\n state,\n DEFAULT_CONFIG,\n DEFAULT_PERMISSIONS,\n} from '@/quote-management/lib/state';\nimport {\n getQuoteData,\n getStoreConfig,\n getQuoteTemplateData,\n} from '@/quote-management/api';\nimport { mapAuthPermissions, AuthPermissionsPayload } from '@/quote-management/utils/mapAuthPermissions';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n quoteId?: string;\n quoteTemplateId?: string;\n};\n\nfunction loadQuoteData(permissions: typeof DEFAULT_PERMISSIONS) {\n // Prevent loading quote data twice\n if (state.quoteDataLoaded) return;\n\n const config = initialize.config.getConfig();\n const { quoteId, quoteTemplateId } = config;\n\n\n // Only proceed if we have permissions and at least one ID to load\n if (!permissions.editQuote || (!quoteId && !quoteTemplateId)) {\n return;\n }\n\n // Mark as loaded before starting the async operations to prevent duplicate calls\n state.quoteDataLoaded = true;\n\n if (quoteId) {\n getQuoteData(quoteId)\n .then((quote) => {\n if (!state.quoteDataInitialized) {\n events.emit('quote-management/quote-data/initialized', { quote, permissions });\n }\n state.quoteDataInitialized = true;\n })\n .catch((error) => {\n state.quoteDataLoaded = false;\n events.emit('quote-management/quote-data/error', { error });\n });\n }\n\n if (quoteTemplateId) {\n getQuoteTemplateData(quoteTemplateId)\n .catch((error) => {\n state.quoteDataLoaded = false;\n events.emit('quote-management/quote-template-data/error', { error });\n });\n }\n}\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = {};\n\n // Set config\n initialize.config.setConfig({ ...defaultConfig, ...config });\n\n // Fetch store config\n await getStoreConfig()\n .then((config) => {\n state.config = config;\n })\n .catch((error) => {\n console.error('Failed to fetch store config: ', error);\n state.config = DEFAULT_CONFIG;\n });\n\n // Mark initialization as complete\n state.initialized = true;\n events.emit('quote-management/initialized', {});\n },\n\n listeners: () => [\n events.on('authenticated', async (authenticated) => {\n state.authenticated = !!authenticated;\n\n // Defensive: reset permissions if user logs out\n // This ensures permissions are cleared even if auth/permissions event doesn't fire\n if (!authenticated) {\n state.permissions = DEFAULT_PERMISSIONS;\n state.quoteDataLoaded = false;\n events.emit('quote-management/permissions', DEFAULT_PERMISSIONS);\n }\n },\n {\n eager: true,\n }\n ),\n\n events.on('auth/permissions', async (payload: AuthPermissionsPayload) => {\n // Map the auth permissions payload to internal permissions structure\n const permissions = mapAuthPermissions(payload);\n\n state.permissions = permissions;\n // Reset quote data loaded flag when permissions change to allow reloading\n state.quoteDataLoaded = false;\n events.emit('quote-management/permissions', state.permissions);\n }, {\n eager: true,\n }),\n\n events.on('quote-management/permissions', async (permissions) => {\n // Only process quote data loading after initialization is complete\n if (!state.initialized) {\n return;\n }\n\n loadQuoteData(permissions);\n }, { eager: true }),\n\n events.on('quote-management/initialized', async () => {\n loadQuoteData(state.permissions);\n }, { eager: true }),\n\n events.on('checkout/updated', async (data) => {\n // Only process after initialization is complete\n if (!state.initialized) {\n return;\n }\n\n if (data?.type !== 'quote') {\n return;\n }\n\n // Reset the flag to allow reloading of quote data\n state.quoteDataLoaded = false;\n loadQuoteData(state.permissions);\n }, { eager: true }),\n ],\n});\n\nexport const config = initialize.config;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport {\n QuoteDisplayAmount,\n StoreConfigModel,\n} from '@/quote-management/data/models';\nimport { DEFAULT_CONFIG } from '@/quote-management/lib/state';\n\nexport function transformStoreConfig(data: any): StoreConfigModel {\n if (!data) return DEFAULT_CONFIG;\n\n const transformQuoteDisplayAmountSetting = (\n quoteDisplayAmountSetting: number\n ) => {\n if (\n [\n QuoteDisplayAmount.TAX_EXCLUDED,\n QuoteDisplayAmount.TAX_INCLUDED,\n QuoteDisplayAmount.TAX_INCLUDED_AND_EXCLUDED,\n ].includes(quoteDisplayAmountSetting)\n ) {\n return quoteDisplayAmountSetting;\n }\n\n return QuoteDisplayAmount.TAX_EXCLUDED;\n };\n\n return {\n quoteSummaryDisplayTotal: data.cart_summary_display_quantity,\n quoteSummaryMaxItems: data.max_items_in_order_summary,\n quoteDisplaySettings: {\n zeroTax: data.shopping_cart_display_zero_tax,\n subtotal: transformQuoteDisplayAmountSetting(\n data.shopping_cart_display_subtotal\n ),\n price: transformQuoteDisplayAmountSetting(\n data.shopping_cart_display_price\n ),\n shipping: transformQuoteDisplayAmountSetting(\n data.shopping_cart_display_shipping\n ),\n fullSummary: data.shopping_cart_display_full_summary,\n grandTotal: data.shopping_cart_display_grand_total,\n },\n useConfigurableParentThumbnail:\n data.configurable_thumbnail_source === 'parent',\n };\n}\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport const STORE_CONFIG_QUERY = /* GraphQL */ `\n query STORE_CONFIG_QUERY {\n storeConfig {\n cart_summary_display_quantity\n max_items_in_order_summary\n shopping_cart_display_full_summary\n shopping_cart_display_grand_total\n shopping_cart_display_price\n shopping_cart_display_shipping\n shopping_cart_display_subtotal\n shopping_cart_display_zero_tax\n configurable_thumbnail_source\n }\n }\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { StoreConfigModel } from '@/quote-management/data/models';\nimport { transformStoreConfig } from '@/quote-management/data/transforms';\nimport { STORE_CONFIG_QUERY } from './graphql/StoreConfigQuery';\n\nexport const getStoreConfig = async (): Promise<StoreConfigModel> => {\n return fetchGraphQl(STORE_CONFIG_QUERY, {\n method: 'GET',\n cache: 'force-cache',\n }).then(({ errors, data }) => {\n if (errors) {\n const errorMessage = errors.map((e: any) => e.message).join(', ');\n throw new Error(`Failed to get store config: ${errorMessage}`);\n }\n\n return transformStoreConfig(data.storeConfig);\n });\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION = `\n mutation SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION(\n $quoteUid: ID!\n $addressId: ID\n $addressData: NegotiableQuoteAddressInput\n ) {\n setNegotiableQuoteShippingAddress(\n input: {\n quote_uid: $quoteUid\n shipping_addresses: {\n customer_address_uid: $addressId\n address: $addressData\n }\n }\n ) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION } from './graphql/SetNegotiableQuoteShippingAddressMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface AddressInput {\n /** City name */\n city: string;\n /** Optional company name */\n company?: string;\n /** Two-letter country code (e.g., 'US') */\n countryCode: string;\n /** First name */\n firstname: string;\n /** Last name */\n lastname: string;\n /** Postal/ZIP code */\n postcode: string;\n /** Optional state/province name */\n region?: string;\n /** Optional state/province ID */\n regionId?: number;\n /** Whether to save this address to the customer's address book */\n saveInAddressBook?: boolean;\n /** Street address lines (array) */\n street: string[];\n /** Phone number */\n telephone: string;\n /** \n * Additional input (optional custom fields for the address).\n * These fields will be merged into the address data sent to GraphQL.\n * Standard fields take precedence over additional fields to prevent\n * accidental override of required address attributes.\n * \n * @example\n * ```ts\n * additionalInput: {\n * vat_id: 'GB123456789',\n * custom_attribute: 'value',\n * delivery_instructions: 'Leave at door'\n * }\n * ```\n */\n additionalInput?: Record<string, any>;\n}\n\nexport interface SetShippingAddressInput {\n /** The unique ID of the negotiable quote */\n quoteUid: string;\n /** The ID of a saved customer address (use this OR addressData, not both) */\n addressId?: number;\n /** New address data (use this OR addressId, not both) */\n addressData?: AddressInput;\n}\n\n/**\n * Transform camelCase address data to snake_case for GraphQL mutation.\n * Additional fields from additionalInput are spread into the result, with\n * standard fields taking precedence (defensive flexibility approach).\n */\nfunction transformAddressToSnakeCase(address: AddressInput) {\n const { additionalInput, ...standardFields } = address;\n \n // Build the standard transformed fields\n const transformedStandardFields = {\n city: standardFields.city,\n company: standardFields.company,\n country_code: standardFields.countryCode,\n firstname: standardFields.firstname,\n lastname: standardFields.lastname,\n postcode: standardFields.postcode,\n region: standardFields.region,\n region_id: standardFields.regionId,\n save_in_address_book: standardFields.saveInAddressBook,\n street: standardFields.street,\n telephone: standardFields.telephone,\n };\n \n // Spread additional input first, then standard fields take precedence\n // This provides defensive flexibility: allows custom fields while protecting core fields\n return {\n ...(additionalInput || {}),\n ...transformedStandardFields,\n };\n}\n\n/**\n * Sets or updates the shipping address for a negotiable quote.\n * \n * @param input - The input parameters for setting the shipping address\n * @param input.quoteUid - The unique ID of the negotiable quote\n * @param input.addressId - Optional ID of a saved customer address (use this OR addressData)\n * @param input.addressData - Optional new address data (use this OR addressId)\n * @param input.addressData.additionalInput - Optional additional address fields to pass through to GraphQL\n * @returns Promise that resolves to the updated quote model with shipping addresses including uid field\n * @throws Error if validation fails or GraphQL operation fails\n * \n * @example\n * ```ts\n * // Using a saved address\n * const quote = await setShippingAddress({\n * quoteUid: 'quote-123',\n * addressId: 5\n * });\n * \n * // Using new address data\n * const quote = await setShippingAddress({\n * quoteUid: 'quote-123',\n * addressData: {\n * firstname: 'John',\n * lastname: 'Doe',\n * street: ['123 Main St'],\n * city: 'San Francisco',\n * countryCode: 'US',\n * postcode: '94103',\n * telephone: '555-1234'\n * }\n * });\n * \n * // Using address data with additional custom fields\n * const quote = await setShippingAddress({\n * quoteUid: 'quote-123',\n * addressData: {\n * firstname: 'John',\n * lastname: 'Doe',\n * street: ['123 Main St'],\n * city: 'San Francisco',\n * countryCode: 'US',\n * postcode: '94103',\n * telephone: '555-1234',\n * additionalInput: {\n * vat_id: 'GB123456789',\n * custom_attribute_1: 'value1',\n * delivery_instructions: 'Leave at door'\n * }\n * }\n * });\n * \n * // Access address identifier\n * if (quote?.shippingAddresses?.[0]) {\n * console.log('Address UID:', quote.shippingAddresses[0].uid);\n * }\n * ```\n */\nexport const setShippingAddress = async (\n input: SetShippingAddressInput\n): Promise<NegotiableQuoteModel | null> => {\n const { quoteUid, addressId, addressData } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n // Validate that exactly one of addressId or addressData is provided\n if (addressId === undefined && !addressData) {\n throw new Error('Either addressId or addressData must be provided');\n }\n\n if (addressId !== undefined && addressData) {\n throw new Error('Cannot provide both addressId and addressData');\n }\n\n // Transform addressData to snake_case if provided\n const transformedAddressData = addressData\n ? transformAddressToSnakeCase(addressData)\n : null;\n\n return fetchGraphQl(SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION, {\n variables: {\n quoteUid,\n addressId: addressId || null,\n addressData: transformedAddressData,\n },\n }).then((response) => {\n const { errors } = response;\n\n if (errors) {\n // Provide more detailed error information\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(`Failed to set shipping address: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.setNegotiableQuoteShippingAddress?.quote\n );\n\n if (!quoteData) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n // Emit event with transformed quote data on success\n events.emit('quote-management/shipping-address-set', {\n quote: quoteData,\n input: { quoteUid, addressId, addressData },\n });\n\n return quoteData;\n });\n};\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteTemplateFragment';\n\nexport const GET_QUOTE_TEMPLATE_DATA = /* GraphQL */ `\n query QUOTE_TEMPLATE_DATA_QUERY($templateId: ID!) {\n negotiableQuoteTemplate(templateId: $templateId) {\n ...NegotiableQuoteTemplateFragment\n }\n }\n\n ${NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { GET_QUOTE_TEMPLATE_DATA } from './graphql/getQuoteTemplateData';\nimport { transformQuoteTemplate } from '@/quote-management/data/transforms';\nimport { NegotiableQuoteTemplateModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const getQuoteTemplateData = async (templateId: string): Promise<NegotiableQuoteTemplateModel | null> => {\n\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n if (!templateId) {\n throw new Error('Template ID is required');\n }\n\n try {\n const results: any = await fetchGraphQl(GET_QUOTE_TEMPLATE_DATA, {\n variables: { templateId },\n });\n\n\n if (!results?.data?.negotiableQuoteTemplate) {\n throw new Error('Quote template not found');\n }\n\n const transformedData = transformQuoteTemplate(results.data.negotiableQuoteTemplate);\n\n if (!transformedData) {\n throw new Error('Failed to transform quote template data');\n }\n\n events.emit('quote-management/quote-template-data', {\n quoteTemplate: transformedData,\n permissions: state.permissions,\n });\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteTemplateFragment';\n\nexport const SET_NEGOTIABLE_QUOTE_TEMPLATE_SHIPPING_ADDRESS_MUTATION = /* GraphQL */ `\n mutation SET_NEGOTIABLE_QUOTE_TEMPLATE_SHIPPING_ADDRESS_MUTATION(\n $templateId: ID!\n $shippingAddress: NegotiableQuoteTemplateShippingAddressInput!\n ) {\n setNegotiableQuoteTemplateShippingAddress(\n input: {\n template_id: $templateId\n shipping_address: $shippingAddress\n }\n ) {\n ...NegotiableQuoteTemplateFragment\n }\n }\n \n ${NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT}\n`;\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { SET_NEGOTIABLE_QUOTE_TEMPLATE_SHIPPING_ADDRESS_MUTATION } from './graphql/setNegotiableQuoteTemplateShippingAddress';\nimport { transformQuoteTemplate } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface NegotiableQuoteAddressInput {\n city: string;\n company?: string;\n countryCode: string;\n fax?: string;\n firstname: string;\n lastname: string;\n middlename?: string;\n postcode?: string;\n prefix?: string;\n region?: string;\n regionId?: number;\n saveInAddressBook?: boolean;\n street: string[];\n suffix?: string;\n telephone?: string;\n vatId?: string;\n}\n\nexport interface NegotiableQuoteTemplateShippingAddressInput {\n address?: NegotiableQuoteAddressInput;\n customerAddressUid?: string;\n customerNotes?: string;\n}\n\nexport interface AddQuoteTemplateShippingAddressParams {\n templateId: string;\n shippingAddress: NegotiableQuoteTemplateShippingAddressInput;\n}\n\nexport const addQuoteTemplateShippingAddress = async (\n params: AddQuoteTemplateShippingAddressParams\n) => {\n if (!params.templateId) {\n throw new Error('Template ID is required');\n }\n\n if (!params.shippingAddress) {\n throw new Error('Shipping address is required');\n }\n\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n // Validate that at least one of address or customerAddressUid is provided\n if (\n !params.shippingAddress.address &&\n !params.shippingAddress.customerAddressUid\n ) {\n throw new Error('Either address or customerAddressUid must be provided');\n }\n\n try {\n const results: any = await fetchGraphQl(\n SET_NEGOTIABLE_QUOTE_TEMPLATE_SHIPPING_ADDRESS_MUTATION,\n {\n variables: {\n templateId: params.templateId,\n shippingAddress: {\n address: params.shippingAddress.address\n ? {\n city: params.shippingAddress.address.city,\n company: params.shippingAddress.address.company,\n country_code: params.shippingAddress.address.countryCode,\n fax: params.shippingAddress.address.fax,\n firstname: params.shippingAddress.address.firstname,\n lastname: params.shippingAddress.address.lastname,\n middlename: params.shippingAddress.address.middlename,\n postcode: params.shippingAddress.address.postcode,\n prefix: params.shippingAddress.address.prefix,\n region: params.shippingAddress.address.region,\n region_id: params.shippingAddress.address.regionId,\n save_in_address_book:\n params.shippingAddress.address.saveInAddressBook,\n street: params.shippingAddress.address.street,\n suffix: params.shippingAddress.address.suffix,\n telephone: params.shippingAddress.address.telephone,\n vat_id: params.shippingAddress.address.vatId,\n }\n : undefined,\n customer_address_uid: params.shippingAddress.customerAddressUid,\n customer_notes: params.shippingAddress.customerNotes,\n },\n },\n }\n );\n\n if (!results?.data?.setNegotiableQuoteTemplateShippingAddress) {\n throw new Error('No quote template data received');\n }\n\n const transformedData = transformQuoteTemplate(\n results.data.setNegotiableQuoteTemplateShippingAddress\n );\n\n if (!transformedData) {\n throw new Error('Failed to transform quote template data');\n }\n\n events.emit('quote-management/quote-template-data', {\n quoteTemplate: transformedData,\n permissions: state.permissions,\n });\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};\n"],"names":["mapAuthPermissions","payload","hasAllQuotePermissions","hasAllTemplatePermissions","hasManagePermission","loadQuoteData","permissions","state","config","initialize","quoteId","quoteTemplateId","getQuoteData","quote","events","error","getQuoteTemplateData","Initializer","defaultConfig","getStoreConfig","DEFAULT_CONFIG","authenticated","DEFAULT_PERMISSIONS","data","transformStoreConfig","transformQuoteDisplayAmountSetting","quoteDisplayAmountSetting","QuoteDisplayAmount","STORE_CONFIG_QUERY","fetchGraphQl","errors","errorMessage","e","SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION","NEGOTIABLE_QUOTE_FRAGMENT","transformAddressToSnakeCase","address","additionalInput","standardFields","transformedStandardFields","setShippingAddress","input","quoteUid","addressId","addressData","transformedAddressData","response","errorMessages","quoteData","transformQuote","_b","_a","GET_QUOTE_TEMPLATE_DATA","NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT","templateId","results","transformedData","transformQuoteTemplate","SET_NEGOTIABLE_QUOTE_TEMPLATE_SHIPPING_ADDRESS_MUTATION","addQuoteTemplateShippingAddress","params"],"mappings":"krCA+CO,SAASA,EACdC,EACsB,CAEtB,GAAI,CAACA,GAAW,OAAOA,GAAY,SACjC,MAAO,CACL,aAAc,GACd,UAAW,GACX,YAAa,GACb,cAAe,GACf,mBAAoB,GACpB,qBAAsB,GACtB,0BAA2B,EAAA,EAK/B,GAAIA,EAAQ,MAAQ,GAClB,MAAO,CACL,aAAc,GACd,UAAW,GACX,YAAa,GACb,cAAe,GACf,mBAAoB,GACpB,qBAAsB,GACtB,0BAA2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,OAAQA,EAAO,gBAAgB,QAAQ,OACvC,OAAQA,EAAO,gBAAgB,QAAQ,OACvC,UAAWA,EAAO,gBAAgB,QAAQ,UAC1C,OAAQA,EAAO,gBAAgB,QAAQ,KAAA,EAEzC,OACJ,qBAAsBA,EAAO,gBAAgB,mBAC7C,eAAgBA,EAAO,gBAAgB,aAAA,CACzC,CACF,CACF,EAGF,GAAI,GAACT,EAAAI,GAAA,YAAAA,EAAS,OAAT,MAAAJ,EAAe,2CAClB,MAAM,IAAI,MAAM,iCAAiC,EAGnD,MAAMK,EAAkBC,EACtBF,EAAQ,KAAK,yCAAA,EAGf,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,yCAAyC,EAG3D,OAAA1C,EAAO,KAAK,uCAAwC,CAClD,cAAe0C,EACf,YAAajD,EAAM,WAAA,CACpB,EAEMiD,CACT,OAASzC,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
|
|
1
|
+
{"version":3,"file":"api.js","sources":["/@dropins/storefront-quote-management/src/utils/mapAuthPermissions.ts","/@dropins/storefront-quote-management/src/api/initialize/initialize.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-store-config.ts","/@dropins/storefront-quote-management/src/api/getStoreConfig/graphql/StoreConfigQuery.ts","/@dropins/storefront-quote-management/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-quote-management/src/api/setShippingAddress/graphql/SetNegotiableQuoteShippingAddressMutation.ts","/@dropins/storefront-quote-management/src/api/setShippingAddress/setShippingAddress.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplateData/graphql/getQuoteTemplateData.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplateData/getQuoteTemplateData.ts","/@dropins/storefront-quote-management/src/api/addQuoteTemplateShippingAddress/graphql/setNegotiableQuoteTemplateShippingAddress.ts","/@dropins/storefront-quote-management/src/api/addQuoteTemplateShippingAddress/addQuoteTemplateShippingAddress.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { State } from '@/quote-management/types/state.types';\n\n/**\n * Type definition for the auth/permissions event payload\n * Contains flat Adobe Commerce permission keys with boolean values\n */\nexport type AuthPermissionsPayload = {\n all?: boolean;\n 'Magento_NegotiableQuote::all'?: boolean;\n 'Magento_NegotiableQuote::manage'?: boolean;\n 'Magento_NegotiableQuote::checkout'?: boolean;\n 'Magento_NegotiableQuoteTemplate::all'?: boolean;\n 'Magento_NegotiableQuoteTemplate::view_template'?: boolean;\n 'Magento_NegotiableQuoteTemplate::manage'?: boolean;\n 'Magento_NegotiableQuoteTemplate::generate_quote'?: boolean;\n [key: string]: boolean | undefined;\n};\n\n/**\n * Maps the auth/permissions event payload to internal permissions structure.\n * \n * Implements hierarchical permission checking:\n * 1. Top-level \"all\": If true, grants all permissions\n * 2. Module-level \"::all\": Grants all permissions for that module\n * 3. Specific permissions: Maps individual keys to internal flags\n * \n * @param payload - The raw auth/permissions event payload\n * @returns Typed permissions object matching the state structure\n * \n * @example\n * ```typescript\n * const permissions = mapAuthPermissions({\n * \"Magento_NegotiableQuote::manage\": true,\n * \"Magento_NegotiableQuote::checkout\": true\n * });\n * // Returns: { requestQuote: true, editQuote: true, deleteQuote: true, checkoutQuote: true, ... }\n * ```\n */\nexport function mapAuthPermissions(\n payload: AuthPermissionsPayload | null | undefined\n): State['permissions'] {\n // Handle null/undefined payload - return all false\n if (!payload || typeof payload !== 'object') {\n return {\n requestQuote: false,\n editQuote: false,\n deleteQuote: false,\n checkoutQuote: false,\n viewQuoteTemplates: false,\n manageQuoteTemplates: false,\n generateQuoteFromTemplate: false,\n };\n }\n\n // If top-level \"all\" is true, grant all permissions\n if (payload.all === true) {\n return {\n requestQuote: true,\n editQuote: true,\n deleteQuote: true,\n checkoutQuote: true,\n viewQuoteTemplates: true,\n manageQuoteTemplates: true,\n generateQuoteFromTemplate: true,\n };\n }\n\n // Check module-level \"all\" permissions\n const hasAllQuotePermissions = payload['Magento_NegotiableQuote::all'] === true;\n const hasAllTemplatePermissions = payload['Magento_NegotiableQuoteTemplate::all'] === true;\n\n // Map specific permissions with fallback to module-level \"all\"\n const hasManagePermission = \n hasAllQuotePermissions || payload['Magento_NegotiableQuote::manage'] === true;\n\n return {\n // Magento_NegotiableQuote::manage maps to request, edit, and delete\n requestQuote: hasManagePermission,\n editQuote: hasManagePermission,\n deleteQuote: hasManagePermission,\n \n // Magento_NegotiableQuote::checkout maps to checkoutQuote\n checkoutQuote: \n hasAllQuotePermissions || payload['Magento_NegotiableQuote::checkout'] === true,\n \n // Template permissions\n viewQuoteTemplates: \n hasAllTemplatePermissions || payload['Magento_NegotiableQuoteTemplate::view_template'] === true,\n manageQuoteTemplates: \n hasAllTemplatePermissions || payload['Magento_NegotiableQuoteTemplate::manage'] === true,\n generateQuoteFromTemplate: \n hasAllTemplatePermissions || payload['Magento_NegotiableQuoteTemplate::generate_quote'] === true,\n };\n}\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { Initializer } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport {\n state,\n DEFAULT_CONFIG,\n DEFAULT_PERMISSIONS,\n} from '@/quote-management/lib/state';\nimport {\n getQuoteData,\n getStoreConfig,\n getQuoteTemplateData,\n} from '@/quote-management/api';\nimport { mapAuthPermissions, AuthPermissionsPayload } from '@/quote-management/utils/mapAuthPermissions';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n quoteId?: string;\n quoteTemplateId?: string;\n};\n\nfunction loadQuoteData(permissions: typeof DEFAULT_PERMISSIONS) {\n // Prevent loading quote data twice\n if (state.quoteDataLoaded) return;\n\n const config = initialize.config.getConfig();\n const { quoteId, quoteTemplateId } = config;\n\n\n // Only proceed if we have permissions and at least one ID to load\n if (!permissions.editQuote || (!quoteId && !quoteTemplateId)) {\n return;\n }\n\n // Mark as loaded before starting the async operations to prevent duplicate calls\n state.quoteDataLoaded = true;\n\n if (quoteId) {\n getQuoteData(quoteId)\n .then((quote) => {\n if (!state.quoteDataInitialized) {\n events.emit('quote-management/quote-data/initialized', { quote, permissions });\n }\n state.quoteDataInitialized = true;\n })\n .catch((error) => {\n state.quoteDataLoaded = false;\n events.emit('quote-management/quote-data/error', { error });\n });\n }\n\n if (quoteTemplateId) {\n getQuoteTemplateData(quoteTemplateId)\n .catch((error) => {\n state.quoteDataLoaded = false;\n events.emit('quote-management/quote-template-data/error', { error });\n });\n }\n}\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = {};\n\n // Set config\n initialize.config.setConfig({ ...defaultConfig, ...config });\n\n // Fetch store config\n await getStoreConfig()\n .then((config) => {\n state.config = config;\n })\n .catch((error) => {\n console.error('Failed to fetch store config: ', error);\n state.config = DEFAULT_CONFIG;\n });\n\n // Mark initialization as complete\n state.initialized = true;\n events.emit('quote-management/initialized', { config: state.config });\n },\n\n listeners: () => [\n events.on('authenticated', async (authenticated) => {\n state.authenticated = !!authenticated;\n\n // Defensive: reset permissions if user logs out\n // This ensures permissions are cleared even if auth/permissions event doesn't fire\n if (!authenticated) {\n state.permissions = DEFAULT_PERMISSIONS;\n state.quoteDataLoaded = false;\n events.emit('quote-management/permissions', DEFAULT_PERMISSIONS);\n }\n },\n {\n eager: true,\n }\n ),\n\n events.on('auth/permissions', async (payload: AuthPermissionsPayload) => {\n // Map the auth permissions payload to internal permissions structure\n const permissions = mapAuthPermissions(payload);\n\n state.permissions = permissions;\n // Reset quote data loaded flag when permissions change to allow reloading\n state.quoteDataLoaded = false;\n events.emit('quote-management/permissions', state.permissions);\n }, {\n eager: true,\n }),\n\n events.on('quote-management/permissions', async (permissions) => {\n // Only process quote data loading after initialization is complete\n if (!state.initialized) {\n return;\n }\n\n loadQuoteData(permissions);\n }, { eager: true }),\n\n events.on('quote-management/initialized', async () => {\n loadQuoteData(state.permissions);\n }, { eager: true }),\n\n events.on('checkout/updated', async (data) => {\n // Only process after initialization is complete\n if (!state.initialized) {\n return;\n }\n\n if (data?.type !== 'quote') {\n return;\n }\n\n // Reset the flag to allow reloading of quote data\n state.quoteDataLoaded = false;\n loadQuoteData(state.permissions);\n }, { eager: true }),\n ],\n});\n\nexport const config = initialize.config;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport {\n QuoteDisplayAmount,\n StoreConfigModel,\n} from '@/quote-management/data/models';\nimport { DEFAULT_CONFIG } from '@/quote-management/lib/state';\n\nexport function transformStoreConfig(data: any): StoreConfigModel {\n if (!data) return DEFAULT_CONFIG;\n\n const transformQuoteDisplayAmountSetting = (\n quoteDisplayAmountSetting: number\n ) => {\n if (\n [\n QuoteDisplayAmount.TAX_EXCLUDED,\n QuoteDisplayAmount.TAX_INCLUDED,\n QuoteDisplayAmount.TAX_INCLUDED_AND_EXCLUDED,\n ].includes(quoteDisplayAmountSetting)\n ) {\n return quoteDisplayAmountSetting;\n }\n\n return QuoteDisplayAmount.TAX_EXCLUDED;\n };\n\n return {\n quoteSummaryDisplayTotal: data.cart_summary_display_quantity,\n quoteSummaryMaxItems: data.max_items_in_order_summary,\n quoteDisplaySettings: {\n zeroTax: data.shopping_cart_display_zero_tax,\n subtotal: transformQuoteDisplayAmountSetting(\n data.shopping_cart_display_subtotal\n ),\n price: transformQuoteDisplayAmountSetting(\n data.shopping_cart_display_price\n ),\n shipping: transformQuoteDisplayAmountSetting(\n data.shopping_cart_display_shipping\n ),\n fullSummary: data.shopping_cart_display_full_summary,\n grandTotal: data.shopping_cart_display_grand_total,\n },\n useConfigurableParentThumbnail:\n data.configurable_thumbnail_source === 'parent',\n quoteMinimumAmount: data.quote_minimum_amount ?? null,\n quoteMinimumAmountMessage: data.quote_minimum_amount_message ?? null,\n };\n}\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport const STORE_CONFIG_QUERY = /* GraphQL */ `\n query STORE_CONFIG_QUERY {\n storeConfig {\n cart_summary_display_quantity\n max_items_in_order_summary\n shopping_cart_display_full_summary\n shopping_cart_display_grand_total\n shopping_cart_display_price\n shopping_cart_display_shipping\n shopping_cart_display_subtotal\n shopping_cart_display_zero_tax\n configurable_thumbnail_source\n quote_minimum_amount\n quote_minimum_amount_message\n }\n }\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { StoreConfigModel } from '@/quote-management/data/models';\nimport { transformStoreConfig } from '@/quote-management/data/transforms';\nimport { STORE_CONFIG_QUERY } from './graphql/StoreConfigQuery';\n\nexport const getStoreConfig = async (): Promise<StoreConfigModel> => {\n return fetchGraphQl(STORE_CONFIG_QUERY, {\n method: 'GET',\n cache: 'force-cache',\n }).then(({ errors, data }) => {\n if (errors) {\n const errorMessage = errors.map((e: any) => e.message).join(', ');\n throw new Error(`Failed to get store config: ${errorMessage}`);\n }\n\n return transformStoreConfig(data.storeConfig);\n });\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION = `\n mutation SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION(\n $quoteUid: ID!\n $addressId: ID\n $addressData: NegotiableQuoteAddressInput\n ) {\n setNegotiableQuoteShippingAddress(\n input: {\n quote_uid: $quoteUid\n shipping_addresses: {\n customer_address_uid: $addressId\n address: $addressData\n }\n }\n ) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION } from './graphql/SetNegotiableQuoteShippingAddressMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface AddressInput {\n /** City name */\n city: string;\n /** Optional company name */\n company?: string;\n /** Two-letter country code (e.g., 'US') */\n countryCode: string;\n /** First name */\n firstname: string;\n /** Last name */\n lastname: string;\n /** Postal/ZIP code */\n postcode: string;\n /** Optional state/province name */\n region?: string;\n /** Optional state/province ID */\n regionId?: number;\n /** Whether to save this address to the customer's address book */\n saveInAddressBook?: boolean;\n /** Street address lines (array) */\n street: string[];\n /** Phone number */\n telephone: string;\n /** \n * Additional input (optional custom fields for the address).\n * These fields will be merged into the address data sent to GraphQL.\n * Standard fields take precedence over additional fields to prevent\n * accidental override of required address attributes.\n * \n * @example\n * ```ts\n * additionalInput: {\n * vat_id: 'GB123456789',\n * custom_attribute: 'value',\n * delivery_instructions: 'Leave at door'\n * }\n * ```\n */\n additionalInput?: Record<string, any>;\n}\n\nexport interface SetShippingAddressInput {\n /** The unique ID of the negotiable quote */\n quoteUid: string;\n /** The ID of a saved customer address (use this OR addressData, not both) */\n addressId?: number;\n /** New address data (use this OR addressId, not both) */\n addressData?: AddressInput;\n}\n\n/**\n * Transform camelCase address data to snake_case for GraphQL mutation.\n * Additional fields from additionalInput are spread into the result, with\n * standard fields taking precedence (defensive flexibility approach).\n */\nfunction transformAddressToSnakeCase(address: AddressInput) {\n const { additionalInput, ...standardFields } = address;\n \n // Build the standard transformed fields\n const transformedStandardFields = {\n city: standardFields.city,\n company: standardFields.company,\n country_code: standardFields.countryCode,\n firstname: standardFields.firstname,\n lastname: standardFields.lastname,\n postcode: standardFields.postcode,\n region: standardFields.region,\n region_id: standardFields.regionId,\n save_in_address_book: standardFields.saveInAddressBook,\n street: standardFields.street,\n telephone: standardFields.telephone,\n };\n \n // Spread additional input first, then standard fields take precedence\n // This provides defensive flexibility: allows custom fields while protecting core fields\n return {\n ...(additionalInput || {}),\n ...transformedStandardFields,\n };\n}\n\n/**\n * Sets or updates the shipping address for a negotiable quote.\n * \n * @param input - The input parameters for setting the shipping address\n * @param input.quoteUid - The unique ID of the negotiable quote\n * @param input.addressId - Optional ID of a saved customer address (use this OR addressData)\n * @param input.addressData - Optional new address data (use this OR addressId)\n * @param input.addressData.additionalInput - Optional additional address fields to pass through to GraphQL\n * @returns Promise that resolves to the updated quote model with shipping addresses including uid field\n * @throws Error if validation fails or GraphQL operation fails\n * \n * @example\n * ```ts\n * // Using a saved address\n * const quote = await setShippingAddress({\n * quoteUid: 'quote-123',\n * addressId: 5\n * });\n * \n * // Using new address data\n * const quote = await setShippingAddress({\n * quoteUid: 'quote-123',\n * addressData: {\n * firstname: 'John',\n * lastname: 'Doe',\n * street: ['123 Main St'],\n * city: 'San Francisco',\n * countryCode: 'US',\n * postcode: '94103',\n * telephone: '555-1234'\n * }\n * });\n * \n * // Using address data with additional custom fields\n * const quote = await setShippingAddress({\n * quoteUid: 'quote-123',\n * addressData: {\n * firstname: 'John',\n * lastname: 'Doe',\n * street: ['123 Main St'],\n * city: 'San Francisco',\n * countryCode: 'US',\n * postcode: '94103',\n * telephone: '555-1234',\n * additionalInput: {\n * vat_id: 'GB123456789',\n * custom_attribute_1: 'value1',\n * delivery_instructions: 'Leave at door'\n * }\n * }\n * });\n * \n * // Access address identifier\n * if (quote?.shippingAddresses?.[0]) {\n * console.log('Address UID:', quote.shippingAddresses[0].uid);\n * }\n * ```\n */\nexport const setShippingAddress = async (\n input: SetShippingAddressInput\n): Promise<NegotiableQuoteModel | null> => {\n const { quoteUid, addressId, addressData } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n // Validate that exactly one of addressId or addressData is provided\n if (addressId === undefined && !addressData) {\n throw new Error('Either addressId or addressData must be provided');\n }\n\n if (addressId !== undefined && addressData) {\n throw new Error('Cannot provide both addressId and addressData');\n }\n\n // Transform addressData to snake_case if provided\n const transformedAddressData = addressData\n ? transformAddressToSnakeCase(addressData)\n : null;\n\n return fetchGraphQl(SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION, {\n variables: {\n quoteUid,\n addressId: addressId || null,\n addressData: transformedAddressData,\n },\n }).then((response) => {\n const { errors } = response;\n\n if (errors) {\n // Provide more detailed error information\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(`Failed to set shipping address: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.setNegotiableQuoteShippingAddress?.quote\n );\n\n if (!quoteData) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n // Emit event with transformed quote data on success\n events.emit('quote-management/shipping-address-set', {\n quote: quoteData,\n input: { quoteUid, addressId, addressData },\n });\n\n return quoteData;\n });\n};\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteTemplateFragment';\n\nexport const GET_QUOTE_TEMPLATE_DATA = /* GraphQL */ `\n query QUOTE_TEMPLATE_DATA_QUERY($templateId: ID!) {\n negotiableQuoteTemplate(templateId: $templateId) {\n ...NegotiableQuoteTemplateFragment\n }\n }\n\n ${NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { GET_QUOTE_TEMPLATE_DATA } from './graphql/getQuoteTemplateData';\nimport { transformQuoteTemplate } from '@/quote-management/data/transforms';\nimport { NegotiableQuoteTemplateModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const getQuoteTemplateData = async (templateId: string): Promise<NegotiableQuoteTemplateModel | null> => {\n\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n if (!templateId) {\n throw new Error('Template ID is required');\n }\n\n try {\n const results: any = await fetchGraphQl(GET_QUOTE_TEMPLATE_DATA, {\n variables: { templateId },\n });\n\n\n if (!results?.data?.negotiableQuoteTemplate) {\n throw new Error('Quote template not found');\n }\n\n const transformedData = transformQuoteTemplate(results.data.negotiableQuoteTemplate);\n\n if (!transformedData) {\n throw new Error('Failed to transform quote template data');\n }\n\n events.emit('quote-management/quote-template-data', {\n quoteTemplate: transformedData,\n permissions: state.permissions,\n });\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteTemplateFragment';\n\nexport const SET_NEGOTIABLE_QUOTE_TEMPLATE_SHIPPING_ADDRESS_MUTATION = /* GraphQL */ `\n mutation SET_NEGOTIABLE_QUOTE_TEMPLATE_SHIPPING_ADDRESS_MUTATION(\n $templateId: ID!\n $shippingAddress: NegotiableQuoteTemplateShippingAddressInput!\n ) {\n setNegotiableQuoteTemplateShippingAddress(\n input: {\n template_id: $templateId\n shipping_address: $shippingAddress\n }\n ) {\n ...NegotiableQuoteTemplateFragment\n }\n }\n \n ${NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT}\n`;\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { SET_NEGOTIABLE_QUOTE_TEMPLATE_SHIPPING_ADDRESS_MUTATION } from './graphql/setNegotiableQuoteTemplateShippingAddress';\nimport { transformQuoteTemplate } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface NegotiableQuoteAddressInput {\n city: string;\n company?: string;\n countryCode: string;\n fax?: string;\n firstname: string;\n lastname: string;\n middlename?: string;\n postcode?: string;\n prefix?: string;\n region?: string;\n regionId?: number;\n saveInAddressBook?: boolean;\n street: string[];\n suffix?: string;\n telephone?: string;\n vatId?: string;\n}\n\nexport interface NegotiableQuoteTemplateShippingAddressInput {\n address?: NegotiableQuoteAddressInput;\n customerAddressUid?: string;\n customerNotes?: string;\n}\n\nexport interface AddQuoteTemplateShippingAddressParams {\n templateId: string;\n shippingAddress: NegotiableQuoteTemplateShippingAddressInput;\n}\n\nexport const addQuoteTemplateShippingAddress = async (\n params: AddQuoteTemplateShippingAddressParams\n) => {\n if (!params.templateId) {\n throw new Error('Template ID is required');\n }\n\n if (!params.shippingAddress) {\n throw new Error('Shipping address is required');\n }\n\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n // Validate that at least one of address or customerAddressUid is provided\n if (\n !params.shippingAddress.address &&\n !params.shippingAddress.customerAddressUid\n ) {\n throw new Error('Either address or customerAddressUid must be provided');\n }\n\n try {\n const results: any = await fetchGraphQl(\n SET_NEGOTIABLE_QUOTE_TEMPLATE_SHIPPING_ADDRESS_MUTATION,\n {\n variables: {\n templateId: params.templateId,\n shippingAddress: {\n address: params.shippingAddress.address\n ? {\n city: params.shippingAddress.address.city,\n company: params.shippingAddress.address.company,\n country_code: params.shippingAddress.address.countryCode,\n fax: params.shippingAddress.address.fax,\n firstname: params.shippingAddress.address.firstname,\n lastname: params.shippingAddress.address.lastname,\n middlename: params.shippingAddress.address.middlename,\n postcode: params.shippingAddress.address.postcode,\n prefix: params.shippingAddress.address.prefix,\n region: params.shippingAddress.address.region,\n region_id: params.shippingAddress.address.regionId,\n save_in_address_book:\n params.shippingAddress.address.saveInAddressBook,\n street: params.shippingAddress.address.street,\n suffix: params.shippingAddress.address.suffix,\n telephone: params.shippingAddress.address.telephone,\n vat_id: params.shippingAddress.address.vatId,\n }\n : undefined,\n customer_address_uid: params.shippingAddress.customerAddressUid,\n customer_notes: params.shippingAddress.customerNotes,\n },\n },\n }\n );\n\n if (!results?.data?.setNegotiableQuoteTemplateShippingAddress) {\n throw new Error('No quote template data received');\n }\n\n const transformedData = transformQuoteTemplate(\n results.data.setNegotiableQuoteTemplateShippingAddress\n );\n\n if (!transformedData) {\n throw new Error('Failed to transform quote template data');\n }\n\n events.emit('quote-management/quote-template-data', {\n quoteTemplate: transformedData,\n permissions: state.permissions,\n });\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};\n"],"names":["mapAuthPermissions","payload","hasAllQuotePermissions","hasAllTemplatePermissions","hasManagePermission","loadQuoteData","permissions","state","config","initialize","quoteId","quoteTemplateId","getQuoteData","quote","events","error","getQuoteTemplateData","Initializer","defaultConfig","getStoreConfig","DEFAULT_CONFIG","authenticated","DEFAULT_PERMISSIONS","data","transformStoreConfig","transformQuoteDisplayAmountSetting","quoteDisplayAmountSetting","QuoteDisplayAmount","STORE_CONFIG_QUERY","fetchGraphQl","errors","errorMessage","e","SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION","NEGOTIABLE_QUOTE_FRAGMENT","transformAddressToSnakeCase","address","additionalInput","standardFields","transformedStandardFields","setShippingAddress","input","quoteUid","addressId","addressData","transformedAddressData","response","errorMessages","quoteData","transformQuote","_b","_a","GET_QUOTE_TEMPLATE_DATA","NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT","templateId","results","transformedData","transformQuoteTemplate","SET_NEGOTIABLE_QUOTE_TEMPLATE_SHIPPING_ADDRESS_MUTATION","addQuoteTemplateShippingAddress","params"],"mappings":"krCA+CO,SAASA,EACdC,EACsB,CAEtB,GAAI,CAACA,GAAW,OAAOA,GAAY,SACjC,MAAO,CACL,aAAc,GACd,UAAW,GACX,YAAa,GACb,cAAe,GACf,mBAAoB,GACpB,qBAAsB,GACtB,0BAA2B,EAAA,EAK/B,GAAIA,EAAQ,MAAQ,GAClB,MAAO,CACL,aAAc,GACd,UAAW,GACX,YAAa,GACb,cAAe,GACf,mBAAoB,GACpB,qBAAsB,GACtB,0BAA2B,EAAA,EAK/B,MAAMC,EAAyBD,EAAQ,8BAA8B,IAAM,GACrEE,EAA4BF,EAAQ,sCAAsC,IAAM,GAGhFG,EACJF,GAA0BD,EAAQ,iCAAiC,IAAM,GAE3E,MAAO,CAEL,aAAcG,EACd,UAAWA,EACX,YAAaA,EAGb,cACEF,GAA0BD,EAAQ,mCAAmC,IAAM,GAG7E,mBACEE,GAA6BF,EAAQ,gDAAgD,IAAM,GAC7F,qBACEE,GAA6BF,EAAQ,yCAAyC,IAAM,GACtF,0BACEE,GAA6BF,EAAQ,iDAAiD,IAAM,EAAA,CAElG,CCxEA,SAASI,EAAcC,EAAyC,CAE9D,GAAIC,EAAM,gBAAiB,OAE3B,MAAM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AkBC,EACtBF,EAAQ,KAAK,yCAAA,EAGf,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,yCAAyC,EAG3D,OAAA1C,EAAO,KAAK,uCAAwC,CAClD,cAAe0C,EACf,YAAajD,EAAM,WAAA,CACpB,EAEMiD,CACT,OAASzC,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
|
package/chunks/state.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
var a=(e=>(e[e.TAX_EXCLUDED=1]="TAX_EXCLUDED",e[e.TAX_INCLUDED=2]="TAX_INCLUDED",e[e.TAX_INCLUDED_AND_EXCLUDED=3]="TAX_INCLUDED_AND_EXCLUDED",e))(a||{});const
|
|
3
|
+
var a=(e=>(e[e.TAX_EXCLUDED=1]="TAX_EXCLUDED",e[e.TAX_INCLUDED=2]="TAX_INCLUDED",e[e.TAX_INCLUDED_AND_EXCLUDED=3]="TAX_INCLUDED_AND_EXCLUDED",e))(a||{});const l={requestQuote:!1,editQuote:!1,deleteQuote:!1,checkoutQuote:!1,viewQuoteTemplates:!1,manageQuoteTemplates:!1,generateQuoteFromTemplate:!1},u={quoteSummaryDisplayTotal:1,quoteSummaryMaxItems:10,quoteDisplaySettings:{zeroTax:!1,subtotal:a.TAX_INCLUDED,price:a.TAX_INCLUDED,shipping:a.TAX_INCLUDED,fullSummary:!1,grandTotal:!0},useConfigurableParentThumbnail:!0,quoteMinimumAmount:null,quoteMinimumAmountMessage:null},D={authenticated:!1,permissions:l,config:u,initialized:!1,quoteDataLoaded:!1,quoteDataInitialized:!1},r=new Proxy(D,{get:(e,t)=>e[t],set:(e,t,s)=>(e[t]=s,!0)});export{l as D,a as Q,u as a,r as s};
|
|
4
4
|
//# sourceMappingURL=state.js.map
|
package/chunks/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sources":["/@dropins/storefront-quote-management/src/data/models/store-config-model.ts","/@dropins/storefront-quote-management/src/lib/state.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport enum QuoteDisplayAmount {\n TAX_EXCLUDED = 1,\n TAX_INCLUDED = 2,\n TAX_INCLUDED_AND_EXCLUDED = 3,\n}\n\nexport interface StoreConfigModel {\n quoteSummaryDisplayTotal: number;\n quoteSummaryMaxItems: number;\n quoteDisplaySettings: {\n zeroTax: boolean;\n subtotal: QuoteDisplayAmount;\n price: QuoteDisplayAmount;\n shipping: QuoteDisplayAmount;\n fullSummary: boolean;\n grandTotal: boolean;\n };\n useConfigurableParentThumbnail: boolean;\n}\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport {\n QuoteDisplayAmount,\n StoreConfigModel,\n} from '@/quote-management/data/models';\nimport { State } from '@/quote-management/types/state.types';\n\nexport const DEFAULT_PERMISSIONS = {\n requestQuote: false,\n editQuote: false,\n deleteQuote: false,\n checkoutQuote: false,\n viewQuoteTemplates: false,\n manageQuoteTemplates: false,\n generateQuoteFromTemplate: false,\n};\n\nexport const DEFAULT_CONFIG: StoreConfigModel = {\n quoteSummaryDisplayTotal: 1,\n quoteSummaryMaxItems: 10,\n quoteDisplaySettings: {\n zeroTax: false,\n subtotal: QuoteDisplayAmount.TAX_INCLUDED,\n price: QuoteDisplayAmount.TAX_INCLUDED,\n shipping: QuoteDisplayAmount.TAX_INCLUDED,\n fullSummary: false,\n grandTotal: true,\n },\n useConfigurableParentThumbnail: true,\n};\n\nconst _state: State = {\n authenticated: false,\n permissions: DEFAULT_PERMISSIONS,\n config: DEFAULT_CONFIG,\n initialized: false,\n quoteDataLoaded: false,\n quoteDataInitialized: false,\n};\n\n// Proxy state to make it reactive\nexport const state = new Proxy(_state, {\n get: (target, key) => {\n return target[key as keyof State];\n },\n set: (target, key, value) => {\n target[key as keyof State] = value;\n return true;\n },\n});\n"],"names":["QuoteDisplayAmount","DEFAULT_PERMISSIONS","DEFAULT_CONFIG","_state","state","target","key","value"],"mappings":"AASO,IAAKA,GAAAA,IACVA,EAAAA,EAAA,aAAe,CAAA,EAAf,eACAA,EAAAA,EAAA,aAAe,CAAA,EAAf,eACAA,EAAAA,EAAA,0BAA4B,CAAA,EAA5B,4BAHUA,IAAAA,GAAA,CAAA,CAAA,ECML,MAAMC,EAAsB,CACjC,aAAc,GACd,UAAW,GACX,YAAa,GACb,cAAe,GACf,mBAAoB,GACpB,qBAAsB,GACtB,0BAA2B,EAC7B,EAEaC,EAAmC,CAC9C,yBAA0B,EAC1B,qBAAsB,GACtB,qBAAsB,CACpB,QAAS,GACT,SAAUF,EAAmB,aAC7B,MAAOA,EAAmB,aAC1B,SAAUA,EAAmB,aAC7B,YAAa,GACb,WAAY,EAAA,EAEd,+BAAgC,
|
|
1
|
+
{"version":3,"file":"state.js","sources":["/@dropins/storefront-quote-management/src/data/models/store-config-model.ts","/@dropins/storefront-quote-management/src/lib/state.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport enum QuoteDisplayAmount {\n TAX_EXCLUDED = 1,\n TAX_INCLUDED = 2,\n TAX_INCLUDED_AND_EXCLUDED = 3,\n}\n\nexport interface StoreConfigModel {\n quoteSummaryDisplayTotal: number;\n quoteSummaryMaxItems: number;\n quoteDisplaySettings: {\n zeroTax: boolean;\n subtotal: QuoteDisplayAmount;\n price: QuoteDisplayAmount;\n shipping: QuoteDisplayAmount;\n fullSummary: boolean;\n grandTotal: boolean;\n };\n useConfigurableParentThumbnail: boolean;\n quoteMinimumAmount: number | null;\n quoteMinimumAmountMessage: string | null;\n}\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport {\n QuoteDisplayAmount,\n StoreConfigModel,\n} from '@/quote-management/data/models';\nimport { State } from '@/quote-management/types/state.types';\n\nexport const DEFAULT_PERMISSIONS = {\n requestQuote: false,\n editQuote: false,\n deleteQuote: false,\n checkoutQuote: false,\n viewQuoteTemplates: false,\n manageQuoteTemplates: false,\n generateQuoteFromTemplate: false,\n};\n\nexport const DEFAULT_CONFIG: StoreConfigModel = {\n quoteSummaryDisplayTotal: 1,\n quoteSummaryMaxItems: 10,\n quoteDisplaySettings: {\n zeroTax: false,\n subtotal: QuoteDisplayAmount.TAX_INCLUDED,\n price: QuoteDisplayAmount.TAX_INCLUDED,\n shipping: QuoteDisplayAmount.TAX_INCLUDED,\n fullSummary: false,\n grandTotal: true,\n },\n useConfigurableParentThumbnail: true,\n quoteMinimumAmount: null,\n quoteMinimumAmountMessage: null,\n};\n\nconst _state: State = {\n authenticated: false,\n permissions: DEFAULT_PERMISSIONS,\n config: DEFAULT_CONFIG,\n initialized: false,\n quoteDataLoaded: false,\n quoteDataInitialized: false,\n};\n\n// Proxy state to make it reactive\nexport const state = new Proxy(_state, {\n get: (target, key) => {\n return target[key as keyof State];\n },\n set: (target, key, value) => {\n target[key as keyof State] = value;\n return true;\n },\n});\n"],"names":["QuoteDisplayAmount","DEFAULT_PERMISSIONS","DEFAULT_CONFIG","_state","state","target","key","value"],"mappings":"AASO,IAAKA,GAAAA,IACVA,EAAAA,EAAA,aAAe,CAAA,EAAf,eACAA,EAAAA,EAAA,aAAe,CAAA,EAAf,eACAA,EAAAA,EAAA,0BAA4B,CAAA,EAA5B,4BAHUA,IAAAA,GAAA,CAAA,CAAA,ECML,MAAMC,EAAsB,CACjC,aAAc,GACd,UAAW,GACX,YAAa,GACb,cAAe,GACf,mBAAoB,GACpB,qBAAsB,GACtB,0BAA2B,EAC7B,EAEaC,EAAmC,CAC9C,yBAA0B,EAC1B,qBAAsB,GACtB,qBAAsB,CACpB,QAAS,GACT,SAAUF,EAAmB,aAC7B,MAAOA,EAAmB,aAC1B,SAAUA,EAAmB,aAC7B,YAAa,GACb,WAAY,EAAA,EAEd,+BAAgC,GAChC,mBAAoB,KACpB,0BAA2B,IAC7B,EAEMG,EAAgB,CACpB,cAAe,GACf,YAAaF,EACb,OAAQC,EACR,YAAa,GACb,gBAAiB,GACjB,qBAAsB,EACxB,EAGaE,EAAQ,IAAI,MAAMD,EAAQ,CACrC,IAAK,CAACE,EAAQC,IACLD,EAAOC,CAAkB,EAElC,IAAK,CAACD,EAAQC,EAAKC,KACjBF,EAAOC,CAAkB,EAAIC,EACtB,GAEX,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{FetchGraphQL as x}from"@dropins/tools/fetch-graphql.js";import{s as p}from"./state.js";var _=(e=>(e.NEW="NEW",e.SUBMITTED="SUBMITTED",e.PENDING="PENDING",e.UPDATED="UPDATED",e.OPEN="OPEN",e.ORDERED="ORDERED",e.CLOSED="CLOSED",e.DECLINED="DECLINED",e.EXPIRED="EXPIRED",e.DRAFT="DRAFT",e))(_||{});const{setEndpoint:F,setFetchGraphQlHeader:L,removeFetchGraphQlHeader:M,setFetchGraphQlHeaders:B,fetchGraphQl:G,getConfig:z}=new x().getMethods();function b(e){var a,n,c,i,u,l,s;return{uid:e.uid,createdAt:e.created_at,author:{firstname:e.author.firstname,lastname:e.author.lastname},changeType:e.change_type,changes:{commentAdded:((a=e.changes)==null?void 0:a.comment_added)&&{comment:e.changes.comment_added.comment},customChanges:((n=e.changes)==null?void 0:n.custom_changes)&&{new_value:e.changes.custom_changes.new_value,old_value:e.changes.custom_changes.old_value,title:e.changes.custom_changes.title},expiration:((c=e.changes)==null?void 0:c.expiration)&&{newExpiration:e.changes.expiration.new_expiration,oldExpiration:e.changes.expiration.old_expiration},productsRemoved:((i=e.changes)==null?void 0:i.products_removed)&&{productsRemovedFromCatalog:e.changes.products_removed.products_removed_from_catalog||[],productsRemovedFromQuote:e.changes.products_removed.products_removed_from_quote||[]},statuses:((u=e.changes)==null?void 0:u.statuses)&&{changes:((l=e.changes.statuses.changes)==null?void 0:l.map(r=>({newStatus:r==null?void 0:r.new_status,oldStatus:r==null?void 0:r.old_status})))||[]},total:((s=e.changes)==null?void 0:s.total)&&e.changes.total.new_price&&e.changes.total.old_price&&{newPrice:{value:e.changes.total.new_price.value,currency:e.changes.total.new_price.currency},oldPrice:{value:e.changes.total.old_price.value,currency:e.changes.total.old_price.currency}}}}}function h(e){if(e)return e.map(b)}function m(e,a){return e!=null&&e.length&&[...e].sort((c,i)=>i.quantity-c.quantity).find(c=>a>=c.quantity)||null}function y(e){var n,c,i,u;const a=p.config;return{src:a!=null&&a.useConfigurableParentThumbnail?e.product.thumbnail.url:((c=(n=e.configured_variant)==null?void 0:n.thumbnail)==null?void 0:c.url)||e.product.thumbnail.url,alt:a!=null&&a.useConfigurableParentThumbnail?e.product.thumbnail.label:((u=(i=e.configured_variant)==null?void 0:i.thumbnail)==null?void 0:u.label)||e.product.thumbnail.label}}function T(e){var a;return((a=e.links)==null?void 0:a.length)>0?{count:e.links.length,result:e.links.map(n=>n.title).join(", ")}:null}function I(e){var l,s,r,t;const a=e.quantity,n=e.__typename==="ConfigurableCartItem",c=n?(l=e.configured_variant)==null?void 0:l.price_tiers:e.product.price_tiers,i=n?(s=e.configured_variant)==null?void 0:s.price_range:e.product.price_range,u=m(c,a);return u?u.discount.amount_off>0:(((t=(r=i==null?void 0:i.maximum_price)==null?void 0:r.discount)==null?void 0:t.amount_off)??0)>0}function D(e){var i,u,l,s,r,t,o,d;const a=e.quantity,n=m(e.product.price_tiers,a);if(n)return Math.round(n.discount.percent_off);let c;if(e.__typename==="ConfigurableCartItem")c=(s=(l=(u=(i=e==null?void 0:e.configured_variant)==null?void 0:i.price_range)==null?void 0:u.maximum_price)==null?void 0:l.discount)==null?void 0:s.percent_off;else{if(e.__typename==="BundleCartItem")return;c=(d=(o=(t=(r=e==null?void 0:e.product)==null?void 0:r.price_range)==null?void 0:t.maximum_price)==null?void 0:o.discount)==null?void 0:d.percent_off}if(c!==0)return Math.round(c)}function E(e){var a,n,c,i;return e.__typename==="ConfigurableCartItem"?{value:(n=(a=e.configured_variant)==null?void 0:a.price_range)==null?void 0:n.maximum_price.regular_price.value,currency:(i=(c=e.configured_variant)==null?void 0:c.price_range)==null?void 0:i.maximum_price.regular_price.currency}:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency}}function P(e){var c,i,u,l,s,r;let a,n;if(a=((i=(c=e==null?void 0:e.prices)==null?void 0:c.original_row_total)==null?void 0:i.value)-((l=(u=e==null?void 0:e.prices)==null?void 0:u.row_total)==null?void 0:l.value),n=(r=(s=e==null?void 0:e.prices)==null?void 0:s.row_total)==null?void 0:r.currency,a!==0)return{value:a,currency:n}}function w(e){var a,n,c,i,u,l,s,r;return{itemType:e.__typename,uid:e.uid,product:{uid:e.product.uid,sku:e.product.sku,name:e.product.name,priceRange:{maximumPrice:{regularPrice:{value:e.product.price_range.maximum_price.regular_price.value,currency:e.product.price_range.maximum_price.regular_price.currency}}}},image:y(e),links:T(e),discounted:I(e),discountedTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},catalogDiscount:{amountOff:e.prices.catalog_discount.amount_off,percentOff:e.prices.catalog_discount.percent_off},discounts:((n=(a=e.prices)==null?void 0:a.discounts)==null?void 0:n.map(t=>({label:t.label,value:t.value,amount:{value:t.amount.value,currency:t.amount.currency}})))??[],discountPercentage:D(e),insufficientQuantity:(e.__typename==="ConfigurableCartItem"?((c=e.configured_variant)==null?void 0:c.stock_status)??e.product.stock_status:e.product.stock_status)==="IN_STOCK"&&!e.is_available,outOfStock:e.product.stock_status==="OUT_OF_STOCK",stockStatus:e.product.stock_status,quantity:e.quantity,prices:{regularPrice:E(e),priceIncludingTax:{value:e.prices.price_including_tax.value,currency:e.prices.price_including_tax.currency},originalItemPrice:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency},originalRowTotal:{value:e.prices.original_row_total.value,currency:e.prices.original_row_total.currency},rowTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},rowTotalIncludingTax:{value:e.prices.row_total_including_tax.value,currency:e.prices.row_total_including_tax.currency}},savingsAmount:P(e),noteFromBuyer:(i=e.note_from_buyer)==null?void 0:i.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),noteFromSeller:(u=e.note_from_seller)==null?void 0:u.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),configurableOptions:(l=e.configurable_options)==null?void 0:l.map(t=>({optionLabel:t.option_label,valueLabel:t.value_label})),bundleOptions:(s=e.bundle_options)==null?void 0:s.map(t=>({label:t.label,values:t.values.map(o=>({label:o.label,quantity:o.quantity,originalPrice:{value:o.original_price.value,currency:o.original_price.currency},price:{value:o.priceV2.value,currency:o.priceV2.currency}}))})),customizableOptions:(r=e.customizable_options)==null?void 0:r.map(t=>({type:t.type,label:t.label,values:t.values.map(o=>({label:o.label,value:o.value}))}))}}function C(e){return e?e.map(w):[]}const g=["DRAFT","UPDATED","DECLINED","EXPIRED","NEW","OPEN"];function A(e){if(!e.items)return 0;const a=p.config;return(a==null?void 0:a.quoteSummaryDisplayTotal)===0?e.items.length:(a==null?void 0:a.quoteSummaryDisplayTotal)===1?e.total_quantity:e.items.length}function O(e){return e.every(a=>!a.outOfStock&&!a.insufficientQuantity)}function R(e){var c,i,u,l,s;const a=v(e),n=C(e.items);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:a?_.NEW:e.status,isVirtual:!!e.is_virtual,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,totalQuantity:A(e),comments:(c=e.comments)==null?void 0:c.map(r=>{const t={uid:r.uid,createdAt:r.created_at,author:{firstname:r.author.firstname,lastname:r.author.lastname},text:r.text};return Array.isArray(r.attachments)&&r.attachments.length>0&&(t.attachments=r.attachments.map(o=>({name:o.name,url:o.url}))),t}),prices:e.prices&&{appliedDiscounts:(i=e.prices.discounts)==null?void 0:i.map(r=>({amount:{value:r.amount.value,currency:r.amount.currency},label:r.label,coupon:r.coupon})),appliedTaxes:(u=e.prices.applied_taxes)==null?void 0:u.map(r=>({amount:{value:r.amount.value,currency:r.amount.currency},label:r.label})),discount:e.prices.discounts&&e.prices.grand_total&&f(e.prices.discounts,e.prices.grand_total.currency),grandTotal:e.prices.grand_total&&{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency},grandTotalExcludingTax:e.prices.grand_total_excluding_tax&&{value:e.prices.grand_total_excluding_tax.value,currency:e.prices.grand_total_excluding_tax.currency},subtotalExcludingTax:e.prices.subtotal_excluding_tax&&{value:e.prices.subtotal_excluding_tax.value,currency:e.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:e.prices.subtotal_including_tax&&{value:e.prices.subtotal_including_tax.value,currency:e.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:e.prices.subtotal_with_discount_excluding_tax&&{value:e.prices.subtotal_with_discount_excluding_tax.value,currency:e.prices.subtotal_with_discount_excluding_tax.currency},...k(e),totalTax:e.prices.applied_taxes&&e.prices.grand_total&&f(e.prices.applied_taxes,e.prices.grand_total.currency)},history:h(e.history),items:n,shippingAddresses:(l=e.shipping_addresses)==null?void 0:l.map(r=>{const t={uid:r.uid,firstname:r.firstname,lastname:r.lastname,company:r.company,street:r.street,city:r.city,postcode:r.postcode,country:{code:r.country.code,label:r.country.label},telephone:r.telephone};return r.region&&(t.region={code:r.region.code,label:r.region.label,regionId:r.region.region_id}),t}),canCheckout:["UPDATED","DECLINED"].includes(e.status)&&p.permissions.checkoutQuote&&((s=e.shipping_addresses)==null?void 0:s.length)>0&&O(n),canSendForReview:(a||g.includes(e.status))&&p.permissions.editQuote,canUpdateQuote:(a||g.includes(e.status))&&p.permissions.editQuote,canDelete:!["PENDING","SUBMITTED","ORDERED"].includes(e.status)&&p.permissions.deleteQuote,canClose:e.status?!["DRAFT","CLOSED","ORDERED","OPEN"].includes(e.status):!1,readOnly:!a&&["ORDERED","SUBMITTED","CLOSED","PENDING"].includes(e.status)||!p.permissions.editQuote}}function H(e){return e?R(e):null}function v(e){return e.status==="SUBMITTED"&&!(e.history??[]).some(a=>{var n,c;return a.change_type==="UPDATED"&&(((c=(n=a.changes)==null?void 0:n.statuses)==null?void 0:c.changes)??[]).length>0})}function S(e){const a=v(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,status:a?_.NEW:e.status,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,prices:{grandTotal:{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency}}}}function W(e){var c;if(!e)return null;const a={items:((c=e.items)==null?void 0:c.filter(i=>i==null?void 0:i.uid).map(S))||[],pageInfo:{currentPage:e.page_info.current_page,pageSize:e.page_info.page_size,totalPages:e.page_info.total_pages},totalCount:e.total_count,sortFields:e.sort_fields?{default:e.sort_fields.default,options:e.sort_fields.options}:void 0},n=N(a);return{...a,paginationInfo:n||void 0}}function N(e){if(!(e!=null&&e.pageInfo)||!e.totalCount)return null;const{currentPage:a,pageSize:n,totalPages:c}=e.pageInfo,{totalCount:i}=e,u=i>0?(a-1)*n+1:0,l=Math.min(a*n,i);return{currentPage:a,totalCount:i,pageSize:n,startItem:u,endItem:l,totalPages:c,pageSizeOptions:[20,30,50,100,200]}}const V=()=>[20,30,50,100,200];function f(e,a){return e!=null&&e.length?e.reduce((n,c)=>({value:n.value+c.amount.value,currency:c.amount.currency}),{value:0,currency:a}):{value:0,currency:a}}function k(e){var c;if(!e||!((c=e.shipping_addresses)!=null&&c.length))return{};const n=e.shipping_addresses[0].selected_shipping_method;return n?{shippingIncludingTax:n.price_incl_tax&&{value:n.price_incl_tax.value,currency:n.price_incl_tax.currency},shippingExcludingTax:n.price_excl_tax&&{value:n.price_excl_tax.value,currency:n.price_excl_tax.currency}}:{}}export{C as a,h as b,N as c,W as d,L as e,G as f,V as g,B as h,z as i,M as r,F as s,H as t};
|
|
3
|
+
import{FetchGraphQL as b}from"@dropins/tools/fetch-graphql.js";import{s as _}from"./state.js";var d=(e=>(e.NEW="NEW",e.SUBMITTED="SUBMITTED",e.PENDING="PENDING",e.UPDATED="UPDATED",e.OPEN="OPEN",e.ORDERED="ORDERED",e.CLOSED="CLOSED",e.DECLINED="DECLINED",e.EXPIRED="EXPIRED",e.DRAFT="DRAFT",e))(d||{});const{setEndpoint:L,setFetchGraphQlHeader:M,removeFetchGraphQlHeader:B,setFetchGraphQlHeaders:G,fetchGraphQl:z,getConfig:H}=new b().getMethods();function h(e){var a,r,c,i,u,s,o;return{uid:e.uid,createdAt:e.created_at,author:{firstname:e.author.firstname,lastname:e.author.lastname},changeType:e.change_type,changes:{commentAdded:((a=e.changes)==null?void 0:a.comment_added)&&{comment:e.changes.comment_added.comment},customChanges:((r=e.changes)==null?void 0:r.custom_changes)&&{new_value:e.changes.custom_changes.new_value,old_value:e.changes.custom_changes.old_value,title:e.changes.custom_changes.title},expiration:((c=e.changes)==null?void 0:c.expiration)&&{newExpiration:e.changes.expiration.new_expiration,oldExpiration:e.changes.expiration.old_expiration},productsRemoved:((i=e.changes)==null?void 0:i.products_removed)&&{productsRemovedFromCatalog:e.changes.products_removed.products_removed_from_catalog||[],productsRemovedFromQuote:e.changes.products_removed.products_removed_from_quote||[]},statuses:((u=e.changes)==null?void 0:u.statuses)&&{changes:((s=e.changes.statuses.changes)==null?void 0:s.map(l=>({newStatus:l==null?void 0:l.new_status,oldStatus:l==null?void 0:l.old_status})))||[]},total:((o=e.changes)==null?void 0:o.total)&&e.changes.total.new_price&&e.changes.total.old_price&&{newPrice:{value:e.changes.total.new_price.value,currency:e.changes.total.new_price.currency},oldPrice:{value:e.changes.total.old_price.value,currency:e.changes.total.old_price.currency}}}}}function y(e){if(e)return e.map(h)}function v(e,a){return e!=null&&e.length&&[...e].sort((c,i)=>i.quantity-c.quantity).find(c=>a>=c.quantity)||null}function T(e){var r,c,i,u;const a=_.config;return{src:a!=null&&a.useConfigurableParentThumbnail?e.product.thumbnail.url:((c=(r=e.configured_variant)==null?void 0:r.thumbnail)==null?void 0:c.url)||e.product.thumbnail.url,alt:a!=null&&a.useConfigurableParentThumbnail?e.product.thumbnail.label:((u=(i=e.configured_variant)==null?void 0:i.thumbnail)==null?void 0:u.label)||e.product.thumbnail.label}}function I(e){var a;return((a=e.links)==null?void 0:a.length)>0?{count:e.links.length,result:e.links.map(r=>r.title).join(", ")}:null}function D(e){var s,o,l,t;const a=e.quantity,r=e.__typename==="ConfigurableCartItem",c=r?(s=e.configured_variant)==null?void 0:s.price_tiers:e.product.price_tiers,i=r?(o=e.configured_variant)==null?void 0:o.price_range:e.product.price_range,u=v(c,a);return u?u.discount.amount_off>0:(((t=(l=i==null?void 0:i.maximum_price)==null?void 0:l.discount)==null?void 0:t.amount_off)??0)>0}function E(e){var i,u,s,o,l,t,n,p;const a=e.quantity,r=v(e.product.price_tiers,a);if(r)return Math.round(r.discount.percent_off);let c;if(e.__typename==="ConfigurableCartItem")c=(o=(s=(u=(i=e==null?void 0:e.configured_variant)==null?void 0:i.price_range)==null?void 0:u.maximum_price)==null?void 0:s.discount)==null?void 0:o.percent_off;else{if(e.__typename==="BundleCartItem")return;c=(p=(n=(t=(l=e==null?void 0:e.product)==null?void 0:l.price_range)==null?void 0:t.maximum_price)==null?void 0:n.discount)==null?void 0:p.percent_off}if(c!==0)return Math.round(c)}function P(e){var a,r,c,i;return e.__typename==="ConfigurableCartItem"?{value:(r=(a=e.configured_variant)==null?void 0:a.price_range)==null?void 0:r.maximum_price.regular_price.value,currency:(i=(c=e.configured_variant)==null?void 0:c.price_range)==null?void 0:i.maximum_price.regular_price.currency}:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency}}function w(e){var c,i,u,s,o,l;let a,r;if(a=((i=(c=e==null?void 0:e.prices)==null?void 0:c.original_row_total)==null?void 0:i.value)-((s=(u=e==null?void 0:e.prices)==null?void 0:u.row_total)==null?void 0:s.value),r=(l=(o=e==null?void 0:e.prices)==null?void 0:o.row_total)==null?void 0:l.currency,a!==0)return{value:a,currency:r}}function C(e){var a,r,c,i,u,s,o,l;return{itemType:e.__typename,uid:e.uid,product:{uid:e.product.uid,sku:e.product.sku,name:e.product.name,priceRange:{maximumPrice:{regularPrice:{value:e.product.price_range.maximum_price.regular_price.value,currency:e.product.price_range.maximum_price.regular_price.currency}}}},image:T(e),links:I(e),discounted:D(e),discountedTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},catalogDiscount:{amountOff:e.prices.catalog_discount.amount_off,percentOff:e.prices.catalog_discount.percent_off},discounts:((r=(a=e.prices)==null?void 0:a.discounts)==null?void 0:r.map(t=>({label:t.label,value:t.value,amount:{value:t.amount.value,currency:t.amount.currency}})))??[],discountPercentage:E(e),insufficientQuantity:(e.__typename==="ConfigurableCartItem"?((c=e.configured_variant)==null?void 0:c.stock_status)??e.product.stock_status:e.product.stock_status)==="IN_STOCK"&&!e.is_available,outOfStock:e.product.stock_status==="OUT_OF_STOCK",stockStatus:e.product.stock_status,quantity:e.quantity,prices:{regularPrice:P(e),priceIncludingTax:{value:e.prices.price_including_tax.value,currency:e.prices.price_including_tax.currency},originalItemPrice:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency},originalRowTotal:{value:e.prices.original_row_total.value,currency:e.prices.original_row_total.currency},rowTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},rowTotalIncludingTax:{value:e.prices.row_total_including_tax.value,currency:e.prices.row_total_including_tax.currency}},savingsAmount:w(e),noteFromBuyer:(i=e.note_from_buyer)==null?void 0:i.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),noteFromSeller:(u=e.note_from_seller)==null?void 0:u.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),configurableOptions:(s=e.configurable_options)==null?void 0:s.map(t=>({optionLabel:t.option_label,valueLabel:t.value_label})),bundleOptions:(o=e.bundle_options)==null?void 0:o.map(t=>({label:t.label,values:t.values.map(n=>({label:n.label,quantity:n.quantity,originalPrice:{value:n.original_price.value,currency:n.original_price.currency},price:{value:n.priceV2.value,currency:n.priceV2.currency}}))})),customizableOptions:(l=e.customizable_options)==null?void 0:l.map(t=>({type:t.type,label:t.label,values:t.values.map(n=>({label:n.label,value:n.value}))}))}}function A(e){return e?e.map(C):[]}const f=["DRAFT","UPDATED","DECLINED","EXPIRED","NEW","OPEN"];function O(e){if(!e.items)return 0;const a=_.config;return(a==null?void 0:a.quoteSummaryDisplayTotal)===0?e.items.length:(a==null?void 0:a.quoteSummaryDisplayTotal)===1?e.total_quantity:e.items.length}function R(e){return e.every(a=>!a.outOfStock&&!a.insufficientQuantity)}function S(e){var i,u,s,o,l,t;const a=x(e),r=!!((i=e.template_name)!=null&&i.trim()),c=A(e.items);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:a?d.NEW:e.status,isVirtual:!!e.is_virtual,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,totalQuantity:O(e),comments:(u=e.comments)==null?void 0:u.map(n=>{const p={uid:n.uid,createdAt:n.created_at,author:{firstname:n.author.firstname,lastname:n.author.lastname},text:n.text};return Array.isArray(n.attachments)&&n.attachments.length>0&&(p.attachments=n.attachments.map(g=>({name:g.name,url:g.url}))),p}),prices:e.prices&&{appliedDiscounts:(s=e.prices.discounts)==null?void 0:s.map(n=>({amount:{value:n.amount.value,currency:n.amount.currency},label:n.label,coupon:n.coupon})),appliedTaxes:(o=e.prices.applied_taxes)==null?void 0:o.map(n=>({amount:{value:n.amount.value,currency:n.amount.currency},label:n.label})),discount:e.prices.discounts&&e.prices.grand_total&&m(e.prices.discounts,e.prices.grand_total.currency),grandTotal:e.prices.grand_total&&{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency},grandTotalExcludingTax:e.prices.grand_total_excluding_tax&&{value:e.prices.grand_total_excluding_tax.value,currency:e.prices.grand_total_excluding_tax.currency},subtotalExcludingTax:e.prices.subtotal_excluding_tax&&{value:e.prices.subtotal_excluding_tax.value,currency:e.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:e.prices.subtotal_including_tax&&{value:e.prices.subtotal_including_tax.value,currency:e.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:e.prices.subtotal_with_discount_excluding_tax&&{value:e.prices.subtotal_with_discount_excluding_tax.value,currency:e.prices.subtotal_with_discount_excluding_tax.currency},...Q(e),totalTax:e.prices.applied_taxes&&e.prices.grand_total&&m(e.prices.applied_taxes,e.prices.grand_total.currency)},history:y(e.history),items:c,shippingAddresses:(l=e.shipping_addresses)==null?void 0:l.map(n=>{const p={uid:n.uid,firstname:n.firstname,lastname:n.lastname,company:n.company,street:n.street,city:n.city,postcode:n.postcode,country:{code:n.country.code,label:n.country.label},telephone:n.telephone};return n.region&&(p.region={code:n.region.code,label:n.region.label,regionId:n.region.region_id}),p}),canCheckout:["UPDATED","DECLINED"].includes(e.status)&&_.permissions.checkoutQuote&&((t=e.shipping_addresses)==null?void 0:t.length)>0&&R(c),canSendForReview:!r&&(a||f.includes(e.status))&&_.permissions.editQuote,canUpdateQuote:!r&&(a||f.includes(e.status))&&_.permissions.editQuote,canDelete:!r&&!["PENDING","SUBMITTED","ORDERED"].includes(e.status)&&_.permissions.deleteQuote,canClose:e.status?!r&&!["DRAFT","CLOSED","ORDERED","OPEN"].includes(e.status):!1,readOnly:r||!a&&["ORDERED","SUBMITTED","CLOSED","PENDING"].includes(e.status)||!_.permissions.editQuote}}function W(e){return e?S(e):null}function x(e){return e.status==="SUBMITTED"&&!(e.history??[]).some(a=>{var r,c;return a.change_type==="UPDATED"&&(((c=(r=a.changes)==null?void 0:r.statuses)==null?void 0:c.changes)??[]).length>0})}function N(e){const a=x(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,status:a?d.NEW:e.status,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,prices:{grandTotal:{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency}}}}function V(e){var c;if(!e)return null;const a={items:((c=e.items)==null?void 0:c.filter(i=>i==null?void 0:i.uid).map(N))||[],pageInfo:{currentPage:e.page_info.current_page,pageSize:e.page_info.page_size,totalPages:e.page_info.total_pages},totalCount:e.total_count,sortFields:e.sort_fields?{default:e.sort_fields.default,options:e.sort_fields.options}:void 0},r=k(a);return{...a,paginationInfo:r||void 0}}function k(e){if(!(e!=null&&e.pageInfo)||!e.totalCount)return null;const{currentPage:a,pageSize:r,totalPages:c}=e.pageInfo,{totalCount:i}=e,u=i>0?(a-1)*r+1:0,s=Math.min(a*r,i);return{currentPage:a,totalCount:i,pageSize:r,startItem:u,endItem:s,totalPages:c,pageSizeOptions:[20,30,50,100,200]}}const X=()=>[20,30,50,100,200];function m(e,a){return e!=null&&e.length?e.reduce((r,c)=>({value:r.value+c.amount.value,currency:c.amount.currency}),{value:0,currency:a}):{value:0,currency:a}}function Q(e){var c;if(!e||!((c=e.shipping_addresses)!=null&&c.length))return{};const r=e.shipping_addresses[0].selected_shipping_method;return r?{shippingIncludingTax:r.price_incl_tax&&{value:r.price_incl_tax.value,currency:r.price_incl_tax.currency},shippingExcludingTax:r.price_excl_tax&&{value:r.price_excl_tax.value,currency:r.price_excl_tax.currency}}:{}}export{A as a,y as b,k as c,V as d,M as e,z as f,X as g,G as h,H as i,B as r,L as s,W as t};
|
|
4
4
|
//# sourceMappingURL=transform-quote.js.map
|