@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,136 +1,142 @@
1
- import { Freemius as I } from "@freemius/sdk";
2
- import { hydrateFreemiusEnvFromDb as h } from "./payment-config.es.js";
3
- import { resolveFreemiusCheckoutCredentials as k } from "./providers/freemius.es.js";
4
- const S = "A NextBlock license or trial already exists for this email. Activate that key from CMS Settings → Packages, or purchase a license at nextblock.dev.", g = "The trial could not be provisioned automatically. Start it from CMS Settings → Packages instead.";
5
- function E(e) {
6
- return e.toISOString().slice(0, 19).replace("T", " ");
1
+ import { hydrateFreemiusEnvFromDb as e } from "./payment-config.es.js";
2
+ import { resolveFreemiusCheckoutCredentials as t } from "./providers/freemius.es.js";
3
+ import { Freemius as n } from "@freemius/sdk";
4
+ //#region src/lib/freemius-trial-provision.ts
5
+ var r = "A NextBlock license or trial already exists for this email. Activate that key from CMS Settings → Packages, or purchase a license at nextblock.dev.", i = "The trial could not be provisioned automatically. Start it from CMS Settings → Packages instead.";
6
+ function a(e) {
7
+ return e.toISOString().slice(0, 19).replace("T", " ");
7
8
  }
8
- function v(e, n) {
9
- const i = Number.isFinite(n) && n > 0 ? Math.floor(n) : 30;
10
- return new Date(e.getTime() + i * 24 * 60 * 60 * 1e3);
9
+ function o(e, t) {
10
+ let n = Number.isFinite(t) && t > 0 ? Math.floor(t) : 30;
11
+ return new Date(e.getTime() + n * 24 * 60 * 60 * 1e3);
11
12
  }
12
- function w(e) {
13
- const n = e.filter((t) => t.id !== null && t.id !== void 0);
14
- if (n.length === 0)
15
- return null;
16
- const i = n.filter((t) => !t.is_hidden);
17
- return [...i.length > 0 ? i : n].sort((t, s) => {
18
- const l = t.licenses === null || t.licenses === void 0 ? Number.POSITIVE_INFINITY : t.licenses, u = s.licenses === null || s.licenses === void 0 ? Number.POSITIVE_INFINITY : s.licenses;
19
- return l - u;
20
- })[0];
13
+ function s(e) {
14
+ let t = e.filter((e) => e.id !== null && e.id !== void 0);
15
+ if (t.length === 0) return null;
16
+ let n = t.filter((e) => !e.is_hidden);
17
+ return [...n.length > 0 ? n : t].sort((e, t) => (e.licenses === null || e.licenses === void 0 ? Infinity : e.licenses) - (t.licenses === null || t.licenses === void 0 ? Infinity : t.licenses))[0];
21
18
  }
22
- function F(e) {
23
- return e.existingLicenses.some(
24
- (i) => i.plugin_id === null || i.plugin_id === void 0 || String(i.plugin_id).trim() === String(e.productId).trim()
25
- ) ? { ok: !1, reason: "already_licensed" } : { ok: !0 };
19
+ function c(e) {
20
+ return e.existingLicenses.some((t) => t.plugin_id === null || t.plugin_id === void 0 || String(t.plugin_id).trim() === String(e.productId).trim()) ? {
21
+ ok: !1,
22
+ reason: "already_licensed"
23
+ } : { ok: !0 };
26
24
  }
27
- function b(e) {
28
- return e.trim().toLowerCase();
25
+ function l(e) {
26
+ return e.trim().toLowerCase();
29
27
  }
30
- async function x(e, n) {
31
- await h();
32
- const i = k(e.productId);
33
- if (!i.apiKey || !i.secretKey || !i.publicKey)
34
- return {
35
- error: "The license service is not configured for this product.",
36
- ok: !1,
37
- reason: "not_configured",
38
- status: 503
39
- };
40
- const c = new I({
41
- apiKey: i.apiKey,
42
- productId: Number(e.productId),
43
- publicKey: i.publicKey,
44
- secretKey: i.secretKey
45
- }), t = b(e.email), s = c.api.__unstable_ApiClient, l = { product_id: e.productId };
46
- let u = [];
47
- try {
48
- const r = await c.api.user.retrieveByEmail(t);
49
- r?.id !== null && r?.id !== void 0 && (u = await c.api.user.retrieveLicenses(r.id));
50
- } catch (r) {
51
- return console.error("[Freemius trial] user lookup failed:", r), {
52
- error: "Freemius could not be reached to verify eligibility.",
53
- ok: !1,
54
- reason: "upstream_error",
55
- status: 502
56
- };
57
- }
58
- if (!F({ existingLicenses: u, productId: e.productId }).ok)
59
- return { error: S, ok: !1, reason: "already_licensed", status: 409 };
60
- let d = null;
61
- try {
62
- const { data: r, error: a } = await s.GET("/products/{product_id}/plans/{plan_id}/pricing.json", {
63
- params: { path: { ...l, plan_id: e.planId } }
64
- });
65
- if (a)
66
- throw new Error(JSON.stringify(a));
67
- const o = w(r?.pricing ?? []);
68
- d = o?.id !== null && o?.id !== void 0 ? String(o.id) : null;
69
- } catch (r) {
70
- return console.error("[Freemius trial] pricing lookup failed:", r), {
71
- error: "Freemius could not be reached to resolve the plan pricing.",
72
- ok: !1,
73
- reason: "upstream_error",
74
- status: 502
75
- };
76
- }
77
- if (!d)
78
- return {
79
- error: g,
80
- ok: !1,
81
- reason: "no_pricing",
82
- status: 502
83
- };
84
- const y = n?.now ?? /* @__PURE__ */ new Date(), m = E(v(y, e.trialDays));
85
- let p = null, f = null;
86
- try {
87
- const { data: r, error: a } = await s.POST(
88
- "/products/{product_id}/plans/{plan_id}/pricing/{pricing_id}/licenses.json",
89
- {
90
- body: { expires_at: m, is_block_features: !0, send_email: !1 },
91
- params: { path: { ...l, plan_id: e.planId, pricing_id: d } }
92
- }
93
- );
94
- if (a)
95
- throw new Error(JSON.stringify(a));
96
- const o = r?.license;
97
- p = o?.secret_key?.trim() || null, f = o?.id !== null && o?.id !== void 0 ? String(o.id) : null;
98
- } catch (r) {
99
- return console.error("[Freemius trial] license creation failed:", r), {
100
- error: "Freemius could not create the trial license.",
101
- ok: !1,
102
- reason: "upstream_error",
103
- status: 502
104
- };
105
- }
106
- if (!p)
107
- return { error: g, ok: !1, reason: "no_key", status: 502 };
108
- let _ = !1;
109
- try {
110
- const { error: r } = await s.PUT("/products/{product_id}/licenses.json", {
111
- body: { email: t, license_key: p, name: e.name.trim() },
112
- params: { path: l }
113
- });
114
- _ = !r, r && console.warn("[Freemius trial] license assignment refused:", JSON.stringify(r));
115
- } catch (r) {
116
- console.warn("[Freemius trial] license assignment failed:", r);
117
- }
118
- return {
119
- assigned: _,
120
- expiresAt: m,
121
- licenseId: f,
122
- licenseKey: p,
123
- ok: !0,
124
- planId: e.planId,
125
- pricingId: d
126
- };
28
+ async function u(u, d) {
29
+ await e();
30
+ let f = t(u.productId);
31
+ if (!f.apiKey || !f.secretKey || !f.publicKey) return {
32
+ error: "The license service is not configured for this product.",
33
+ ok: !1,
34
+ reason: "not_configured",
35
+ status: 503
36
+ };
37
+ let p = new n({
38
+ apiKey: f.apiKey,
39
+ productId: Number(u.productId),
40
+ publicKey: f.publicKey,
41
+ secretKey: f.secretKey
42
+ }), m = l(u.email), h = p.api.__unstable_ApiClient, g = { product_id: u.productId }, _ = [];
43
+ try {
44
+ let e = await p.api.user.retrieveByEmail(m);
45
+ e?.id !== null && e?.id !== void 0 && (_ = await p.api.user.retrieveLicenses(e.id));
46
+ } catch (e) {
47
+ return console.error("[Freemius trial] user lookup failed:", e), {
48
+ error: "Freemius could not be reached to verify eligibility.",
49
+ ok: !1,
50
+ reason: "upstream_error",
51
+ status: 502
52
+ };
53
+ }
54
+ if (!c({
55
+ existingLicenses: _,
56
+ productId: u.productId
57
+ }).ok) return {
58
+ error: r,
59
+ ok: !1,
60
+ reason: "already_licensed",
61
+ status: 409
62
+ };
63
+ let v = null;
64
+ try {
65
+ let { data: e, error: t } = await h.GET("/products/{product_id}/plans/{plan_id}/pricing.json", { params: { path: {
66
+ ...g,
67
+ plan_id: u.planId
68
+ } } });
69
+ if (t) throw Error(JSON.stringify(t));
70
+ let n = s(e?.pricing ?? []);
71
+ v = n?.id !== null && n?.id !== void 0 ? String(n.id) : null;
72
+ } catch (e) {
73
+ return console.error("[Freemius trial] pricing lookup failed:", e), {
74
+ error: "Freemius could not be reached to resolve the plan pricing.",
75
+ ok: !1,
76
+ reason: "upstream_error",
77
+ status: 502
78
+ };
79
+ }
80
+ if (!v) return {
81
+ error: i,
82
+ ok: !1,
83
+ reason: "no_pricing",
84
+ status: 502
85
+ };
86
+ let y = a(o(d?.now ?? /* @__PURE__ */ new Date(), u.trialDays)), b = null, x = null;
87
+ try {
88
+ let { data: e, error: t } = await h.POST("/products/{product_id}/plans/{plan_id}/pricing/{pricing_id}/licenses.json", {
89
+ body: {
90
+ expires_at: y,
91
+ is_block_features: !0,
92
+ send_email: !1
93
+ },
94
+ params: { path: {
95
+ ...g,
96
+ plan_id: u.planId,
97
+ pricing_id: v
98
+ } }
99
+ });
100
+ if (t) throw Error(JSON.stringify(t));
101
+ let n = e?.license;
102
+ b = n?.secret_key?.trim() || null, x = n?.id !== null && n?.id !== void 0 ? String(n.id) : null;
103
+ } catch (e) {
104
+ return console.error("[Freemius trial] license creation failed:", e), {
105
+ error: "Freemius could not create the trial license.",
106
+ ok: !1,
107
+ reason: "upstream_error",
108
+ status: 502
109
+ };
110
+ }
111
+ if (!b) return {
112
+ error: i,
113
+ ok: !1,
114
+ reason: "no_key",
115
+ status: 502
116
+ };
117
+ let S = !1;
118
+ try {
119
+ let { error: e } = await h.PUT("/products/{product_id}/licenses.json", {
120
+ body: {
121
+ email: m,
122
+ license_key: b,
123
+ name: u.name.trim()
124
+ },
125
+ params: { path: g }
126
+ });
127
+ S = !e, e && console.warn("[Freemius trial] license assignment refused:", JSON.stringify(e));
128
+ } catch (e) {
129
+ console.warn("[Freemius trial] license assignment failed:", e);
130
+ }
131
+ return {
132
+ assigned: S,
133
+ expiresAt: y,
134
+ licenseId: x,
135
+ licenseKey: b,
136
+ ok: !0,
137
+ planId: u.planId,
138
+ pricingId: v
139
+ };
127
140
  }
128
- export {
129
- S as FREEMIUS_TRIAL_ALREADY_USED_MESSAGE,
130
- g as FREEMIUS_TRIAL_PROVISION_FAILED_MESSAGE,
131
- v as computeTrialExpiry,
132
- F as evaluateTrialEligibility,
133
- E as formatFreemiusTimestamp,
134
- w as pickTrialPricing,
135
- x as provisionFreemiusTrialLicense
136
- };
141
+ //#endregion
142
+ export { r as FREEMIUS_TRIAL_ALREADY_USED_MESSAGE, i as FREEMIUS_TRIAL_PROVISION_FAILED_MESSAGE, o as computeTrialExpiry, c as evaluateTrialEligibility, a as formatFreemiusTimestamp, s as pickTrialPricing, u as provisionFreemiusTrialLicense };
@@ -0,0 +1 @@
1
+ var e=`ecommerce_inventory_settings`,t={trackQuantities:!0,enableTaxes:!1,taxCalculationMode:`manual`};function n(e,t=!0){if(typeof e==`boolean`)return e;if(typeof e==`string`){let t=e.trim().toLowerCase();if([`true`,`1`,`yes`,`on`].includes(t))return!0;if([`false`,`0`,`no`,`off`].includes(t))return!1}return t}function r(e,n=t.taxCalculationMode){return e===`automatic`?`automatic`:e===`manual`?`manual`:n}function i(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let i=e;return{trackQuantities:n(i.trackQuantities??i.track_quantities,t.trackQuantities),enableTaxes:n(i.enableTaxes??i.enable_taxes,t.enableTaxes),taxCalculationMode:r(i.taxCalculationMode??i.tax_calculation_mode,t.taxCalculationMode)}}return{trackQuantities:n(e,t.trackQuantities),enableTaxes:t.enableTaxes,taxCalculationMode:t.taxCalculationMode}}async function a(n){let{data:r,error:a}=await n.from(`site_settings`).select(`value`).eq(`key`,e).maybeSingle();return a||!r?t:i(r.value)}async function o(t,n){return t.from(`site_settings`).upsert({key:e,value:{track_quantities:n.trackQuantities,enable_taxes:n.enableTaxes,tax_calculation_mode:n.taxCalculationMode}})}function s(e){return{error:`${e} is no longer available.`,errorKey:`ecommerce.inventory_item_unavailable`,errorParams:{item:e},errorStatus:409}}function c(e,t){return{error:`Only ${t} units remain for ${e}.`,errorKey:`ecommerce.inventory_insufficient`,errorParams:{item:e,count:t},errorStatus:409}}exports.DEFAULT_ECOMMERCE_INVENTORY_SETTINGS=t,exports.ECOMMERCE_INVENTORY_SETTINGS_KEY=e,exports.createInventoryInsufficientError=c,exports.createInventoryUnavailableError=s,exports.getEcommerceInventorySettings=a,exports.normalizeEcommerceInventorySettings=i,exports.upsertEcommerceInventorySettings=o;
@@ -1,86 +1,78 @@
1
- const o = "ecommerce_inventory_settings", a = {
2
- trackQuantities: !0,
3
- enableTaxes: !1,
4
- taxCalculationMode: "manual"
1
+ //#region src/lib/inventory-settings.ts
2
+ var e = "ecommerce_inventory_settings", t = {
3
+ trackQuantities: !0,
4
+ enableTaxes: !1,
5
+ taxCalculationMode: "manual"
5
6
  };
6
7
  function n(e, t = !0) {
7
- if (typeof e == "boolean")
8
- return e;
9
- if (typeof e == "string") {
10
- const r = e.trim().toLowerCase();
11
- if (["true", "1", "yes", "on"].includes(r))
12
- return !0;
13
- if (["false", "0", "no", "off"].includes(r))
14
- return !1;
15
- }
16
- return t;
8
+ if (typeof e == "boolean") return e;
9
+ if (typeof e == "string") {
10
+ let t = e.trim().toLowerCase();
11
+ if ([
12
+ "true",
13
+ "1",
14
+ "yes",
15
+ "on"
16
+ ].includes(t)) return !0;
17
+ if ([
18
+ "false",
19
+ "0",
20
+ "no",
21
+ "off"
22
+ ].includes(t)) return !1;
23
+ }
24
+ return t;
17
25
  }
18
- function i(e, t = a.taxCalculationMode) {
19
- return e === "automatic" ? "automatic" : e === "manual" ? "manual" : t;
26
+ function r(e, n = t.taxCalculationMode) {
27
+ return e === "automatic" ? "automatic" : e === "manual" ? "manual" : n;
20
28
  }
21
- function c(e) {
22
- if (e && typeof e == "object" && !Array.isArray(e)) {
23
- const t = e;
24
- return {
25
- trackQuantities: n(
26
- t.trackQuantities ?? t.track_quantities,
27
- a.trackQuantities
28
- ),
29
- enableTaxes: n(
30
- t.enableTaxes ?? t.enable_taxes,
31
- a.enableTaxes
32
- ),
33
- taxCalculationMode: i(
34
- t.taxCalculationMode ?? t.tax_calculation_mode,
35
- a.taxCalculationMode
36
- )
37
- };
38
- }
39
- return {
40
- trackQuantities: n(
41
- e,
42
- a.trackQuantities
43
- ),
44
- enableTaxes: a.enableTaxes,
45
- taxCalculationMode: a.taxCalculationMode
46
- };
29
+ function i(e) {
30
+ if (e && typeof e == "object" && !Array.isArray(e)) {
31
+ let i = e;
32
+ return {
33
+ trackQuantities: n(i.trackQuantities ?? i.track_quantities, t.trackQuantities),
34
+ enableTaxes: n(i.enableTaxes ?? i.enable_taxes, t.enableTaxes),
35
+ taxCalculationMode: r(i.taxCalculationMode ?? i.tax_calculation_mode, t.taxCalculationMode)
36
+ };
37
+ }
38
+ return {
39
+ trackQuantities: n(e, t.trackQuantities),
40
+ enableTaxes: t.enableTaxes,
41
+ taxCalculationMode: t.taxCalculationMode
42
+ };
47
43
  }
48
- async function u(e) {
49
- const { data: t, error: r } = await e.from("site_settings").select("value").eq("key", o).maybeSingle();
50
- return r || !t ? a : c(t.value);
44
+ async function a(n) {
45
+ let { data: r, error: a } = await n.from("site_settings").select("value").eq("key", e).maybeSingle();
46
+ return a || !r ? t : i(r.value);
51
47
  }
52
- async function s(e, t) {
53
- return e.from("site_settings").upsert({
54
- key: o,
55
- value: {
56
- track_quantities: t.trackQuantities,
57
- enable_taxes: t.enableTaxes,
58
- tax_calculation_mode: t.taxCalculationMode
59
- }
60
- });
48
+ async function o(t, n) {
49
+ return t.from("site_settings").upsert({
50
+ key: e,
51
+ value: {
52
+ track_quantities: n.trackQuantities,
53
+ enable_taxes: n.enableTaxes,
54
+ tax_calculation_mode: n.taxCalculationMode
55
+ }
56
+ });
61
57
  }
62
- function l(e) {
63
- return {
64
- error: `${e} is no longer available.`,
65
- errorKey: "ecommerce.inventory_item_unavailable",
66
- errorParams: { item: e },
67
- errorStatus: 409
68
- };
58
+ function s(e) {
59
+ return {
60
+ error: `${e} is no longer available.`,
61
+ errorKey: "ecommerce.inventory_item_unavailable",
62
+ errorParams: { item: e },
63
+ errorStatus: 409
64
+ };
69
65
  }
70
- function f(e, t) {
71
- return {
72
- error: `Only ${t} units remain for ${e}.`,
73
- errorKey: "ecommerce.inventory_insufficient",
74
- errorParams: { item: e, count: t },
75
- errorStatus: 409
76
- };
66
+ function c(e, t) {
67
+ return {
68
+ error: `Only ${t} units remain for ${e}.`,
69
+ errorKey: "ecommerce.inventory_insufficient",
70
+ errorParams: {
71
+ item: e,
72
+ count: t
73
+ },
74
+ errorStatus: 409
75
+ };
77
76
  }
78
- export {
79
- a as DEFAULT_ECOMMERCE_INVENTORY_SETTINGS,
80
- o as ECOMMERCE_INVENTORY_SETTINGS_KEY,
81
- f as createInventoryInsufficientError,
82
- l as createInventoryUnavailableError,
83
- u as getEcommerceInventorySettings,
84
- c as normalizeEcommerceInventorySettings,
85
- s as upsertEcommerceInventorySettings
86
- };
77
+ //#endregion
78
+ export { t as DEFAULT_ECOMMERCE_INVENTORY_SETTINGS, e as ECOMMERCE_INVENTORY_SETTINGS_KEY, c as createInventoryInsufficientError, s as createInventoryUnavailableError, a as getEcommerceInventorySettings, i as normalizeEcommerceInventorySettings, o as upsertEcommerceInventorySettings };
@@ -0,0 +1,33 @@
1
+ const e=require("./customer.cjs"),t=require("./invoice.cjs"),n=require("./order-tax-details.cjs");let r=require("@nextblock-cms/db/server");function i(e){return e?e.startsWith(`http`)||e.startsWith(`/`)?e:process.env.NEXT_PUBLIC_R2_BASE_URL?`${process.env.NEXT_PUBLIC_R2_BASE_URL}/${e}`:process.env.NEXT_PUBLIC_SUPABASE_URL?`${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/media/${e}`:e:null}function a(e){return e??(0,r.getServiceRoleSupabaseClient)()}function o(e){if(!e)return null;let t=e.media?.object_key??e.media?.file_path??null;return{id:e.id,name:e.name??null,url:i(t),width:e.media?.width??null,height:e.media?.height??null}}var s=`active_logo_id`,c=`
2
+ id,
3
+ name,
4
+ media:media_id (
5
+ object_key,
6
+ file_path,
7
+ width,
8
+ height
9
+ )
10
+ `;async function l(e){let{data:t}=await e.from(`site_settings`).select(`value`).eq(`key`,s).maybeSingle(),n=t?.value,r=typeof n==`string`&&n.length>0?n:null;if(r){let{data:t}=await e.from(`logos`).select(c).eq(`id`,r).maybeSingle();if(t)return t}let{data:i}=await e.from(`logos`).select(c).order(`created_at`,{ascending:!1}).limit(1).maybeSingle();return i??null}async function u(e){let n=a(e),[r,i]=await Promise.all([n.from(`site_settings`).select(`value`).eq(`key`,t.INVOICE_SETTINGS_KEY).maybeSingle(),l(n)]);return{settings:t.normalizeInvoiceSettings(r.data?.value??t.DEFAULT_INVOICE_SETTINGS),logo:o(i)}}async function d(e){let{data:t,error:n}=await a(e.client).rpc(`assign_order_invoice_metadata`,{p_order_id:e.orderId,p_paid_at:e.paidAt??null}).single();if(n)throw Error(n.message);return{invoiceNumber:t?.invoice_number??null,paidAt:t?.paid_at??null}}async function f(t,r){let i=a(r),{data:o,error:s}=await i.from(`orders`).select(`
11
+ id,
12
+ invoice_number,
13
+ paid_at,
14
+ created_at,
15
+ currency,
16
+ status,
17
+ provider,
18
+ subtotal,
19
+ shipping_total,
20
+ discount_total,
21
+ coupon_code,
22
+ tax_total,
23
+ total,
24
+ customer_details,
25
+ tax_details,
26
+ order_items (
27
+ id,
28
+ product_id,
29
+ variant_id,
30
+ quantity,
31
+ price_at_purchase
32
+ )
33
+ `).eq(`id`,t).single();if(s||!o)throw Error(s?.message||`Order not found`);let c=(o.order_items||[]).map(e=>e.product_id).filter(Boolean),l=(o.order_items||[]).map(e=>e.variant_id).filter(Boolean),[u,d]=await Promise.all([c.length?i.from(`products`).select(`id, title, sku`).in(`id`,c):Promise.resolve({data:[],error:null}),l.length?i.from(`product_variants`).select(`id, sku`).in(`id`,l):Promise.resolve({data:[],error:null})]),f=new Map((u.data||[]).map(e=>[e.id,e])),p=new Map((d.data||[]).map(e=>[e.id,e])),m=(o.order_items||[]).map(e=>{let t=e.product_id?f.get(e.product_id):null,n=e.variant_id?p.get(e.variant_id):null,r=t?.title||`Product`,i=n?.sku?`SKU: ${n.sku}`:t?.sku?`SKU: ${t.sku}`:null;return{id:e.id,product_id:e.product_id??null,variant_id:e.variant_id??null,title:r,description:i,quantity:e.quantity,unit_amount:e.price_at_purchase,total_amount:e.price_at_purchase*e.quantity,sku:n?.sku??t?.sku??null}});return{id:o.id,invoice_number:o.invoice_number??null,paid_at:o.paid_at??null,created_at:o.created_at??null,currency:o.currency||`usd`,status:o.status,provider:o.provider??null,subtotal:typeof o.subtotal==`number`?o.subtotal:m.reduce((e,t)=>e+t.total_amount,0),shipping_total:typeof o.shipping_total==`number`?o.shipping_total:0,discount_total:typeof o.discount_total==`number`?o.discount_total:0,coupon_code:o.coupon_code??null,tax_total:typeof o.tax_total==`number`?o.tax_total:0,total:o.total,customer_details:e.normalizeOrderCustomerDetails(o.customer_details??{}),tax_details:n.normalizeOrderTaxDetails(o.tax_details),items:m}}async function p(e,t){let n=a(t),[r,i]=await Promise.all([f(e,n),u(n)]);return{order:r,settings:i.settings,logo:i.logo}}exports.assignInvoiceMetadata=d,exports.getInvoiceBrandingData=u,exports.getInvoiceOrder=f,exports.getInvoicePresentationData=p;