@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,149 +1,102 @@
1
- import { getServiceRoleSupabaseClient as y } from "@nextblock-cms/db/server";
2
- import { normalizeOrderCustomerDetails as E } from "./customer.es.js";
3
- import { INVOICE_SETTINGS_KEY as I, normalizeInvoiceSettings as S, DEFAULT_INVOICE_SETTINGS as h } from "./invoice.es.js";
4
- import { normalizeOrderTaxDetails as w } from "./order-tax-details.es.js";
5
- function L(e) {
6
- 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;
1
+ import { normalizeOrderCustomerDetails as e } from "./customer.es.js";
2
+ import { DEFAULT_INVOICE_SETTINGS as t, INVOICE_SETTINGS_KEY as n, normalizeInvoiceSettings as r } from "./invoice.es.js";
3
+ import { normalizeOrderTaxDetails as i } from "./order-tax-details.es.js";
4
+ import { getServiceRoleSupabaseClient as a } from "@nextblock-cms/db/server";
5
+ //#region src/lib/invoice-server.ts
6
+ function o(e) {
7
+ 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;
7
8
  }
8
- function l(e) {
9
- return e ?? y();
9
+ function s(e) {
10
+ return e ?? a();
10
11
  }
11
- function T(e) {
12
- if (!e)
13
- return null;
14
- const n = e.media?.object_key ?? e.media?.file_path ?? null;
15
- return {
16
- id: e.id,
17
- name: e.name ?? null,
18
- url: L(n),
19
- width: e.media?.width ?? null,
20
- height: e.media?.height ?? null
21
- };
12
+ function c(e) {
13
+ if (!e) return null;
14
+ let t = e.media?.object_key ?? e.media?.file_path ?? null;
15
+ return {
16
+ id: e.id,
17
+ name: e.name ?? null,
18
+ url: o(t),
19
+ width: e.media?.width ?? null,
20
+ height: e.media?.height ?? null
21
+ };
22
22
  }
23
- const U = "active_logo_id", _ = `
24
- id,
25
- name,
26
- media:media_id (
27
- object_key,
28
- file_path,
29
- width,
30
- height
31
- )
32
- `;
33
- async function k(e) {
34
- const { data: n } = await e.from("site_settings").select("value").eq("key", U).maybeSingle(), o = n?.value, t = typeof o == "string" && o.length > 0 ? o : null;
35
- if (t) {
36
- const { data: s } = await e.from("logos").select(_).eq("id", t).maybeSingle();
37
- if (s) return s;
38
- }
39
- const { data: r } = await e.from("logos").select(_).order("created_at", { ascending: !1 }).limit(1).maybeSingle();
40
- return r ?? null;
23
+ var l = "active_logo_id", u = "\n id,\n name,\n media:media_id (\n object_key,\n file_path,\n width,\n height\n )\n ";
24
+ async function d(e) {
25
+ let { data: t } = await e.from("site_settings").select("value").eq("key", l).maybeSingle(), n = t?.value, r = typeof n == "string" && n.length > 0 ? n : null;
26
+ if (r) {
27
+ let { data: t } = await e.from("logos").select(u).eq("id", r).maybeSingle();
28
+ if (t) return t;
29
+ }
30
+ let { data: i } = await e.from("logos").select(u).order("created_at", { ascending: !1 }).limit(1).maybeSingle();
31
+ return i ?? null;
41
32
  }
42
- async function R(e) {
43
- const n = l(e), [o, t] = await Promise.all([
44
- n.from("site_settings").select("value").eq("key", I).maybeSingle(),
45
- k(n)
46
- ]);
47
- return {
48
- settings: S(o.data?.value ?? h),
49
- logo: T(t)
50
- };
33
+ async function f(e) {
34
+ let i = s(e), [a, o] = await Promise.all([i.from("site_settings").select("value").eq("key", n).maybeSingle(), d(i)]);
35
+ return {
36
+ settings: r(a.data?.value ?? t),
37
+ logo: c(o)
38
+ };
51
39
  }
52
- async function q(e) {
53
- const n = l(e.client), { data: o, error: t } = await n.rpc("assign_order_invoice_metadata", {
54
- p_order_id: e.orderId,
55
- p_paid_at: e.paidAt ?? null
56
- }).single();
57
- if (t)
58
- throw new Error(t.message);
59
- return {
60
- invoiceNumber: o?.invoice_number ?? null,
61
- paidAt: o?.paid_at ?? null
62
- };
40
+ async function p(e) {
41
+ let { data: t, error: n } = await s(e.client).rpc("assign_order_invoice_metadata", {
42
+ p_order_id: e.orderId,
43
+ p_paid_at: e.paidAt ?? null
44
+ }).single();
45
+ if (n) throw Error(n.message);
46
+ return {
47
+ invoiceNumber: t?.invoice_number ?? null,
48
+ paidAt: t?.paid_at ?? null
49
+ };
63
50
  }
64
- async function C(e, n) {
65
- const o = l(n), { data: t, error: r } = await o.from("orders").select(
66
- `
67
- id,
68
- invoice_number,
69
- paid_at,
70
- created_at,
71
- currency,
72
- status,
73
- provider,
74
- subtotal,
75
- shipping_total,
76
- discount_total,
77
- coupon_code,
78
- tax_total,
79
- total,
80
- customer_details,
81
- tax_details,
82
- order_items (
83
- id,
84
- product_id,
85
- variant_id,
86
- quantity,
87
- price_at_purchase
88
- )
89
- `
90
- ).eq("id", e).single();
91
- if (r || !t)
92
- throw new Error(r?.message || "Order not found");
93
- const s = (t.order_items || []).map((a) => a.product_id).filter(Boolean), u = (t.order_items || []).map((a) => a.variant_id).filter(Boolean), [p, m] = await Promise.all([
94
- s.length ? o.from("products").select("id, title, sku").in("id", s) : Promise.resolve({ data: [], error: null }),
95
- u.length ? o.from("product_variants").select("id, sku").in("id", u) : Promise.resolve({ data: [], error: null })
96
- ]), g = new Map(
97
- (p.data || []).map((a) => [a.id, a])
98
- ), v = new Map(
99
- (m.data || []).map((a) => [a.id, a])
100
- ), c = (t.order_items || []).map((a) => {
101
- const i = a.product_id ? g.get(a.product_id) : null, d = a.variant_id ? v.get(a.variant_id) : null, f = i?.title || "Product", b = d?.sku ? `SKU: ${d.sku}` : i?.sku ? `SKU: ${i.sku}` : null;
102
- return {
103
- id: a.id,
104
- product_id: a.product_id ?? null,
105
- variant_id: a.variant_id ?? null,
106
- title: f,
107
- description: b,
108
- quantity: a.quantity,
109
- unit_amount: a.price_at_purchase,
110
- total_amount: a.price_at_purchase * a.quantity,
111
- sku: d?.sku ?? i?.sku ?? null
112
- };
113
- });
114
- return {
115
- id: t.id,
116
- invoice_number: t.invoice_number ?? null,
117
- paid_at: t.paid_at ?? null,
118
- created_at: t.created_at ?? null,
119
- currency: t.currency || "usd",
120
- status: t.status,
121
- provider: t.provider ?? null,
122
- subtotal: typeof t.subtotal == "number" ? t.subtotal : c.reduce((a, i) => a + i.total_amount, 0),
123
- shipping_total: typeof t.shipping_total == "number" ? t.shipping_total : 0,
124
- discount_total: typeof t.discount_total == "number" ? t.discount_total : 0,
125
- coupon_code: t.coupon_code ?? null,
126
- tax_total: typeof t.tax_total == "number" ? t.tax_total : 0,
127
- total: t.total,
128
- customer_details: E(t.customer_details ?? {}),
129
- tax_details: w(t.tax_details),
130
- items: c
131
- };
51
+ async function m(t, n) {
52
+ let r = s(n), { data: a, error: o } = await r.from("orders").select("\n id,\n invoice_number,\n paid_at,\n created_at,\n currency,\n status,\n provider,\n subtotal,\n shipping_total,\n discount_total,\n coupon_code,\n tax_total,\n total,\n customer_details,\n tax_details,\n order_items (\n id,\n product_id,\n variant_id,\n quantity,\n price_at_purchase\n )\n ").eq("id", t).single();
53
+ if (o || !a) throw Error(o?.message || "Order not found");
54
+ let c = (a.order_items || []).map((e) => e.product_id).filter(Boolean), l = (a.order_items || []).map((e) => e.variant_id).filter(Boolean), [u, d] = await Promise.all([c.length ? r.from("products").select("id, title, sku").in("id", c) : Promise.resolve({
55
+ data: [],
56
+ error: null
57
+ }), l.length ? r.from("product_variants").select("id, sku").in("id", l) : Promise.resolve({
58
+ data: [],
59
+ error: null
60
+ })]), f = new Map((u.data || []).map((e) => [e.id, e])), p = new Map((d.data || []).map((e) => [e.id, e])), m = (a.order_items || []).map((e) => {
61
+ 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;
62
+ return {
63
+ id: e.id,
64
+ product_id: e.product_id ?? null,
65
+ variant_id: e.variant_id ?? null,
66
+ title: r,
67
+ description: i,
68
+ quantity: e.quantity,
69
+ unit_amount: e.price_at_purchase,
70
+ total_amount: e.price_at_purchase * e.quantity,
71
+ sku: n?.sku ?? t?.sku ?? null
72
+ };
73
+ });
74
+ return {
75
+ id: a.id,
76
+ invoice_number: a.invoice_number ?? null,
77
+ paid_at: a.paid_at ?? null,
78
+ created_at: a.created_at ?? null,
79
+ currency: a.currency || "usd",
80
+ status: a.status,
81
+ provider: a.provider ?? null,
82
+ subtotal: typeof a.subtotal == "number" ? a.subtotal : m.reduce((e, t) => e + t.total_amount, 0),
83
+ shipping_total: typeof a.shipping_total == "number" ? a.shipping_total : 0,
84
+ discount_total: typeof a.discount_total == "number" ? a.discount_total : 0,
85
+ coupon_code: a.coupon_code ?? null,
86
+ tax_total: typeof a.tax_total == "number" ? a.tax_total : 0,
87
+ total: a.total,
88
+ customer_details: e(a.customer_details ?? {}),
89
+ tax_details: i(a.tax_details),
90
+ items: m
91
+ };
132
92
  }
133
- async function M(e, n) {
134
- const o = l(n), [t, r] = await Promise.all([
135
- C(e, o),
136
- R(o)
137
- ]);
138
- return {
139
- order: t,
140
- settings: r.settings,
141
- logo: r.logo
142
- };
93
+ async function h(e, t) {
94
+ let n = s(t), [r, i] = await Promise.all([m(e, n), f(n)]);
95
+ return {
96
+ order: r,
97
+ settings: i.settings,
98
+ logo: i.logo
99
+ };
143
100
  }
144
- export {
145
- q as assignInvoiceMetadata,
146
- R as getInvoiceBrandingData,
147
- C as getInvoiceOrder,
148
- M as getInvoicePresentationData
149
- };
101
+ //#endregion
102
+ export { p as assignInvoiceMetadata, f as getInvoiceBrandingData, m as getInvoiceOrder, h as getInvoicePresentationData };
@@ -0,0 +1 @@
1
+ function e(e,t,n){let r=e(t);return r===t?n:r}function t(t){return{invoice:e(t,`invoice`,`Invoice`),invoiceNumber:e(t,`invoice_number`,`Invoice #`),orderNumber:e(t,`order_number`,`Order #`),paidOn:e(t,`paid_on`,`Paid on`),status:e(t,`status`,`Status`),from:e(t,`from`,`From`),billTo:e(t,`bill_to`,`Bill to`),shipTo:e(t,`ship_to`,`Ship to`),item:e(t,`product`,`Item`),details:e(t,`details`,`Details`),quantity:e(t,`ecommerce.qty`,`Qty`),price:e(t,`price`,`Price`),amount:e(t,`amount`,`Amount`),subtotal:e(t,`ecommerce.subtotal`,`Subtotal`),discount:e(t,`ecommerce.discount`,`Discount`),shipping:e(t,`ecommerce.shipping`,`Shipping`),tax:e(t,`ecommerce.tax`,`Tax`),total:e(t,`ecommerce.total`,`Total`),taxBreakdown:e(t,`tax_breakdown`,`Tax breakdown`),taxRegistrations:e(t,`tax_registrations`,`Tax registrations`)}}function n(e){return e===`fr`?`fr-CA`:`en-US`}function r(t,n){if(!t)return``;switch(t.toLowerCase()){case`paid`:return e(n,`order_status_paid`,`Paid`);case`pending`:return e(n,`order_status_pending`,`Pending`);case`trial`:return e(n,`order_status_trial`,`Trial`);case`shipped`:return e(n,`order_status_shipped`,`Shipped`);case`cancelled`:return e(n,`order_status_cancelled`,`Cancelled`);case`refunded`:return e(n,`order_status_refunded`,`Refunded`);default:return t}}function i(e,t){return e?{...e,order:{...e.order,status:r(e.order.status,t)}}:null}exports.buildInvoiceDocumentLabels=t,exports.getInvoiceLocale=n,exports.localizeInvoicePresentationData=i,exports.translateOrFallback=e,exports.translateOrderStatus=r;
@@ -1,71 +1,55 @@
1
- function r(e, t, n) {
2
- const a = e(t);
3
- return a === t ? n : a;
1
+ //#region src/lib/invoice-ui.ts
2
+ function e(e, t, n) {
3
+ let r = e(t);
4
+ return r === t ? n : r;
4
5
  }
5
- function i(e) {
6
- return {
7
- invoice: r(e, "invoice", "Invoice"),
8
- invoiceNumber: r(e, "invoice_number", "Invoice #"),
9
- orderNumber: r(e, "order_number", "Order #"),
10
- paidOn: r(e, "paid_on", "Paid on"),
11
- status: r(e, "status", "Status"),
12
- from: r(e, "from", "From"),
13
- billTo: r(e, "bill_to", "Bill to"),
14
- shipTo: r(e, "ship_to", "Ship to"),
15
- item: r(e, "product", "Item"),
16
- details: r(e, "details", "Details"),
17
- quantity: r(e, "ecommerce.qty", "Qty"),
18
- price: r(e, "price", "Price"),
19
- amount: r(e, "amount", "Amount"),
20
- subtotal: r(e, "ecommerce.subtotal", "Subtotal"),
21
- discount: r(e, "ecommerce.discount", "Discount"),
22
- shipping: r(e, "ecommerce.shipping", "Shipping"),
23
- tax: r(e, "ecommerce.tax", "Tax"),
24
- total: r(e, "ecommerce.total", "Total"),
25
- taxBreakdown: r(e, "tax_breakdown", "Tax breakdown"),
26
- taxRegistrations: r(
27
- e,
28
- "tax_registrations",
29
- "Tax registrations"
30
- )
31
- };
6
+ function t(t) {
7
+ return {
8
+ invoice: e(t, "invoice", "Invoice"),
9
+ invoiceNumber: e(t, "invoice_number", "Invoice #"),
10
+ orderNumber: e(t, "order_number", "Order #"),
11
+ paidOn: e(t, "paid_on", "Paid on"),
12
+ status: e(t, "status", "Status"),
13
+ from: e(t, "from", "From"),
14
+ billTo: e(t, "bill_to", "Bill to"),
15
+ shipTo: e(t, "ship_to", "Ship to"),
16
+ item: e(t, "product", "Item"),
17
+ details: e(t, "details", "Details"),
18
+ quantity: e(t, "ecommerce.qty", "Qty"),
19
+ price: e(t, "price", "Price"),
20
+ amount: e(t, "amount", "Amount"),
21
+ subtotal: e(t, "ecommerce.subtotal", "Subtotal"),
22
+ discount: e(t, "ecommerce.discount", "Discount"),
23
+ shipping: e(t, "ecommerce.shipping", "Shipping"),
24
+ tax: e(t, "ecommerce.tax", "Tax"),
25
+ total: e(t, "ecommerce.total", "Total"),
26
+ taxBreakdown: e(t, "tax_breakdown", "Tax breakdown"),
27
+ taxRegistrations: e(t, "tax_registrations", "Tax registrations")
28
+ };
32
29
  }
33
- function s(e) {
34
- return e === "fr" ? "fr-CA" : "en-US";
30
+ function n(e) {
31
+ return e === "fr" ? "fr-CA" : "en-US";
35
32
  }
36
- function o(e, t) {
37
- if (!e)
38
- return "";
39
- switch (e.toLowerCase()) {
40
- case "paid":
41
- return r(t, "order_status_paid", "Paid");
42
- case "pending":
43
- return r(t, "order_status_pending", "Pending");
44
- case "trial":
45
- return r(t, "order_status_trial", "Trial");
46
- case "shipped":
47
- return r(t, "order_status_shipped", "Shipped");
48
- case "cancelled":
49
- return r(t, "order_status_cancelled", "Cancelled");
50
- case "refunded":
51
- return r(t, "order_status_refunded", "Refunded");
52
- default:
53
- return e;
54
- }
33
+ function r(t, n) {
34
+ if (!t) return "";
35
+ switch (t.toLowerCase()) {
36
+ case "paid": return e(n, "order_status_paid", "Paid");
37
+ case "pending": return e(n, "order_status_pending", "Pending");
38
+ case "trial": return e(n, "order_status_trial", "Trial");
39
+ case "shipped": return e(n, "order_status_shipped", "Shipped");
40
+ case "cancelled": return e(n, "order_status_cancelled", "Cancelled");
41
+ case "refunded": return e(n, "order_status_refunded", "Refunded");
42
+ default: return t;
43
+ }
55
44
  }
56
- function u(e, t) {
57
- return e ? {
58
- ...e,
59
- order: {
60
- ...e.order,
61
- status: o(e.order.status, t)
62
- }
63
- } : null;
45
+ function i(e, t) {
46
+ return e ? {
47
+ ...e,
48
+ order: {
49
+ ...e.order,
50
+ status: r(e.order.status, t)
51
+ }
52
+ } : null;
64
53
  }
65
- export {
66
- i as buildInvoiceDocumentLabels,
67
- s as getInvoiceLocale,
68
- u as localizeInvoicePresentationData,
69
- r as translateOrFallback,
70
- o as translateOrderStatus
71
- };
54
+ //#endregion
55
+ export { t as buildInvoiceDocumentLabels, n as getInvoiceLocale, i as localizeInvoicePresentationData, e as translateOrFallback, r as translateOrderStatus };
@@ -0,0 +1 @@
1
+ var e=`invoice_settings`,t={businessName:``,email:``,phone:``,address:{line1:``,line2:``,city:``,state:``,postal_code:``,country_code:`CA`},taxRegistrations:[]};function n(e){return typeof e==`string`?e.trim():``}function r(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...t.address};let r=e;return{line1:n(r.line1),line2:n(r.line2),city:n(r.city),state:n(r.state),postal_code:n(r.postal_code),country_code:n(r.country_code).toUpperCase()||`CA`}}function i(e){return Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,r=n(t.label),i=n(t.value);return!r&&!i?null:{label:r,value:i}}).filter(e=>!!e):[]}function a(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...t};let a=e;return{businessName:n(a.business_name??a.businessName),email:n(a.email),phone:n(a.phone),address:r(a.address),taxRegistrations:i(a.tax_registrations??a.taxRegistrations)}}function o(e){return{business_name:n(e.businessName),email:n(e.email),phone:n(e.phone),address:r(e.address),tax_registrations:i(e.taxRegistrations)}}function s(e,t=`usd`,n=`en-US`){return new Intl.NumberFormat(n,{style:`currency`,currency:t.toUpperCase()}).format(e/100)}function c(e,t=`en-US`,n=`UTC`){if(!e)return``;let r=new Date(e);return Number.isNaN(r.getTime())?``:new Intl.DateTimeFormat(t,{year:`numeric`,month:`short`,day:`numeric`,timeZone:n}).format(r)}function l(e){if(!e)return[];let t=[e.city,e.state,e.postal_code].filter(Boolean).join(`, `).replace(`, ,`,`,`).trim();return[`company_name`in e&&e.company_name||``,`recipient_name`in e&&e.recipient_name||``,e.line1||``,e.line2||``,t,e.country_code||``].filter(Boolean)}exports.DEFAULT_INVOICE_SETTINGS=t,exports.INVOICE_SETTINGS_KEY=e,exports.formatInvoiceCurrency=s,exports.formatInvoiceDate=c,exports.getInvoiceAddressLines=l,exports.normalizeInvoiceSettings=a,exports.serializeInvoiceSettings=o;
package/lib/invoice.es.js CHANGED
@@ -1,103 +1,94 @@
1
- const u = "invoice_settings", a = {
2
- businessName: "",
3
- email: "",
4
- phone: "",
5
- address: {
6
- line1: "",
7
- line2: "",
8
- city: "",
9
- state: "",
10
- postal_code: "",
11
- country_code: "CA"
12
- },
13
- taxRegistrations: []
1
+ //#region src/lib/invoice.ts
2
+ var e = "invoice_settings", t = {
3
+ businessName: "",
4
+ email: "",
5
+ phone: "",
6
+ address: {
7
+ line1: "",
8
+ line2: "",
9
+ city: "",
10
+ state: "",
11
+ postal_code: "",
12
+ country_code: "CA"
13
+ },
14
+ taxRegistrations: []
14
15
  };
15
- function t(e) {
16
- return typeof e != "string" ? "" : e.trim();
16
+ function n(e) {
17
+ return typeof e == "string" ? e.trim() : "";
17
18
  }
18
- function s(e) {
19
- if (!e || typeof e != "object" || Array.isArray(e))
20
- return { ...a.address };
21
- const n = e;
22
- return {
23
- line1: t(n.line1),
24
- line2: t(n.line2),
25
- city: t(n.city),
26
- state: t(n.state),
27
- postal_code: t(n.postal_code),
28
- country_code: t(n.country_code).toUpperCase() || "CA"
29
- };
19
+ function r(e) {
20
+ if (!e || typeof e != "object" || Array.isArray(e)) return { ...t.address };
21
+ let r = e;
22
+ return {
23
+ line1: n(r.line1),
24
+ line2: n(r.line2),
25
+ city: n(r.city),
26
+ state: n(r.state),
27
+ postal_code: n(r.postal_code),
28
+ country_code: n(r.country_code).toUpperCase() || "CA"
29
+ };
30
30
  }
31
- function c(e) {
32
- return Array.isArray(e) ? e.map((n) => {
33
- if (!n || typeof n != "object" || Array.isArray(n))
34
- return null;
35
- const r = n, i = t(r.label), o = t(r.value);
36
- return !i && !o ? null : {
37
- label: i,
38
- value: o
39
- };
40
- }).filter((n) => !!n) : [];
31
+ function i(e) {
32
+ return Array.isArray(e) ? e.map((e) => {
33
+ if (!e || typeof e != "object" || Array.isArray(e)) return null;
34
+ let t = e, r = n(t.label), i = n(t.value);
35
+ return !r && !i ? null : {
36
+ label: r,
37
+ value: i
38
+ };
39
+ }).filter((e) => !!e) : [];
41
40
  }
42
- function m(e) {
43
- if (!e || typeof e != "object" || Array.isArray(e))
44
- return { ...a };
45
- const n = e;
46
- return {
47
- businessName: t(n.business_name ?? n.businessName),
48
- email: t(n.email),
49
- phone: t(n.phone),
50
- address: s(n.address),
51
- taxRegistrations: c(
52
- n.tax_registrations ?? n.taxRegistrations
53
- )
54
- };
41
+ function a(e) {
42
+ if (!e || typeof e != "object" || Array.isArray(e)) return { ...t };
43
+ let a = e;
44
+ return {
45
+ businessName: n(a.business_name ?? a.businessName),
46
+ email: n(a.email),
47
+ phone: n(a.phone),
48
+ address: r(a.address),
49
+ taxRegistrations: i(a.tax_registrations ?? a.taxRegistrations)
50
+ };
55
51
  }
56
- function l(e) {
57
- return {
58
- business_name: t(e.businessName),
59
- email: t(e.email),
60
- phone: t(e.phone),
61
- address: s(e.address),
62
- tax_registrations: c(e.taxRegistrations)
63
- };
52
+ function o(e) {
53
+ return {
54
+ business_name: n(e.businessName),
55
+ email: n(e.email),
56
+ phone: n(e.phone),
57
+ address: r(e.address),
58
+ tax_registrations: i(e.taxRegistrations)
59
+ };
64
60
  }
65
- function f(e, n = "usd", r = "en-US") {
66
- return new Intl.NumberFormat(r, {
67
- style: "currency",
68
- currency: n.toUpperCase()
69
- }).format(e / 100);
61
+ function s(e, t = "usd", n = "en-US") {
62
+ return new Intl.NumberFormat(n, {
63
+ style: "currency",
64
+ currency: t.toUpperCase()
65
+ }).format(e / 100);
70
66
  }
71
- function y(e, n = "en-US", r = "UTC") {
72
- if (!e)
73
- return "";
74
- const i = new Date(e);
75
- return Number.isNaN(i.getTime()) ? "" : new Intl.DateTimeFormat(n, {
76
- year: "numeric",
77
- month: "short",
78
- day: "numeric",
79
- timeZone: r
80
- }).format(i);
67
+ function c(e, t = "en-US", n = "UTC") {
68
+ if (!e) return "";
69
+ let r = new Date(e);
70
+ return Number.isNaN(r.getTime()) ? "" : new Intl.DateTimeFormat(t, {
71
+ year: "numeric",
72
+ month: "short",
73
+ day: "numeric",
74
+ timeZone: n
75
+ }).format(r);
81
76
  }
82
- function p(e) {
83
- if (!e)
84
- return [];
85
- const n = [e.city, e.state, e.postal_code].filter(Boolean).join(", ").replace(", ,", ",").trim();
86
- return [
87
- "company_name" in e && e.company_name || "",
88
- "recipient_name" in e && e.recipient_name || "",
89
- e.line1 || "",
90
- e.line2 || "",
91
- n,
92
- e.country_code || ""
93
- ].filter(Boolean);
77
+ function l(e) {
78
+ if (!e) return [];
79
+ let t = [
80
+ e.city,
81
+ e.state,
82
+ e.postal_code
83
+ ].filter(Boolean).join(", ").replace(", ,", ",").trim();
84
+ return [
85
+ "company_name" in e && e.company_name || "",
86
+ "recipient_name" in e && e.recipient_name || "",
87
+ e.line1 || "",
88
+ e.line2 || "",
89
+ t,
90
+ e.country_code || ""
91
+ ].filter(Boolean);
94
92
  }
95
- export {
96
- a as DEFAULT_INVOICE_SETTINGS,
97
- u as INVOICE_SETTINGS_KEY,
98
- f as formatInvoiceCurrency,
99
- y as formatInvoiceDate,
100
- p as getInvoiceAddressLines,
101
- m as normalizeInvoiceSettings,
102
- l as serializeInvoiceSettings
103
- };
93
+ //#endregion
94
+ export { t as DEFAULT_INVOICE_SETTINGS, e as INVOICE_SETTINGS_KEY, s as formatInvoiceCurrency, c as formatInvoiceDate, l as getInvoiceAddressLines, a as normalizeInvoiceSettings, o as serializeInvoiceSettings };
@@ -0,0 +1,61 @@
1
+ const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("./inventory-settings.cjs");require("server-only");let n=require("postgres");n=e.__toESM(n,1);function r(){return process.env.POSTGRES_URL||process.env.DATABASE_URL||null}async function i(e){let i=r();if(!i)throw Error(`Missing POSTGRES_URL or DATABASE_URL for inventory fallback`);let a=(0,n.default)(i,{ssl:`require`,onnotice:()=>{}});try{await a.begin(async n=>{let r=n,i=(await r`
2
+ SELECT inventory_deducted_at
3
+ FROM public.orders
4
+ WHERE id = ${e}
5
+ FOR UPDATE
6
+ `)[0];if(!i||i.inventory_deducted_at)return;let a=await r`
7
+ SELECT value
8
+ FROM public.site_settings
9
+ WHERE key = ${t.ECOMMERCE_INVENTORY_SETTINGS_KEY}
10
+ LIMIT 1
11
+ `;if(!t.normalizeEcommerceInventorySettings(a[0]?.value).trackQuantities){await r`
12
+ UPDATE public.orders
13
+ SET inventory_deducted_at = now()
14
+ WHERE id = ${e}
15
+ `;return}let o=await r`
16
+ SELECT
17
+ product_id,
18
+ variant_id,
19
+ SUM(quantity)::integer AS quantity
20
+ FROM public.order_items
21
+ WHERE order_id = ${e}
22
+ GROUP BY product_id, variant_id
23
+ `;for(let e of o){if(e.variant_id){let t=(await r`
24
+ SELECT
25
+ sku,
26
+ stock_quantity
27
+ FROM public.product_variants
28
+ WHERE id = ${e.variant_id}
29
+ LIMIT 1
30
+ `)[0];if(!t?.sku)continue;await r`
31
+ INSERT INTO public.inventory_items (sku, quantity)
32
+ VALUES (${t.sku}, ${Math.max(0,t.stock_quantity??0)})
33
+ ON CONFLICT (sku) DO NOTHING
34
+ `,await r`
35
+ UPDATE public.inventory_items
36
+ SET
37
+ quantity = GREATEST(COALESCE(quantity, 0) - ${e.quantity}, 0),
38
+ updated_at = now()
39
+ WHERE sku = ${t.sku}
40
+ `;continue}if(e.product_id){let t=(await r`
41
+ SELECT
42
+ sku,
43
+ stock
44
+ FROM public.products
45
+ WHERE id = ${e.product_id}
46
+ LIMIT 1
47
+ `)[0];if(!t?.sku)continue;await r`
48
+ INSERT INTO public.inventory_items (sku, quantity)
49
+ VALUES (${t.sku}, ${Math.max(0,t.stock??0)})
50
+ ON CONFLICT (sku) DO NOTHING
51
+ `,await r`
52
+ UPDATE public.inventory_items
53
+ SET
54
+ quantity = GREATEST(COALESCE(quantity, 0) - ${e.quantity}, 0),
55
+ updated_at = now()
56
+ WHERE sku = ${t.sku}
57
+ `}}await r`
58
+ UPDATE public.orders
59
+ SET inventory_deducted_at = now()
60
+ WHERE id = ${e}
61
+ `})}finally{await a.end()}}async function a(e,t){let{error:n}=await e.rpc(`apply_order_inventory_deduction`,{p_order_id:t});if(!n)return{method:`rpc`};console.error(`[Inventory] RPC deduction failed for order ${t}:`,n);try{return await i(t),{method:`sql-fallback`}}catch(e){let r=e instanceof Error?e.message:String(e);throw Error(`Failed to reconcile inventory for order ${t}. RPC error: ${n.message}. Fallback error: ${r}`)}}exports.applyOrderInventoryDeduction=a;