@nextblock-cms/ecom 0.20.3 → 0.21.1

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 (446) hide show
  1. package/README.md +43 -0
  2. package/_virtual/_rolldown/runtime.cjs +1 -0
  3. package/index.cjs +1 -0
  4. package/index.es.js +38 -146
  5. package/lib/CurrencyProvider.cjs +1 -0
  6. package/lib/CurrencyProvider.d.ts +1 -1
  7. package/lib/CurrencyProvider.es.js +85 -95
  8. package/lib/PaymentReadinessProvider.cjs +1 -0
  9. package/lib/PaymentReadinessProvider.d.ts +1 -1
  10. package/lib/PaymentReadinessProvider.es.js +24 -27
  11. package/lib/cart-store.cjs +1 -0
  12. package/lib/cart-store.es.js +109 -121
  13. package/lib/components/AccountNavigationMenu.cjs +1 -0
  14. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  15. package/lib/components/AccountNavigationMenu.es.js +36 -50
  16. package/lib/components/AddToCartButton.cjs +1 -0
  17. package/lib/components/AddToCartButton.d.ts +1 -1
  18. package/lib/components/AddToCartButton.es.js +94 -89
  19. package/lib/components/Cart.cjs +1 -0
  20. package/lib/components/Cart.d.ts +1 -1
  21. package/lib/components/Cart.es.js +261 -180
  22. package/lib/components/CartDrawer.cjs +1 -0
  23. package/lib/components/CartDrawer.d.ts +1 -1
  24. package/lib/components/CartDrawer.es.js +218 -148
  25. package/lib/components/CartIcon.cjs +1 -0
  26. package/lib/components/CartIcon.d.ts +1 -1
  27. package/lib/components/CartIcon.es.js +33 -35
  28. package/lib/components/Checkout.cjs +1 -0
  29. package/lib/components/Checkout.d.ts +1 -1
  30. package/lib/components/Checkout.es.js +1092 -1108
  31. package/lib/components/CouponForm.cjs +1 -0
  32. package/lib/components/CouponForm.d.ts +1 -1
  33. package/lib/components/CouponForm.es.js +136 -148
  34. package/lib/components/CurrencySwitcher.cjs +1 -0
  35. package/lib/components/CurrencySwitcher.d.ts +1 -1
  36. package/lib/components/CurrencySwitcher.es.js +22 -18
  37. package/lib/components/CustomerProfileForm.cjs +1 -0
  38. package/lib/components/CustomerProfileForm.es.js +454 -313
  39. package/lib/components/FeaturedProduct.cjs +1 -0
  40. package/lib/components/FeaturedProduct.d.ts +1 -1
  41. package/lib/components/FeaturedProduct.es.js +98 -83
  42. package/lib/components/FreemiusLicensePanel.cjs +1 -0
  43. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  44. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  45. package/lib/components/InvoiceDocument.cjs +1 -0
  46. package/lib/components/InvoiceDocument.es.js +256 -192
  47. package/lib/components/InvoiceViewerShell.cjs +29 -0
  48. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  49. package/lib/components/InvoiceViewerShell.es.js +75 -106
  50. package/lib/components/ProductCard.cjs +1 -0
  51. package/lib/components/ProductCard.d.ts +1 -1
  52. package/lib/components/ProductCard.es.js +186 -171
  53. package/lib/components/ProductDetailsLayout.cjs +1 -0
  54. package/lib/components/ProductDetailsLayout.es.js +405 -404
  55. package/lib/components/ProductGallery.cjs +1 -0
  56. package/lib/components/ProductGallery.d.ts +1 -1
  57. package/lib/components/ProductGallery.es.js +51 -54
  58. package/lib/components/ProductGrid.cjs +1 -0
  59. package/lib/components/ProductGrid.d.ts +1 -1
  60. package/lib/components/ProductGrid.es.js +23 -25
  61. package/lib/components/ShippingEstimator.cjs +1 -0
  62. package/lib/components/ShippingEstimator.d.ts +1 -1
  63. package/lib/components/ShippingEstimator.es.js +158 -153
  64. package/lib/components/ShortDescription.cjs +1 -0
  65. package/lib/components/ShortDescription.es.js +17 -17
  66. package/lib/components/SimpleTiptapRenderer.cjs +1 -0
  67. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  68. package/lib/components/SubscriptionSelector.cjs +1 -0
  69. package/lib/components/SubscriptionSelector.es.js +159 -154
  70. package/lib/countries.cjs +1 -0
  71. package/lib/countries.es.js +232 -75
  72. package/lib/coupon-server.cjs +1 -0
  73. package/lib/coupon-server.es.js +180 -224
  74. package/lib/coupons.cjs +1 -0
  75. package/lib/coupons.es.js +12 -14
  76. package/lib/currency-constants.cjs +1 -0
  77. package/lib/currency-constants.es.js +4 -4
  78. package/lib/currency-rest-client.cjs +1 -0
  79. package/lib/currency-rest-client.es.js +15 -22
  80. package/lib/currency-store.cjs +1 -0
  81. package/lib/currency-store.es.js +20 -27
  82. package/lib/currency-sync.cjs +1 -0
  83. package/lib/currency-sync.es.js +124 -170
  84. package/lib/currency.cjs +1 -0
  85. package/lib/currency.es.js +242 -310
  86. package/lib/customer-addresses.cjs +1 -0
  87. package/lib/customer-addresses.es.js +80 -109
  88. package/lib/customer-orders.cjs +1 -0
  89. package/lib/customer-orders.es.js +31 -43
  90. package/lib/customer.cjs +1 -0
  91. package/lib/customer.es.js +43 -52
  92. package/lib/export-helpers.cjs +1 -0
  93. package/lib/export-helpers.es.js +53 -52
  94. package/lib/factory.cjs +1 -0
  95. package/lib/factory.es.js +10 -7
  96. package/lib/freemius-coupons.cjs +1 -0
  97. package/lib/freemius-coupons.es.js +245 -262
  98. package/lib/freemius-license-claim.cjs +1 -0
  99. package/lib/freemius-license-claim.es.js +87 -71
  100. package/lib/freemius-license.cjs +1 -0
  101. package/lib/freemius-license.es.js +32 -39
  102. package/lib/freemius-order-sync.cjs +1 -0
  103. package/lib/freemius-order-sync.es.js +226 -290
  104. package/lib/freemius-trial-provision.cjs +1 -0
  105. package/lib/freemius-trial-provision.es.js +136 -130
  106. package/lib/inventory-settings.cjs +1 -0
  107. package/lib/inventory-settings.es.js +69 -77
  108. package/lib/invoice-server.cjs +33 -0
  109. package/lib/invoice-server.es.js +94 -141
  110. package/lib/invoice-ui.cjs +1 -0
  111. package/lib/invoice-ui.es.js +50 -66
  112. package/lib/invoice.cjs +1 -0
  113. package/lib/invoice.es.js +85 -94
  114. package/lib/order-inventory.cjs +61 -0
  115. package/lib/order-inventory.es.js +67 -79
  116. package/lib/order-tax-details.cjs +1 -0
  117. package/lib/order-tax-details.es.js +142 -153
  118. package/lib/pages/cms/coupons/CouponEditorForm.cjs +1 -0
  119. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  120. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  121. package/lib/pages/cms/coupons/CouponsPage.cjs +5 -0
  122. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  123. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  124. package/lib/pages/cms/coupons/CreateCouponDialog.cjs +1 -0
  125. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  126. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  127. package/lib/pages/cms/coupons/EditCouponPage.cjs +1 -0
  128. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  129. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  130. package/lib/pages/cms/coupons/ProductScopePicker.cjs +1 -0
  131. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  132. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  133. package/lib/pages/cms/coupons/actions.cjs +1 -0
  134. package/lib/pages/cms/coupons/actions.es.js +112 -115
  135. package/lib/pages/cms/coupons/index.cjs +1 -0
  136. package/lib/pages/cms/coupons/index.es.js +3 -0
  137. package/lib/pages/cms/coupons/product-options.cjs +1 -0
  138. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  139. package/lib/pages/cms/orders/ExportReportsDialog.cjs +1 -0
  140. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  141. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.cjs +1 -0
  143. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  144. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  145. package/lib/pages/cms/orders/OrderPrintButton.cjs +1 -0
  146. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  147. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  148. package/lib/pages/cms/orders/OrderStatusForm.cjs +1 -0
  149. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  150. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  151. package/lib/pages/cms/orders/OrdersPage.cjs +1 -0
  152. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  153. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  154. package/lib/pages/cms/orders/actions.cjs +7 -0
  155. package/lib/pages/cms/orders/actions.es.js +53 -69
  156. package/lib/pages/cms/orders/export-actions.cjs +1 -0
  157. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  158. package/lib/pages/cms/orders/index.cjs +1 -0
  159. package/lib/pages/cms/orders/index.es.js +6 -0
  160. package/lib/pages/cms/orders/server-actions.cjs +1 -0
  161. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  162. package/lib/pages/cms/payments/PaymentsClient.cjs +1 -0
  163. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  164. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  165. package/lib/pages/cms/payments/PaymentsPage.cjs +1 -0
  166. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  167. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  168. package/lib/pages/cms/payments/actions.cjs +1 -0
  169. package/lib/pages/cms/payments/actions.es.js +38 -48
  170. package/lib/pages/cms/payments/index.cjs +1 -0
  171. package/lib/pages/cms/payments/index.es.js +3 -0
  172. package/lib/pages/cms/payments/queries.cjs +1 -0
  173. package/lib/pages/cms/payments/queries.es.js +38 -48
  174. package/lib/pages/cms/products/ProductsPage.cjs +1 -0
  175. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  176. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  177. package/lib/pages/cms/products/[id]/edit/EditProductPage.cjs +1 -0
  178. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  179. package/lib/pages/cms/products/[id]/edit/EditProductPage.es.js +139 -0
  180. package/lib/pages/cms/products/actions.cjs +44 -0
  181. package/lib/pages/cms/products/actions.es.js +121 -162
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs +1 -0
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  184. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs +1 -0
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  187. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs +1 -0
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  190. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  191. package/lib/pages/cms/products/categories/components/CategoryManager.cjs +1 -0
  192. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs +1 -0
  194. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs +1 -0
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  197. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  198. package/lib/pages/cms/products/components/DeleteProductButton.cjs +1 -0
  199. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  200. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs +1 -0
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  203. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  204. package/lib/pages/cms/products/components/ProductCategorySelector.cjs +1 -0
  205. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  206. package/lib/pages/cms/products/components/ProductForm.cjs +1 -0
  207. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  208. package/lib/pages/cms/products/components/ProductMediaManager.cjs +1 -0
  209. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  210. package/lib/pages/cms/products/components/ProductsBulkTable.cjs +1 -0
  211. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  212. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  213. package/lib/pages/cms/products/components/SaleScheduleFields.cjs +1 -0
  214. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  215. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs +1 -0
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  218. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs +5 -0
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  221. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  222. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.cjs +1 -0
  224. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  225. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  226. package/lib/pages/cms/products/index.cjs +1 -0
  227. package/lib/pages/cms/products/index.es.js +8 -0
  228. package/lib/pages/cms/products/inventory/InventoryPage.cjs +1 -0
  229. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  230. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs +2 -0
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  233. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  234. package/lib/pages/cms/products/inventory/actions.cjs +3 -0
  235. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  236. package/lib/pages/cms/products/new/NewProductPage.cjs +1 -0
  237. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  238. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  239. package/lib/pages/cms/products/product-price-sync.cjs +1 -0
  240. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  241. package/lib/pages/cms/products/server-actions.cjs +1 -0
  242. package/lib/pages/cms/products/server-actions.es.js +250 -233
  243. package/lib/pages/cms/shipping/ShippingPage.cjs +5 -0
  244. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  245. package/lib/pages/cms/shipping/components/RateForm.cjs +1 -0
  246. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  247. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  248. package/lib/pages/cms/shipping/components/ZoneForm.cjs +1 -0
  249. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  250. package/lib/pages/cms/shipping/index.cjs +1 -0
  251. package/lib/pages/cms/shipping/index.es.js +3 -0
  252. package/lib/pages/cms/shipping/server-actions.cjs +1 -0
  253. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  254. package/lib/pages/cms/taxes/TaxesPage.cjs +1 -0
  255. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  256. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  257. package/lib/pages/cms/taxes/actions.cjs +1 -0
  258. package/lib/pages/cms/taxes/actions.es.js +41 -53
  259. package/lib/pages/cms/taxes/components/TaxRateForm.cjs +1 -0
  260. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  261. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  262. package/lib/pages/cms/taxes/index.cjs +1 -0
  263. package/lib/pages/cms/taxes/index.es.js +3 -0
  264. package/lib/payment-config.cjs +1 -0
  265. package/lib/payment-config.es.js +110 -126
  266. package/lib/product-actions.cjs +238 -0
  267. package/lib/product-actions.es.js +289 -544
  268. package/lib/product-context.cjs +1 -0
  269. package/lib/product-context.es.js +13 -15
  270. package/lib/product-schema.cjs +1 -0
  271. package/lib/product-schema.es.js +99 -134
  272. package/lib/providers/freemius.cjs +1 -0
  273. package/lib/providers/freemius.es.js +446 -530
  274. package/lib/providers/stripe.cjs +1 -0
  275. package/lib/providers/stripe.es.js +417 -477
  276. package/lib/server-actions/coupon-actions.cjs +1 -0
  277. package/lib/server-actions/coupon-actions.es.js +22 -22
  278. package/lib/server-actions/customer-actions.cjs +1 -0
  279. package/lib/server-actions/customer-actions.es.js +26 -28
  280. package/lib/server-actions/product-actions.cjs +1 -0
  281. package/lib/server-actions/product-actions.es.js +9 -15
  282. package/lib/server-actions/shipping-actions.cjs +1 -0
  283. package/lib/server-actions/shipping-actions.es.js +27 -24
  284. package/lib/server-actions/tax-actions.cjs +1 -0
  285. package/lib/server-actions/tax-actions.es.js +33 -39
  286. package/lib/shared-inventory.cjs +15 -0
  287. package/lib/shared-inventory.es.js +111 -160
  288. package/lib/shipping/resolver.cjs +7 -0
  289. package/lib/shipping/resolver.es.js +44 -61
  290. package/lib/shipping-rate-currency.cjs +1 -0
  291. package/lib/shipping-rate-currency.es.js +52 -67
  292. package/lib/states.cjs +1 -0
  293. package/lib/states.es.js +333 -154
  294. package/lib/stripe/checkout.cjs +1 -0
  295. package/lib/stripe/checkout.es.js +125 -181
  296. package/lib/stripe/client.cjs +1 -0
  297. package/lib/stripe/client.es.js +14 -19
  298. package/lib/stripe/order-sync.cjs +1 -0
  299. package/lib/stripe/order-sync.es.js +106 -126
  300. package/lib/stripe/webhooks.cjs +1 -0
  301. package/lib/stripe/webhooks.es.js +37 -31
  302. package/lib/tax-calculation.cjs +1 -0
  303. package/lib/tax-calculation.es.js +84 -98
  304. package/lib/trials.cjs +1 -0
  305. package/lib/trials.es.js +24 -30
  306. package/lib/types.cjs +1 -0
  307. package/lib/types.es.js +21 -27
  308. package/lib/use-cart.cjs +1 -0
  309. package/lib/use-cart.es.js +38 -40
  310. package/lib/use-price-formatter.cjs +1 -0
  311. package/lib/use-price-formatter.es.js +10 -11
  312. package/lib/variation-utils.cjs +1 -0
  313. package/lib/variation-utils.es.js +199 -261
  314. package/lib/zod-config.cjs +1 -0
  315. package/lib/zod-config.es.js +5 -6
  316. package/package.json +22 -21
  317. package/server.cjs +1 -0
  318. package/server.es.js +56 -211
  319. package/index.cjs.js +0 -1
  320. package/lib/CurrencyProvider.cjs.js +0 -1
  321. package/lib/PaymentReadinessProvider.cjs.js +0 -1
  322. package/lib/cart-store.cjs.js +0 -1
  323. package/lib/components/AccountNavigationMenu.cjs.js +0 -1
  324. package/lib/components/AddToCartButton.cjs.js +0 -1
  325. package/lib/components/Cart.cjs.js +0 -1
  326. package/lib/components/CartDrawer.cjs.js +0 -1
  327. package/lib/components/CartIcon.cjs.js +0 -1
  328. package/lib/components/Checkout.cjs.js +0 -1
  329. package/lib/components/CouponForm.cjs.js +0 -1
  330. package/lib/components/CurrencySwitcher.cjs.js +0 -1
  331. package/lib/components/CustomerProfileForm.cjs.js +0 -1
  332. package/lib/components/FeaturedProduct.cjs.js +0 -1
  333. package/lib/components/FreemiusLicensePanel.cjs.js +0 -1
  334. package/lib/components/InvoiceDocument.cjs.js +0 -1
  335. package/lib/components/InvoiceViewerShell.cjs.js +0 -29
  336. package/lib/components/ProductCard.cjs.js +0 -1
  337. package/lib/components/ProductDetailsLayout.cjs.js +0 -1
  338. package/lib/components/ProductGallery.cjs.js +0 -1
  339. package/lib/components/ProductGrid.cjs.js +0 -1
  340. package/lib/components/ShippingEstimator.cjs.js +0 -1
  341. package/lib/components/ShortDescription.cjs.js +0 -1
  342. package/lib/components/SimpleTiptapRenderer.cjs.js +0 -1
  343. package/lib/components/SubscriptionSelector.cjs.js +0 -1
  344. package/lib/countries.cjs.js +0 -1
  345. package/lib/coupon-server.cjs.js +0 -1
  346. package/lib/coupons.cjs.js +0 -1
  347. package/lib/currency-constants.cjs.js +0 -1
  348. package/lib/currency-rest-client.cjs.js +0 -1
  349. package/lib/currency-store.cjs.js +0 -1
  350. package/lib/currency-sync.cjs.js +0 -1
  351. package/lib/currency.cjs.js +0 -1
  352. package/lib/customer-addresses.cjs.js +0 -1
  353. package/lib/customer-orders.cjs.js +0 -1
  354. package/lib/customer.cjs.js +0 -1
  355. package/lib/export-helpers.cjs.js +0 -1
  356. package/lib/factory.cjs.js +0 -1
  357. package/lib/freemius-coupons.cjs.js +0 -1
  358. package/lib/freemius-license-claim.cjs.js +0 -1
  359. package/lib/freemius-license.cjs.js +0 -1
  360. package/lib/freemius-order-sync.cjs.js +0 -1
  361. package/lib/freemius-trial-provision.cjs.js +0 -1
  362. package/lib/inventory-settings.cjs.js +0 -1
  363. package/lib/invoice-server.cjs.js +0 -33
  364. package/lib/invoice-ui.cjs.js +0 -1
  365. package/lib/invoice.cjs.js +0 -1
  366. package/lib/order-inventory.cjs.js +0 -61
  367. package/lib/order-tax-details.cjs.js +0 -1
  368. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +0 -1
  369. package/lib/pages/cms/coupons/CouponsPage.cjs.js +0 -5
  370. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +0 -1
  371. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +0 -1
  372. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +0 -1
  373. package/lib/pages/cms/coupons/actions.cjs.js +0 -1
  374. package/lib/pages/cms/coupons/product-options.cjs.js +0 -1
  375. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +0 -1
  376. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +0 -1
  377. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +0 -1
  378. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +0 -1
  379. package/lib/pages/cms/orders/OrdersPage.cjs.js +0 -1
  380. package/lib/pages/cms/orders/actions.cjs.js +0 -7
  381. package/lib/pages/cms/orders/export-actions.cjs.js +0 -1
  382. package/lib/pages/cms/orders/server-actions.cjs.js +0 -1
  383. package/lib/pages/cms/payments/PaymentsClient.cjs.js +0 -1
  384. package/lib/pages/cms/payments/PaymentsPage.cjs.js +0 -1
  385. package/lib/pages/cms/payments/actions.cjs.js +0 -1
  386. package/lib/pages/cms/payments/queries.cjs.js +0 -1
  387. package/lib/pages/cms/products/ProductsPage.cjs.js +0 -1
  388. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +0 -1
  389. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +0 -156
  390. package/lib/pages/cms/products/actions.cjs.js +0 -44
  391. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +0 -1
  392. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +0 -1
  393. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +0 -1
  394. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +0 -1
  395. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +0 -1
  396. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +0 -1
  397. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +0 -1
  398. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +0 -1
  399. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +0 -1
  400. package/lib/pages/cms/products/components/ProductForm.cjs.js +0 -1
  401. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +0 -1
  402. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +0 -1
  403. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +0 -1
  404. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +0 -1
  405. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +0 -5
  406. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +0 -1
  407. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +0 -1
  408. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +0 -2
  409. package/lib/pages/cms/products/inventory/actions.cjs.js +0 -3
  410. package/lib/pages/cms/products/new/NewProductPage.cjs.js +0 -1
  411. package/lib/pages/cms/products/product-price-sync.cjs.js +0 -1
  412. package/lib/pages/cms/products/server-actions.cjs.js +0 -1
  413. package/lib/pages/cms/shipping/ShippingPage.cjs.js +0 -5
  414. package/lib/pages/cms/shipping/components/RateForm.cjs.js +0 -1
  415. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +0 -1
  416. package/lib/pages/cms/shipping/server-actions.cjs.js +0 -1
  417. package/lib/pages/cms/taxes/TaxesPage.cjs.js +0 -1
  418. package/lib/pages/cms/taxes/actions.cjs.js +0 -1
  419. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +0 -1
  420. package/lib/payment-config.cjs.js +0 -1
  421. package/lib/product-actions.cjs.js +0 -238
  422. package/lib/product-context.cjs.js +0 -1
  423. package/lib/product-schema.cjs.js +0 -1
  424. package/lib/providers/freemius.cjs.js +0 -5
  425. package/lib/providers/stripe.cjs.js +0 -1
  426. package/lib/server-actions/coupon-actions.cjs.js +0 -1
  427. package/lib/server-actions/customer-actions.cjs.js +0 -1
  428. package/lib/server-actions/product-actions.cjs.js +0 -1
  429. package/lib/server-actions/shipping-actions.cjs.js +0 -1
  430. package/lib/server-actions/tax-actions.cjs.js +0 -1
  431. package/lib/shared-inventory.cjs.js +0 -15
  432. package/lib/shipping/resolver.cjs.js +0 -7
  433. package/lib/shipping-rate-currency.cjs.js +0 -1
  434. package/lib/states.cjs.js +0 -1
  435. package/lib/stripe/checkout.cjs.js +0 -1
  436. package/lib/stripe/client.cjs.js +0 -1
  437. package/lib/stripe/order-sync.cjs.js +0 -1
  438. package/lib/stripe/webhooks.cjs.js +0 -1
  439. package/lib/tax-calculation.cjs.js +0 -1
  440. package/lib/trials.cjs.js +0 -1
  441. package/lib/types.cjs.js +0 -1
  442. package/lib/use-cart.cjs.js +0 -1
  443. package/lib/use-price-formatter.cjs.js +0 -1
  444. package/lib/variation-utils.cjs.js +0 -1
  445. package/lib/zod-config.cjs.js +0 -1
  446. package/server.cjs.js +0 -1
