@dropins/storefront-purchase-order 0.0.5-alpha2 → 0.0.5-alpha4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/api/getPurchaseOrder/graphql/getPurchaseOrder.graphql.d.ts +1 -1
  2. package/api/graphql/PurchaseOrderQuoteFragment.d.ts +22 -0
  3. package/api/initialize/initialize.d.ts +1 -0
  4. package/api.js +404 -72
  5. package/api.js.map +1 -1
  6. package/chunks/getPurchaseOrders.js +3 -77
  7. package/chunks/getPurchaseOrders.js.map +1 -1
  8. package/chunks/placeOrderForPurchaseOrder.js +39 -0
  9. package/chunks/placeOrderForPurchaseOrder.js.map +1 -0
  10. package/chunks/rejectPurchaseOrders.js +78 -0
  11. package/chunks/rejectPurchaseOrders.js.map +1 -0
  12. package/chunks/usePurchaseOrders.js +1 -1
  13. package/chunks/usePurchaseOrders.js.map +1 -1
  14. package/components/PurchaseOrderStatusContent/PurchaseOrderStatusContent.d.ts +5 -0
  15. package/components/PurchaseOrderStatusContent/index.d.ts +19 -0
  16. package/components/index.d.ts +1 -0
  17. package/containers/CompanyPurchaseOrders.js +1 -1
  18. package/containers/CompanyPurchaseOrders.js.map +1 -1
  19. package/containers/CustomerPurchaseOrders.js +1 -1
  20. package/containers/CustomerPurchaseOrders.js.map +1 -1
  21. package/containers/PurchaseOrderStatus/PurchaseOrderStatus.d.ts +5 -0
  22. package/containers/PurchaseOrderStatus/index.d.ts +19 -0
  23. package/containers/PurchaseOrderStatus.d.ts +3 -0
  24. package/containers/PurchaseOrderStatus.js +4 -0
  25. package/containers/PurchaseOrderStatus.js.map +1 -0
  26. package/containers/RequireApprovalPurchaseOrders.js +1 -1
  27. package/containers/RequireApprovalPurchaseOrders.js.map +1 -1
  28. package/containers/index.d.ts +1 -0
  29. package/data/models/customer-order-model.d.ts +0 -1
  30. package/data/models/purchase-order-model.d.ts +228 -14
  31. package/hooks/index.d.ts +1 -0
  32. package/hooks/usePurchaseOrderStatus.d.ts +4 -0
  33. package/i18n/en_US.json.d.ts +60 -0
  34. package/package.json +1 -1
  35. package/render.js +2 -2
  36. package/render.js.map +1 -1
  37. package/types/components/index.d.ts +1 -0
  38. package/types/components/purchaseOrderStatusContent.types.d.ts +17 -0
  39. package/types/containers/index.d.ts +1 -0
  40. package/types/containers/purchaseOrderStatus.types.d.ts +18 -0
  41. package/types/hooks/index.d.ts +1 -0
  42. package/types/hooks/usePurchaseOrderStatus.types.d.ts +19 -0
@@ -14,5 +14,5 @@
14
14
  * is strictly forbidden unless prior written permission is obtained
15
15
  * from Adobe.
16
16
  *******************************************************************/
17
- export declare const GET_PURCHASE_ORDER = "\n query GET_PURCHASE_ORDER($uid: ID!) {\n customer {\n purchase_order(uid: $uid) {\n uid\n number\n created_at\n updated_at\n status\n available_actions\n created_by {\n firstname\n lastname\n email\n }\n order {\n id\n number\n total {\n grand_total {\n value\n currency\n }\n }\n }\n quote {\n prices {\n grand_total {\n value\n currency\n }\n }\n }\n }\n }\n }\n";
17
+ export declare const GET_PURCHASE_ORDER: string;
18
18
  //# sourceMappingURL=getPurchaseOrder.graphql.d.ts.map
