@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,116 +1,87 @@
1
- import { createClient as u } from "@nextblock-cms/db/server";
2
- import { normalizeCustomerAddress as w } from "./customer.es.js";
3
- function l(e) {
4
- const n = e?.trim();
5
- return n || null;
1
+ import { normalizeCustomerAddress as e } from "./customer.es.js";
2
+ import { createClient as t } from "@nextblock-cms/db/server";
3
+ //#region src/lib/customer-addresses.ts
4
+ function n(e) {
5
+ return e?.trim() || null;
6
6
  }
7
- function p(e) {
8
- return e ? w({
9
- company_name: e.company_name,
10
- recipient_name: e.recipient_name,
11
- line1: e.line1,
12
- line2: e.line2,
13
- city: e.city,
14
- state: e.state,
15
- postal_code: e.postal_code,
16
- country_code: e.country_code
17
- }) : null;
7
+ function r(t) {
8
+ return t ? e({
9
+ company_name: t.company_name,
10
+ recipient_name: t.recipient_name,
11
+ line1: t.line1,
12
+ line2: t.line2,
13
+ city: t.city,
14
+ state: t.state,
15
+ postal_code: t.postal_code,
16
+ country_code: t.country_code
17
+ }) : null;
18
18
  }
19
- function _(e, n) {
20
- return e?.find(
21
- (t) => t.address_type === n && t.is_default
22
- ) ?? e?.find((t) => t.address_type === n) ?? null;
19
+ function i(e, t) {
20
+ return e?.find((e) => e.address_type === t && e.is_default) ?? e?.find((e) => e.address_type === t) ?? null;
23
21
  }
24
- async function g(e, n, t, i) {
25
- const r = w(i), { data: o, error: a } = await e.from("user_addresses").select("*").eq("user_id", n).eq("address_type", t).order("is_default", { ascending: !1 }).order("updated_at", { ascending: !1 });
26
- if (a)
27
- throw new Error(a.message);
28
- const d = o?.[0] ?? null, c = (o ?? []).slice(1).map((s) => s.id);
29
- if (!r) {
30
- if (o?.length) {
31
- const s = o.map((h) => h.id), { error: m } = await e.from("user_addresses").delete().in("id", s);
32
- if (m)
33
- throw new Error(m.message);
34
- }
35
- return;
36
- }
37
- const f = {
38
- user_id: n,
39
- address_type: t,
40
- is_default: !0,
41
- company_name: r.company_name ?? null,
42
- recipient_name: r.recipient_name ?? null,
43
- line1: r.line1 ?? null,
44
- line2: r.line2 ?? null,
45
- city: r.city ?? null,
46
- state: r.state ?? null,
47
- postal_code: r.postal_code ?? null,
48
- country_code: r.country_code ?? null,
49
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
50
- };
51
- if (d) {
52
- const { error: s } = await e.from("user_addresses").update(f).eq("id", d.id);
53
- if (s)
54
- throw new Error(s.message);
55
- } else {
56
- const { error: s } = await e.from("user_addresses").insert(f);
57
- if (s)
58
- throw new Error(s.message);
59
- }
60
- if (c.length) {
61
- const { error: s } = await e.from("user_addresses").delete().in("id", c);
62
- if (s)
63
- throw new Error(s.message);
64
- }
22
+ async function a(t, n, r, i) {
23
+ let a = e(i), { data: o, error: s } = await t.from("user_addresses").select("*").eq("user_id", n).eq("address_type", r).order("is_default", { ascending: !1 }).order("updated_at", { ascending: !1 });
24
+ if (s) throw Error(s.message);
25
+ let c = o?.[0] ?? null, l = (o ?? []).slice(1).map((e) => e.id);
26
+ if (!a) {
27
+ if (o?.length) {
28
+ let e = o.map((e) => e.id), { error: n } = await t.from("user_addresses").delete().in("id", e);
29
+ if (n) throw Error(n.message);
30
+ }
31
+ return;
32
+ }
33
+ let u = {
34
+ user_id: n,
35
+ address_type: r,
36
+ is_default: !0,
37
+ company_name: a.company_name ?? null,
38
+ recipient_name: a.recipient_name ?? null,
39
+ line1: a.line1 ?? null,
40
+ line2: a.line2 ?? null,
41
+ city: a.city ?? null,
42
+ state: a.state ?? null,
43
+ postal_code: a.postal_code ?? null,
44
+ country_code: a.country_code ?? null,
45
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
46
+ };
47
+ if (c) {
48
+ let { error: e } = await t.from("user_addresses").update(u).eq("id", c.id);
49
+ if (e) throw Error(e.message);
50
+ } else {
51
+ let { error: e } = await t.from("user_addresses").insert(u);
52
+ if (e) throw Error(e.message);
53
+ }
54
+ if (l.length) {
55
+ let { error: e } = await t.from("user_addresses").delete().in("id", l);
56
+ if (e) throw Error(e.message);
57
+ }
65
58
  }
66
- async function A(e, n) {
67
- const t = n ?? u(), { data: i, error: r } = await t.from("user_addresses").select("*").eq("user_id", e).in("address_type", ["billing", "shipping"]).order("is_default", { ascending: !1 }).order("updated_at", { ascending: !1 });
68
- if (r)
69
- throw new Error(r.message);
70
- const o = p(_(i ?? [], "billing")), a = p(
71
- _(i ?? [], "shipping")
72
- );
73
- return {
74
- billingAddress: o,
75
- shippingAddress: a
76
- };
59
+ async function o(e, n) {
60
+ let { data: a, error: o } = await (n ?? t()).from("user_addresses").select("*").eq("user_id", e).in("address_type", ["billing", "shipping"]).order("is_default", { ascending: !1 }).order("updated_at", { ascending: !1 });
61
+ if (o) throw Error(o.message);
62
+ return {
63
+ billingAddress: r(i(a ?? [], "billing")),
64
+ shippingAddress: r(i(a ?? [], "shipping"))
65
+ };
77
66
  }
78
- async function D(e) {
79
- const n = e.client ?? u();
80
- await g(
81
- n,
82
- e.userId,
83
- "billing",
84
- e.billingAddress ?? null
85
- ), await g(
86
- n,
87
- e.userId,
88
- "shipping",
89
- e.shippingAddress ?? null
90
- );
67
+ async function s(e) {
68
+ let n = e.client ?? t();
69
+ await a(n, e.userId, "billing", e.billingAddress ?? null), await a(n, e.userId, "shipping", e.shippingAddress ?? null);
91
70
  }
92
- async function q(e) {
93
- const n = e.client ?? u(), t = l(e.fullName), i = l(e.phone);
94
- if (!t && !i)
95
- return;
96
- const { data: r, error: o } = await n.from("profiles").select("full_name, phone").eq("id", e.userId).maybeSingle();
97
- if (o)
98
- throw new Error(o.message);
99
- if (!r)
100
- return;
101
- const a = l(r.full_name) || t, d = l(r.phone) || i;
102
- if (l(r.full_name) === a && l(r.phone) === d)
103
- return;
104
- const { error: c } = await n.from("profiles").update({
105
- full_name: a,
106
- phone: d,
107
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
108
- }).eq("id", e.userId);
109
- if (c)
110
- throw new Error(c.message);
71
+ async function c(e) {
72
+ let r = e.client ?? t(), i = n(e.fullName), a = n(e.phone);
73
+ if (!i && !a) return;
74
+ let { data: o, error: s } = await r.from("profiles").select("full_name, phone").eq("id", e.userId).maybeSingle();
75
+ if (s) throw Error(s.message);
76
+ if (!o) return;
77
+ let c = n(o.full_name) || i, l = n(o.phone) || a;
78
+ if (n(o.full_name) === c && n(o.phone) === l) return;
79
+ let { error: u } = await r.from("profiles").update({
80
+ full_name: c,
81
+ phone: l,
82
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
83
+ }).eq("id", e.userId);
84
+ if (u) throw Error(u.message);
111
85
  }
112
- export {
113
- q as fillMissingUserProfileCheckoutDetails,
114
- A as getDefaultUserAddresses,
115
- D as upsertDefaultUserAddresses
116
- };
86
+ //#endregion
87
+ export { c as fillMissingUserProfileCheckoutDetails, o as getDefaultUserAddresses, s as upsertDefaultUserAddresses };
@@ -0,0 +1 @@
1
+ const e=require("./invoice-server.cjs"),t=require("./freemius-license.cjs");let n=require("@nextblock-cms/db/server");var r=[`pending`];function i(e){return e??(0,n.createClient)()}async function a(e){let{data:{user:t},error:n}=await e.auth.getUser();if(n||!t)throw Error(`Unauthorized`);return t}async function o(e){let t=i(e),n=await a(t),{data:o,error:s}=await t.from(`orders`).select(`id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total`).eq(`user_id`,n.id).not(`status`,`in`,`(${r.join(`,`)})`).order(`created_at`,{ascending:!1});if(s)throw Error(s.message);return o??[]}async function s(e,t){let n=i(t),o=await a(n),{data:s,error:c}=await n.from(`orders`).select(`id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total`).eq(`id`,e).eq(`user_id`,o.id).not(`status`,`in`,`(${r.join(`,`)})`).maybeSingle();if(c)throw Error(c.message);return s??null}async function c(n,r){let a=i(r),o=await s(n,a);return o?{order:o,invoice:o.invoice_number?await e.getInvoicePresentationData(n,a):null,license:o.provider===`freemius`?await t.getFreemiusOrderLicense({orderId:n,client:a}):null}:null}exports.getCurrentCustomerOrder=s,exports.getCurrentCustomerOrderInvoice=c,exports.getCurrentCustomerOrders=o;
@@ -1,48 +1,36 @@
1
- import { createClient as c } from "@nextblock-cms/db/server";
2
- import { getInvoicePresentationData as d } from "./invoice-server.es.js";
3
- import { getFreemiusOrderLicense as l } from "./freemius-license.es.js";
4
- const s = ["pending"];
5
- function o(t) {
6
- return t ?? c();
1
+ import { getInvoicePresentationData as e } from "./invoice-server.es.js";
2
+ import { getFreemiusOrderLicense as t } from "./freemius-license.es.js";
3
+ import { createClient as n } from "@nextblock-cms/db/server";
4
+ //#region src/lib/customer-orders.ts
5
+ var r = ["pending"];
6
+ function i(e) {
7
+ return e ?? n();
7
8
  }
8
- async function u(t) {
9
- const {
10
- data: { user: r },
11
- error: e
12
- } = await t.auth.getUser();
13
- if (e || !r)
14
- throw new Error("Unauthorized");
15
- return r;
9
+ async function a(e) {
10
+ let { data: { user: t }, error: n } = await e.auth.getUser();
11
+ if (n || !t) throw Error("Unauthorized");
12
+ return t;
16
13
  }
17
- async function g(t) {
18
- const r = o(t), e = await u(r), { data: n, error: a } = await r.from("orders").select(
19
- "id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total"
20
- ).eq("user_id", e.id).not("status", "in", `(${s.join(",")})`).order("created_at", { ascending: !1 });
21
- if (a)
22
- throw new Error(a.message);
23
- return n ?? [];
14
+ async function o(e) {
15
+ let t = i(e), n = await a(t), { data: o, error: s } = await t.from("orders").select("id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total").eq("user_id", n.id).not("status", "in", `(${r.join(",")})`).order("created_at", { ascending: !1 });
16
+ if (s) throw Error(s.message);
17
+ return o ?? [];
24
18
  }
25
- async function m(t, r) {
26
- const e = o(r), n = await u(e), { data: a, error: i } = await e.from("orders").select(
27
- "id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total"
28
- ).eq("id", t).eq("user_id", n.id).not("status", "in", `(${s.join(",")})`).maybeSingle();
29
- if (i)
30
- throw new Error(i.message);
31
- return a ?? null;
19
+ async function s(e, t) {
20
+ let n = i(t), o = await a(n), { data: s, error: c } = await n.from("orders").select("id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total").eq("id", e).eq("user_id", o.id).not("status", "in", `(${r.join(",")})`).maybeSingle();
21
+ if (c) throw Error(c.message);
22
+ return s ?? null;
32
23
  }
33
- async function w(t, r) {
34
- const e = o(r), n = await m(t, e);
35
- if (!n)
36
- return null;
37
- const a = n.invoice_number ? await d(t, e) : null, i = n.provider === "freemius" ? await l({ orderId: t, client: e }) : null;
38
- return {
39
- order: n,
40
- invoice: a,
41
- license: i
42
- };
24
+ async function c(n, r) {
25
+ let a = i(r), o = await s(n, a);
26
+ return o ? {
27
+ order: o,
28
+ invoice: o.invoice_number ? await e(n, a) : null,
29
+ license: o.provider === "freemius" ? await t({
30
+ orderId: n,
31
+ client: a
32
+ }) : null
33
+ } : null;
43
34
  }
44
- export {
45
- m as getCurrentCustomerOrder,
46
- w as getCurrentCustomerOrderInvoice,
47
- g as getCurrentCustomerOrders
48
- };
35
+ //#endregion
36
+ export { s as getCurrentCustomerOrder, c as getCurrentCustomerOrderInvoice, o as getCurrentCustomerOrders };
@@ -0,0 +1 @@
1
+ const e=require("./countries.cjs"),t=require("./states.cjs");var n=()=>({company_name:``,recipient_name:``,line1:``,line2:``,city:``,state:``,postal_code:``,country_code:`CA`});function r(e){return e?.trim()||null}function i(n){if(!n)return null;let i={company_name:r(n.company_name),recipient_name:r(n.recipient_name),line1:r(n.line1),line2:r(n.line2),city:r(n.city),postal_code:r(n.postal_code),country_code:e.normalizeCountryCode(n.country_code)};return i.state=t.normalizeSubdivisionCode(i.country_code,r(n.state)),Object.values(i).some(Boolean)?i:null}function a(e){let n=i(e);return n?!!(n.recipient_name&&n.line1&&n.city&&n.postal_code&&n.country_code&&(!t.countryUsesStructuredStates(n.country_code)||n.state)):!1}function o(e){let t=i(e.billing),n=i(e.shipping),a=r(e.email)?.toLowerCase()??null,o=r(e.phone);return{email:a,name:r(e.name)??t?.recipient_name??n?.recipient_name??null,phone:o,billing:t,shipping:n}}function s(e,t){let n=i(e),r=i(t);return JSON.stringify(n)===JSON.stringify(r)}exports.addressesMatch=s,exports.emptyCustomerAddress=n,exports.isCustomerAddressComplete=a,exports.normalizeCustomerAddress=i,exports.normalizeOrderCustomerDetails=o;
@@ -1,58 +1,49 @@
1
- import { normalizeCountryCode as a } from "./countries.es.js";
2
- import { countryUsesStructuredStates as m, normalizeSubdivisionCode as s } from "./states.es.js";
3
- const y = () => ({
4
- company_name: "",
5
- recipient_name: "",
6
- line1: "",
7
- line2: "",
8
- city: "",
9
- state: "",
10
- postal_code: "",
11
- country_code: "CA"
1
+ import { normalizeCountryCode as e } from "./countries.es.js";
2
+ import { countryUsesStructuredStates as t, normalizeSubdivisionCode as n } from "./states.es.js";
3
+ //#region src/lib/customer.ts
4
+ var r = () => ({
5
+ company_name: "",
6
+ recipient_name: "",
7
+ line1: "",
8
+ line2: "",
9
+ city: "",
10
+ state: "",
11
+ postal_code: "",
12
+ country_code: "CA"
12
13
  });
13
- function o(n) {
14
- const e = n?.trim();
15
- return e || null;
14
+ function i(e) {
15
+ return e?.trim() || null;
16
16
  }
17
- function i(n) {
18
- if (!n)
19
- return null;
20
- const e = {
21
- company_name: o(n.company_name),
22
- recipient_name: o(n.recipient_name),
23
- line1: o(n.line1),
24
- line2: o(n.line2),
25
- city: o(n.city),
26
- postal_code: o(n.postal_code),
27
- country_code: a(n.country_code)
28
- };
29
- return e.state = s(
30
- e.country_code,
31
- o(n.state)
32
- ), Object.values(e).some(Boolean) ? e : null;
17
+ function a(t) {
18
+ if (!t) return null;
19
+ let r = {
20
+ company_name: i(t.company_name),
21
+ recipient_name: i(t.recipient_name),
22
+ line1: i(t.line1),
23
+ line2: i(t.line2),
24
+ city: i(t.city),
25
+ postal_code: i(t.postal_code),
26
+ country_code: e(t.country_code)
27
+ };
28
+ return r.state = n(r.country_code, i(t.state)), Object.values(r).some(Boolean) ? r : null;
33
29
  }
34
- function _(n) {
35
- const e = i(n);
36
- return e ? !!(e.recipient_name && e.line1 && e.city && e.postal_code && e.country_code && (!m(e.country_code) || e.state)) : !1;
30
+ function o(e) {
31
+ let n = a(e);
32
+ return n ? !!(n.recipient_name && n.line1 && n.city && n.postal_code && n.country_code && (!t(n.country_code) || n.state)) : !1;
37
33
  }
38
- function d(n) {
39
- const e = i(n.billing), t = i(n.shipping), c = o(n.email)?.toLowerCase() ?? null, r = o(n.phone), l = o(n.name) ?? e?.recipient_name ?? t?.recipient_name ?? null;
40
- return {
41
- email: c,
42
- name: l,
43
- phone: r,
44
- billing: e,
45
- shipping: t
46
- };
34
+ function s(e) {
35
+ let t = a(e.billing), n = a(e.shipping), r = i(e.email)?.toLowerCase() ?? null, o = i(e.phone);
36
+ return {
37
+ email: r,
38
+ name: i(e.name) ?? t?.recipient_name ?? n?.recipient_name ?? null,
39
+ phone: o,
40
+ billing: t,
41
+ shipping: n
42
+ };
47
43
  }
48
- function f(n, e) {
49
- const t = i(n), c = i(e);
50
- return JSON.stringify(t) === JSON.stringify(c);
44
+ function c(e, t) {
45
+ let n = a(e), r = a(t);
46
+ return JSON.stringify(n) === JSON.stringify(r);
51
47
  }
52
- export {
53
- f as addressesMatch,
54
- y as emptyCustomerAddress,
55
- _ as isCustomerAddressComplete,
56
- i as normalizeCustomerAddress,
57
- d as normalizeOrderCustomerDetails
58
- };
48
+ //#endregion
49
+ export { c as addressesMatch, r as emptyCustomerAddress, o as isCustomerAddressComplete, a as normalizeCustomerAddress, s as normalizeOrderCustomerDetails };
@@ -0,0 +1 @@
1
+ const e=require("../_virtual/_rolldown/runtime.cjs");let t=require("papaparse");t=e.__toESM(t,1);function n(e,n){let r=t.default.unparse(e),i=new Blob([r],{type:`text/csv;charset=utf-8;`}),a=document.createElement(`a`);if(a.download!==void 0){let e=URL.createObjectURL(i);a.setAttribute(`href`,e),a.setAttribute(`download`,n),a.style.visibility=`hidden`,document.body.appendChild(a),a.click(),document.body.removeChild(a)}}function r(e){return e.map(e=>({"Order ID":e.id,Date:new Date(e.created_at).toLocaleDateString(),"Customer Name":e.customer?.full_name||e.customer_details?.name||`Guest`,"Customer Email":e.customer?.email||e.customer_details?.email||`N/A`,Subtotal:(e.subtotal/100).toFixed(2),"Tax Amount":(e.tax_total/100).toFixed(2),"Shipping Amount":(e.shipping_total/100).toFixed(2),Total:(e.total/100).toFixed(2),Currency:e.currency.toUpperCase(),"Payment Status":e.status,"Fulfillment Status":e.status===`shipped`?`Shipped`:e.status===`paid`?`Paid`:e.status===`trial`?`Trial`:`Pending`,"Payment Gateway":e.provider===`freemius`?`Freemius`:`Stripe`}))}function i(e){return e.filter(e=>e.status===`paid`).map(e=>{let t=e.customer_details?.shipping||e.customer_details?.billing,n=t?.country_code||`N/A`,r=t?.state||`N/A`,i=e.tax_details?.lines?.[0]?.rate?.display_name||`N/A`,a=e.tax_details?.lines?.[0]?.rate?.percentage||0;return{Date:e.paid_at?new Date(e.paid_at).toLocaleDateString():new Date(e.created_at).toLocaleDateString(),"Order ID":e.id,Destination:`${r}, ${n}`,"Tax Rate Applied":`${a}% (${i})`,"Total Taxable Amount":(e.subtotal/100).toFixed(2),"Tax Collected":(e.tax_total/100).toFixed(2),Currency:e.currency.toUpperCase()}})}function a(e){let t={};return e.filter(e=>e.status===`paid`).forEach(e=>{let n=e.currency.toUpperCase();t[n]||(t[n]={volume:0,subtotal:0,tax:0}),t[n].volume+=e.total,t[n].subtotal+=e.subtotal,t[n].tax+=e.tax_total}),Object.entries(t).map(([e,t])=>({Currency:e,"Total Transaction Volume":(t.volume/100).toFixed(2),"Total Subtotal":(t.subtotal/100).toFixed(2),"Total Tax Collected":(t.tax/100).toFixed(2)}))}exports.generateCSV=n,exports.mapGeneralSalesLedger=r,exports.mapMultiCurrencyRevenue=a,exports.mapTaxLiabilitySummary=i;
@@ -1,56 +1,57 @@
1
- import u from "papaparse";
2
- function c(n, t) {
3
- const a = u.unparse(n), e = new Blob([a], { type: "text/csv;charset=utf-8;" }), i = document.createElement("a");
4
- if (i.download !== void 0) {
5
- const s = URL.createObjectURL(e);
6
- i.setAttribute("href", s), i.setAttribute("download", t), i.style.visibility = "hidden", document.body.appendChild(i), i.click(), document.body.removeChild(i);
7
- }
1
+ import e from "papaparse";
2
+ //#region src/lib/export-helpers.ts
3
+ function t(t, n) {
4
+ let r = e.unparse(t), i = new Blob([r], { type: "text/csv;charset=utf-8;" }), a = document.createElement("a");
5
+ if (a.download !== void 0) {
6
+ let e = URL.createObjectURL(i);
7
+ a.setAttribute("href", e), a.setAttribute("download", n), a.style.visibility = "hidden", document.body.appendChild(a), a.click(), document.body.removeChild(a);
8
+ }
8
9
  }
9
- function m(n) {
10
- return n.map((t) => ({
11
- "Order ID": t.id,
12
- Date: new Date(t.created_at).toLocaleDateString(),
13
- "Customer Name": t.customer?.full_name || t.customer_details?.name || "Guest",
14
- "Customer Email": t.customer?.email || t.customer_details?.email || "N/A",
15
- Subtotal: (t.subtotal / 100).toFixed(2),
16
- "Tax Amount": (t.tax_total / 100).toFixed(2),
17
- "Shipping Amount": (t.shipping_total / 100).toFixed(2),
18
- Total: (t.total / 100).toFixed(2),
19
- Currency: t.currency.toUpperCase(),
20
- "Payment Status": t.status,
21
- "Fulfillment Status": t.status === "shipped" ? "Shipped" : t.status === "paid" ? "Paid" : t.status === "trial" ? "Trial" : "Pending",
22
- "Payment Gateway": t.provider === "freemius" ? "Freemius" : "Stripe"
23
- }));
10
+ function n(e) {
11
+ return e.map((e) => ({
12
+ "Order ID": e.id,
13
+ Date: new Date(e.created_at).toLocaleDateString(),
14
+ "Customer Name": e.customer?.full_name || e.customer_details?.name || "Guest",
15
+ "Customer Email": e.customer?.email || e.customer_details?.email || "N/A",
16
+ Subtotal: (e.subtotal / 100).toFixed(2),
17
+ "Tax Amount": (e.tax_total / 100).toFixed(2),
18
+ "Shipping Amount": (e.shipping_total / 100).toFixed(2),
19
+ Total: (e.total / 100).toFixed(2),
20
+ Currency: e.currency.toUpperCase(),
21
+ "Payment Status": e.status,
22
+ "Fulfillment Status": e.status === "shipped" ? "Shipped" : e.status === "paid" ? "Paid" : e.status === "trial" ? "Trial" : "Pending",
23
+ "Payment Gateway": e.provider === "freemius" ? "Freemius" : "Stripe"
24
+ }));
24
25
  }
25
- function p(n) {
26
- return n.filter((t) => t.status === "paid").map((t) => {
27
- const a = t.customer_details?.shipping || t.customer_details?.billing, e = a?.country_code || "N/A", i = a?.state || "N/A", s = t.tax_details?.lines?.[0]?.rate?.display_name || "N/A", l = t.tax_details?.lines?.[0]?.rate?.percentage || 0;
28
- return {
29
- Date: t.paid_at ? new Date(t.paid_at).toLocaleDateString() : new Date(t.created_at).toLocaleDateString(),
30
- "Order ID": t.id,
31
- Destination: `${i}, ${e}`,
32
- "Tax Rate Applied": `${l}% (${s})`,
33
- "Total Taxable Amount": (t.subtotal / 100).toFixed(2),
34
- "Tax Collected": (t.tax_total / 100).toFixed(2),
35
- Currency: t.currency.toUpperCase()
36
- };
37
- });
26
+ function r(e) {
27
+ return e.filter((e) => e.status === "paid").map((e) => {
28
+ let t = e.customer_details?.shipping || e.customer_details?.billing, n = t?.country_code || "N/A", r = t?.state || "N/A", i = e.tax_details?.lines?.[0]?.rate?.display_name || "N/A", a = e.tax_details?.lines?.[0]?.rate?.percentage || 0;
29
+ return {
30
+ Date: e.paid_at ? new Date(e.paid_at).toLocaleDateString() : new Date(e.created_at).toLocaleDateString(),
31
+ "Order ID": e.id,
32
+ Destination: `${r}, ${n}`,
33
+ "Tax Rate Applied": `${a}% (${i})`,
34
+ "Total Taxable Amount": (e.subtotal / 100).toFixed(2),
35
+ "Tax Collected": (e.tax_total / 100).toFixed(2),
36
+ Currency: e.currency.toUpperCase()
37
+ };
38
+ });
38
39
  }
39
- function x(n) {
40
- const t = {};
41
- return n.filter((a) => a.status === "paid").forEach((a) => {
42
- const e = a.currency.toUpperCase();
43
- t[e] || (t[e] = { volume: 0, subtotal: 0, tax: 0 }), t[e].volume += a.total, t[e].subtotal += a.subtotal, t[e].tax += a.tax_total;
44
- }), Object.entries(t).map(([a, e]) => ({
45
- Currency: a,
46
- "Total Transaction Volume": (e.volume / 100).toFixed(2),
47
- "Total Subtotal": (e.subtotal / 100).toFixed(2),
48
- "Total Tax Collected": (e.tax / 100).toFixed(2)
49
- }));
40
+ function i(e) {
41
+ let t = {};
42
+ return e.filter((e) => e.status === "paid").forEach((e) => {
43
+ let n = e.currency.toUpperCase();
44
+ t[n] || (t[n] = {
45
+ volume: 0,
46
+ subtotal: 0,
47
+ tax: 0
48
+ }), t[n].volume += e.total, t[n].subtotal += e.subtotal, t[n].tax += e.tax_total;
49
+ }), Object.entries(t).map(([e, t]) => ({
50
+ Currency: e,
51
+ "Total Transaction Volume": (t.volume / 100).toFixed(2),
52
+ "Total Subtotal": (t.subtotal / 100).toFixed(2),
53
+ "Total Tax Collected": (t.tax / 100).toFixed(2)
54
+ }));
50
55
  }
51
- export {
52
- c as generateCSV,
53
- m as mapGeneralSalesLedger,
54
- x as mapMultiCurrencyRevenue,
55
- p as mapTaxLiabilitySummary
56
- };
56
+ //#endregion
57
+ export { t as generateCSV, n as mapGeneralSalesLedger, i as mapMultiCurrencyRevenue, r as mapTaxLiabilitySummary };
@@ -0,0 +1 @@
1
+ const e=require("./providers/freemius.cjs"),t=require("./providers/stripe.cjs");function n(n){switch(n){case`freemius`:return new e.FreemiusProvider;default:return new t.StripeProvider}}exports.getPaymentProvider=n;
package/lib/factory.es.js CHANGED
@@ -1,8 +1,11 @@
1
- import { StripeProvider as r } from "./providers/stripe.es.js";
2
- import { FreemiusProvider as t } from "./providers/freemius.es.js";
3
- function m(e) {
4
- return e === "freemius" ? new t() : new r();
1
+ import { FreemiusProvider as e } from "./providers/freemius.es.js";
2
+ import { StripeProvider as t } from "./providers/stripe.es.js";
3
+ //#region src/lib/factory.ts
4
+ function n(n) {
5
+ switch (n) {
6
+ case "freemius": return new e();
7
+ default: return new t();
8
+ }
5
9
  }
6
- export {
7
- m as getPaymentProvider
8
- };
10
+ //#endregion
11
+ export { n as getPaymentProvider };
@@ -0,0 +1 @@
1
+ const e=require("./payment-config.cjs"),t=require("./providers/freemius.cjs");let n=require("@nextblock-cms/utils");function r(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().replace(`T`,` `).replace(/\.\d{3}Z$/,``)}function i(e){return e===`percent`?`percentage`:`dollar`}function a(e){return t.resolveFreemiusCheckoutCredentials(e).apiKey||t.readFreemiusEnvValue(`FREEMIUS_API_KEY`)}async function o(t){await e.hydrateFreemiusEnvFromDb();let n=a(t.productId);if(!n)throw Error(`Missing Freemius API bearer token for product ${t.productId}. Set FREEMIUS_API_KEY or FREEMIUS_CHECKOUT_PRODUCTS_JSON[${t.productId}].apiKey.`);let r=t.couponId?`/${t.couponId}`:``,i=await fetch(`https://api.freemius.com/v1/products/${t.productId}/coupons${r}.json`,{method:t.method,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`,Accept:`application/json`},body:t.method===`DELETE`?void 0:JSON.stringify(t.body||{})}),o=await i.text(),s=o?JSON.parse(o):null;if(!i.ok)throw Error(s?.message||s?.error?.message||`Freemius coupon request failed with ${i.status}`);return s}function s(e,t){return{code:e.code,discount:e.discount_type===`fixed`?(0,n.minorUnitAmountToMajor)(e.discount_amount,`USD`):e.discount_amount,discount_type:i(e.discount_type),plans:t.planIds.length>0?t.planIds.join(`,`):null,licenses:null,billing_cycles:null,start_date:r(e.starts_at),end_date:r(e.ends_at),redemptions_limit:e.redemption_limit??null,has_renewals_discount:!1,has_addons_discount:!1,is_one_per_user:!1,is_active:e.is_active,user_type:`all`}}async function c(e,t){if(t.provider_scope===`stripe`)return[];let{data:n,error:r}=await e.from(`coupon_products`).select(`product_id`).eq(`coupon_id`,t.id);if(r)throw Error(r.message);let i=(n||[]).map(e=>e.product_id),a=e.from(`products`).select(`id, freemius_product_id, freemius_plan_id`).eq(`payment_provider`,`freemius`).not(`freemius_product_id`,`is`,null);i.length>0&&(a=a.in(`id`,i));let{data:o,error:s}=await a;if(s)throw Error(s.message);let c=new Map;for(let e of o||[]){let t=String(e.freemius_product_id||``).trim();if(!t)continue;let n=c.get(t)??{freemiusProductId:t,productId:e.id,planIds:[]};i.length>0&&e.freemius_plan_id&&n.planIds.push(String(e.freemius_plan_id)),c.set(t,n)}return[...c.values()].map(e=>({...e,planIds:[...new Set(e.planIds)]}))}async function l(e,t){let{data:n}=await e.from(`coupon_freemius_mappings`).select(`sync_status, sync_error`).eq(`coupon_id`,t),r=n||[];if(r.length===0){await e.from(`coupons`).update({freemius_sync_status:`not_required`,freemius_sync_error:null}).eq(`id`,t);return}let i=r.find(e=>e.sync_status===`failed`);await e.from(`coupons`).update({freemius_sync_status:i?`failed`:`synced`,freemius_sync_error:i?.sync_error??null}).eq(`id`,t)}async function u(e){let{data:t,error:n}=await e.client.from(`coupons`).select(`id, code, name, internal_note, provider_scope, discount_type, discount_amount, is_active, starts_at, ends_at, redemption_limit`).eq(`id`,e.couponId).single();if(n||!t)return{success:!1,error:n?.message||`Coupon not found`};let r=t,i=await c(e.client,r);await e.client.from(`coupons`).update({freemius_sync_status:i.length>0?`pending`:`not_required`,freemius_sync_error:null}).eq(`id`,r.id);for(let t of i){let{data:n}=await e.client.from(`coupon_freemius_mappings`).select(`id, freemius_coupon_id`).eq(`coupon_id`,r.id).eq(`freemius_product_id`,t.freemiusProductId).maybeSingle(),i=s(r,t);try{let a=await o({productId:t.freemiusProductId,method:n?.freemius_coupon_id?`PUT`:`POST`,couponId:n?.freemius_coupon_id??null,body:i}),s=a?.coupon??a;await e.client.from(`coupon_freemius_mappings`).upsert({id:n?.id,coupon_id:r.id,product_id:t.productId,freemius_product_id:t.freemiusProductId,freemius_coupon_id:s?.id?String(s.id):n?.freemius_coupon_id??null,freemius_coupon_code:r.code,sync_status:`synced`,sync_error:null,remote_payload:a,last_synced_at:new Date().toISOString()},{onConflict:`coupon_id,freemius_product_id`})}catch(i){await e.client.from(`coupon_freemius_mappings`).upsert({id:n?.id,coupon_id:r.id,product_id:t.productId,freemius_product_id:t.freemiusProductId,freemius_coupon_id:n?.freemius_coupon_id??null,freemius_coupon_code:r.code,sync_status:`failed`,sync_error:i.message||`Freemius sync failed`,last_synced_at:new Date().toISOString()},{onConflict:`coupon_id,freemius_product_id`})}}return await l(e.client,r.id),{success:!0,targetCount:i.length}}function d(e){let t=(e.sku||``).toUpperCase().replace(/[^A-Z0-9]/g,``);return t?`SALE${t}`.slice(0,32):`SALE${e.productId.replace(/[^A-Za-z0-9]/g,``).toUpperCase()}`.slice(0,32)}function f(e,t){if(typeof e!=`number`||e<=0||typeof t!=`number`||t<0||t>=e)return null;let n=Math.round((1-t/e)*100);return n<=0||n>100?null:n}async function p(e){let{data:t,error:n}=await e.client.from(`products`).select(`id, sku, price, sale_price, sale_start_at, sale_end_at, payment_provider, freemius_product_id, freemius_plan_id`).eq(`id`,e.productId).maybeSingle();if(n||!t)return{success:!1,error:n?.message||`Product not found`};let r=t,i=String(r.freemius_product_id||``).trim();if(r.payment_provider!==`freemius`||!i)return{success:!0,skipped:!0,reason:`not_a_freemius_product`};let a=f(r.price,r.sale_price),c=a!==null,{data:l}=await e.client.from(`product_freemius_sale_coupons`).select(`id, freemius_coupon_id, freemius_coupon_code, discount_percent, is_active`).eq(`product_id`,r.id).maybeSingle();if(!c&&!l?.freemius_coupon_id)return l?.id&&await e.client.from(`product_freemius_sale_coupons`).update({is_active:!1,updated_at:new Date().toISOString()}).eq(`id`,l.id),{success:!0,active:!1};let u=l?.freemius_coupon_code||d({sku:r.sku,productId:r.id}),p=r.freemius_plan_id?[String(r.freemius_plan_id)]:[],m=a??l?.discount_percent??1,h=s({id:r.id,code:u,name:`Scheduled sale ${r.sku||r.id}`,provider_scope:`freemius`,discount_type:`percent`,discount_amount:m,is_active:c,starts_at:r.sale_start_at,ends_at:r.sale_end_at,redemption_limit:null},{freemiusProductId:i,productId:r.id,planIds:p});try{let t=await o({productId:i,method:l?.freemius_coupon_id?`PUT`:`POST`,couponId:l?.freemius_coupon_id??null,body:h}),n=t?.coupon??t;return await e.client.from(`product_freemius_sale_coupons`).upsert({id:l?.id,product_id:r.id,freemius_product_id:i,freemius_plan_id:r.freemius_plan_id?String(r.freemius_plan_id):null,freemius_coupon_id:n?.id?String(n.id):l?.freemius_coupon_id??null,freemius_coupon_code:u,discount_percent:a,starts_at:r.sale_start_at,ends_at:r.sale_end_at,is_active:c,sync_status:`synced`,sync_error:null,remote_payload:t,last_synced_at:new Date().toISOString()},{onConflict:`product_id`}),{success:!0,active:c,code:u}}catch(t){return await e.client.from(`product_freemius_sale_coupons`).upsert({id:l?.id,product_id:r.id,freemius_product_id:i,freemius_plan_id:r.freemius_plan_id?String(r.freemius_plan_id):null,freemius_coupon_id:l?.freemius_coupon_id??null,freemius_coupon_code:u,discount_percent:a,starts_at:r.sale_start_at,ends_at:r.sale_end_at,is_active:c,sync_status:`failed`,sync_error:t.message||`Freemius sale coupon sync failed`,last_synced_at:new Date().toISOString()},{onConflict:`product_id`}),{success:!1,error:t.message||`Freemius sale coupon sync failed`}}}async function m(e){let{data:t}=await e.client.from(`coupon_freemius_mappings`).select(`id, freemius_product_id, freemius_coupon_id`).eq(`coupon_id`,e.couponId).not(`freemius_coupon_id`,`is`,null);for(let n of t||[])try{await o({productId:n.freemius_product_id,couponId:n.freemius_coupon_id,method:`DELETE`}),await e.client.from(`coupon_freemius_mappings`).update({sync_status:`deleted`,sync_error:null,updated_at:new Date().toISOString()}).eq(`id`,n.id)}catch(t){await e.client.from(`coupon_freemius_mappings`).update({sync_status:`failed`,sync_error:t.message||`Freemius delete failed`,updated_at:new Date().toISOString()}).eq(`id`,n.id)}}exports.deleteCouponFromFreemius=m,exports.syncCouponToFreemius=u,exports.syncProductSaleCouponToFreemius=p;