@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
@@ -1,95 +1,87 @@
1
- 'use server';
2
- import { revalidatePath as u } from "next/cache";
3
- import { getServiceRoleSupabaseClient as h } from "@nextblock-cms/db/server";
4
- import { setSharedInventoryQuantity as p, getInventoryItems as y } from "../../../../shared-inventory.es.js";
5
- function v(t) {
6
- const e = [];
7
- let o = [], r = "", c = !1;
8
- for (let s = 0; s < t.length; s += 1) {
9
- const n = t[s], i = t[s + 1];
10
- if (n === '"') {
11
- c && i === '"' ? (r += '"', s += 1) : c = !c;
12
- continue;
13
- }
14
- if (n === "," && !c) {
15
- o.push(r), r = "";
16
- continue;
17
- }
18
- if ((n === `
19
- ` || n === "\r") && !c) {
20
- n === "\r" && i === `
21
- ` && (s += 1), (r.length > 0 || o.length > 0) && (o.push(r), e.push(o)), o = [], r = "";
22
- continue;
23
- }
24
- r += n;
25
- }
26
- return (r.length > 0 || o.length > 0) && (o.push(r), e.push(o)), e.filter((s) => s.some((n) => n.trim().length > 0));
1
+ "use server";
2
+ import { getInventoryItems as e, setSharedInventoryQuantity as t } from "../../../../shared-inventory.es.js";
3
+ import { getServiceRoleSupabaseClient as n } from "@nextblock-cms/db/server";
4
+ import { revalidatePath as r } from "next/cache";
5
+ //#region src/lib/pages/cms/products/inventory/actions.ts
6
+ function i(e) {
7
+ let t = [], n = [], r = "", i = !1;
8
+ for (let a = 0; a < e.length; a += 1) {
9
+ let o = e[a], s = e[a + 1];
10
+ if (o === "\"") {
11
+ i && s === "\"" ? (r += "\"", a += 1) : i = !i;
12
+ continue;
13
+ }
14
+ if (o === "," && !i) {
15
+ n.push(r), r = "";
16
+ continue;
17
+ }
18
+ if ((o === "\n" || o === "\r") && !i) {
19
+ o === "\r" && s === "\n" && (a += 1), (r.length > 0 || n.length > 0) && (n.push(r), t.push(n)), n = [], r = "";
20
+ continue;
21
+ }
22
+ r += o;
23
+ }
24
+ return (r.length > 0 || n.length > 0) && (n.push(r), t.push(n)), t.filter((e) => e.some((e) => e.trim().length > 0));
27
25
  }
28
- function k(t) {
29
- return t.sku;
26
+ function a(e) {
27
+ return e.sku;
30
28
  }
31
- async function C(t) {
32
- try {
33
- const e = Math.max(0, Math.trunc(t.stock));
34
- return await p({
35
- sku: t.sku,
36
- stock: e
37
- }), u("/cms/products"), u("/cms/products/inventory"), {
38
- success: !0,
39
- itemKey: k(t),
40
- stock: e
41
- };
42
- } catch (e) {
43
- return {
44
- success: !1,
45
- error: e instanceof Error ? e.message : "Failed to update inventory."
46
- };
47
- }
29
+ async function o(e) {
30
+ try {
31
+ let n = Math.max(0, Math.trunc(e.stock));
32
+ return await t({
33
+ sku: e.sku,
34
+ stock: n
35
+ }), r("/cms/products"), r("/cms/products/inventory"), {
36
+ success: !0,
37
+ itemKey: a(e),
38
+ stock: n
39
+ };
40
+ } catch (e) {
41
+ return {
42
+ success: !1,
43
+ error: e instanceof Error ? e.message : "Failed to update inventory."
44
+ };
45
+ }
48
46
  }
49
- async function x(t) {
50
- try {
51
- const e = v(t);
52
- if (e.length < 2)
53
- return { success: !1, error: "The CSV file is empty." };
54
- const [o, ...r] = e, c = o.map((a) => a.trim().toLowerCase()), s = c.indexOf("sku"), n = c.indexOf("stock");
55
- if (s === -1 || n === -1)
56
- return {
57
- success: !1,
58
- error: "The CSV format is invalid. Please import a file exported from the Inventory page."
59
- };
60
- const i = h();
61
- let m = 0;
62
- for (const a of r) {
63
- const f = (a[s] || "").trim(), l = Number.parseInt((a[n] || "").trim(), 10);
64
- if (f) {
65
- if (!Number.isFinite(l) || l < 0)
66
- return {
67
- success: !1,
68
- error: `Invalid stock value for SKU "${f}".`
69
- };
70
- await p(
71
- {
72
- sku: f,
73
- stock: l
74
- },
75
- i
76
- ), m += 1;
77
- }
78
- }
79
- const d = await y(i);
80
- return u("/cms/products"), u("/cms/products/inventory"), {
81
- success: !0,
82
- updatedCount: m,
83
- items: d
84
- };
85
- } catch (e) {
86
- return {
87
- success: !1,
88
- error: e instanceof Error ? e.message : "Failed to import inventory CSV."
89
- };
90
- }
47
+ async function s(a) {
48
+ try {
49
+ let o = i(a);
50
+ if (o.length < 2) return {
51
+ success: !1,
52
+ error: "The CSV file is empty."
53
+ };
54
+ let [s, ...c] = o, l = s.map((e) => e.trim().toLowerCase()), u = l.indexOf("sku"), d = l.indexOf("stock");
55
+ if (u === -1 || d === -1) return {
56
+ success: !1,
57
+ error: "The CSV format is invalid. Please import a file exported from the Inventory page."
58
+ };
59
+ let f = n(), p = 0;
60
+ for (let e of c) {
61
+ let n = (e[u] || "").trim(), r = Number.parseInt((e[d] || "").trim(), 10);
62
+ if (n) {
63
+ if (!Number.isFinite(r) || r < 0) return {
64
+ success: !1,
65
+ error: `Invalid stock value for SKU "${n}".`
66
+ };
67
+ await t({
68
+ sku: n,
69
+ stock: r
70
+ }, f), p += 1;
71
+ }
72
+ }
73
+ let m = await e(f);
74
+ return r("/cms/products"), r("/cms/products/inventory"), {
75
+ success: !0,
76
+ updatedCount: p,
77
+ items: m
78
+ };
79
+ } catch (e) {
80
+ return {
81
+ success: !1,
82
+ error: e instanceof Error ? e.message : "Failed to import inventory CSV."
83
+ };
84
+ }
91
85
  }
92
- export {
93
- x as importInventoryCsvAction,
94
- C as updateInventoryQuantityAction
95
- };
86
+ //#endregion
87
+ export { s as importInventoryCsvAction, o as updateInventoryQuantityAction };
@@ -0,0 +1 @@
1
+ const e=require("../../../../currency.cjs"),t=require("../../../../variation-utils.cjs"),n=require("../actions.cjs"),r=require("../server-actions.cjs"),i=require("../components/ProductForm.cjs"),a=require("../../payments/queries.cjs");let o=require("@nextblock-cms/utils"),s=require("react/jsx-runtime"),c=require("@nextblock-cms/db/server");async function l({mediaPickerNode:l,availableLanguagesProp:u,translationGroupId:d,targetLanguageId:f,initialData:p}){let[m,h,g,_]=await Promise.all([a.getEnabledPaymentProviders(),a.getStoreConfigStatus(),n.getGlobalProductAttributes(),(0,c.getServiceRoleSupabaseClient)().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}).then(e=>e.data||[])]),v=(_||[]).map(t=>e.normalizeCurrencyRecord(t)),y=(g||[]).map(e=>({id:e.id,name:e.name,name_translations:e.name_translations||{},slug:e.slug,terms:(e.product_attribute_terms||[]).map(e=>({...e,value_translations:e.value_translations||{}}))})),b=u.find(e=>e.id===p?.language_id)?.code||u.find(e=>e.id===(f?parseInt(f,10):void 0))?.code||u.find(e=>e.is_default)?.code,{attributes:x,variants:S}=t.mapRawVariantRelations(p?.product_variants||[],b),C=p&&{...p,variation_attributes:p.variation_attributes||x.map(e=>({attribute_id:e.id,term_ids:e.terms.map(e=>e.id)})),variants:p.variants||S.map(e=>({...e,upc:e.upc??null,price:e.price/100,prices:Object.entries(e.prices||{}).reduce((e,[t,n])=>(e[t]=(0,o.minorUnitAmountToMajor)(n,t),e),{}),sale_price:typeof e.sale_price==`number`?e.sale_price/100:null,sale_prices:Object.entries(e.sale_prices||{}).reduce((e,[t,n])=>(e[t]=typeof n==`number`?(0,o.minorUnitAmountToMajor)(n,t):null,e),{}),main_media_id:e.main_media_id??null,main_image_url:e.image_url??null}))};return(0,s.jsx)(`div`,{className:`p-8`,children:(0,s.jsx)(i.ProductForm,{mediaPickerNode:l,availableLanguagesProp:u,globalAttributesProp:y,currenciesProp:v,translationGroupId:d,targetLanguageId:f,initialData:C,enabledProviders:m,configStatus:h,createAction:r.createProductAction})})}exports.NewProductPage=l;
@@ -5,5 +5,5 @@ interface NewProductPageProps {
5
5
  targetLanguageId?: string;
6
6
  initialData?: any;
7
7
  }
8
- export declare function NewProductPage({ mediaPickerNode, availableLanguagesProp, translationGroupId, targetLanguageId, initialData }: NewProductPageProps): Promise<import("react").JSX.Element>;
8
+ export declare function NewProductPage({ mediaPickerNode, availableLanguagesProp, translationGroupId, targetLanguageId, initialData }: NewProductPageProps): Promise<import('react').JSX.Element>;
9
9
  export {};
@@ -1,76 +1,60 @@
1
+ import { normalizeCurrencyRecord as e } from "../../../../currency.es.js";
2
+ import { mapRawVariantRelations as t } from "../../../../variation-utils.es.js";
3
+ import { getGlobalProductAttributes as n } from "../actions.es.js";
4
+ import { createProductAction as r } from "../server-actions.es.js";
5
+ import { ProductForm as i } from "../components/ProductForm.es.js";
6
+ import { getEnabledPaymentProviders as a, getStoreConfigStatus as o } from "../../payments/queries.es.js";
7
+ import { minorUnitAmountToMajor as s } from "@nextblock-cms/utils";
1
8
  import { jsx as c } from "react/jsx-runtime";
2
- import { ProductForm as x } from "../components/ProductForm.es.js";
3
- import { getGlobalProductAttributes as R } from "../actions.es.js";
4
- import { mapRawVariantRelations as y } from "../../../../variation-utils.es.js";
5
- import { createProductAction as S } from "../server-actions.es.js";
6
- import { getEnabledPaymentProviders as j, getStoreConfigStatus as v } from "../../payments/queries.es.js";
7
- import { getServiceRoleSupabaseClient as w } from "@nextblock-cms/db/server";
8
- import { minorUnitAmountToMajor as m } from "@nextblock-cms/utils";
9
- import { normalizeCurrencyRecord as z } from "../../../../currency.es.js";
10
- async function U({
11
- mediaPickerNode: d,
12
- availableLanguagesProp: i,
13
- translationGroupId: a,
14
- targetLanguageId: s,
15
- initialData: t
16
- }) {
17
- const [u, _, l, p] = await Promise.all([
18
- j(),
19
- v(),
20
- R(),
21
- w().from("currencies").select(
22
- "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"
23
- ).eq("is_active", !0).order("code", { ascending: !0 }).then((e) => e.data || [])
24
- ]), f = (p || []).map(
25
- (e) => z(e)
26
- ), b = (l || []).map((e) => ({
27
- id: e.id,
28
- name: e.name,
29
- name_translations: e.name_translations || {},
30
- slug: e.slug,
31
- terms: (e.product_attribute_terms || []).map((r) => ({
32
- ...r,
33
- value_translations: r.value_translations || {}
34
- }))
35
- })), g = i.find((e) => e.id === t?.language_id)?.code || i.find((e) => e.id === (s ? parseInt(s, 10) : void 0))?.code || i.find((e) => e.is_default)?.code, { attributes: A, variants: P } = y(
36
- t?.product_variants || [],
37
- g
38
- ), h = t && {
39
- ...t,
40
- variation_attributes: t.variation_attributes || A.map((e) => ({
41
- attribute_id: e.id,
42
- term_ids: e.terms.map((r) => r.id)
43
- })),
44
- variants: t.variants || P.map((e) => ({
45
- ...e,
46
- upc: e.upc ?? null,
47
- price: e.price / 100,
48
- prices: Object.entries(e.prices || {}).reduce(
49
- (r, [o, n]) => (r[o] = m(n, o), r),
50
- {}
51
- ),
52
- sale_price: typeof e.sale_price == "number" ? e.sale_price / 100 : null,
53
- sale_prices: Object.entries(e.sale_prices || {}).reduce((r, [o, n]) => (r[o] = typeof n == "number" ? m(n, o) : null, r), {}),
54
- main_media_id: e.main_media_id ?? null,
55
- main_image_url: e.image_url ?? null
56
- }))
57
- };
58
- return /* @__PURE__ */ c("div", { className: "p-8", children: /* @__PURE__ */ c(
59
- x,
60
- {
61
- mediaPickerNode: d,
62
- availableLanguagesProp: i,
63
- globalAttributesProp: b,
64
- currenciesProp: f,
65
- translationGroupId: a,
66
- targetLanguageId: s,
67
- initialData: h,
68
- enabledProviders: u,
69
- configStatus: _,
70
- createAction: S
71
- }
72
- ) });
9
+ import { getServiceRoleSupabaseClient as l } from "@nextblock-cms/db/server";
10
+ //#region src/lib/pages/cms/products/new/NewProductPage.tsx
11
+ async function u({ mediaPickerNode: u, availableLanguagesProp: d, translationGroupId: f, targetLanguageId: p, initialData: m }) {
12
+ let [h, g, _, v] = await Promise.all([
13
+ a(),
14
+ o(),
15
+ n(),
16
+ l().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 }).then((e) => e.data || [])
17
+ ]), y = (v || []).map((t) => e(t)), b = (_ || []).map((e) => ({
18
+ id: e.id,
19
+ name: e.name,
20
+ name_translations: e.name_translations || {},
21
+ slug: e.slug,
22
+ terms: (e.product_attribute_terms || []).map((e) => ({
23
+ ...e,
24
+ value_translations: e.value_translations || {}
25
+ }))
26
+ })), x = d.find((e) => e.id === m?.language_id)?.code || d.find((e) => e.id === (p ? parseInt(p, 10) : void 0))?.code || d.find((e) => e.is_default)?.code, { attributes: S, variants: C } = t(m?.product_variants || [], x), w = m && {
27
+ ...m,
28
+ variation_attributes: m.variation_attributes || S.map((e) => ({
29
+ attribute_id: e.id,
30
+ term_ids: e.terms.map((e) => e.id)
31
+ })),
32
+ variants: m.variants || C.map((e) => ({
33
+ ...e,
34
+ upc: e.upc ?? null,
35
+ price: e.price / 100,
36
+ prices: Object.entries(e.prices || {}).reduce((e, [t, n]) => (e[t] = s(n, t), e), {}),
37
+ sale_price: typeof e.sale_price == "number" ? e.sale_price / 100 : null,
38
+ sale_prices: Object.entries(e.sale_prices || {}).reduce((e, [t, n]) => (e[t] = typeof n == "number" ? s(n, t) : null, e), {}),
39
+ main_media_id: e.main_media_id ?? null,
40
+ main_image_url: e.image_url ?? null
41
+ }))
42
+ };
43
+ return /* @__PURE__ */ c("div", {
44
+ className: "p-8",
45
+ children: /* @__PURE__ */ c(i, {
46
+ mediaPickerNode: u,
47
+ availableLanguagesProp: d,
48
+ globalAttributesProp: b,
49
+ currenciesProp: y,
50
+ translationGroupId: f,
51
+ targetLanguageId: p,
52
+ initialData: w,
53
+ enabledProviders: h,
54
+ configStatus: g,
55
+ createAction: r
56
+ })
57
+ });
73
58
  }
74
- export {
75
- U as NewProductPage
76
- };
59
+ //#endregion
60
+ export { u as NewProductPage };
@@ -0,0 +1 @@
1
+ const e=require("../../../currency.cjs");let t=require("@nextblock-cms/utils");function n(e){return Object.entries(e||{}).reduce((e,[n,r])=>(typeof r==`number`&&Number.isFinite(r)&&r>=0?e[(0,t.normalizeCurrencyCode)(n)]=r:r===null&&(e[(0,t.normalizeCurrencyCode)(n)]=null),e),{})}function r(t){let n=e.normalizeCurrencyRecord(t);return n.is_default!==!0&&n.auto_sync_product_prices===!0}function i(t){return t.map(t=>e.normalizeCurrencyRecord(t)).filter(e=>r(e)).map(e=>e.code)}function a(e,t){let r=new Set(i(t)),a=n(e);return Object.entries(a).reduce((e,[t,n])=>(r.has(t)||(e[t]=n),e),{})}function o(n){let{baseAmount:r,defaultCurrencyCode:i,targetCurrencyCode:a,currencies:o}=n;if(typeof r!=`number`||!Number.isFinite(r)||r<0)return null;let s=e.convertMinorUnitAmount({amount:(0,t.majorUnitAmountToMinor)(r,i),fromCurrencyCode:i,toCurrencyCode:a,currencies:o,applyRounding:!0});return(0,t.minorUnitAmountToMajor)(s,a)}function s(i){let{currencies:a,fallbackPrice:s,fallbackSalePrice:c}=i,l=n(i.prices),u=n(i.salePrices),d=a.find(e=>e.is_default)??a[0];if(!d)return{prices:l,salePrices:u};let f=(0,t.normalizeCurrencyCode)(d.code),p=l[f]??(typeof s==`number`?s:null),m=u[f]??(typeof c==`number`?c:null);return{prices:a.reduce((t,n)=>{let i=e.normalizeCurrencyRecord(n);return r(i)?(t[i.code]=o({baseAmount:p,defaultCurrencyCode:f,targetCurrencyCode:i.code,currencies:a}),t):(t[i.code]=l[i.code]??(i.code===f?p:void 0),t)},{}),salePrices:a.reduce((t,n)=>{let i=e.normalizeCurrencyRecord(n);return r(i)?(t[i.code]=o({baseAmount:m,defaultCurrencyCode:f,targetCurrencyCode:i.code,currencies:a}),t):(t[i.code]=u[i.code]??(i.code===f?m:void 0),t)},{})}}function c(e,n){let r=n.find(e=>e.is_default)??n[0],i=r?(0,t.normalizeCurrencyCode)(r.code):`USD`,o=a(e.prices,n),s=a(e.sale_prices,n);return{...e,price:typeof o[i]==`number`?o[i]:e.price,prices:o,sale_price:typeof s[i]==`number`?s[i]:e.sale_price??null,sale_prices:s}}function l(e,t){return e?.map(e=>c(e,t))||[]}function u(e,n){let r=n.find(e=>e.is_default)??n[0],i=r?(0,t.normalizeCurrencyCode)(r.code):`USD`,o=a(e.prices,n),s=a(e.sale_prices,n);return{...e,price:typeof o[i]==`number`?o[i]:e.price,prices:o,sale_price:typeof s[i]==`number`?s[i]:e.sale_price??null,sale_prices:s,variants:l(e.variants,n)}}exports.getStoreManagedPriceCurrencyCodes=i,exports.isCurrencyStoreManagedPrice=r,exports.resolveEditorCurrencyPriceMaps=s,exports.sanitizeProductFormValuesForStoreManagedCurrencies=u,exports.sanitizeVariantDraftForStoreManagedCurrencies=c,exports.sanitizeVariantDraftsForStoreManagedCurrencies=l;
@@ -1,98 +1,83 @@
1
- import { normalizeCurrencyCode as l, majorUnitAmountToMinor as M, minorUnitAmountToMajor as z } from "@nextblock-cms/utils";
2
- import { normalizeCurrencyRecord as a, convertMinorUnitAmount as S } from "../../../currency.es.js";
3
- function C(r) {
4
- return Object.entries(r || {}).reduce(
5
- (e, [o, n]) => (typeof n == "number" && Number.isFinite(n) && n >= 0 ? e[l(o)] = n : n === null && (e[l(o)] = null), e),
6
- {}
7
- );
1
+ import { convertMinorUnitAmount as e, normalizeCurrencyRecord as t } from "../../../currency.es.js";
2
+ import { majorUnitAmountToMinor as n, minorUnitAmountToMajor as r, normalizeCurrencyCode as i } from "@nextblock-cms/utils";
3
+ //#region src/lib/pages/cms/products/product-price-sync.ts
4
+ function a(e) {
5
+ return Object.entries(e || {}).reduce((e, [t, n]) => (typeof n == "number" && Number.isFinite(n) && n >= 0 ? e[i(t)] = n : n === null && (e[i(t)] = null), e), {});
8
6
  }
9
- function y(r) {
10
- const e = a(r);
11
- return e.is_default !== !0 && e.auto_sync_product_prices === !0;
7
+ function o(e) {
8
+ let n = t(e);
9
+ return n.is_default !== !0 && n.auto_sync_product_prices === !0;
12
10
  }
13
- function A(r) {
14
- return r.map((e) => a(e)).filter((e) => y(e)).map((e) => e.code);
11
+ function s(e) {
12
+ return e.map((e) => t(e)).filter((e) => o(e)).map((e) => e.code);
15
13
  }
16
- function f(r, e) {
17
- const o = new Set(A(e)), n = C(r);
18
- return Object.entries(n).reduce(
19
- (t, [i, u]) => (o.has(i) || (t[i] = u), t),
20
- {}
21
- );
14
+ function c(e, t) {
15
+ let n = new Set(s(t)), r = a(e);
16
+ return Object.entries(r).reduce((e, [t, r]) => (n.has(t) || (e[t] = r), e), {});
22
17
  }
23
- function P(r) {
24
- const { baseAmount: e, defaultCurrencyCode: o, targetCurrencyCode: n, currencies: t } = r;
25
- if (typeof e != "number" || !Number.isFinite(e) || e < 0)
26
- return null;
27
- const i = S({
28
- amount: M(e, o),
29
- fromCurrencyCode: o,
30
- toCurrencyCode: n,
31
- currencies: t,
32
- applyRounding: !0
33
- });
34
- return z(i, n);
18
+ function l(t) {
19
+ let { baseAmount: i, defaultCurrencyCode: a, targetCurrencyCode: o, currencies: s } = t;
20
+ if (typeof i != "number" || !Number.isFinite(i) || i < 0) return null;
21
+ let c = e({
22
+ amount: n(i, a),
23
+ fromCurrencyCode: a,
24
+ toCurrencyCode: o,
25
+ currencies: s,
26
+ applyRounding: !0
27
+ });
28
+ return r(c, o);
35
29
  }
36
- function v(r) {
37
- const { currencies: e, fallbackPrice: o, fallbackSalePrice: n } = r, t = C(r.prices), i = C(r.salePrices), u = e.find((s) => s.is_default) ?? e[0];
38
- if (!u)
39
- return {
40
- prices: t,
41
- salePrices: i
42
- };
43
- const d = l(u.code), m = t[d] ?? (typeof o == "number" ? o : null), b = i[d] ?? (typeof n == "number" ? n : null), _ = e.reduce((s, p) => {
44
- const c = a(p);
45
- return y(c) ? (s[c.code] = P({
46
- baseAmount: m,
47
- defaultCurrencyCode: d,
48
- targetCurrencyCode: c.code,
49
- currencies: e
50
- }), s) : (s[c.code] = t[c.code] ?? (c.code === d ? m : void 0), s);
51
- }, {}), g = e.reduce((s, p) => {
52
- const c = a(p);
53
- return y(c) ? (s[c.code] = P({
54
- baseAmount: b,
55
- defaultCurrencyCode: d,
56
- targetCurrencyCode: c.code,
57
- currencies: e
58
- }), s) : (s[c.code] = i[c.code] ?? (c.code === d ? b : void 0), s);
59
- }, {});
60
- return {
61
- prices: _,
62
- salePrices: g
63
- };
30
+ function u(e) {
31
+ let { currencies: n, fallbackPrice: r, fallbackSalePrice: s } = e, c = a(e.prices), u = a(e.salePrices), d = n.find((e) => e.is_default) ?? n[0];
32
+ if (!d) return {
33
+ prices: c,
34
+ salePrices: u
35
+ };
36
+ let f = i(d.code), p = c[f] ?? (typeof r == "number" ? r : null), m = u[f] ?? (typeof s == "number" ? s : null);
37
+ return {
38
+ prices: n.reduce((e, r) => {
39
+ let i = t(r);
40
+ return o(i) ? (e[i.code] = l({
41
+ baseAmount: p,
42
+ defaultCurrencyCode: f,
43
+ targetCurrencyCode: i.code,
44
+ currencies: n
45
+ }), e) : (e[i.code] = c[i.code] ?? (i.code === f ? p : void 0), e);
46
+ }, {}),
47
+ salePrices: n.reduce((e, r) => {
48
+ let i = t(r);
49
+ return o(i) ? (e[i.code] = l({
50
+ baseAmount: m,
51
+ defaultCurrencyCode: f,
52
+ targetCurrencyCode: i.code,
53
+ currencies: n
54
+ }), e) : (e[i.code] = u[i.code] ?? (i.code === f ? m : void 0), e);
55
+ }, {})
56
+ };
64
57
  }
65
- function F(r, e) {
66
- const o = e.find((u) => u.is_default) ?? e[0], n = o ? l(o.code) : "USD", t = f(r.prices, e), i = f(r.sale_prices, e);
67
- return {
68
- ...r,
69
- price: typeof t[n] == "number" ? t[n] : r.price,
70
- prices: t,
71
- sale_price: typeof i[n] == "number" ? i[n] : r.sale_price ?? null,
72
- sale_prices: i
73
- };
58
+ function d(e, t) {
59
+ let n = t.find((e) => e.is_default) ?? t[0], r = n ? i(n.code) : "USD", a = c(e.prices, t), o = c(e.sale_prices, t);
60
+ return {
61
+ ...e,
62
+ price: typeof a[r] == "number" ? a[r] : e.price,
63
+ prices: a,
64
+ sale_price: typeof o[r] == "number" ? o[r] : e.sale_price ?? null,
65
+ sale_prices: o
66
+ };
74
67
  }
75
- function D(r, e) {
76
- return r?.map(
77
- (o) => F(o, e)
78
- ) || [];
68
+ function f(e, t) {
69
+ return e?.map((e) => d(e, t)) || [];
79
70
  }
80
- function E(r, e) {
81
- const o = e.find((u) => u.is_default) ?? e[0], n = o ? l(o.code) : "USD", t = f(r.prices, e), i = f(r.sale_prices, e);
82
- return {
83
- ...r,
84
- price: typeof t[n] == "number" ? t[n] : r.price,
85
- prices: t,
86
- sale_price: typeof i[n] == "number" ? i[n] : r.sale_price ?? null,
87
- sale_prices: i,
88
- variants: D(r.variants, e)
89
- };
71
+ function p(e, t) {
72
+ let n = t.find((e) => e.is_default) ?? t[0], r = n ? i(n.code) : "USD", a = c(e.prices, t), o = c(e.sale_prices, t);
73
+ return {
74
+ ...e,
75
+ price: typeof a[r] == "number" ? a[r] : e.price,
76
+ prices: a,
77
+ sale_price: typeof o[r] == "number" ? o[r] : e.sale_price ?? null,
78
+ sale_prices: o,
79
+ variants: f(e.variants, t)
80
+ };
90
81
  }
91
- export {
92
- A as getStoreManagedPriceCurrencyCodes,
93
- y as isCurrencyStoreManagedPrice,
94
- v as resolveEditorCurrencyPriceMaps,
95
- E as sanitizeProductFormValuesForStoreManagedCurrencies,
96
- F as sanitizeVariantDraftForStoreManagedCurrencies,
97
- D as sanitizeVariantDraftsForStoreManagedCurrencies
98
- };
82
+ //#endregion
83
+ export { s as getStoreManagedPriceCurrencyCodes, o as isCurrencyStoreManagedPrice, u as resolveEditorCurrencyPriceMaps, p as sanitizeProductFormValuesForStoreManagedCurrencies, d as sanitizeVariantDraftForStoreManagedCurrencies, f as sanitizeVariantDraftsForStoreManagedCurrencies };
@@ -0,0 +1 @@
1
+ "use server";const e=require("../../../currency.cjs"),t=require("../../../product-actions.cjs"),n=require("./product-price-sync.cjs"),r=require("../../../freemius-coupons.cjs");let i=require("@nextblock-cms/db/server"),a=require("next/navigation"),o=require("next/cache");function s(e){return e.toLowerCase().trim().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``)}async function c(s){let c=(0,i.createClient)(),{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=n.sanitizeProductFormValuesForStoreManagedCurrencies(s,(l||[]).map(t=>e.normalizeCurrencyRecord(t))),d=await t.createProduct(c,u);if(u.payment_provider===`freemius`&&d?.id)try{await r.syncProductSaleCouponToFreemius({productId:d.id,client:(0,i.getServiceRoleSupabaseClient)()})}catch(e){console.error(`Failed to sync Freemius sale coupon on create:`,e)}(0,o.revalidatePath)(`/cms/products`),(0,a.redirect)(`/cms/products`)}async function l(e,t,n,r){let i={author_id:n,meta:r,updated_at:new Date().toISOString()},a=async()=>{let{error:n}=await e.from(`product_drafts`).update(i).eq(`product_id`,t);if(n)throw Error(`Failed to save product draft: ${n.message}`)},{data:o,error:s}=await e.from(`product_drafts`).select(`id`).eq(`product_id`,t).maybeSingle();if(s)throw Error(`Failed to read product draft: ${s.message}`);if(o){await a();return}let{data:c,error:l}=await e.from(`blocks`).select(`id, page_id, post_id, product_id, language_id, block_type, content, order, created_at, updated_at`).eq(`product_id`,t).order(`order`,{ascending:!0});if(l)throw Error(`Failed to read product blocks: ${l.message}`);let{error:u}=await e.from(`product_drafts`).insert({...i,blocks:c??[],product_id:t});if(u){if(u.code===`23505`){await a();return}throw Error(`Failed to save product draft: ${u.message}`)}}async function u(t,r){let a=(0,i.createClient)(),{data:{user:o}}=await a.auth.getUser();if(!o)throw Error(`User not authenticated.`);let{data:s}=await a.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}),c=n.sanitizeProductFormValuesForStoreManagedCurrencies(r,(s||[]).map(t=>e.normalizeCurrencyRecord(t)));return await l(a,t,o.id,c),{success:!0}}async function d(e){let n=(0,i.createClient)();await t.deleteProduct(n,e),(0,o.revalidatePath)(`/cms/products`)}function f(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}async function p(e){let t=f(e);if(t.length===0)return{success:!1,error:`Select at least one product.`};let{error:n}=await(0,i.createClient)().from(`products`).delete().in(`id`,t);return n?{success:!1,error:n.message}:((0,o.revalidatePath)(`/cms/products`),{success:!0,count:t.length})}async function m(e){let t=f(e);if(t.length===0)return{success:!1,error:`Select at least one product.`};let{error:n}=await(0,i.createClient)().from(`products`).update({status:`draft`,updated_at:new Date().toISOString()}).in(`id`,t);return n?{success:!1,error:n.message}:((0,o.revalidatePath)(`/cms/products`),{success:!0,count:t.length})}async function h(e){let t=String(e||``).trim();if(!t)return{error:`Missing product id.`};let n=(0,i.createClient)(),{data:{user:r}}=await n.auth.getUser();if(!r)return{error:`You must be signed in to publish a product.`};let{data:a,error:s}=await n.from(`products`).update({status:`active`,updated_at:new Date().toISOString()}).eq(`id`,t).select(`slug`).single();return s||!a?{error:s?.message||`Could not publish the product.`}:((0,o.revalidatePath)(`/cms/products`),(0,o.revalidatePath)(`/cms/products/${t}/edit`),a.slug&&(0,o.revalidatePath)(`/product/${a.slug}`),{})}async function g(e){let t=(0,i.getServiceRoleSupabaseClient)(),n=e.name.trim(),r=s(e.slug?.trim()||e.name);if(!n||!r)return{success:!1,error:`Attribute name is required.`};let{error:a}=await t.from(`product_attributes`).insert({name:n,slug:r});return a?{success:!1,error:a.message}:((0,o.revalidatePath)(`/cms/products/attributes`),(0,o.revalidatePath)(`/cms/products/new`),(0,o.revalidatePath)(`/cms/products`),{success:!0})}async function _(e){let{error:t}=await(0,i.getServiceRoleSupabaseClient)().from(`product_attributes`).delete().eq(`id`,e);return t?{success:!1,error:t.message}:((0,o.revalidatePath)(`/cms/products/attributes`),(0,o.revalidatePath)(`/cms/products/new`),(0,o.revalidatePath)(`/cms/products`),{success:!0})}async function v(e){let t=(0,i.getServiceRoleSupabaseClient)(),n=e.value.trim(),r=s(e.slug?.trim()||e.value);if(!n||!r)return{success:!1,error:`Term value is required.`};let{data:a}=await t.from(`product_attribute_terms`).select(`sort_order`).eq(`attribute_id`,e.attributeId).order(`sort_order`,{ascending:!1}).limit(1),c=typeof a?.[0]?.sort_order==`number`?a[0].sort_order+1:0,{error:l}=await t.from(`product_attribute_terms`).insert({attribute_id:e.attributeId,value:n,slug:r,sort_order:c});return l?{success:!1,error:l.message}:((0,o.revalidatePath)(`/cms/products/attributes`),(0,o.revalidatePath)(`/cms/products/new`),(0,o.revalidatePath)(`/cms/products`),{success:!0})}async function y(e){let t=(0,i.getServiceRoleSupabaseClient)();for(let[n,r]of e.orderedTermIds.entries()){let{error:i}=await t.from(`product_attribute_terms`).update({sort_order:n,updated_at:new Date().toISOString()}).eq(`id`,r).eq(`attribute_id`,e.attributeId);if(i)return{success:!1,error:i.message}}return(0,o.revalidatePath)(`/cms/products/attributes`),(0,o.revalidatePath)(`/cms/products/new`),(0,o.revalidatePath)(`/cms/products`),{success:!0}}async function b(e){let t=(0,i.getServiceRoleSupabaseClient)(),{error:n}=await t.from(`product_attributes`).update({name_translations:e.nameTranslations,updated_at:new Date().toISOString()}).eq(`id`,e.attributeId);if(n)return{success:!1,error:n.message};for(let n of e.termTranslations){let{error:r}=await t.from(`product_attribute_terms`).update({value_translations:n.valueTranslations,updated_at:new Date().toISOString()}).eq(`id`,n.termId).eq(`attribute_id`,e.attributeId);if(r)return{success:!1,error:r.message}}return(0,o.revalidatePath)(`/cms/products/attributes`),(0,o.revalidatePath)(`/cms/products/new`),(0,o.revalidatePath)(`/cms/products`),{success:!0}}async function x(e){let{error:t}=await(0,i.getServiceRoleSupabaseClient)().from(`product_attribute_terms`).delete().eq(`id`,e);return t?{success:!1,error:t.message}:((0,o.revalidatePath)(`/cms/products/attributes`),(0,o.revalidatePath)(`/cms/products/new`),(0,o.revalidatePath)(`/cms/products`),{success:!0})}async function S(e){let t=(0,i.getServiceRoleSupabaseClient)(),n=e.name.trim(),r=s(e.slug?.trim()||e.name);if(!n||!r)return{success:!1,error:`Category name is required.`};let{data:a,error:c}=await t.from(`categories`).insert({name:n,slug:r,description:e.description?.trim()||null,name_translations:e.nameTranslations||{},description_translations:e.descriptionTranslations||{}}).select().single();return c?{success:!1,error:c.message}:((0,o.revalidatePath)(`/cms/products/categories`),(0,o.revalidatePath)(`/cms/products/new`),(0,o.revalidatePath)(`/cms/products`),{success:!0,category:a})}async function C(e,t){let n=(0,i.getServiceRoleSupabaseClient)(),r=t.name.trim(),a=s(t.slug?.trim()||t.name);if(!r||!a)return{success:!1,error:`Category name is required.`};let{error:c}=await n.from(`categories`).update({name:r,slug:a,description:t.description?.trim()||null,name_translations:t.nameTranslations||{},description_translations:t.descriptionTranslations||{}}).eq(`id`,e);return c?{success:!1,error:c.message}:((0,o.revalidatePath)(`/cms/products/categories`),(0,o.revalidatePath)(`/cms/products/new`),(0,o.revalidatePath)(`/cms/products`),{success:!0})}async function w(e){let{error:t}=await(0,i.getServiceRoleSupabaseClient)().from(`categories`).delete().eq(`id`,e);return t?{success:!1,error:t.message}:((0,o.revalidatePath)(`/cms/products/categories`),(0,o.revalidatePath)(`/cms/products/new`),(0,o.revalidatePath)(`/cms/products`),{success:!0})}async function T(e,n){let r=(0,i.getServiceRoleSupabaseClient)();try{return await t.syncCategoriesForTranslationGroup(r,e,n),(0,o.revalidatePath)(`/cms/products`),(0,o.revalidatePath)(`/cms/products/${e}/edit`),{success:!0}}catch(e){return{success:!1,error:e.message}}}exports.bulkDeleteProductsAction=p,exports.bulkDraftProductsAction=m,exports.createCategoryAction=S,exports.createProductAction=c,exports.createProductAttributeAction=g,exports.createProductAttributeTermAction=v,exports.deleteCategoryAction=w,exports.deleteProductAction=d,exports.deleteProductAttributeAction=_,exports.deleteProductAttributeTermAction=x,exports.publishProductAction=h,exports.reorderProductAttributeTermsAction=y,exports.syncProductCategoriesAction=T,exports.updateCategoryAction=C,exports.updateProductAction=u,exports.updateProductAttributeTranslationsAction=b;