@@ -0,0 +1,22 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ /**
18
+ * Limited Quote fragment for Purchase Order context
19
+ * Some fields from full Cart type may not be available in purchase_order.quote
20
+ */
21
+ export declare const PURCHASE_ORDER_QUOTE_FRAGMENT = "\n fragment PURCHASE_ORDER_QUOTE_FRAGMENT on Cart {\n __typename\n id\n email\n is_virtual\n total_quantity\n applied_coupons {\n code\n }\n applied_gift_cards {\n code\n applied_balance {\n value\n currency\n }\n current_balance {\n value\n currency\n }\n expiration_date\n }\n applied_reward_points {\n money {\n value\n currency\n }\n points\n }\n applied_store_credit {\n applied_balance {\n value\n currency\n }\n current_balance {\n value\n currency\n }\n }\n available_gift_wrappings {\n uid\n design\n price {\n value\n currency\n }\n image {\n url\n label\n }\n }\n gift_message {\n from\n to\n message\n }\n gift_receipt_included\n gift_wrapping {\n uid\n design\n price {\n value\n currency\n }\n image {\n url\n label\n }\n }\n printed_card_included\n available_payment_methods {\n code\n title\n is_deferred\n }\n selected_payment_method {\n code\n title\n }\n billing_address {\n city\n company\n country {\n code\n label\n }\n firstname\n lastname\n postcode\n region {\n code\n label\n }\n street\n telephone\n custom_attributes {\n code\n }\n fax\n id\n middlename\n prefix\n suffix\n uid\n vat_id\n }\n shipping_addresses {\n city\n company\n country {\n code\n label\n }\n firstname\n lastname\n postcode\n region {\n code\n label\n }\n street\n telephone\n custom_attributes {\n code\n }\n fax\n id\n middlename\n prefix\n suffix\n uid\n vat_id\n available_shipping_methods {\n amount {\n value\n currency\n }\n carrier_code\n carrier_title\n method_code\n method_title\n }\n selected_shipping_method {\n amount {\n value\n currency\n }\n carrier_code\n carrier_title\n method_code\n method_title\n }\n }\n rules {\n uid\n }\n itemsV2(pageSize: 100, currentPage: 1) {\n items {\n uid\n quantity\n product {\n __typename\n uid\n name\n sku\n url_key\n canonical_url\n stock_status\n only_x_left_in_stock\n image {\n url\n label\n }\n small_image {\n url\n label\n }\n thumbnail {\n url\n label\n }\n price_range {\n maximum_price {\n regular_price {\n value\n currency\n }\n final_price {\n value\n currency\n }\n }\n }\n }\n prices {\n price {\n value\n currency\n }\n price_including_tax {\n value\n currency\n }\n original_item_price {\n value\n currency\n }\n original_row_total {\n value\n currency\n }\n row_total {\n value\n currency\n }\n row_total_including_tax {\n value\n currency\n }\n total_item_discount {\n value\n currency\n }\n discounts {\n label\n amount {\n value\n currency\n }\n }\n fixed_product_taxes {\n label\n amount {\n value\n currency\n }\n }\n }\n ... on SimpleCartItem {\n customizable_options {\n label\n values {\n label\n value\n }\n }\n }\n ... on ConfigurableCartItem {\n configurable_options {\n option_label\n value_label\n }\n }\n ... on BundleCartItem {\n bundle_options {\n uid\n label\n type\n values {\n uid\n label\n quantity\n }\n }\n }\n ... on DownloadableCartItem {\n links {\n uid\n title\n }\n }\n ... on GiftCardCartItem {\n sender_name\n sender_email\n recipient_name\n recipient_email\n message\n amount {\n value\n currency\n }\n }\n errors {\n code\n message\n }\n is_available\n max_qty\n min_qty\n not_available_message\n note_from_buyer {\n note_uid\n note\n created_at\n }\n note_from_seller {\n note_uid\n note\n created_at\n }\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n total_count\n }\n prices {\n grand_total {\n value\n currency\n }\n grand_total_excluding_tax {\n value\n currency\n }\n subtotal_excluding_tax {\n value\n currency\n }\n subtotal_including_tax {\n value\n currency\n }\n subtotal_with_discount_excluding_tax {\n value\n currency\n }\n applied_taxes {\n label\n amount {\n value\n currency\n }\n }\n discounts {\n label\n amount {\n value\n currency\n }\n }\n gift_options {\n gift_wrapping_for_items {\n value\n currency\n }\n gift_wrapping_for_items_incl_tax {\n value\n currency\n }\n gift_wrapping_for_order {\n value\n currency\n }\n gift_wrapping_for_order_incl_tax {\n value\n currency\n }\n printed_card {\n value\n currency\n }\n printed_card_incl_tax {\n value\n currency\n }\n }\n }\n }\n";
22
+ //# sourceMappingURL=PurchaseOrderQuoteFragment.d.ts.map
@@ -3,6 +3,7 @@ import { Lang } from '@dropins/tools/types/elsie/src/i18n';
3
3
 
4
4
  type ConfigProps = {
5
5
  langDefinitions?: Lang;
6
+ poRef?: string;
6
7
  };
7
8
  export declare const initialize: Initializer<ConfigProps>;
8
9
  export declare const config: import('@dropins/tools/types/elsie/src/lib').Config<ConfigProps>;
