@nextblock-cms/ecom 0.20.1 → 0.21.0

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 (317) hide show
  1. package/_virtual/_rolldown/runtime.cjs.js +1 -0
  2. package/index.cjs.js +1 -1
  3. package/index.es.js +38 -146
  4. package/lib/CurrencyProvider.cjs.js +1 -1
  5. package/lib/CurrencyProvider.d.ts +1 -1
  6. package/lib/CurrencyProvider.es.js +85 -95
  7. package/lib/PaymentReadinessProvider.cjs.js +1 -1
  8. package/lib/PaymentReadinessProvider.d.ts +1 -1
  9. package/lib/PaymentReadinessProvider.es.js +24 -27
  10. package/lib/cart-store.cjs.js +1 -1
  11. package/lib/cart-store.es.js +109 -121
  12. package/lib/components/AccountNavigationMenu.cjs.js +1 -1
  13. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  14. package/lib/components/AccountNavigationMenu.es.js +36 -50
  15. package/lib/components/AddToCartButton.cjs.js +1 -1
  16. package/lib/components/AddToCartButton.d.ts +1 -1
  17. package/lib/components/AddToCartButton.es.js +94 -89
  18. package/lib/components/Cart.cjs.js +1 -1
  19. package/lib/components/Cart.d.ts +1 -1
  20. package/lib/components/Cart.es.js +261 -180
  21. package/lib/components/CartDrawer.cjs.js +1 -1
  22. package/lib/components/CartDrawer.d.ts +1 -1
  23. package/lib/components/CartDrawer.es.js +218 -148
  24. package/lib/components/CartIcon.cjs.js +1 -1
  25. package/lib/components/CartIcon.d.ts +1 -1
  26. package/lib/components/CartIcon.es.js +33 -35
  27. package/lib/components/Checkout.cjs.js +1 -1
  28. package/lib/components/Checkout.d.ts +1 -1
  29. package/lib/components/Checkout.es.js +1092 -1108
  30. package/lib/components/CouponForm.cjs.js +1 -1
  31. package/lib/components/CouponForm.d.ts +1 -1
  32. package/lib/components/CouponForm.es.js +136 -148
  33. package/lib/components/CurrencySwitcher.cjs.js +1 -1
  34. package/lib/components/CurrencySwitcher.d.ts +1 -1
  35. package/lib/components/CurrencySwitcher.es.js +22 -18
  36. package/lib/components/CustomerProfileForm.cjs.js +1 -1
  37. package/lib/components/CustomerProfileForm.es.js +454 -313
  38. package/lib/components/FeaturedProduct.cjs.js +1 -1
  39. package/lib/components/FeaturedProduct.d.ts +1 -1
  40. package/lib/components/FeaturedProduct.es.js +98 -83
  41. package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
  42. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  43. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  44. package/lib/components/InvoiceDocument.cjs.js +1 -1
  45. package/lib/components/InvoiceDocument.es.js +256 -192
  46. package/lib/components/InvoiceViewerShell.cjs.js +2 -2
  47. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  48. package/lib/components/InvoiceViewerShell.es.js +75 -106
  49. package/lib/components/ProductCard.cjs.js +1 -1
  50. package/lib/components/ProductCard.d.ts +1 -1
  51. package/lib/components/ProductCard.es.js +186 -171
  52. package/lib/components/ProductDetailsLayout.cjs.js +1 -1
  53. package/lib/components/ProductDetailsLayout.es.js +405 -404
  54. package/lib/components/ProductGallery.cjs.js +1 -1
  55. package/lib/components/ProductGallery.d.ts +1 -1
  56. package/lib/components/ProductGallery.es.js +51 -54
  57. package/lib/components/ProductGrid.cjs.js +1 -1
  58. package/lib/components/ProductGrid.d.ts +1 -1
  59. package/lib/components/ProductGrid.es.js +23 -25
  60. package/lib/components/ShippingEstimator.cjs.js +1 -1
  61. package/lib/components/ShippingEstimator.d.ts +1 -1
  62. package/lib/components/ShippingEstimator.es.js +158 -153
  63. package/lib/components/ShortDescription.cjs.js +1 -1
  64. package/lib/components/ShortDescription.es.js +17 -17
  65. package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
  66. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  67. package/lib/components/SubscriptionSelector.cjs.js +1 -1
  68. package/lib/components/SubscriptionSelector.es.js +159 -154
  69. package/lib/countries.cjs.js +1 -1
  70. package/lib/countries.es.js +232 -75
  71. package/lib/coupon-server.cjs.js +1 -1
  72. package/lib/coupon-server.es.js +180 -224
  73. package/lib/coupons.cjs.js +1 -1
  74. package/lib/coupons.es.js +12 -14
  75. package/lib/currency-constants.cjs.js +1 -1
  76. package/lib/currency-constants.es.js +4 -4
  77. package/lib/currency-rest-client.cjs.js +1 -1
  78. package/lib/currency-rest-client.es.js +15 -22
  79. package/lib/currency-store.cjs.js +1 -1
  80. package/lib/currency-store.es.js +20 -27
  81. package/lib/currency-sync.cjs.js +1 -1
  82. package/lib/currency-sync.es.js +124 -170
  83. package/lib/currency.cjs.js +1 -1
  84. package/lib/currency.es.js +242 -310
  85. package/lib/customer-addresses.cjs.js +1 -1
  86. package/lib/customer-addresses.es.js +80 -109
  87. package/lib/customer-orders.cjs.js +1 -1
  88. package/lib/customer-orders.es.js +31 -43
  89. package/lib/customer.cjs.js +1 -1
  90. package/lib/customer.es.js +43 -52
  91. package/lib/export-helpers.cjs.js +1 -1
  92. package/lib/export-helpers.es.js +53 -52
  93. package/lib/factory.cjs.js +1 -1
  94. package/lib/factory.es.js +10 -7
  95. package/lib/freemius-coupons.cjs.js +1 -1
  96. package/lib/freemius-coupons.es.js +245 -262
  97. package/lib/freemius-license-claim.cjs.js +1 -1
  98. package/lib/freemius-license-claim.es.js +87 -71
  99. package/lib/freemius-license.cjs.js +1 -1
  100. package/lib/freemius-license.es.js +32 -39
  101. package/lib/freemius-order-sync.cjs.js +1 -1
  102. package/lib/freemius-order-sync.es.js +226 -290
  103. package/lib/freemius-trial-provision.cjs.js +1 -1
  104. package/lib/freemius-trial-provision.es.js +136 -130
  105. package/lib/inventory-settings.cjs.js +1 -1
  106. package/lib/inventory-settings.es.js +69 -77
  107. package/lib/invoice-server.cjs.js +3 -3
  108. package/lib/invoice-server.es.js +94 -141
  109. package/lib/invoice-ui.cjs.js +1 -1
  110. package/lib/invoice-ui.es.js +50 -66
  111. package/lib/invoice.cjs.js +1 -1
  112. package/lib/invoice.es.js +85 -94
  113. package/lib/order-inventory.cjs.js +25 -25
  114. package/lib/order-inventory.es.js +67 -79
  115. package/lib/order-tax-details.cjs.js +1 -1
  116. package/lib/order-tax-details.es.js +142 -153
  117. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
  118. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  119. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  120. package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
  121. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  122. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  123. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
  124. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  125. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  126. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
  127. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  128. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  129. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
  130. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  131. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  132. package/lib/pages/cms/coupons/actions.cjs.js +1 -1
  133. package/lib/pages/cms/coupons/actions.es.js +112 -115
  134. package/lib/pages/cms/coupons/index.cjs.js +1 -0
  135. package/lib/pages/cms/coupons/index.es.js +3 -0
  136. package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
  137. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  138. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
  139. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  140. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  141. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  143. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  144. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
  145. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  146. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  147. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
  148. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  149. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  150. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
  151. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  152. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  153. package/lib/pages/cms/orders/actions.cjs.js +3 -3
  154. package/lib/pages/cms/orders/actions.es.js +53 -69
  155. package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
  156. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  157. package/lib/pages/cms/orders/index.cjs.js +1 -0
  158. package/lib/pages/cms/orders/index.es.js +6 -0
  159. package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
  160. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  161. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
  162. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  163. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  164. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
  165. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  166. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  167. package/lib/pages/cms/payments/actions.cjs.js +1 -1
  168. package/lib/pages/cms/payments/actions.es.js +38 -48
  169. package/lib/pages/cms/payments/index.cjs.js +1 -0
  170. package/lib/pages/cms/payments/index.es.js +3 -0
  171. package/lib/pages/cms/payments/queries.cjs.js +1 -1
  172. package/lib/pages/cms/payments/queries.es.js +38 -48
  173. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
  174. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  175. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  176. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  177. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
  178. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
  179. package/lib/pages/cms/products/actions.cjs.js +4 -4
  180. package/lib/pages/cms/products/actions.es.js +121 -162
  181. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  184. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  187. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  190. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
  191. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  192. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  194. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  197. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
  198. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  199. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  200. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  203. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
  204. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  205. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
  206. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  207. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
  208. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  209. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
  210. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  211. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  212. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
  213. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  214. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  215. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  218. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  221. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  222. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  224. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  225. package/lib/pages/cms/products/index.cjs.js +1 -0
  226. package/lib/pages/cms/products/index.es.js +8 -0
  227. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
  228. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  229. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  230. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  233. package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
  234. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  235. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
  236. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  237. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  238. package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
  239. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  240. package/lib/pages/cms/products/server-actions.cjs.js +1 -1
  241. package/lib/pages/cms/products/server-actions.es.js +250 -233
  242. package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
  243. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  244. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
  245. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  246. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  247. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
  248. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  249. package/lib/pages/cms/shipping/index.cjs.js +1 -0
  250. package/lib/pages/cms/shipping/index.es.js +3 -0
  251. package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
  252. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  253. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
  254. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  255. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  256. package/lib/pages/cms/taxes/actions.cjs.js +1 -1
  257. package/lib/pages/cms/taxes/actions.es.js +41 -53
  258. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
  259. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  260. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  261. package/lib/pages/cms/taxes/index.cjs.js +1 -0
  262. package/lib/pages/cms/taxes/index.es.js +3 -0
  263. package/lib/payment-config.cjs.js +1 -1
  264. package/lib/payment-config.es.js +110 -126
  265. package/lib/product-actions.cjs.js +4 -4
  266. package/lib/product-actions.es.js +289 -544
  267. package/lib/product-context.cjs.js +1 -1
  268. package/lib/product-context.es.js +13 -15
  269. package/lib/product-schema.cjs.js +1 -1
  270. package/lib/product-schema.es.js +99 -134
  271. package/lib/providers/freemius.cjs.js +1 -5
  272. package/lib/providers/freemius.es.js +446 -530
  273. package/lib/providers/stripe.cjs.js +1 -1
  274. package/lib/providers/stripe.es.js +417 -477
  275. package/lib/server-actions/coupon-actions.cjs.js +1 -1
  276. package/lib/server-actions/coupon-actions.es.js +22 -22
  277. package/lib/server-actions/customer-actions.cjs.js +1 -1
  278. package/lib/server-actions/customer-actions.es.js +26 -28
  279. package/lib/server-actions/product-actions.cjs.js +1 -1
  280. package/lib/server-actions/product-actions.es.js +9 -15
  281. package/lib/server-actions/shipping-actions.cjs.js +1 -1
  282. package/lib/server-actions/shipping-actions.es.js +27 -24
  283. package/lib/server-actions/tax-actions.cjs.js +1 -1
  284. package/lib/server-actions/tax-actions.es.js +33 -39
  285. package/lib/shared-inventory.cjs.js +2 -2
  286. package/lib/shared-inventory.es.js +111 -160
  287. package/lib/shipping/resolver.cjs.js +2 -2
  288. package/lib/shipping/resolver.es.js +44 -61
  289. package/lib/shipping-rate-currency.cjs.js +1 -1
  290. package/lib/shipping-rate-currency.es.js +52 -67
  291. package/lib/states.cjs.js +1 -1
  292. package/lib/states.es.js +333 -154
  293. package/lib/stripe/checkout.cjs.js +1 -1
  294. package/lib/stripe/checkout.es.js +125 -181
  295. package/lib/stripe/client.cjs.js +1 -1
  296. package/lib/stripe/client.es.js +14 -19
  297. package/lib/stripe/order-sync.cjs.js +1 -1
  298. package/lib/stripe/order-sync.es.js +106 -126
  299. package/lib/stripe/webhooks.cjs.js +1 -1
  300. package/lib/stripe/webhooks.es.js +37 -31
  301. package/lib/tax-calculation.cjs.js +1 -1
  302. package/lib/tax-calculation.es.js +84 -98
  303. package/lib/trials.cjs.js +1 -1
  304. package/lib/trials.es.js +24 -30
  305. package/lib/types.cjs.js +1 -1
  306. package/lib/types.es.js +21 -27
  307. package/lib/use-cart.cjs.js +1 -1
  308. package/lib/use-cart.es.js +38 -40
  309. package/lib/use-price-formatter.cjs.js +1 -1
  310. package/lib/use-price-formatter.es.js +10 -11
  311. package/lib/variation-utils.cjs.js +1 -1
  312. package/lib/variation-utils.es.js +199 -261
  313. package/lib/zod-config.cjs.js +1 -1
  314. package/lib/zod-config.es.js +5 -6
  315. package/package.json +16 -16
  316. package/server.cjs.js +1 -1
  317. package/server.es.js +56 -211
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@nextblock-cms/db/server"),t=require("../coupon-server.cjs.js");async function c(e){try{const o=r.getServiceRoleSupabaseClient();return await t.getCouponQuote({client:o,code:e.code,items:Array.isArray(e.items)?e.items:[],currencyCode:e.currencyCode})}catch(o){return console.error("Failed to validate coupon:",o),{success:!1,error:o.message||"Failed to validate coupon.",errorKey:"ecommerce.coupon_validation_failed"}}}exports.getCouponQuoteAction=c;
1
+ "use server";const e=require("../coupon-server.cjs.js");let t=require("@nextblock-cms/db/server");async function n(n){try{let r=(0,t.getServiceRoleSupabaseClient)();return await e.getCouponQuote({client:r,code:n.code,items:Array.isArray(n.items)?n.items:[],currencyCode:n.currencyCode})}catch(e){return console.error(`Failed to validate coupon:`,e),{success:!1,error:e.message||`Failed to validate coupon.`,errorKey:`ecommerce.coupon_validation_failed`}}}exports.getCouponQuoteAction=n;
@@ -1,23 +1,23 @@
1
- 'use server';
2
- import { getServiceRoleSupabaseClient as r } from "@nextblock-cms/db/server";
3
- import { getCouponQuote as t } from "../coupon-server.es.js";
4
- async function i(e) {
5
- try {
6
- const o = r();
7
- return await t({
8
- client: o,
9
- code: e.code,
10
- items: Array.isArray(e.items) ? e.items : [],
11
- currencyCode: e.currencyCode
12
- });
13
- } catch (o) {
14
- return console.error("Failed to validate coupon:", o), {
15
- success: !1,
16
- error: o.message || "Failed to validate coupon.",
17
- errorKey: "ecommerce.coupon_validation_failed"
18
- };
19
- }
1
+ "use server";
2
+ import { getCouponQuote as e } from "../coupon-server.es.js";
3
+ import { getServiceRoleSupabaseClient as t } from "@nextblock-cms/db/server";
4
+ //#region libs/ecommerce/src/lib/server-actions/coupon-actions.ts
5
+ async function n(n) {
6
+ try {
7
+ let r = t();
8
+ return await e({
9
+ client: r,
10
+ code: n.code,
11
+ items: Array.isArray(n.items) ? n.items : [],
12
+ currencyCode: n.currencyCode
13
+ });
14
+ } catch (e) {
15
+ return console.error("Failed to validate coupon:", e), {
16
+ success: !1,
17
+ error: e.message || "Failed to validate coupon.",
18
+ errorKey: "ecommerce.coupon_validation_failed"
19
+ };
20
+ }
20
21
  }
21
- export {
22
- i as getCouponQuoteAction
23
- };
22
+ //#endregion
23
+ export { n as getCouponQuoteAction };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@nextblock-cms/db/server"),o=require("next/cache"),n=require("../customer.cjs.js"),c=require("../customer-addresses.cjs.js");async function p(e){const r=d.createClient(),{data:{user:s},error:l}=await r.auth.getUser();if(l||!s)throw new Error("Unauthorized");const u={full_name:e.full_name||null,avatar_url:e.avatar_url||null,website:e.website||null,phone:e.phone||null,updated_at:new Date().toISOString()},{error:t}=await r.from("profiles").update(u).eq("id",s.id);if(t)throw console.error("Error updating profile:",t),new Error("Failed to update profile");const i=n.normalizeCustomerAddress(e.billing_address),a=e.use_billing_for_shipping?i:n.normalizeCustomerAddress(e.shipping_address);return await c.upsertDefaultUserAddresses({userId:s.id,billingAddress:i,shippingAddress:a,client:r}),o.revalidatePath("/profile"),o.revalidatePath("/checkout"),{success:!0}}exports.updateProfile=p;
1
+ "use server";const e=require("../customer.cjs.js"),t=require("../customer-addresses.cjs.js");let n=require("@nextblock-cms/db/server"),r=require("next/cache");async function i(i){let a=(0,n.createClient)(),{data:{user:o},error:s}=await a.auth.getUser();if(s||!o)throw Error(`Unauthorized`);let c={full_name:i.full_name||null,avatar_url:i.avatar_url||null,website:i.website||null,phone:i.phone||null,updated_at:new Date().toISOString()},{error:l}=await a.from(`profiles`).update(c).eq(`id`,o.id);if(l)throw console.error(`Error updating profile:`,l),Error(`Failed to update profile`);let u=e.normalizeCustomerAddress(i.billing_address),d=i.use_billing_for_shipping?u:e.normalizeCustomerAddress(i.shipping_address);return await t.upsertDefaultUserAddresses({userId:o.id,billingAddress:u,shippingAddress:d,client:a}),(0,r.revalidatePath)(`/profile`),(0,r.revalidatePath)(`/checkout`),{success:!0}}exports.updateProfile=i;
@@ -1,29 +1,27 @@
1
- 'use server';
2
- import { createClient as p } from "@nextblock-cms/db/server";
3
- import { revalidatePath as s } from "next/cache";
4
- import { normalizeCustomerAddress as n } from "../customer.es.js";
5
- import { upsertDefaultUserAddresses as d } from "../customer-addresses.es.js";
6
- async function w(r) {
7
- const e = p(), { data: { user: o }, error: l } = await e.auth.getUser();
8
- if (l || !o)
9
- throw new Error("Unauthorized");
10
- const a = {
11
- full_name: r.full_name || null,
12
- avatar_url: r.avatar_url || null,
13
- website: r.website || null,
14
- phone: r.phone || null,
15
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
16
- }, { error: t } = await e.from("profiles").update(a).eq("id", o.id);
17
- if (t)
18
- throw console.error("Error updating profile:", t), new Error("Failed to update profile");
19
- const i = n(r.billing_address), u = r.use_billing_for_shipping ? i : n(r.shipping_address);
20
- return await d({
21
- userId: o.id,
22
- billingAddress: i,
23
- shippingAddress: u,
24
- client: e
25
- }), s("/profile"), s("/checkout"), { success: !0 };
1
+ "use server";
2
+ import { normalizeCustomerAddress as e } from "../customer.es.js";
3
+ import { upsertDefaultUserAddresses as t } from "../customer-addresses.es.js";
4
+ import { createClient as n } from "@nextblock-cms/db/server";
5
+ import { revalidatePath as r } from "next/cache";
6
+ //#region libs/ecommerce/src/lib/server-actions/customer-actions.ts
7
+ async function i(i) {
8
+ let a = n(), { data: { user: o }, error: s } = await a.auth.getUser();
9
+ if (s || !o) throw Error("Unauthorized");
10
+ let c = {
11
+ full_name: i.full_name || null,
12
+ avatar_url: i.avatar_url || null,
13
+ website: i.website || null,
14
+ phone: i.phone || null,
15
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
16
+ }, { error: l } = await a.from("profiles").update(c).eq("id", o.id);
17
+ if (l) throw console.error("Error updating profile:", l), Error("Failed to update profile");
18
+ let u = e(i.billing_address), d = i.use_billing_for_shipping ? u : e(i.shipping_address);
19
+ return await t({
20
+ userId: o.id,
21
+ billingAddress: u,
22
+ shippingAddress: d,
23
+ client: a
24
+ }), r("/profile"), r("/checkout"), { success: !0 };
26
25
  }
27
- export {
28
- w as updateProfile
29
- };
26
+ //#endregion
27
+ export { i as updateProfile };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@nextblock-cms/db/server"),u=require("../product-actions.cjs.js");async function d(t,e,o=[],a=[]){const n=c.createClient(),{data:s,error:r}=await u.fetchTranslatedProductsForCartInternal(n,t,e,o,a);return r?(console.error("[getTranslatedProductsForCart] Error:",r),[]):s||[]}exports.getTranslatedProductsForCart=d;
1
+ "use server";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../product-actions.cjs.js");let t=require("@nextblock-cms/db/server");async function n(n,r,i=[],a=[]){let o=(0,t.createClient)(),{data:s,error:c}=await e.fetchTranslatedProductsForCartInternal(o,n,r,i,a);return c?(console.error(`[getTranslatedProductsForCart] Error:`,c),[]):s||[]}exports.getTranslatedProductsForCart=n;
@@ -1,16 +1,10 @@
1
- 'use server';
2
- import { createClient as c } from "@nextblock-cms/db/server";
3
- import { fetchTranslatedProductsForCartInternal as d } from "../product-actions.es.js";
4
- async function l(t, o, a = [], e = []) {
5
- const n = c(), { data: s, error: r } = await d(
6
- n,
7
- t,
8
- o,
9
- a,
10
- e
11
- );
12
- return r ? (console.error("[getTranslatedProductsForCart] Error:", r), []) : s || [];
1
+ "use server";
2
+ import { fetchTranslatedProductsForCartInternal as e } from "../product-actions.es.js";
3
+ import { createClient as t } from "@nextblock-cms/db/server";
4
+ //#region libs/ecommerce/src/lib/server-actions/product-actions.ts
5
+ async function n(n, r, i = [], a = []) {
6
+ let o = t(), { data: s, error: c } = await e(o, n, r, i, a);
7
+ return c ? (console.error("[getTranslatedProductsForCart] Error:", c), []) : s || [];
13
8
  }
14
- export {
15
- l as getTranslatedProductsForCart
16
- };
9
+ //#endregion
10
+ export { n as getTranslatedProductsForCart };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../shipping/resolver.cjs.js"),n=require("../countries.cjs.js"),c=require("../states.cjs.js");async function u(o,r,s,t){try{const e=n.normalizeCountryCode(r.country);return e?{success:!0,methods:await i.resolveShippingOptions(o,{...r,country:e,state:c.normalizeSubdivisionCode(e,r.state)||void 0},s,t)}:{success:!1,error:"Country is required for shipping calculation",errorKey:"ecommerce.shipping_country_required"}}catch(e){return console.error("Failed to resolve shipping options:",e),{success:!1,error:e.message||"Failed to calculate shipping",errorKey:"ecommerce.shipping_calculation_failed"}}}exports.getShippingEstimates=u;
1
+ "use server";const e=require("../countries.cjs.js"),t=require("../shipping/resolver.cjs.js"),n=require("../states.cjs.js");async function r(r,i,a,o){try{let s=e.normalizeCountryCode(i.country);return s?{success:!0,methods:await t.resolveShippingOptions(r,{...i,country:s,state:n.normalizeSubdivisionCode(s,i.state)||void 0},a,o)}:{success:!1,error:`Country is required for shipping calculation`,errorKey:`ecommerce.shipping_country_required`}}catch(e){return console.error(`Failed to resolve shipping options:`,e),{success:!1,error:e.message||`Failed to calculate shipping`,errorKey:`ecommerce.shipping_calculation_failed`}}}exports.getShippingEstimates=r;
@@ -1,27 +1,30 @@
1
- 'use server';
1
+ "use server";
2
+ import { normalizeCountryCode as e } from "../countries.es.js";
2
3
  import { resolveShippingOptions as t } from "../shipping/resolver.es.js";
3
- import { normalizeCountryCode as c } from "../countries.es.js";
4
4
  import { normalizeSubdivisionCode as n } from "../states.es.js";
5
- async function m(o, e, i, s) {
6
- try {
7
- const r = c(e.country);
8
- return r ? { success: !0, methods: await t(o, {
9
- ...e,
10
- country: r,
11
- state: n(r, e.state) || void 0
12
- }, i, s) } : {
13
- success: !1,
14
- error: "Country is required for shipping calculation",
15
- errorKey: "ecommerce.shipping_country_required"
16
- };
17
- } catch (r) {
18
- return console.error("Failed to resolve shipping options:", r), {
19
- success: !1,
20
- error: r.message || "Failed to calculate shipping",
21
- errorKey: "ecommerce.shipping_calculation_failed"
22
- };
23
- }
5
+ //#region libs/ecommerce/src/lib/server-actions/shipping-actions.ts
6
+ async function r(r, i, a, o) {
7
+ try {
8
+ let s = e(i.country);
9
+ return s ? {
10
+ success: !0,
11
+ methods: await t(r, {
12
+ ...i,
13
+ country: s,
14
+ state: n(s, i.state) || void 0
15
+ }, a, o)
16
+ } : {
17
+ success: !1,
18
+ error: "Country is required for shipping calculation",
19
+ errorKey: "ecommerce.shipping_country_required"
20
+ };
21
+ } catch (e) {
22
+ return console.error("Failed to resolve shipping options:", e), {
23
+ success: !1,
24
+ error: e.message || "Failed to calculate shipping",
25
+ errorKey: "ecommerce.shipping_calculation_failed"
26
+ };
27
+ }
24
28
  }
25
- export {
26
- m as getShippingEstimates
27
- };
29
+ //#endregion
30
+ export { r as getShippingEstimates };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@nextblock-cms/db/server"),n=require("../tax-calculation.cjs.js"),o=require("../coupon-server.cjs.js");async function x(a,l,s="USD",c,t){try{const e=u.createClient(),_=u.getServiceRoleSupabaseClient(),{data:d}=await e.from("currencies").select("code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount").eq("is_active",!0).order("code",{ascending:!0}),g=d??[];let r;if(c){const i=await o.getCouponQuote({client:_,code:c,items:t&&t.length>0?t:a,currencyCode:s});i.success&&(r=o.getQuoteLineDiscountMap(i.quote))}const m=await n.buildCheckoutTaxableItemsFromCart(e,a,s,g,r);return{success:!0,tax:await n.calculateCheckoutTaxes(e,{items:m,destination:l})}}catch(e){return console.error("Failed to estimate taxes:",e),{success:!1,error:e.message||"Failed to calculate taxes"}}}exports.getTaxEstimate=x;
1
+ "use server";const e=require("../coupon-server.cjs.js"),t=require("../tax-calculation.cjs.js");let n=require("@nextblock-cms/db/server");async function r(r,i,a=`USD`,o,s){try{let c=(0,n.createClient)(),l=(0,n.getServiceRoleSupabaseClient)(),{data:u}=await c.from(`currencies`).select(`code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount`).eq(`is_active`,!0).order(`code`,{ascending:!0}),d=u??[],f;if(o){let t=await e.getCouponQuote({client:l,code:o,items:s&&s.length>0?s:r,currencyCode:a});t.success&&(f=e.getQuoteLineDiscountMap(t.quote))}let p=await t.buildCheckoutTaxableItemsFromCart(c,r,a,d,f);return{success:!0,tax:await t.calculateCheckoutTaxes(c,{items:p,destination:i})}}catch(e){return console.error(`Failed to estimate taxes:`,e),{success:!1,error:e.message||`Failed to calculate taxes`}}}exports.getTaxEstimate=r;
@@ -1,40 +1,34 @@
1
- 'use server';
2
- import { createClient as d, getServiceRoleSupabaseClient as m } from "@nextblock-cms/db/server";
3
- import { buildCheckoutTaxableItemsFromCart as g, calculateCheckoutTaxes as p } from "../tax-calculation.es.js";
4
- import { getCouponQuote as x, getQuoteLineDiscountMap as f } from "../coupon-server.es.js";
5
- async function S(a, o, s = "USD", c, t) {
6
- try {
7
- const e = d(), u = m(), { data: n } = await e.from("currencies").select(
8
- "code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount"
9
- ).eq("is_active", !0).order("code", { ascending: !0 }), l = n ?? [];
10
- let r;
11
- if (c) {
12
- const i = await x({
13
- client: u,
14
- code: c,
15
- items: t && t.length > 0 ? t : a,
16
- currencyCode: s
17
- });
18
- i.success && (r = f(i.quote));
19
- }
20
- const _ = await g(
21
- e,
22
- a,
23
- s,
24
- l,
25
- r
26
- );
27
- return { success: !0, tax: await p(e, {
28
- items: _,
29
- destination: o
30
- }) };
31
- } catch (e) {
32
- return console.error("Failed to estimate taxes:", e), {
33
- success: !1,
34
- error: e.message || "Failed to calculate taxes"
35
- };
36
- }
1
+ "use server";
2
+ import { getCouponQuote as e, getQuoteLineDiscountMap as t } from "../coupon-server.es.js";
3
+ import { buildCheckoutTaxableItemsFromCart as n, calculateCheckoutTaxes as r } from "../tax-calculation.es.js";
4
+ import { createClient as i, getServiceRoleSupabaseClient as a } from "@nextblock-cms/db/server";
5
+ //#region libs/ecommerce/src/lib/server-actions/tax-actions.ts
6
+ async function o(o, s, c = "USD", l, u) {
7
+ try {
8
+ let d = i(), f = a(), { data: p } = await d.from("currencies").select("code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount").eq("is_active", !0).order("code", { ascending: !0 }), m = p ?? [], h;
9
+ if (l) {
10
+ let n = await e({
11
+ client: f,
12
+ code: l,
13
+ items: u && u.length > 0 ? u : o,
14
+ currencyCode: c
15
+ });
16
+ n.success && (h = t(n.quote));
17
+ }
18
+ let g = await n(d, o, c, m, h);
19
+ return {
20
+ success: !0,
21
+ tax: await r(d, {
22
+ items: g,
23
+ destination: s
24
+ })
25
+ };
26
+ } catch (e) {
27
+ return console.error("Failed to estimate taxes:", e), {
28
+ success: !1,
29
+ error: e.message || "Failed to calculate taxes"
30
+ };
31
+ }
37
32
  }
38
- export {
39
- S as getTaxEstimate
40
- };
33
+ //#endregion
34
+ export { o as getTaxEstimate };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("server-only");const w=require("@nextblock-cms/db/server");function p(a){return a??w.getServiceRoleSupabaseClient()}function S(a){return a?(Array.isArray(a)?a:[a]).map(r=>r?.code?.toUpperCase().trim()).filter(r=>!!r):[]}function d(a){return[...new Set(a)].sort((n,r)=>n.localeCompare(r))}function v(a,n){return!a||a===n?n:"mixed"}async function y(a,n){const r=Array.from(n.reduce((u,s)=>{const t=s.sku.trim();return t&&u.set(t,{sku:t,quantity:Math.max(0,Math.trunc(s.quantity))}),u},new Map).values());if(r.length===0)return;const{error:o}=await a.from("inventory_items").upsert(r,{onConflict:"sku"});if(o)throw new Error(o.message)}async function k(a,n){const r=d(n.map(s=>s.trim()).filter(Boolean));if(r.length===0)return new Map;const{data:o,error:u}=await a.from("inventory_items").select("sku, quantity").in("sku",r);if(u)throw new Error(u.message);return new Map((o||[]).map(s=>[s.sku,Math.max(0,s.quantity??0)]))}async function m(a){const{data:n,error:r}=await a.from("products").select(`
1
+ let e=require("@nextblock-cms/db/server");require("server-only");function t(t){return t??(0,e.getServiceRoleSupabaseClient)()}function n(e){return e?(Array.isArray(e)?e:[e]).map(e=>e?.code?.toUpperCase().trim()).filter(e=>!!e):[]}function r(e){return[...new Set(e)].sort((e,t)=>e.localeCompare(t))}function i(e,t){return!e||e===t?t:`mixed`}async function a(e,t){let n=Array.from(t.reduce((e,t)=>{let n=t.sku.trim();return n&&e.set(n,{sku:n,quantity:Math.max(0,Math.trunc(t.quantity))}),e},new Map).values());if(n.length===0)return;let{error:r}=await e.from(`inventory_items`).upsert(n,{onConflict:`sku`});if(r)throw Error(r.message)}async function o(e,t){let n=r(t.map(e=>e.trim()).filter(Boolean));if(n.length===0)return new Map;let{data:i,error:a}=await e.from(`inventory_items`).select(`sku, quantity`).in(`sku`,n);if(a)throw Error(a.message);return new Map((i||[]).map(e=>[e.sku,Math.max(0,e.quantity??0)]))}async function s(e){let{data:t,error:r}=await e.from(`products`).select(`
2
2
  id,
3
3
  title,
4
4
  sku,
@@ -12,4 +12,4 @@
12
12
  sku,
13
13
  stock_quantity
14
14
  )
15
- `).order("title",{ascending:!0});if(r)throw new Error(r.message);const o=new Map,u=(s,t,e,c,g)=>{const l=s.trim();if(!l)return;const f=S(c.languages),i=o.get(l);if(i){i.usageType=v(i.usageType,t),i.stockFallback=Math.min(i.stockFallback,e),i.productTitles.add(c.title),i.parentProductSkus.add(c.sku),i.languages=new Set([...i.languages,...f]),i.statuses.add(c.status),i.productIds.add(c.id),g&&i.variantIds.add(g);return}o.set(l,{sku:l,stockFallback:e,usageType:t,productTitles:new Set([c.title]),parentProductSkus:new Set([c.sku]),languages:new Set(f),statuses:new Set([c.status]),productIds:new Set([c.id]),variantIds:g?new Set([g]):new Set})};for(const s of n||[]){const t=s.product_variants||[];if(t.length>0){for(const e of t)u(e.sku,"variant",Math.max(0,e.stock_quantity??0),s,e.id);continue}u(s.sku,"product",Math.max(0,s.stock??0),s)}return o}async function h(a){const n=p(a),r=await m(n),o=[...r.keys()];if(o.length===0)return[];let u=await k(n,o);const s=o.filter(t=>!u.has(t)).flatMap(t=>{const e=r.get(t);return e?[{sku:t,quantity:e.stockFallback}]:[]});return s.length>0&&(await y(n,s),u=await k(n,o)),o.flatMap(t=>{const e=r.get(t);return e?{key:t,sku:t,stock:u.get(t)??e.stockFallback,usageType:e.usageType,productTitles:d(e.productTitles),parentProductSkus:d(e.parentProductSkus),languages:d(e.languages),statuses:d(e.statuses),productIds:d(e.productIds),variantIds:d(e.variantIds)}:[]}).sort((t,e)=>t.sku.localeCompare(e.sku)||t.usageType.localeCompare(e.usageType)||t.productTitles.join(", ").localeCompare(e.productTitles.join(", ")))}async function M(a,n){const r=p(n),o=a.sku.trim(),u=Math.max(0,Math.trunc(a.stock));if(!o)throw new Error("SKU is required to update inventory.");await y(r,[{sku:o,quantity:u}]);const t=(await m(r)).get(o),e=(t?.productIds.size??0)+(t?.variantIds.size??0);return{stock:u,affectedCount:e}}async function I(a,n,r){const o=p(r);if(n.variants&&n.variants.length>0){const u=Array.from(n.variants.reduce((s,t)=>(s.set(t.sku.trim(),Math.max(0,Math.trunc(t.stock_quantity))),s),new Map).entries()).map(([s,t])=>({sku:s,quantity:t}));await y(o,u);return}await y(o,[{sku:n.sku,quantity:Math.max(0,Math.trunc(n.stock))}])}exports.getInventoryItems=h;exports.setSharedInventoryQuantity=M;exports.syncSharedInventoryForSavedProduct=I;
15
+ `).order(`title`,{ascending:!0});if(r)throw Error(r.message);let a=new Map,o=(e,t,r,o,s)=>{let c=e.trim();if(!c)return;let l=n(o.languages),u=a.get(c);if(u){u.usageType=i(u.usageType,t),u.stockFallback=Math.min(u.stockFallback,r),u.productTitles.add(o.title),u.parentProductSkus.add(o.sku),u.languages=new Set([...u.languages,...l]),u.statuses.add(o.status),u.productIds.add(o.id),s&&u.variantIds.add(s);return}a.set(c,{sku:c,stockFallback:r,usageType:t,productTitles:new Set([o.title]),parentProductSkus:new Set([o.sku]),languages:new Set(l),statuses:new Set([o.status]),productIds:new Set([o.id]),variantIds:s?new Set([s]):new Set})};for(let e of t||[]){let t=e.product_variants||[];if(t.length>0){for(let n of t)o(n.sku,`variant`,Math.max(0,n.stock_quantity??0),e,n.id);continue}o(e.sku,`product`,Math.max(0,e.stock??0),e)}return a}async function c(e){let n=t(e),i=await s(n),c=[...i.keys()];if(c.length===0)return[];let l=await o(n,c),u=c.filter(e=>!l.has(e)).flatMap(e=>{let t=i.get(e);return t?[{sku:e,quantity:t.stockFallback}]:[]});return u.length>0&&(await a(n,u),l=await o(n,c)),c.flatMap(e=>{let t=i.get(e);return t?{key:e,sku:e,stock:l.get(e)??t.stockFallback,usageType:t.usageType,productTitles:r(t.productTitles),parentProductSkus:r(t.parentProductSkus),languages:r(t.languages),statuses:r(t.statuses),productIds:r(t.productIds),variantIds:r(t.variantIds)}:[]}).sort((e,t)=>e.sku.localeCompare(t.sku)||e.usageType.localeCompare(t.usageType)||e.productTitles.join(`, `).localeCompare(t.productTitles.join(`, `)))}async function l(e,n){let r=t(n),i=e.sku.trim(),o=Math.max(0,Math.trunc(e.stock));if(!i)throw Error(`SKU is required to update inventory.`);await a(r,[{sku:i,quantity:o}]);let c=(await s(r)).get(i);return{stock:o,affectedCount:(c?.productIds.size??0)+(c?.variantIds.size??0)}}async function u(e,n,r){let i=t(r);if(n.variants&&n.variants.length>0){await a(i,Array.from(n.variants.reduce((e,t)=>(e.set(t.sku.trim(),Math.max(0,Math.trunc(t.stock_quantity))),e),new Map).entries()).map(([e,t])=>({sku:e,quantity:t})));return}await a(i,[{sku:n.sku,quantity:Math.max(0,Math.trunc(n.stock))}])}exports.getInventoryItems=c,exports.setSharedInventoryQuantity=l,exports.syncSharedInventoryForSavedProduct=u;