@@ -0,0 +1 @@
1
+ "use server";const e=require("../coupon-server.cjs");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 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 };
@@ -0,0 +1 @@
1
+ "use server";const e=require("../customer.cjs"),t=require("../customer-addresses.cjs");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 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 };
@@ -0,0 +1 @@
1
+ "use server";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../product-actions.cjs");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 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 };
@@ -0,0 +1 @@
1
+ "use server";const e=require("../countries.cjs"),t=require("../shipping/resolver.cjs"),n=require("../states.cjs");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 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 };
@@ -0,0 +1 @@
1
+ "use server";const e=require("../coupon-server.cjs"),t=require("../tax-calculation.cjs");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 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 };
@@ -0,0 +1,15 @@
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
+ id,
3
+ title,
4
+ sku,
5
+ stock,
6
+ status,
7
+ languages (
8
+ code
9
+ ),
10
+ product_variants (
11
+ id,
12
+ sku,
13
+ stock_quantity
14
+ )
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;
@@ -1,171 +1,122 @@
1
+ import { getServiceRoleSupabaseClient as e } from "@nextblock-cms/db/server";
1
2
  import "server-only";
2
- import { getServiceRoleSupabaseClient as w } from "@nextblock-cms/db/server";
3
- function f(a) {
4
- return a ?? w();
3
+ //#region src/lib/shared-inventory.ts
4
+ function t(t) {
5
+ return t ?? e();
5
6
  }
6
- function S(a) {
7
- return a ? (Array.isArray(a) ? a : [a]).map((r) => r?.code?.toUpperCase().trim()).filter((r) => !!r) : [];
7
+ function n(e) {
8
+ return e ? (Array.isArray(e) ? e : [e]).map((e) => e?.code?.toUpperCase().trim()).filter((e) => !!e) : [];
8
9
  }
9
- function g(a) {
10
- return [...new Set(a)].sort((n, r) => n.localeCompare(r));
10
+ function r(e) {
11
+ return [...new Set(e)].sort((e, t) => e.localeCompare(t));
11
12
  }
12
- function M(a, n) {
13
- return !a || a === n ? n : "mixed";
13
+ function i(e, t) {
14
+ return !e || e === t ? t : "mixed";
14
15
  }
15
- async function l(a, n) {
16
- const r = Array.from(
17
- n.reduce((u, s) => {
18
- const t = s.sku.trim();
19
- return t && u.set(t, {
20
- sku: t,
21
- quantity: Math.max(0, Math.trunc(s.quantity))
22
- }), u;
23
- }, /* @__PURE__ */ new Map()).values()
24
- );
25
- if (r.length === 0)
26
- return;
27
- const { error: o } = await a.from("inventory_items").upsert(r, { onConflict: "sku" });
28
- if (o)
29
- throw new Error(o.message);
16
+ async function a(e, t) {
17
+ let n = Array.from(t.reduce((e, t) => {
18
+ let n = t.sku.trim();
19
+ return n && e.set(n, {
20
+ sku: n,
21
+ quantity: Math.max(0, Math.trunc(t.quantity))
22
+ }), e;
23
+ }, /* @__PURE__ */ new Map()).values());
24
+ if (n.length === 0) return;
25
+ let { error: r } = await e.from("inventory_items").upsert(n, { onConflict: "sku" });
26
+ if (r) throw Error(r.message);
30
27
  }
31
- async function k(a, n) {
32
- const r = g(
33
- n.map((s) => s.trim()).filter(Boolean)
34
- );
35
- if (r.length === 0)
36
- return /* @__PURE__ */ new Map();
37
- const { data: o, error: u } = await a.from("inventory_items").select("sku, quantity").in("sku", r);
38
- if (u)
39
- throw new Error(u.message);
40
- return new Map(
41
- (o || []).map((s) => [
42
- s.sku,
43
- Math.max(0, s.quantity ?? 0)
44
- ])
45
- );
28
+ async function o(e, t) {
29
+ let n = r(t.map((e) => e.trim()).filter(Boolean));
30
+ if (n.length === 0) return /* @__PURE__ */ new Map();
31
+ let { data: i, error: a } = await e.from("inventory_items").select("sku, quantity").in("sku", n);
32
+ if (a) throw Error(a.message);
33
+ return new Map((i || []).map((e) => [e.sku, Math.max(0, e.quantity ?? 0)]));
46
34
  }
47
- async function m(a) {
48
- const { data: n, error: r } = await a.from("products").select(
49
- `
50
- id,
51
- title,
52
- sku,
53
- stock,
54
- status,
55
- languages (
56
- code
57
- ),
58
- product_variants (
59
- id,
60
- sku,
61
- stock_quantity
62
- )
63
- `
64
- ).order("title", { ascending: !0 });
65
- if (r)
66
- throw new Error(r.message);
67
- const o = /* @__PURE__ */ new Map(), u = (s, t, e, c, d) => {
68
- const p = s.trim();
69
- if (!p)
70
- return;
71
- const y = S(c.languages), i = o.get(p);
72
- if (i) {
73
- i.usageType = M(i.usageType, t), i.stockFallback = Math.min(i.stockFallback, e), i.productTitles.add(c.title), i.parentProductSkus.add(c.sku), i.languages = /* @__PURE__ */ new Set([...i.languages, ...y]), i.statuses.add(c.status), i.productIds.add(c.id), d && i.variantIds.add(d);
74
- return;
75
- }
76
- o.set(p, {
77
- sku: p,
78
- stockFallback: e,
79
- usageType: t,
80
- productTitles: /* @__PURE__ */ new Set([c.title]),
81
- parentProductSkus: /* @__PURE__ */ new Set([c.sku]),
82
- languages: new Set(y),
83
- statuses: /* @__PURE__ */ new Set([c.status]),
84
- productIds: /* @__PURE__ */ new Set([c.id]),
85
- variantIds: d ? /* @__PURE__ */ new Set([d]) : /* @__PURE__ */ new Set()
86
- });
87
- };
88
- for (const s of n || []) {
89
- const t = s.product_variants || [];
90
- if (t.length > 0) {
91
- for (const e of t)
92
- u(
93
- e.sku,
94
- "variant",
95
- Math.max(0, e.stock_quantity ?? 0),
96
- s,
97
- e.id
98
- );
99
- continue;
100
- }
101
- u(
102
- s.sku,
103
- "product",
104
- Math.max(0, s.stock ?? 0),
105
- s
106
- );
107
- }
108
- return o;
35
+ async function s(e) {
36
+ let { data: t, error: r } = await e.from("products").select("\n id,\n title,\n sku,\n stock,\n status,\n languages (\n code\n ),\n product_variants (\n id,\n sku,\n stock_quantity\n )\n ").order("title", { ascending: !0 });
37
+ if (r) throw Error(r.message);
38
+ let a = /* @__PURE__ */ new Map(), o = (e, t, r, o, s) => {
39
+ let c = e.trim();
40
+ if (!c) return;
41
+ let l = n(o.languages), u = a.get(c);
42
+ if (u) {
43
+ 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 = /* @__PURE__ */ new Set([...u.languages, ...l]), u.statuses.add(o.status), u.productIds.add(o.id), s && u.variantIds.add(s);
44
+ return;
45
+ }
46
+ a.set(c, {
47
+ sku: c,
48
+ stockFallback: r,
49
+ usageType: t,
50
+ productTitles: /* @__PURE__ */ new Set([o.title]),
51
+ parentProductSkus: /* @__PURE__ */ new Set([o.sku]),
52
+ languages: new Set(l),
53
+ statuses: /* @__PURE__ */ new Set([o.status]),
54
+ productIds: /* @__PURE__ */ new Set([o.id]),
55
+ variantIds: s ? /* @__PURE__ */ new Set([s]) : /* @__PURE__ */ new Set()
56
+ });
57
+ };
58
+ for (let e of t || []) {
59
+ let t = e.product_variants || [];
60
+ if (t.length > 0) {
61
+ for (let n of t) o(n.sku, "variant", Math.max(0, n.stock_quantity ?? 0), e, n.id);
62
+ continue;
63
+ }
64
+ o(e.sku, "product", Math.max(0, e.stock ?? 0), e);
65
+ }
66
+ return a;
109
67
  }
110
- async function I(a) {
111
- const n = f(a), r = await m(n), o = [...r.keys()];
112
- if (o.length === 0)
113
- return [];
114
- let u = await k(n, o);
115
- const s = o.filter((t) => !u.has(t)).flatMap((t) => {
116
- const e = r.get(t);
117
- return e ? [
118
- {
119
- sku: t,
120
- quantity: e.stockFallback
121
- }
122
- ] : [];
123
- });
124
- return s.length > 0 && (await l(n, s), u = await k(n, o)), o.flatMap((t) => {
125
- const e = r.get(t);
126
- return e ? {
127
- key: t,
128
- sku: t,
129
- stock: u.get(t) ?? e.stockFallback,
130
- usageType: e.usageType,
131
- productTitles: g(e.productTitles),
132
- parentProductSkus: g(e.parentProductSkus),
133
- languages: g(e.languages),
134
- statuses: g(e.statuses),
135
- productIds: g(e.productIds),
136
- variantIds: g(e.variantIds)
137
- } : [];
138
- }).sort((t, e) => t.sku.localeCompare(e.sku) || t.usageType.localeCompare(e.usageType) || t.productTitles.join(", ").localeCompare(e.productTitles.join(", ")));
68
+ async function c(e) {
69
+ let n = t(e), i = await s(n), c = [...i.keys()];
70
+ if (c.length === 0) return [];
71
+ let l = await o(n, c), u = c.filter((e) => !l.has(e)).flatMap((e) => {
72
+ let t = i.get(e);
73
+ return t ? [{
74
+ sku: e,
75
+ quantity: t.stockFallback
76
+ }] : [];
77
+ });
78
+ return u.length > 0 && (await a(n, u), l = await o(n, c)), c.flatMap((e) => {
79
+ let t = i.get(e);
80
+ return t ? {
81
+ key: e,
82
+ sku: e,
83
+ stock: l.get(e) ?? t.stockFallback,
84
+ usageType: t.usageType,
85
+ productTitles: r(t.productTitles),
86
+ parentProductSkus: r(t.parentProductSkus),
87
+ languages: r(t.languages),
88
+ statuses: r(t.statuses),
89
+ productIds: r(t.productIds),
90
+ variantIds: r(t.variantIds)
91
+ } : [];
92
+ }).sort((e, t) => e.sku.localeCompare(t.sku) || e.usageType.localeCompare(t.usageType) || e.productTitles.join(", ").localeCompare(t.productTitles.join(", ")));
139
93
  }
140
- async function q(a, n) {
141
- const r = f(n), o = a.sku.trim(), u = Math.max(0, Math.trunc(a.stock));
142
- if (!o)
143
- throw new Error("SKU is required to update inventory.");
144
- await l(r, [{ sku: o, quantity: u }]);
145
- const t = (await m(r)).get(o), e = (t?.productIds.size ?? 0) + (t?.variantIds.size ?? 0);
146
- return { stock: u, affectedCount: e };
94
+ async function l(e, n) {
95
+ let r = t(n), i = e.sku.trim(), o = Math.max(0, Math.trunc(e.stock));
96
+ if (!i) throw Error("SKU is required to update inventory.");
97
+ await a(r, [{
98
+ sku: i,
99
+ quantity: o
100
+ }]);
101
+ let c = (await s(r)).get(i);
102
+ return {
103
+ stock: o,
104
+ affectedCount: (c?.productIds.size ?? 0) + (c?.variantIds.size ?? 0)
105
+ };
147
106
  }
148
- async function T(a, n, r) {
149
- const o = f(r);
150
- if (n.variants && n.variants.length > 0) {
151
- const u = Array.from(
152
- n.variants.reduce((s, t) => (s.set(
153
- t.sku.trim(),
154
- Math.max(0, Math.trunc(t.stock_quantity))
155
- ), s), /* @__PURE__ */ new Map()).entries()
156
- ).map(([s, t]) => ({ sku: s, quantity: t }));
157
- await l(o, u);
158
- return;
159
- }
160
- await l(o, [
161
- {
162
- sku: n.sku,
163
- quantity: Math.max(0, Math.trunc(n.stock))
164
- }
165
- ]);
107
+ async function u(e, n, r) {
108
+ let i = t(r);
109
+ if (n.variants && n.variants.length > 0) {
110
+ await a(i, Array.from(n.variants.reduce((e, t) => (e.set(t.sku.trim(), Math.max(0, Math.trunc(t.stock_quantity))), e), /* @__PURE__ */ new Map()).entries()).map(([e, t]) => ({
111
+ sku: e,
112
+ quantity: t
113
+ })));
114
+ return;
115
+ }
116
+ await a(i, [{
117
+ sku: n.sku,
118
+ quantity: Math.max(0, Math.trunc(n.stock))
119
+ }]);
166
120
  }
167
- export {
168
- I as getInventoryItems,
169
- q as setSharedInventoryQuantity,
170
- T as syncSharedInventoryForSavedProduct
171
- };
121
+ //#endregion
122
+ export { c as getInventoryItems, l as setSharedInventoryQuantity, u as syncSharedInventoryForSavedProduct };
@@ -0,0 +1,7 @@
1
+ const e=require("../currency.cjs"),t=require("../shipping-rate-currency.cjs"),n=require("../variation-utils.cjs");let r=require("@nextblock-cms/db/server");async function i(i,a,o,s){let c=(0,r.getSsgSupabaseClient)(),{data:l}=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}),u=l??[],d=e.getDefaultCurrency(u),f=s||d.code,{data:p,error:m}=await c.from(`shipping_zone_locations`).select(`
2
+ zone_id,
3
+ country_code,
4
+ state_code,
5
+ postal_code,
6
+ shipping_zones!inner(priority_order)
7
+ `).eq(`country_code`,a.country).order(`shipping_zones(priority_order)`,{ascending:!0});if(m||!p||p.length===0)return[];let h=null;if(a.state){let e=p.find(e=>e.state_code===a.state);e&&(h=e.zone_id)}if(!h){let e=p.find(e=>!e.state_code&&!e.postal_code);e&&(h=e.zone_id)}h||=p[0].zone_id;let{data:g,error:_}=await c.from(`shipping_zone_methods`).select(`id, zone_id, method_type, cost_amount, cost_amounts, cost_currency, currency_pricing_mode, min_order_amount, min_order_amounts, name, name_translations`).eq(`zone_id`,h);if(_||!g)return[];let v=g.filter(e=>i>=t.resolveShippingRateAmountForCurrency({amountMap:e.min_order_amounts||{},fallbackAmount:e.min_order_amount||0,sourceCurrencyCode:e.cost_currency||d.code,mode:e.currency_pricing_mode,currencyCode:f,currencies:u})).map(e=>({id:e.id,name:n.resolveTranslatedText(e.name,e.name_translations||null,o),amount:t.resolveShippingRateAmountForCurrency({amountMap:e.cost_amounts||{},fallbackAmount:e.cost_amount||0,sourceCurrencyCode:e.cost_currency||d.code,mode:e.currency_pricing_mode,currencyCode:f,currencies:u}),currency:f,type:e.method_type})).sort((e,t)=>e.amount-t.amount)[0];return v?[v]:[]}exports.resolveShippingOptions=i;