package/api.js CHANGED
@@ -1,19 +1,409 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{Initializer as y}from"@dropins/tools/lib.js";import{f as P,h as A}from"./chunks/fetch-graphql.js";import{g as sr,r as ur,s as ir,a as nr,b as lr}from"./chunks/fetch-graphql.js";import{P as C,t as D}from"./chunks/getPurchaseOrders.js";import{a as pr,g as _r,r as cr}from"./chunks/getPurchaseOrders.js";import{h as a}from"./chunks/fetch-error.js";import{a as tr,c as Or,g as fr,u as Er}from"./chunks/currencyInfo.js";import{d as Rr,g as Pr}from"./chunks/getPurchaseOrderApprovalRules.js";import{g as ar}from"./chunks/getPurchaseOrderApprovalRule.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/case-converter.js";import"./chunks/transform-purchase-order-approval-rule.js";const v=new y({init:async e=>{const n={};v.config.setConfig({...n,...e})},listeners:()=>[]}),k=v.config,T=`
4
- mutation CANCEL_PURCHASE_ORDERS($input: PurchaseOrdersActionInput!) {
5
- cancelPurchaseOrders(input: $input) {
6
- purchase_orders {
7
- ...PURCHASE_ORDERS_FRAGMENT
3
+ import{Initializer as w}from"@dropins/tools/lib.js";import{f as y,h as O}from"./chunks/fetch-graphql.js";import{g as m,r as rr,s as er,a as ar,b as tr}from"./chunks/fetch-graphql.js";import{h as v}from"./chunks/fetch-error.js";import{t as R,P as C}from"./chunks/rejectPurchaseOrders.js";import{a as ur,r as sr}from"./chunks/rejectPurchaseOrders.js";import{events as D}from"@dropins/tools/event-bus.js";import{c as _r,p as cr}from"./chunks/placeOrderForPurchaseOrder.js";import{a as or,c as dr,g as pr,u as hr}from"./chunks/currencyInfo.js";import{d as fr,g as yr}from"./chunks/getPurchaseOrderApprovalRules.js";import{g as vr}from"./chunks/getPurchaseOrders.js";import{g as Er}from"./chunks/getPurchaseOrderApprovalRule.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-purchase-order-approval-rule.js";import"./chunks/case-converter.js";const S=`
4
+ fragment PURCHASE_ORDER_QUOTE_FRAGMENT on Cart {
5
+ __typename
6
+ id
7
+ email
8
+ is_virtual
9
+ total_quantity
10
+ applied_coupons {
11
+ code
12
+ }
13
+ applied_gift_cards {
14
+ code
15
+ applied_balance {
16
+ value
17
+ currency
8
18
  }
9
- errors {
10
- message
11
- type
19
+ current_balance {
20
+ value
21
+ currency
22
+ }
23
+ expiration_date
24
+ }
25
+ applied_reward_points {
26
+ money {
27
+ value
28
+ currency
29
+ }
30
+ points
31
+ }
32
+ applied_store_credit {
33
+ applied_balance {
34
+ value
35
+ currency
36
+ }
37
+ current_balance {
38
+ value
39
+ currency
40
+ }
41
+ }
42
+ available_gift_wrappings {
43
+ uid
44
+ design
45
+ price {
46
+ value
47
+ currency
48
+ }
49
+ image {
50
+ url
51
+ label
52
+ }
53
+ }
54
+ gift_message {
55
+ from
56
+ to
57
+ message
58
+ }
59
+ gift_receipt_included
60
+ gift_wrapping {
61
+ uid
62
+ design
63
+ price {
64
+ value
65
+ currency
66
+ }
67
+ image {
68
+ url
69
+ label
70
+ }
71
+ }
72
+ printed_card_included
73
+ available_payment_methods {
74
+ code
75
+ title
76
+ is_deferred
77
+ }
78
+ selected_payment_method {
79
+ code
80
+ title
81
+ }
82
+ billing_address {
83
+ city
84
+ company
85
+ country {
86
+ code
87
+ label
88
+ }
89
+ firstname
90
+ lastname
91
+ postcode
92
+ region {
93
+ code
94
+ label
95
+ }
96
+ street
97
+ telephone
98
+ custom_attributes {
99
+ code
100
+ }
101
+ fax
102
+ id
103
+ middlename
104
+ prefix
105
+ suffix
106
+ uid
107
+ vat_id
108
+ }
109
+ shipping_addresses {
110
+ city
111
+ company
112
+ country {
113
+ code
114
+ label
115
+ }
116
+ firstname
117
+ lastname
118
+ postcode
119
+ region {
120
+ code
121
+ label
122
+ }
123
+ street
124
+ telephone
125
+ custom_attributes {
126
+ code
127
+ }
128
+ fax
129
+ id
130
+ middlename
131
+ prefix
132
+ suffix
133
+ uid
134
+ vat_id
135
+ available_shipping_methods {
136
+ amount {
137
+ value
138
+ currency
139
+ }
140
+ carrier_code
141
+ carrier_title
142
+ method_code
143
+ method_title
144
+ }
145
+ selected_shipping_method {
146
+ amount {
147
+ value
148
+ currency
149
+ }
150
+ carrier_code
151
+ carrier_title
152
+ method_code
153
+ method_title
154
+ }
155
+ }
156
+ rules {
157
+ uid
158
+ }
159
+ itemsV2(pageSize: 100, currentPage: 1) {
160
+ items {
161
+ uid
162
+ quantity
163
+ product {
164
+ __typename
165
+ uid
166
+ name
167
+ sku
168
+ url_key
169
+ canonical_url
170
+ stock_status
171
+ only_x_left_in_stock
172
+ image {
173
+ url
174
+ label
175
+ }
176
+ small_image {
177
+ url
178
+ label
179
+ }
180
+ thumbnail {
181
+ url
182
+ label
183
+ }
184
+ price_range {
185
+ maximum_price {
186
+ regular_price {
187
+ value
188
+ currency
189
+ }
190
+ final_price {
191
+ value
192
+ currency
193
+ }
194
+ }
195
+ }
196
+ }
197
+ prices {
198
+ price {
199
+ value
200
+ currency
201
+ }
202
+ price_including_tax {
203
+ value
204
+ currency
205
+ }
206
+ original_item_price {
207
+ value
208
+ currency
209
+ }
210
+ original_row_total {
211
+ value
212
+ currency
213
+ }
214
+ row_total {
215
+ value
216
+ currency
217
+ }
218
+ row_total_including_tax {
219
+ value
220
+ currency
221
+ }
222
+ total_item_discount {
223
+ value
224
+ currency
225
+ }
226
+ discounts {
227
+ label
228
+ amount {
229
+ value
230
+ currency
231
+ }
232
+ }
233
+ fixed_product_taxes {
234
+ label
235
+ amount {
236
+ value
237
+ currency
238
+ }
239
+ }
240
+ }
241
+ ... on SimpleCartItem {
242
+ customizable_options {
243
+ label
244
+ values {
245
+ label
246
+ value
247
+ }
248
+ }
249
+ }
250
+ ... on ConfigurableCartItem {
251
+ configurable_options {
252
+ option_label
253
+ value_label
254
+ }
255
+ }
256
+ ... on BundleCartItem {
257
+ bundle_options {
258
+ uid
259
+ label
260
+ type
261
+ values {
262
+ uid
263
+ label
264
+ quantity
265
+ }
266
+ }
267
+ }
268
+ ... on DownloadableCartItem {
269
+ links {
270
+ uid
271
+ title
272
+ }
273
+ }
274
+ ... on GiftCardCartItem {
275
+ sender_name
276
+ sender_email
277
+ recipient_name
278
+ recipient_email
279
+ message
280
+ amount {
281
+ value
282
+ currency
283
+ }
284
+ }
285
+ errors {
286
+ code
287
+ message
288
+ }
289
+ is_available
290
+ max_qty
291
+ min_qty
292
+ not_available_message
293
+ note_from_buyer {
294
+ note_uid
295
+ note
296
+ created_at
297
+ }
298
+ note_from_seller {
299
+ note_uid
300
+ note
301
+ created_at
302
+ }
303
+ }
304
+ page_info {
305
+ current_page
306
+ page_size
307
+ total_pages
308
+ }
309
+ total_count
310
+ }
311
+ prices {
312
+ grand_total {
313
+ value
314
+ currency
315
+ }
316
+ grand_total_excluding_tax {
317
+ value
318
+ currency
319
+ }
320
+ subtotal_excluding_tax {
321
+ value
322
+ currency
323
+ }
324
+ subtotal_including_tax {
325
+ value
326
+ currency
327
+ }
328
+ subtotal_with_discount_excluding_tax {
329
+ value
330
+ currency
331
+ }
332
+ applied_taxes {
333
+ label
334
+ amount {
335
+ value
336
+ currency
337
+ }
338
+ }
339
+ discounts {
340
+ label
341
+ amount {
342
+ value
343
+ currency
344
+ }
345
+ }
346
+ gift_options {
347
+ gift_wrapping_for_items {
348
+ value
349
+ currency
350
+ }
351
+ gift_wrapping_for_items_incl_tax {
352
+ value
353
+ currency
354
+ }
355
+ gift_wrapping_for_order {
356
+ value
357
+ currency
358
+ }
359
+ gift_wrapping_for_order_incl_tax {
360
+ value
361
+ currency
362
+ }
363
+ printed_card {
364
+ value
365
+ currency
366
+ }
367
+ printed_card_incl_tax {
368
+ value
369
+ currency
370
+ }
12
371
  }
13
372
  }
14
373
  }
15
- ${C}
16
- `,J=async e=>{const n=Array.isArray(e)?e:[e];if(!n||n.length===0)throw new Error("Purchase Order UID(s) are required");if(n.some(s=>!s||s.trim()===""))throw new Error("All Purchase Order UIDs must be valid");return P(T,{variables:{input:{purchase_order_uids:n}}}).then(s=>{var l,o,_;(l=s.errors)!=null&&l.length&&a(s.errors);const i=(o=s.data)==null?void 0:o.cancelPurchaseOrders;if(!i)throw new Error("Failed to cancel purchase orders");return{errors:((i==null?void 0:i.errors)??[]).map(c=>({message:(c==null?void 0:c.message)??"",type:(c==null?void 0:c.type)??""})),purchaseOrders:((_=i==null?void 0:i.purchase_orders)==null?void 0:_.map(c=>D(c)))??[]}}).catch(A)},U=`
374
+ `,I=`
375
+ query GET_PURCHASE_ORDER($uid: ID!) {
376
+ customer {
377
+ purchase_order(uid: $uid) {
378
+ uid
379
+ number
380
+ created_at
381
+ updated_at
382
+ status
383
+ available_actions
384
+ created_by {
385
+ firstname
386
+ lastname
387
+ email
388
+ }
389
+ order {
390
+ id
391
+ number
392
+ total {
393
+ grand_total {
394
+ value
395
+ currency
396
+ }
397
+ }
398
+ }
399
+ quote {
400
+ ...PURCHASE_ORDER_QUOTE_FRAGMENT
401
+ }
402
+ }
403
+ }
404
+ }
405
+ ${S}
406
+ `,U=async r=>{if(!r||r.trim()==="")throw new Error("Purchase Order UID is required");return y(I,{variables:{uid:r}}).then(i=>{var t,a,e;(t=i.errors)!=null&&t.length&&v(i.errors);const s=(e=(a=i.data)==null?void 0:a.customer)==null?void 0:e.purchase_order;if(!s)throw new Error("Failed to get purchase order");return{purchaseOrder:R(s)}}).catch(O)},x=new w({init:async r=>{var t,a;const i={};if(x.config.setConfig({...i,...r}),typeof(r==null?void 0:r.poRef)=="string"&&r.poRef.trim()!==""){const e=await U(r.poRef);(t=e==null?void 0:e.purchaseOrder)!=null&&t.quote&&D.emit("order/data",{...e.purchaseOrder.quote,poNumber:(a=e==null?void 0:e.purchaseOrder)==null?void 0:a.number})}},listeners:()=>[]}),B=x.config,T=`
17
407
  mutation VALIDATE_PURCHASE_ORDERS($input: ValidatePurchaseOrdersInput!) {
18
408
  validatePurchaseOrders(input: $input) {
19
409
  errors {
@@ -26,7 +416,7 @@ import{Initializer as y}from"@dropins/tools/lib.js";import{f as P,h as A}from"./
26
416
  }
27
417
  }
28
418
  ${C}
29
- `,K=async e=>{const n=Array.isArray(e)?e:[e];if(!n||n.length===0)throw new Error("Purchase Order UID(s) are required");if(n.some(s=>!s||s.trim()===""))throw new Error("All Purchase Order UIDs must be valid");return P(U,{variables:{input:{purchase_order_uids:n}}}).then(s=>{var l,o;(l=s.errors)!=null&&l.length&&a(s.errors);const i=(o=s.data)==null?void 0:o.validatePurchaseOrders;return{errors:((i==null?void 0:i.errors)??[]).map(_=>({message:(_==null?void 0:_.message)??"",type:(_==null?void 0:_.type)??""})),purchaseOrders:((i==null?void 0:i.purchase_orders)||[]).map(D)}}).catch(A)},q=`
419
+ `,J=async r=>{const i=Array.isArray(r)?r:[r];if(!i||i.length===0)throw new Error("Purchase Order UID(s) are required");if(i.some(t=>!t||t.trim()===""))throw new Error("All Purchase Order UIDs must be valid");return y(T,{variables:{input:{purchase_order_uids:i}}}).then(t=>{var e,l;(e=t.errors)!=null&&e.length&&v(t.errors);const a=(l=t.data)==null?void 0:l.validatePurchaseOrders;return{errors:((a==null?void 0:a.errors)??[]).map(_=>({message:(_==null?void 0:_.message)??"",type:(_==null?void 0:_.type)??""})),purchaseOrders:((a==null?void 0:a.purchase_orders)||[]).map(R)}}).catch(O)},q=`
30
420
  mutation ADD_PURCHASE_ORDER_COMMENT(
31
421
  $purchaseOrderUid: ID!
32
422
  $comment: String!
@@ -58,7 +448,7 @@ import{Initializer as y}from"@dropins/tools/lib.js";import{f as P,h as A}from"./
58
448
  }
59
449
  }
60
450
  }
