@nextblock-cms/ecom 0.20.1 → 0.21.0

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 (317) hide show
  1. package/_virtual/_rolldown/runtime.cjs.js +1 -0
  2. package/index.cjs.js +1 -1
  3. package/index.es.js +38 -146
  4. package/lib/CurrencyProvider.cjs.js +1 -1
  5. package/lib/CurrencyProvider.d.ts +1 -1
  6. package/lib/CurrencyProvider.es.js +85 -95
  7. package/lib/PaymentReadinessProvider.cjs.js +1 -1
  8. package/lib/PaymentReadinessProvider.d.ts +1 -1
  9. package/lib/PaymentReadinessProvider.es.js +24 -27
  10. package/lib/cart-store.cjs.js +1 -1
  11. package/lib/cart-store.es.js +109 -121
  12. package/lib/components/AccountNavigationMenu.cjs.js +1 -1
  13. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  14. package/lib/components/AccountNavigationMenu.es.js +36 -50
  15. package/lib/components/AddToCartButton.cjs.js +1 -1
  16. package/lib/components/AddToCartButton.d.ts +1 -1
  17. package/lib/components/AddToCartButton.es.js +94 -89
  18. package/lib/components/Cart.cjs.js +1 -1
  19. package/lib/components/Cart.d.ts +1 -1
  20. package/lib/components/Cart.es.js +261 -180
  21. package/lib/components/CartDrawer.cjs.js +1 -1
  22. package/lib/components/CartDrawer.d.ts +1 -1
  23. package/lib/components/CartDrawer.es.js +218 -148
  24. package/lib/components/CartIcon.cjs.js +1 -1
  25. package/lib/components/CartIcon.d.ts +1 -1
  26. package/lib/components/CartIcon.es.js +33 -35
  27. package/lib/components/Checkout.cjs.js +1 -1
  28. package/lib/components/Checkout.d.ts +1 -1
  29. package/lib/components/Checkout.es.js +1092 -1108
  30. package/lib/components/CouponForm.cjs.js +1 -1
  31. package/lib/components/CouponForm.d.ts +1 -1
  32. package/lib/components/CouponForm.es.js +136 -148
  33. package/lib/components/CurrencySwitcher.cjs.js +1 -1
  34. package/lib/components/CurrencySwitcher.d.ts +1 -1
  35. package/lib/components/CurrencySwitcher.es.js +22 -18
  36. package/lib/components/CustomerProfileForm.cjs.js +1 -1
  37. package/lib/components/CustomerProfileForm.es.js +454 -313
  38. package/lib/components/FeaturedProduct.cjs.js +1 -1
  39. package/lib/components/FeaturedProduct.d.ts +1 -1
  40. package/lib/components/FeaturedProduct.es.js +98 -83
  41. package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
  42. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  43. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  44. package/lib/components/InvoiceDocument.cjs.js +1 -1
  45. package/lib/components/InvoiceDocument.es.js +256 -192
  46. package/lib/components/InvoiceViewerShell.cjs.js +2 -2
  47. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  48. package/lib/components/InvoiceViewerShell.es.js +75 -106
  49. package/lib/components/ProductCard.cjs.js +1 -1
  50. package/lib/components/ProductCard.d.ts +1 -1
  51. package/lib/components/ProductCard.es.js +186 -171
  52. package/lib/components/ProductDetailsLayout.cjs.js +1 -1
  53. package/lib/components/ProductDetailsLayout.es.js +405 -404
  54. package/lib/components/ProductGallery.cjs.js +1 -1
  55. package/lib/components/ProductGallery.d.ts +1 -1
  56. package/lib/components/ProductGallery.es.js +51 -54
  57. package/lib/components/ProductGrid.cjs.js +1 -1
  58. package/lib/components/ProductGrid.d.ts +1 -1
  59. package/lib/components/ProductGrid.es.js +23 -25
  60. package/lib/components/ShippingEstimator.cjs.js +1 -1
  61. package/lib/components/ShippingEstimator.d.ts +1 -1
  62. package/lib/components/ShippingEstimator.es.js +158 -153
  63. package/lib/components/ShortDescription.cjs.js +1 -1
  64. package/lib/components/ShortDescription.es.js +17 -17
  65. package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
  66. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  67. package/lib/components/SubscriptionSelector.cjs.js +1 -1
  68. package/lib/components/SubscriptionSelector.es.js +159 -154
  69. package/lib/countries.cjs.js +1 -1
  70. package/lib/countries.es.js +232 -75
  71. package/lib/coupon-server.cjs.js +1 -1
  72. package/lib/coupon-server.es.js +180 -224
  73. package/lib/coupons.cjs.js +1 -1
  74. package/lib/coupons.es.js +12 -14
  75. package/lib/currency-constants.cjs.js +1 -1
  76. package/lib/currency-constants.es.js +4 -4
  77. package/lib/currency-rest-client.cjs.js +1 -1
  78. package/lib/currency-rest-client.es.js +15 -22
  79. package/lib/currency-store.cjs.js +1 -1
  80. package/lib/currency-store.es.js +20 -27
  81. package/lib/currency-sync.cjs.js +1 -1
  82. package/lib/currency-sync.es.js +124 -170
  83. package/lib/currency.cjs.js +1 -1
  84. package/lib/currency.es.js +242 -310
  85. package/lib/customer-addresses.cjs.js +1 -1
  86. package/lib/customer-addresses.es.js +80 -109
  87. package/lib/customer-orders.cjs.js +1 -1
  88. package/lib/customer-orders.es.js +31 -43
  89. package/lib/customer.cjs.js +1 -1
  90. package/lib/customer.es.js +43 -52
  91. package/lib/export-helpers.cjs.js +1 -1
  92. package/lib/export-helpers.es.js +53 -52
  93. package/lib/factory.cjs.js +1 -1
  94. package/lib/factory.es.js +10 -7
  95. package/lib/freemius-coupons.cjs.js +1 -1
  96. package/lib/freemius-coupons.es.js +245 -262
  97. package/lib/freemius-license-claim.cjs.js +1 -1
  98. package/lib/freemius-license-claim.es.js +87 -71
  99. package/lib/freemius-license.cjs.js +1 -1
  100. package/lib/freemius-license.es.js +32 -39
  101. package/lib/freemius-order-sync.cjs.js +1 -1
  102. package/lib/freemius-order-sync.es.js +226 -290
  103. package/lib/freemius-trial-provision.cjs.js +1 -1
  104. package/lib/freemius-trial-provision.es.js +136 -130
  105. package/lib/inventory-settings.cjs.js +1 -1
  106. package/lib/inventory-settings.es.js +69 -77
  107. package/lib/invoice-server.cjs.js +3 -3
  108. package/lib/invoice-server.es.js +94 -141
  109. package/lib/invoice-ui.cjs.js +1 -1
  110. package/lib/invoice-ui.es.js +50 -66
  111. package/lib/invoice.cjs.js +1 -1
  112. package/lib/invoice.es.js +85 -94
  113. package/lib/order-inventory.cjs.js +25 -25
  114. package/lib/order-inventory.es.js +67 -79
  115. package/lib/order-tax-details.cjs.js +1 -1
  116. package/lib/order-tax-details.es.js +142 -153
  117. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
  118. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  119. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  120. package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
  121. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  122. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  123. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
  124. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  125. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  126. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
  127. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  128. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  129. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
  130. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  131. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  132. package/lib/pages/cms/coupons/actions.cjs.js +1 -1
  133. package/lib/pages/cms/coupons/actions.es.js +112 -115
  134. package/lib/pages/cms/coupons/index.cjs.js +1 -0
  135. package/lib/pages/cms/coupons/index.es.js +3 -0
  136. package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
  137. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  138. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
  139. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  140. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  141. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  143. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  144. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
  145. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  146. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  147. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
  148. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  149. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  150. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
  151. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  152. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  153. package/lib/pages/cms/orders/actions.cjs.js +3 -3
  154. package/lib/pages/cms/orders/actions.es.js +53 -69
  155. package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
  156. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  157. package/lib/pages/cms/orders/index.cjs.js +1 -0
  158. package/lib/pages/cms/orders/index.es.js +6 -0
  159. package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
  160. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  161. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
  162. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  163. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  164. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
  165. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  166. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  167. package/lib/pages/cms/payments/actions.cjs.js +1 -1
  168. package/lib/pages/cms/payments/actions.es.js +38 -48
  169. package/lib/pages/cms/payments/index.cjs.js +1 -0
  170. package/lib/pages/cms/payments/index.es.js +3 -0
  171. package/lib/pages/cms/payments/queries.cjs.js +1 -1
  172. package/lib/pages/cms/payments/queries.es.js +38 -48
  173. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
  174. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  175. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  176. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  177. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
  178. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
  179. package/lib/pages/cms/products/actions.cjs.js +4 -4
  180. package/lib/pages/cms/products/actions.es.js +121 -162
  181. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  184. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  187. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  190. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
  191. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  192. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  194. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  197. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
  198. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  199. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  200. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  203. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
  204. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  205. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
  206. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  207. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
  208. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  209. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
  210. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  211. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  212. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
  213. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  214. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  215. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  218. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  221. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  222. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  224. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  225. package/lib/pages/cms/products/index.cjs.js +1 -0
  226. package/lib/pages/cms/products/index.es.js +8 -0
  227. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
  228. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  229. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  230. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  233. package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
  234. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  235. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
  236. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  237. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  238. package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
  239. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  240. package/lib/pages/cms/products/server-actions.cjs.js +1 -1
  241. package/lib/pages/cms/products/server-actions.es.js +250 -233
  242. package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
  243. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  244. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
  245. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  246. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  247. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
  248. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  249. package/lib/pages/cms/shipping/index.cjs.js +1 -0
  250. package/lib/pages/cms/shipping/index.es.js +3 -0
  251. package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
  252. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  253. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
  254. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  255. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  256. package/lib/pages/cms/taxes/actions.cjs.js +1 -1
  257. package/lib/pages/cms/taxes/actions.es.js +41 -53
  258. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
  259. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  260. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  261. package/lib/pages/cms/taxes/index.cjs.js +1 -0
  262. package/lib/pages/cms/taxes/index.es.js +3 -0
  263. package/lib/payment-config.cjs.js +1 -1
  264. package/lib/payment-config.es.js +110 -126
  265. package/lib/product-actions.cjs.js +4 -4
  266. package/lib/product-actions.es.js +289 -544
  267. package/lib/product-context.cjs.js +1 -1
  268. package/lib/product-context.es.js +13 -15
  269. package/lib/product-schema.cjs.js +1 -1
  270. package/lib/product-schema.es.js +99 -134
  271. package/lib/providers/freemius.cjs.js +1 -5
  272. package/lib/providers/freemius.es.js +446 -530
  273. package/lib/providers/stripe.cjs.js +1 -1
  274. package/lib/providers/stripe.es.js +417 -477
  275. package/lib/server-actions/coupon-actions.cjs.js +1 -1
  276. package/lib/server-actions/coupon-actions.es.js +22 -22
  277. package/lib/server-actions/customer-actions.cjs.js +1 -1
  278. package/lib/server-actions/customer-actions.es.js +26 -28
  279. package/lib/server-actions/product-actions.cjs.js +1 -1
  280. package/lib/server-actions/product-actions.es.js +9 -15
  281. package/lib/server-actions/shipping-actions.cjs.js +1 -1
  282. package/lib/server-actions/shipping-actions.es.js +27 -24
  283. package/lib/server-actions/tax-actions.cjs.js +1 -1
  284. package/lib/server-actions/tax-actions.es.js +33 -39
  285. package/lib/shared-inventory.cjs.js +2 -2
  286. package/lib/shared-inventory.es.js +111 -160
  287. package/lib/shipping/resolver.cjs.js +2 -2
  288. package/lib/shipping/resolver.es.js +44 -61
  289. package/lib/shipping-rate-currency.cjs.js +1 -1
  290. package/lib/shipping-rate-currency.es.js +52 -67
  291. package/lib/states.cjs.js +1 -1
  292. package/lib/states.es.js +333 -154
  293. package/lib/stripe/checkout.cjs.js +1 -1
  294. package/lib/stripe/checkout.es.js +125 -181
  295. package/lib/stripe/client.cjs.js +1 -1
  296. package/lib/stripe/client.es.js +14 -19
  297. package/lib/stripe/order-sync.cjs.js +1 -1
  298. package/lib/stripe/order-sync.es.js +106 -126
  299. package/lib/stripe/webhooks.cjs.js +1 -1
  300. package/lib/stripe/webhooks.es.js +37 -31
  301. package/lib/tax-calculation.cjs.js +1 -1
  302. package/lib/tax-calculation.es.js +84 -98
  303. package/lib/trials.cjs.js +1 -1
  304. package/lib/trials.es.js +24 -30
  305. package/lib/types.cjs.js +1 -1
  306. package/lib/types.es.js +21 -27
  307. package/lib/use-cart.cjs.js +1 -1
  308. package/lib/use-cart.es.js +38 -40
  309. package/lib/use-price-formatter.cjs.js +1 -1
  310. package/lib/use-price-formatter.es.js +10 -11
  311. package/lib/variation-utils.cjs.js +1 -1
  312. package/lib/variation-utils.es.js +199 -261
  313. package/lib/zod-config.cjs.js +1 -1
  314. package/lib/zod-config.es.js +5 -6
  315. package/package.json +16 -16
  316. package/server.cjs.js +1 -1
  317. package/server.es.js +56 -211