61
- `,$=e=>{var u,s,i,l,o,_,c,t,O,f,E,g,R,h,b;const n=((s=(u=e==null?void 0:e.cart)==null?void 0:u.itemsV2)==null?void 0:s.items)??[];return{cart:{id:((i=e==null?void 0:e.cart)==null?void 0:i.id)??"",items:n.map(p=>{var r,S,w;return{uid:(p==null?void 0:p.uid)??"",quantity:(p==null?void 0:p.quantity)??0,product:{uid:((r=p==null?void 0:p.product)==null?void 0:r.uid)??"",name:((S=p==null?void 0:p.product)==null?void 0:S.name)??"",sku:((w=p==null?void 0:p.product)==null?void 0:w.sku)??""}}}),pagination:{currentPage:((_=(o=(l=e==null?void 0:e.cart)==null?void 0:l.itemsV2)==null?void 0:o.page_info)==null?void 0:_.current_page)??1,pageSize:((O=(t=(c=e==null?void 0:e.cart)==null?void 0:c.itemsV2)==null?void 0:t.page_info)==null?void 0:O.page_size)??20,totalPages:((g=(E=(f=e==null?void 0:e.cart)==null?void 0:f.itemsV2)==null?void 0:E.page_info)==null?void 0:g.total_pages)??0,totalCount:((h=(R=e==null?void 0:e.cart)==null?void 0:R.itemsV2)==null?void 0:h.total_count)??0}},userErrors:((b=e==null?void 0:e.user_errors)==null?void 0:b.map(p=>({message:(p==null?void 0:p.message)??""})))??[]}},x=e=>{var b,p;const n=(p=(b=e.data)==null?void 0:b.placeOrderForPurchaseOrder)==null?void 0:p.order,u=r=>({value:(r==null?void 0:r.value)||0,currency:(r==null?void 0:r.currency)||""}),s=r=>({code:(r==null?void 0:r.code)||"",label:(r==null?void 0:r.label)||""}),i=r=>({code:(r==null?void 0:r.code)||"",appliedBalance:u(r==null?void 0:r.applied_balance),currentBalance:u(r==null?void 0:r.current_balance)}),l=r=>({firstname:(r==null?void 0:r.firstname)||"",lastname:(r==null?void 0:r.lastname)||"",street:(r==null?void 0:r.street)||[],city:(r==null?void 0:r.city)||"",region:(r==null?void 0:r.region)||"",postcode:(r==null?void 0:r.postcode)||"",countryCode:(r==null?void 0:r.country_code)||"",telephone:(r==null?void 0:r.telephone)||"",company:(r==null?void 0:r.company)||""}),o=r=>({name:(r==null?void 0:r.name)||"",type:(r==null?void 0:r.type)||"",additionalData:(r==null?void 0:r.additional_data)||{}}),_=r=>({id:(r==null?void 0:r.id)||"",productName:(r==null?void 0:r.product_name)||"",productSku:(r==null?void 0:r.product_sku)||"",quantityOrdered:(r==null?void 0:r.quantity_ordered)||0,quantityShipped:(r==null?void 0:r.quantity_shipped)||0,quantityInvoiced:(r==null?void 0:r.quantity_invoiced)||0,quantityRefunded:(r==null?void 0:r.quantity_refunded)||0,price:u(r==null?void 0:r.price),total:u(r==null?void 0:r.total)}),c=r=>({number:(r==null?void 0:r.number)||"",carrier:(r==null?void 0:r.carrier)||"",title:(r==null?void 0:r.title)||""}),t=r=>({message:(r==null?void 0:r.message)||"",timestamp:(r==null?void 0:r.timestamp)||""}),O=r=>({id:(r==null?void 0:r.id)||"",productName:(r==null?void 0:r.product_name)||"",productSku:(r==null?void 0:r.product_sku)||"",quantityShipped:(r==null?void 0:r.quantity_shipped)||0}),f=r=>({id:(r==null?void 0:r.id)||"",number:(r==null?void 0:r.number)||"",tracking:((r==null?void 0:r.tracking)||[]).map(c),comments:((r==null?void 0:r.comments)||[]).map(t),items:((r==null?void 0:r.items)||[]).map(O)}),E=r=>({firstname:(r==null?void 0:r.firstname)||"",lastname:(r==null?void 0:r.lastname)||"",email:(r==null?void 0:r.email)||""}),g=r=>({label:(r==null?void 0:r.label)||"",amount:u(r==null?void 0:r.amount)}),R=r=>({baseGrandTotal:u(r==null?void 0:r.base_grand_total),grandTotal:u(r==null?void 0:r.grand_total),subtotal:u(r==null?void 0:r.subtotal),totalTax:u(r==null?void 0:r.total_tax),totalShipping:u(r==null?void 0:r.total_shipping),discounts:((r==null?void 0:r.discounts)||[]).map(g)}),h=r=>({appliedCoupons:((r==null?void 0:r.applied_coupons)||[]).map(s),appliedGiftCards:((r==null?void 0:r.applied_gift_cards)||[]).map(i),availableActions:(r==null?void 0:r.available_actions)||[],billingAddress:r!=null&&r.billing_address?l(r.billing_address):{firstname:"",lastname:"",street:[],city:"",region:"",postcode:"",countryCode:"",telephone:"",company:""},carrier:(r==null?void 0:r.carrier)||"",comments:(r==null?void 0:r.comments)||[],creditMemos:(r==null?void 0:r.credit_memos)||[],customAttributes:(r==null?void 0:r.custom_attributes)||[],customerInfo:r!=null&&r.customer_info?E(r.customer_info):{firstname:"",lastname:"",email:""},email:(r==null?void 0:r.email)||"",giftMessage:(r==null?void 0:r.gift_message)||"",giftReceiptIncluded:(r==null?void 0:r.gift_receipt_included)||!1,giftWrapping:(r==null?void 0:r.gift_wrapping)||null,id:(r==null?void 0:r.id)||"",invoices:(r==null?void 0:r.invoices)||[],isVirtual:(r==null?void 0:r.is_virtual)||!1,items:((r==null?void 0:r.items)||[]).map(_),itemsEligibleForReturn:(r==null?void 0:r.items_eligible_for_return)||[],number:(r==null?void 0:r.number)||"",orderDate:(r==null?void 0:r.order_date)||"",orderStatusChangeDate:(r==null?void 0:r.order_status_change_date)||"",paymentMethods:((r==null?void 0:r.payment_methods)||[]).map(o),printedCardIncluded:(r==null?void 0:r.printed_card_included)||!1,returns:(r==null?void 0:r.returns)||null,shipments:((r==null?void 0:r.shipments)||[]).map(f),shippingAddress:r!=null&&r.shipping_address?l(r.shipping_address):{firstname:"",lastname:"",street:[],city:"",region:"",postcode:"",countryCode:"",telephone:"",company:""},shippingMethod:(r==null?void 0:r.shipping_method)||"",status:(r==null?void 0:r.status)||"",token:(r==null?void 0:r.token)||"",total:r!=null&&r.total?R(r.total):{baseGrandTotal:u(null),grandTotal:u(null),subtotal:u(null),totalTax:u(null),totalShipping:u(null),discounts:[]}});return h(n||null)},I=e=>{var n,u,s,i,l,o,_,c,t,O,f,E,g,R,h;return{createdAt:(e==null?void 0:e.created_at)??"",text:(e==null?void 0:e.text)??"",uid:(e==null?void 0:e.uid)??"",author:{allowRemoteShoppingAssistance:((n=e==null?void 0:e.author)==null?void 0:n.allow_remote_shopping_assistance)??!1,confirmationStatus:((u=e==null?void 0:e.author)==null?void 0:u.confirmation_status)??"",createdAt:((s=e==null?void 0:e.author)==null?void 0:s.created_at)??"",dateOfBirth:((i=e==null?void 0:e.author)==null?void 0:i.date_of_birth)??"",email:((l=e==null?void 0:e.author)==null?void 0:l.email)??"",firstname:((o=e==null?void 0:e.author)==null?void 0:o.firstname)??"",gender:((_=e==null?void 0:e.author)==null?void 0:_.gender)??0,jobTitle:((c=e==null?void 0:e.author)==null?void 0:c.job_title)??"",lastname:((t=e==null?void 0:e.author)==null?void 0:t.lastname)??"",middlename:((O=e==null?void 0:e.author)==null?void 0:O.middlename)??"",prefix:((f=e==null?void 0:e.author)==null?void 0:f.prefix)??"",status:((E=e==null?void 0:e.author)==null?void 0:E.status)??"",structureId:((g=e==null?void 0:e.author)==null?void 0:g.structure_id)??"",suffix:((R=e==null?void 0:e.author)==null?void 0:R.suffix)??"",telephone:((h=e==null?void 0:e.author)==null?void 0:h.telephone)??""}}},X=async(e,n)=>{if(!e)throw new Error("Purchase Order ID is required");if(!n)throw new Error("Comment text is required");return P(q,{variables:{purchaseOrderUid:e,comment:n}}).then(s=>{var i,l,o;return(i=s.errors)!=null&&i.length&&a(s.errors),I((o=(l=s.data)==null?void 0:l.addPurchaseOrderComment)==null?void 0:o.comment)}).catch(A)},H=`
451
+ `,H=r=>{var s,t,a,e,l,_,c,n,o,d,p,h,g,f,E;const i=((t=(s=r==null?void 0:r.cart)==null?void 0:s.itemsV2)==null?void 0:t.items)??[];return{cart:{id:((a=r==null?void 0:r.cart)==null?void 0:a.id)??"",items:i.map(u=>{var b,P,A;return{uid:(u==null?void 0:u.uid)??"",quantity:(u==null?void 0:u.quantity)??0,product:{uid:((b=u==null?void 0:u.product)==null?void 0:b.uid)??"",name:((P=u==null?void 0:u.product)==null?void 0:P.name)??"",sku:((A=u==null?void 0:u.product)==null?void 0:A.sku)??""}}}),pagination:{currentPage:((_=(l=(e=r==null?void 0:r.cart)==null?void 0:e.itemsV2)==null?void 0:l.page_info)==null?void 0:_.current_page)??1,pageSize:((o=(n=(c=r==null?void 0:r.cart)==null?void 0:c.itemsV2)==null?void 0:n.page_info)==null?void 0:o.page_size)??20,totalPages:((h=(p=(d=r==null?void 0:r.cart)==null?void 0:d.itemsV2)==null?void 0:p.page_info)==null?void 0:h.total_pages)??0,totalCount:((f=(g=r==null?void 0:r.cart)==null?void 0:g.itemsV2)==null?void 0:f.total_count)??0}},userErrors:((E=r==null?void 0:r.user_errors)==null?void 0:E.map(u=>({message:(u==null?void 0:u.message)??""})))??[]}},$=r=>{var i,s,t,a,e,l,_,c,n,o,d,p,h,g,f;return{createdAt:(r==null?void 0:r.created_at)??"",text:(r==null?void 0:r.text)??"",uid:(r==null?void 0:r.uid)??"",author:{allowRemoteShoppingAssistance:((i=r==null?void 0:r.author)==null?void 0:i.allow_remote_shopping_assistance)??!1,confirmationStatus:((s=r==null?void 0:r.author)==null?void 0:s.confirmation_status)??"",createdAt:((t=r==null?void 0:r.author)==null?void 0:t.created_at)??"",dateOfBirth:((a=r==null?void 0:r.author)==null?void 0:a.date_of_birth)??"",email:((e=r==null?void 0:r.author)==null?void 0:e.email)??"",firstname:((l=r==null?void 0:r.author)==null?void 0:l.firstname)??"",gender:((_=r==null?void 0:r.author)==null?void 0:_.gender)??0,jobTitle:((c=r==null?void 0:r.author)==null?void 0:c.job_title)??"",lastname:((n=r==null?void 0:r.author)==null?void 0:n.lastname)??"",middlename:((o=r==null?void 0:r.author)==null?void 0:o.middlename)??"",prefix:((d=r==null?void 0:r.author)==null?void 0:d.prefix)??"",status:((p=r==null?void 0:r.author)==null?void 0:p.status)??"",structureId:((h=r==null?void 0:r.author)==null?void 0:h.structure_id)??"",suffix:((g=r==null?void 0:r.author)==null?void 0:g.suffix)??"",telephone:((f=r==null?void 0:r.author)==null?void 0:f.telephone)??""}}},K=async(r,i)=>{if(!r)throw new Error("Purchase Order ID is required");if(!i)throw new Error("Comment text is required");return y(q,{variables:{purchaseOrderUid:r,comment:i}}).then(t=>{var a,e,l;return(a=t.errors)!=null&&a.length&&v(t.errors),$((l=(e=t.data)==null?void 0:e.addPurchaseOrderComment)==null?void 0:l.comment)}).catch(O)},F=`
62
452
  mutation ADD_PURCHASE_ORDER_ITEMS_TO_CART(
63
453
  $purchaseOrderUid: ID!
64
454
  $cartId: String!
@@ -93,65 +483,7 @@ import{Initializer as y}from"@dropins/tools/lib.js";import{f as P,h as A}from"./
93
483
  }