@@ -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 libs/ecommerce/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 };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@nextblock-cms/db/server"),l=require("./invoice-server.cjs.js"),g=require("./freemius-license.cjs.js"),o=["pending"];function i(e){return e??d.createClient()}async function u(e){const{data:{user:r},error:t}=await e.auth.getUser();if(t||!r)throw new Error("Unauthorized");return r}async function m(e){const r=i(e),t=await u(r),{data:n,error:s}=await r.from("orders").select("id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total").eq("user_id",t.id).not("status","in",`(${o.join(",")})`).order("created_at",{ascending:!1});if(s)throw new Error(s.message);return n??[]}async function c(e,r){const t=i(r),n=await u(t),{data:s,error:a}=await t.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",n.id).not("status","in",`(${o.join(",")})`).maybeSingle();if(a)throw new Error(a.message);return s??null}async function _(e,r){const t=i(r),n=await c(e,t);if(!n)return null;const s=n.invoice_number?await l.getInvoicePresentationData(e,t):null,a=n.provider==="freemius"?await g.getFreemiusOrderLicense({orderId:e,client:t}):null;return{order:n,invoice:s,license:a}}exports.getCurrentCustomerOrder=c;exports.getCurrentCustomerOrderInvoice=_;exports.getCurrentCustomerOrders=m;
1
+ const e=require("./invoice-server.cjs.js"),t=require("./freemius-license.cjs.js");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 libs/ecommerce/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 };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./countries.cjs.js"),c=require("./states.cjs.js"),m=()=>({company_name:"",recipient_name:"",line1:"",line2:"",city:"",state:"",postal_code:"",country_code:"CA"});function t(e){const n=e?.trim();return n||null}function o(e){if(!e)return null;const n={company_name:t(e.company_name),recipient_name:t(e.recipient_name),line1:t(e.line1),line2:t(e.line2),city:t(e.city),postal_code:t(e.postal_code),country_code:a.normalizeCountryCode(e.country_code)};return n.state=c.normalizeSubdivisionCode(n.country_code,t(e.state)),Object.values(n).some(Boolean)?n:null}function u(e){const n=o(e);return n?!!(n.recipient_name&&n.line1&&n.city&&n.postal_code&&n.country_code&&(!c.countryUsesStructuredStates(n.country_code)||n.state)):!1}function d(e){const n=o(e.billing),r=o(e.shipping),i=t(e.email)?.toLowerCase()??null,s=t(e.phone),l=t(e.name)??n?.recipient_name??r?.recipient_name??null;return{email:i,name:l,phone:s,billing:n,shipping:r}}function y(e,n){const r=o(e),i=o(n);return JSON.stringify(r)===JSON.stringify(i)}exports.addressesMatch=y;exports.emptyCustomerAddress=m;exports.isCustomerAddressComplete=u;exports.normalizeCustomerAddress=o;exports.normalizeOrderCustomerDetails=d;
1
+ const e=require("./countries.cjs.js"),t=require("./states.cjs.js");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 libs/ecommerce/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 };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("papaparse");function o(n,t){const e=u.unparse(n),a=new Blob([e],{type:"text/csv;charset=utf-8;"}),i=document.createElement("a");if(i.download!==void 0){const l=URL.createObjectURL(a);i.setAttribute("href",l),i.setAttribute("download",t),i.style.visibility="hidden",document.body.appendChild(i),i.click(),document.body.removeChild(i)}}function c(n){return n.map(t=>({"Order ID":t.id,Date:new Date(t.created_at).toLocaleDateString(),"Customer Name":t.customer?.full_name||t.customer_details?.name||"Guest","Customer Email":t.customer?.email||t.customer_details?.email||"N/A",Subtotal:(t.subtotal/100).toFixed(2),"Tax Amount":(t.tax_total/100).toFixed(2),"Shipping Amount":(t.shipping_total/100).toFixed(2),Total:(t.total/100).toFixed(2),Currency:t.currency.toUpperCase(),"Payment Status":t.status,"Fulfillment Status":t.status==="shipped"?"Shipped":t.status==="paid"?"Paid":t.status==="trial"?"Trial":"Pending","Payment Gateway":t.provider==="freemius"?"Freemius":"Stripe"}))}function m(n){return n.filter(t=>t.status==="paid").map(t=>{const e=t.customer_details?.shipping||t.customer_details?.billing,a=e?.country_code||"N/A",i=e?.state||"N/A",l=t.tax_details?.lines?.[0]?.rate?.display_name||"N/A",s=t.tax_details?.lines?.[0]?.rate?.percentage||0;return{Date:t.paid_at?new Date(t.paid_at).toLocaleDateString():new Date(t.created_at).toLocaleDateString(),"Order ID":t.id,Destination:`${i}, ${a}`,"Tax Rate Applied":`${s}% (${l})`,"Total Taxable Amount":(t.subtotal/100).toFixed(2),"Tax Collected":(t.tax_total/100).toFixed(2),Currency:t.currency.toUpperCase()}})}function p(n){const t={};return n.filter(e=>e.status==="paid").forEach(e=>{const a=e.currency.toUpperCase();t[a]||(t[a]={volume:0,subtotal:0,tax:0}),t[a].volume+=e.total,t[a].subtotal+=e.subtotal,t[a].tax+=e.tax_total}),Object.entries(t).map(([e,a])=>({Currency:e,"Total Transaction Volume":(a.volume/100).toFixed(2),"Total Subtotal":(a.subtotal/100).toFixed(2),"Total Tax Collected":(a.tax/100).toFixed(2)}))}exports.generateCSV=o;exports.mapGeneralSalesLedger=c;exports.mapMultiCurrencyRevenue=p;exports.mapTaxLiabilitySummary=m;
1
+ const e=require("../_virtual/_rolldown/runtime.cjs.js");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 libs/ecommerce/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 };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./providers/stripe.cjs.js"),t=require("./providers/freemius.cjs.js");function i(e){return e==="freemius"?new t.FreemiusProvider:new r.StripeProvider}exports.getPaymentProvider=i;
1
+ const e=require("./providers/freemius.cjs.js"),t=require("./providers/stripe.cjs.js");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 libs/ecommerce/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 };