94
484
  }
95
485
  }
96
- `,Y=async(e,n,u=!1)=>{if(!e)throw new Error("Purchase Order UID is required");if(!n)throw new Error("Cart ID is required");return P(H,{variables:{purchaseOrderUid:e,cartId:n,replaceExistingCartItems:u}}).then(i=>{var o,_;(o=i.errors)!=null&&o.length&&a(i.errors);const l=(_=i.data)==null?void 0:_.addPurchaseOrderItemsToCart;if(!(l!=null&&l.cart))throw new Error("Failed to add purchase order items to cart");return $(l)}).catch(A)},F=`
97
- query GET_PURCHASE_ORDER($uid: ID!) {
98
- customer {
99
- purchase_order(uid: $uid) {
100
- uid
101
- number
102
- created_at
103
- updated_at
104
- status
105
- available_actions
106
- created_by {
107
- firstname
108
- lastname
109
- email
110
- }
111
- order {
112
- id
113
- number
114
- total {
115
- grand_total {
116
- value
117
- currency
118
- }
119
- }
120
- }
121
- quote {
122
- prices {
123
- grand_total {
124
- value
125
- currency
126
- }
127
- }
128
- }
129
- }
130
- }
131
- }
132
- `,Z=async e=>{if(!e||e.trim()==="")throw new Error("Purchase Order UID is required");return P(F,{variables:{uid:e}}).then(n=>{var s,i,l;(s=n.errors)!=null&&s.length&&a(n.errors);const u=(l=(i=n.data)==null?void 0:i.customer)==null?void 0:l.purchase_order;if(!u)throw new Error("Failed to get purchase order");return{purchaseOrder:D(u)}}).catch(A)},M=`
133
- mutation PLACE_ORDER_FOR_PURCHASE_ORDER(
134
- $input: PlaceOrderForPurchaseOrderInput!
135
- ) {
136
- placeOrderForPurchaseOrder(input: $input) {
137
- order {
138
- available_actions
139
- carrier
140
- email
141
- gift_receipt_included
142
- id
143
- is_virtual
144
- number
145
- order_date
146
- order_status_change_date
147
- printed_card_included
148
- shipping_method
149
- status
150
- token
151
- }
152
- }
153
- }
154
- `,d=async e=>{var u;if(!e||e.trim()==="")throw new Error("Purchase Order UID is required");const n={purchase_order_uid:e};try{const s=await P(M,{variables:{input:n}});return(u=s.errors)!=null&&u.length&&a(s.errors),x(s)}catch(s){throw A(s)}},G=`
486
+ `,W=async(r,i,s=!1)=>{if(!r)throw new Error("Purchase Order UID is required");if(!i)throw new Error("Cart ID is required");return y(F,{variables:{purchaseOrderUid:r,cartId:i,replaceExistingCartItems:s}}).then(a=>{var l,_;(l=a.errors)!=null&&l.length&&v(a.errors);const e=(_=a.data)==null?void 0:_.addPurchaseOrderItemsToCart;if(!(e!=null&&e.cart))throw new Error("Failed to add purchase order items to cart");return H(e)}).catch(O)},G=`
155
487
  mutation PLACE_PURCHASE_ORDER($input: PlacePurchaseOrderInput!) {
156
488
  placePurchaseOrder(input: $input) {
157
489
  purchase_order {
@@ -160,5 +492,5 @@ import{Initializer as y}from"@dropins/tools/lib.js";import{f as P,h as A}from"./
160
492
  }
161
493
  }
162
494
  ${C}
163
- `,m=async e=>{if(!e||e.trim()==="")throw new Error("Cart ID is required");return P(G,{variables:{input:{cart_id:e}}}).then(u=>{var i,l,o;(i=u.errors)!=null&&i.length&&a(u.errors);const s=(o=(l=u.data)==null?void 0:l.placePurchaseOrder)==null?void 0:o.purchase_order;return{purchaseOrder:D(s)}}).catch(A)};export{X as addPurchaseOrderComment,Y as addPurchaseOrderItemsToCart,pr as approvePurchaseOrders,J as cancelPurchaseOrders,k as config,tr as createPurchaseOrderApprovalRule,Or as currencyInfo,Rr as deletePurchaseOrderApprovalRule,P as fetchGraphQl,sr as getConfig,Z as getPurchaseOrder,ar as getPurchaseOrderApprovalRule,fr as getPurchaseOrderApprovalRuleMetadata,Pr as getPurchaseOrderApprovalRules,_r as getPurchaseOrders,v as initialize,d as placeOrderForPurchaseOrder,m as placePurchaseOrder,cr as rejectPurchaseOrders,ur as removeFetchGraphQlHeader,ir as setEndpoint,nr as setFetchGraphQlHeader,lr as setFetchGraphQlHeaders,Er as updatePurchaseOrderApprovalRule,K as validatePurchaseOrders};
495
+ `,X=async r=>{if(!r||r.trim()==="")throw new Error("Cart ID is required");return y(G,{variables:{input:{cart_id:r}}}).then(s=>{var a,e,l;(a=s.errors)!=null&&a.length&&v(s.errors);const t=(l=(e=s.data)==null?void 0:e.placePurchaseOrder)==null?void 0:l.purchase_order;return{purchaseOrder:R(t)}}).catch(O)};export{K as addPurchaseOrderComment,W as addPurchaseOrderItemsToCart,ur as approvePurchaseOrders,_r as cancelPurchaseOrders,B as config,or as createPurchaseOrderApprovalRule,dr as currencyInfo,fr as deletePurchaseOrderApprovalRule,y as fetchGraphQl,m as getConfig,U as getPurchaseOrder,Er as getPurchaseOrderApprovalRule,pr as getPurchaseOrderApprovalRuleMetadata,yr as getPurchaseOrderApprovalRules,vr as getPurchaseOrders,x as initialize,cr as placeOrderForPurchaseOrder,X as placePurchaseOrder,sr as rejectPurchaseOrders,rr as removeFetchGraphQlHeader,er as setEndpoint,ar as setFetchGraphQlHeader,tr as setFetchGraphQlHeaders,hr as updatePurchaseOrderApprovalRule,J as validatePurchaseOrders};
164
496
  //# sourceMappingURL=api.js.map