@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.
- package/README.md +43 -0
- package/_virtual/_rolldown/runtime.cjs +1 -0
- package/index.cjs +1 -0
- package/index.es.js +38 -146
- package/lib/CurrencyProvider.cjs +1 -0
- package/lib/CurrencyProvider.d.ts +1 -1
- package/lib/CurrencyProvider.es.js +85 -95
- package/lib/PaymentReadinessProvider.cjs +1 -0
- package/lib/PaymentReadinessProvider.d.ts +1 -1
- package/lib/PaymentReadinessProvider.es.js +24 -27
- package/lib/cart-store.cjs +1 -0
- package/lib/cart-store.es.js +109 -121
- package/lib/components/AccountNavigationMenu.cjs +1 -0
- package/lib/components/AccountNavigationMenu.d.ts +1 -1
- package/lib/components/AccountNavigationMenu.es.js +36 -50
- package/lib/components/AddToCartButton.cjs +1 -0
- package/lib/components/AddToCartButton.d.ts +1 -1
- package/lib/components/AddToCartButton.es.js +94 -89
- package/lib/components/Cart.cjs +1 -0
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +261 -180
- package/lib/components/CartDrawer.cjs +1 -0
- package/lib/components/CartDrawer.d.ts +1 -1
- package/lib/components/CartDrawer.es.js +218 -148
- package/lib/components/CartIcon.cjs +1 -0
- package/lib/components/CartIcon.d.ts +1 -1
- package/lib/components/CartIcon.es.js +33 -35
- package/lib/components/Checkout.cjs +1 -0
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +1092 -1108
- package/lib/components/CouponForm.cjs +1 -0
- package/lib/components/CouponForm.d.ts +1 -1
- package/lib/components/CouponForm.es.js +136 -148
- package/lib/components/CurrencySwitcher.cjs +1 -0
- package/lib/components/CurrencySwitcher.d.ts +1 -1
- package/lib/components/CurrencySwitcher.es.js +22 -18
- package/lib/components/CustomerProfileForm.cjs +1 -0
- package/lib/components/CustomerProfileForm.es.js +454 -313
- package/lib/components/FeaturedProduct.cjs +1 -0
- package/lib/components/FeaturedProduct.d.ts +1 -1
- package/lib/components/FeaturedProduct.es.js +98 -83
- package/lib/components/FreemiusLicensePanel.cjs +1 -0
- package/lib/components/FreemiusLicensePanel.d.ts +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +70 -65
- package/lib/components/InvoiceDocument.cjs +1 -0
- package/lib/components/InvoiceDocument.es.js +256 -192
- package/lib/components/InvoiceViewerShell.cjs +29 -0
- package/lib/components/InvoiceViewerShell.d.ts +1 -1
- package/lib/components/InvoiceViewerShell.es.js +75 -106
- package/lib/components/ProductCard.cjs +1 -0
- package/lib/components/ProductCard.d.ts +1 -1
- package/lib/components/ProductCard.es.js +186 -171
- package/lib/components/ProductDetailsLayout.cjs +1 -0
- package/lib/components/ProductDetailsLayout.es.js +405 -404
- package/lib/components/ProductGallery.cjs +1 -0
- package/lib/components/ProductGallery.d.ts +1 -1
- package/lib/components/ProductGallery.es.js +51 -54
- package/lib/components/ProductGrid.cjs +1 -0
- package/lib/components/ProductGrid.d.ts +1 -1
- package/lib/components/ProductGrid.es.js +23 -25
- package/lib/components/ShippingEstimator.cjs +1 -0
- package/lib/components/ShippingEstimator.d.ts +1 -1
- package/lib/components/ShippingEstimator.es.js +158 -153
- package/lib/components/ShortDescription.cjs +1 -0
- package/lib/components/ShortDescription.es.js +17 -17
- package/lib/components/SimpleTiptapRenderer.cjs +1 -0
- package/lib/components/SimpleTiptapRenderer.es.js +238 -211
- package/lib/components/SubscriptionSelector.cjs +1 -0
- package/lib/components/SubscriptionSelector.es.js +159 -154
- package/lib/countries.cjs +1 -0
- package/lib/countries.es.js +232 -75
- package/lib/coupon-server.cjs +1 -0
- package/lib/coupon-server.es.js +180 -224
- package/lib/coupons.cjs +1 -0
- package/lib/coupons.es.js +12 -14
- package/lib/currency-constants.cjs +1 -0
- package/lib/currency-constants.es.js +4 -4
- package/lib/currency-rest-client.cjs +1 -0
- package/lib/currency-rest-client.es.js +15 -22
- package/lib/currency-store.cjs +1 -0
- package/lib/currency-store.es.js +20 -27
- package/lib/currency-sync.cjs +1 -0
- package/lib/currency-sync.es.js +124 -170
- package/lib/currency.cjs +1 -0
- package/lib/currency.es.js +242 -310
- package/lib/customer-addresses.cjs +1 -0
- package/lib/customer-addresses.es.js +80 -109
- package/lib/customer-orders.cjs +1 -0
- package/lib/customer-orders.es.js +31 -43
- package/lib/customer.cjs +1 -0
- package/lib/customer.es.js +43 -52
- package/lib/export-helpers.cjs +1 -0
- package/lib/export-helpers.es.js +53 -52
- package/lib/factory.cjs +1 -0
- package/lib/factory.es.js +10 -7
- package/lib/freemius-coupons.cjs +1 -0
- package/lib/freemius-coupons.es.js +245 -262
- package/lib/freemius-license-claim.cjs +1 -0
- package/lib/freemius-license-claim.es.js +87 -71
- package/lib/freemius-license.cjs +1 -0
- package/lib/freemius-license.es.js +32 -39
- package/lib/freemius-order-sync.cjs +1 -0
- package/lib/freemius-order-sync.es.js +226 -290
- package/lib/freemius-trial-provision.cjs +1 -0
- package/lib/freemius-trial-provision.es.js +136 -130
- package/lib/inventory-settings.cjs +1 -0
- package/lib/inventory-settings.es.js +69 -77
- package/lib/invoice-server.cjs +33 -0
- package/lib/invoice-server.es.js +94 -141
- package/lib/invoice-ui.cjs +1 -0
- package/lib/invoice-ui.es.js +50 -66
- package/lib/invoice.cjs +1 -0
- package/lib/invoice.es.js +85 -94
- package/lib/order-inventory.cjs +61 -0
- package/lib/order-inventory.es.js +67 -79
- package/lib/order-tax-details.cjs +1 -0
- package/lib/order-tax-details.es.js +142 -153
- package/lib/pages/cms/coupons/CouponEditorForm.cjs +1 -0
- package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
- package/lib/pages/cms/coupons/CouponsPage.cjs +5 -0
- package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs +1 -0
- package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
- package/lib/pages/cms/coupons/EditCouponPage.cjs +1 -0
- package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
- package/lib/pages/cms/coupons/ProductScopePicker.cjs +1 -0
- package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
- package/lib/pages/cms/coupons/actions.cjs +1 -0
- package/lib/pages/cms/coupons/actions.es.js +112 -115
- package/lib/pages/cms/coupons/index.cjs +1 -0
- package/lib/pages/cms/coupons/index.es.js +3 -0
- package/lib/pages/cms/coupons/product-options.cjs +1 -0
- package/lib/pages/cms/coupons/product-options.es.js +21 -23
- package/lib/pages/cms/orders/ExportReportsDialog.cjs +1 -0
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
- package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs +1 -0
- package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
- package/lib/pages/cms/orders/OrderPrintButton.cjs +1 -0
- package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs +1 -0
- package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
- package/lib/pages/cms/orders/OrdersPage.cjs +1 -0
- package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
- package/lib/pages/cms/orders/actions.cjs +7 -0
- package/lib/pages/cms/orders/actions.es.js +53 -69
- package/lib/pages/cms/orders/export-actions.cjs +1 -0
- package/lib/pages/cms/orders/export-actions.es.js +23 -26
- package/lib/pages/cms/orders/index.cjs +1 -0
- package/lib/pages/cms/orders/index.es.js +6 -0
- package/lib/pages/cms/orders/server-actions.cjs +1 -0
- package/lib/pages/cms/orders/server-actions.es.js +60 -51
- package/lib/pages/cms/payments/PaymentsClient.cjs +1 -0
- package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
- package/lib/pages/cms/payments/PaymentsPage.cjs +1 -0
- package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
- package/lib/pages/cms/payments/actions.cjs +1 -0
- package/lib/pages/cms/payments/actions.es.js +38 -48
- package/lib/pages/cms/payments/index.cjs +1 -0
- package/lib/pages/cms/payments/index.es.js +3 -0
- package/lib/pages/cms/payments/queries.cjs +1 -0
- package/lib/pages/cms/payments/queries.es.js +38 -48
- package/lib/pages/cms/products/ProductsPage.cjs +1 -0
- package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +63 -66
- package/lib/pages/cms/products/[id]/edit/EditProductPage.cjs +1 -0
- package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
- package/lib/pages/cms/products/[id]/edit/EditProductPage.es.js +139 -0
- package/lib/pages/cms/products/actions.cjs +44 -0
- package/lib/pages/cms/products/actions.es.js +121 -162
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs +1 -0
- package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs +1 -0
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs +1 -0
- package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs +1 -0
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs +1 -0
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs +1 -0
- package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
- package/lib/pages/cms/products/components/DeleteProductButton.cjs +1 -0
- package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs +1 -0
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs +1 -0
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
- package/lib/pages/cms/products/components/ProductForm.cjs +1 -0
- package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
- package/lib/pages/cms/products/components/ProductMediaManager.cjs +1 -0
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs +1 -0
- package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs +1 -0
- package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs +1 -0
- package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs +5 -0
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
- package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.cjs +1 -0
- package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
- package/lib/pages/cms/products/index.cjs +1 -0
- package/lib/pages/cms/products/index.es.js +8 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs +1 -0
- package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs +2 -0
- package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
- package/lib/pages/cms/products/inventory/actions.cjs +3 -0
- package/lib/pages/cms/products/inventory/actions.es.js +83 -91
- package/lib/pages/cms/products/new/NewProductPage.cjs +1 -0
- package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
- package/lib/pages/cms/products/product-price-sync.cjs +1 -0
- package/lib/pages/cms/products/product-price-sync.es.js +74 -89
- package/lib/pages/cms/products/server-actions.cjs +1 -0
- package/lib/pages/cms/products/server-actions.es.js +250 -233
- package/lib/pages/cms/shipping/ShippingPage.cjs +5 -0
- package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
- package/lib/pages/cms/shipping/components/RateForm.cjs +1 -0
- package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
- package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
- package/lib/pages/cms/shipping/components/ZoneForm.cjs +1 -0
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
- package/lib/pages/cms/shipping/index.cjs +1 -0
- package/lib/pages/cms/shipping/index.es.js +3 -0
- package/lib/pages/cms/shipping/server-actions.cjs +1 -0
- package/lib/pages/cms/shipping/server-actions.es.js +131 -149
- package/lib/pages/cms/taxes/TaxesPage.cjs +1 -0
- package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
- package/lib/pages/cms/taxes/actions.cjs +1 -0
- package/lib/pages/cms/taxes/actions.es.js +41 -53
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs +1 -0
- package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
- package/lib/pages/cms/taxes/index.cjs +1 -0
- package/lib/pages/cms/taxes/index.es.js +3 -0
- package/lib/payment-config.cjs +1 -0
- package/lib/payment-config.es.js +110 -126
- package/lib/product-actions.cjs +238 -0
- package/lib/product-actions.es.js +289 -544
- package/lib/product-context.cjs +1 -0
- package/lib/product-context.es.js +13 -15
- package/lib/product-schema.cjs +1 -0
- package/lib/product-schema.es.js +99 -134
- package/lib/providers/freemius.cjs +1 -0
- package/lib/providers/freemius.es.js +446 -530
- package/lib/providers/stripe.cjs +1 -0
- package/lib/providers/stripe.es.js +417 -477
- package/lib/server-actions/coupon-actions.cjs +1 -0
- package/lib/server-actions/coupon-actions.es.js +22 -22
- package/lib/server-actions/customer-actions.cjs +1 -0
- package/lib/server-actions/customer-actions.es.js +26 -28
- package/lib/server-actions/product-actions.cjs +1 -0
- package/lib/server-actions/product-actions.es.js +9 -15
- package/lib/server-actions/shipping-actions.cjs +1 -0
- package/lib/server-actions/shipping-actions.es.js +27 -24
- package/lib/server-actions/tax-actions.cjs +1 -0
- package/lib/server-actions/tax-actions.es.js +33 -39
- package/lib/shared-inventory.cjs +15 -0
- package/lib/shared-inventory.es.js +111 -160
- package/lib/shipping/resolver.cjs +7 -0
- package/lib/shipping/resolver.es.js +44 -61
- package/lib/shipping-rate-currency.cjs +1 -0
- package/lib/shipping-rate-currency.es.js +52 -67
- package/lib/states.cjs +1 -0
- package/lib/states.es.js +333 -154
- package/lib/stripe/checkout.cjs +1 -0
- package/lib/stripe/checkout.es.js +125 -181
- package/lib/stripe/client.cjs +1 -0
- package/lib/stripe/client.es.js +14 -19
- package/lib/stripe/order-sync.cjs +1 -0
- package/lib/stripe/order-sync.es.js +106 -126
- package/lib/stripe/webhooks.cjs +1 -0
- package/lib/stripe/webhooks.es.js +37 -31
- package/lib/tax-calculation.cjs +1 -0
- package/lib/tax-calculation.es.js +84 -98
- package/lib/trials.cjs +1 -0
- package/lib/trials.es.js +24 -30
- package/lib/types.cjs +1 -0
- package/lib/types.es.js +21 -27
- package/lib/use-cart.cjs +1 -0
- package/lib/use-cart.es.js +38 -40
- package/lib/use-price-formatter.cjs +1 -0
- package/lib/use-price-formatter.es.js +10 -11
- package/lib/variation-utils.cjs +1 -0
- package/lib/variation-utils.es.js +199 -261
- package/lib/zod-config.cjs +1 -0
- package/lib/zod-config.es.js +5 -6
- package/package.json +22 -21
- package/server.cjs +1 -0
- package/server.es.js +56 -211
- package/index.cjs.js +0 -1
- package/lib/CurrencyProvider.cjs.js +0 -1
- package/lib/PaymentReadinessProvider.cjs.js +0 -1
- package/lib/cart-store.cjs.js +0 -1
- package/lib/components/AccountNavigationMenu.cjs.js +0 -1
- package/lib/components/AddToCartButton.cjs.js +0 -1
- package/lib/components/Cart.cjs.js +0 -1
- package/lib/components/CartDrawer.cjs.js +0 -1
- package/lib/components/CartIcon.cjs.js +0 -1
- package/lib/components/Checkout.cjs.js +0 -1
- package/lib/components/CouponForm.cjs.js +0 -1
- package/lib/components/CurrencySwitcher.cjs.js +0 -1
- package/lib/components/CustomerProfileForm.cjs.js +0 -1
- package/lib/components/FeaturedProduct.cjs.js +0 -1
- package/lib/components/FreemiusLicensePanel.cjs.js +0 -1
- package/lib/components/InvoiceDocument.cjs.js +0 -1
- package/lib/components/InvoiceViewerShell.cjs.js +0 -29
- package/lib/components/ProductCard.cjs.js +0 -1
- package/lib/components/ProductDetailsLayout.cjs.js +0 -1
- package/lib/components/ProductGallery.cjs.js +0 -1
- package/lib/components/ProductGrid.cjs.js +0 -1
- package/lib/components/ShippingEstimator.cjs.js +0 -1
- package/lib/components/ShortDescription.cjs.js +0 -1
- package/lib/components/SimpleTiptapRenderer.cjs.js +0 -1
- package/lib/components/SubscriptionSelector.cjs.js +0 -1
- package/lib/countries.cjs.js +0 -1
- package/lib/coupon-server.cjs.js +0 -1
- package/lib/coupons.cjs.js +0 -1
- package/lib/currency-constants.cjs.js +0 -1
- package/lib/currency-rest-client.cjs.js +0 -1
- package/lib/currency-store.cjs.js +0 -1
- package/lib/currency-sync.cjs.js +0 -1
- package/lib/currency.cjs.js +0 -1
- package/lib/customer-addresses.cjs.js +0 -1
- package/lib/customer-orders.cjs.js +0 -1
- package/lib/customer.cjs.js +0 -1
- package/lib/export-helpers.cjs.js +0 -1
- package/lib/factory.cjs.js +0 -1
- package/lib/freemius-coupons.cjs.js +0 -1
- package/lib/freemius-license-claim.cjs.js +0 -1
- package/lib/freemius-license.cjs.js +0 -1
- package/lib/freemius-order-sync.cjs.js +0 -1
- package/lib/freemius-trial-provision.cjs.js +0 -1
- package/lib/inventory-settings.cjs.js +0 -1
- package/lib/invoice-server.cjs.js +0 -33
- package/lib/invoice-ui.cjs.js +0 -1
- package/lib/invoice.cjs.js +0 -1
- package/lib/order-inventory.cjs.js +0 -61
- package/lib/order-tax-details.cjs.js +0 -1
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +0 -1
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +0 -5
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +0 -1
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +0 -1
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +0 -1
- package/lib/pages/cms/coupons/actions.cjs.js +0 -1
- package/lib/pages/cms/coupons/product-options.cjs.js +0 -1
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +0 -1
- package/lib/pages/cms/orders/OrdersPage.cjs.js +0 -1
- package/lib/pages/cms/orders/actions.cjs.js +0 -7
- package/lib/pages/cms/orders/export-actions.cjs.js +0 -1
- package/lib/pages/cms/orders/server-actions.cjs.js +0 -1
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +0 -1
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +0 -1
- package/lib/pages/cms/payments/actions.cjs.js +0 -1
- package/lib/pages/cms/payments/queries.cjs.js +0 -1
- package/lib/pages/cms/products/ProductsPage.cjs.js +0 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +0 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +0 -156
- package/lib/pages/cms/products/actions.cjs.js +0 -44
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +0 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +0 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +0 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +0 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +0 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +0 -1
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +0 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductForm.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +0 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +0 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +0 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +0 -5
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +0 -1
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +0 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +0 -2
- package/lib/pages/cms/products/inventory/actions.cjs.js +0 -3
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +0 -1
- package/lib/pages/cms/products/product-price-sync.cjs.js +0 -1
- package/lib/pages/cms/products/server-actions.cjs.js +0 -1
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +0 -5
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +0 -1
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +0 -1
- package/lib/pages/cms/shipping/server-actions.cjs.js +0 -1
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +0 -1
- package/lib/pages/cms/taxes/actions.cjs.js +0 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +0 -1
- package/lib/payment-config.cjs.js +0 -1
- package/lib/product-actions.cjs.js +0 -238
- package/lib/product-context.cjs.js +0 -1
- package/lib/product-schema.cjs.js +0 -1
- package/lib/providers/freemius.cjs.js +0 -5
- package/lib/providers/stripe.cjs.js +0 -1
- package/lib/server-actions/coupon-actions.cjs.js +0 -1
- package/lib/server-actions/customer-actions.cjs.js +0 -1
- package/lib/server-actions/product-actions.cjs.js +0 -1
- package/lib/server-actions/shipping-actions.cjs.js +0 -1
- package/lib/server-actions/tax-actions.cjs.js +0 -1
- package/lib/shared-inventory.cjs.js +0 -15
- package/lib/shipping/resolver.cjs.js +0 -7
- package/lib/shipping-rate-currency.cjs.js +0 -1
- package/lib/states.cjs.js +0 -1
- package/lib/stripe/checkout.cjs.js +0 -1
- package/lib/stripe/client.cjs.js +0 -1
- package/lib/stripe/order-sync.cjs.js +0 -1
- package/lib/stripe/webhooks.cjs.js +0 -1
- package/lib/tax-calculation.cjs.js +0 -1
- package/lib/trials.cjs.js +0 -1
- package/lib/types.cjs.js +0 -1
- package/lib/use-cart.cjs.js +0 -1
- package/lib/use-price-formatter.cjs.js +0 -1
- package/lib/variation-utils.cjs.js +0 -1
- package/lib/zod-config.cjs.js +0 -1
- package/server.cjs.js +0 -1
|
@@ -1,116 +1,87 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { normalizeCustomerAddress as e } from "./customer.es.js";
|
|
2
|
+
import { createClient as t } from "@nextblock-cms/db/server";
|
|
3
|
+
//#region src/lib/customer-addresses.ts
|
|
4
|
+
function n(e) {
|
|
5
|
+
return e?.trim() || null;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
20
|
-
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
|
79
|
-
|
|
80
|
-
|
|
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
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
A as getDefaultUserAddresses,
|
|
115
|
-
D as upsertDefaultUserAddresses
|
|
116
|
-
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { c as fillMissingUserProfileCheckoutDetails, o as getDefaultUserAddresses, s as upsertDefaultUserAddresses };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./invoice-server.cjs"),t=require("./freemius-license.cjs");let n=require("@nextblock-cms/db/server");var r=[`pending`];function i(e){return e??(0,n.createClient)()}async function a(e){let{data:{user:t},error:n}=await e.auth.getUser();if(n||!t)throw Error(`Unauthorized`);return t}async function o(e){let t=i(e),n=await a(t),{data:o,error:s}=await t.from(`orders`).select(`id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total`).eq(`user_id`,n.id).not(`status`,`in`,`(${r.join(`,`)})`).order(`created_at`,{ascending:!1});if(s)throw Error(s.message);return o??[]}async function s(e,t){let n=i(t),o=await a(n),{data:s,error:c}=await n.from(`orders`).select(`id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total`).eq(`id`,e).eq(`user_id`,o.id).not(`status`,`in`,`(${r.join(`,`)})`).maybeSingle();if(c)throw Error(c.message);return s??null}async function c(n,r){let a=i(r),o=await s(n,a);return o?{order:o,invoice:o.invoice_number?await e.getInvoicePresentationData(n,a):null,license:o.provider===`freemius`?await t.getFreemiusOrderLicense({orderId:n,client:a}):null}:null}exports.getCurrentCustomerOrder=s,exports.getCurrentCustomerOrderInvoice=c,exports.getCurrentCustomerOrders=o;
|
|
@@ -1,48 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { getInvoicePresentationData as e } from "./invoice-server.es.js";
|
|
2
|
+
import { getFreemiusOrderLicense as t } from "./freemius-license.es.js";
|
|
3
|
+
import { createClient as n } from "@nextblock-cms/db/server";
|
|
4
|
+
//#region src/lib/customer-orders.ts
|
|
5
|
+
var r = ["pending"];
|
|
6
|
+
function i(e) {
|
|
7
|
+
return e ?? n();
|
|
7
8
|
}
|
|
8
|
-
async function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
w as getCurrentCustomerOrderInvoice,
|
|
47
|
-
g as getCurrentCustomerOrders
|
|
48
|
-
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { s as getCurrentCustomerOrder, c as getCurrentCustomerOrderInvoice, o as getCurrentCustomerOrders };
|
package/lib/customer.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./countries.cjs"),t=require("./states.cjs");var n=()=>({company_name:``,recipient_name:``,line1:``,line2:``,city:``,state:``,postal_code:``,country_code:`CA`});function r(e){return e?.trim()||null}function i(n){if(!n)return null;let i={company_name:r(n.company_name),recipient_name:r(n.recipient_name),line1:r(n.line1),line2:r(n.line2),city:r(n.city),postal_code:r(n.postal_code),country_code:e.normalizeCountryCode(n.country_code)};return i.state=t.normalizeSubdivisionCode(i.country_code,r(n.state)),Object.values(i).some(Boolean)?i:null}function a(e){let n=i(e);return n?!!(n.recipient_name&&n.line1&&n.city&&n.postal_code&&n.country_code&&(!t.countryUsesStructuredStates(n.country_code)||n.state)):!1}function o(e){let t=i(e.billing),n=i(e.shipping),a=r(e.email)?.toLowerCase()??null,o=r(e.phone);return{email:a,name:r(e.name)??t?.recipient_name??n?.recipient_name??null,phone:o,billing:t,shipping:n}}function s(e,t){let n=i(e),r=i(t);return JSON.stringify(n)===JSON.stringify(r)}exports.addressesMatch=s,exports.emptyCustomerAddress=n,exports.isCustomerAddressComplete=a,exports.normalizeCustomerAddress=i,exports.normalizeOrderCustomerDetails=o;
|
package/lib/customer.es.js
CHANGED
|
@@ -1,58 +1,49 @@
|
|
|
1
|
-
import { normalizeCountryCode as
|
|
2
|
-
import { countryUsesStructuredStates as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { normalizeCountryCode as e } from "./countries.es.js";
|
|
2
|
+
import { countryUsesStructuredStates as t, normalizeSubdivisionCode as n } from "./states.es.js";
|
|
3
|
+
//#region src/lib/customer.ts
|
|
4
|
+
var r = () => ({
|
|
5
|
+
company_name: "",
|
|
6
|
+
recipient_name: "",
|
|
7
|
+
line1: "",
|
|
8
|
+
line2: "",
|
|
9
|
+
city: "",
|
|
10
|
+
state: "",
|
|
11
|
+
postal_code: "",
|
|
12
|
+
country_code: "CA"
|
|
12
13
|
});
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
return e || null;
|
|
14
|
+
function i(e) {
|
|
15
|
+
return e?.trim() || null;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
function c(e, t) {
|
|
45
|
+
let n = a(e), r = a(t);
|
|
46
|
+
return JSON.stringify(n) === JSON.stringify(r);
|
|
51
47
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
y as emptyCustomerAddress,
|
|
55
|
-
_ as isCustomerAddressComplete,
|
|
56
|
-
i as normalizeCustomerAddress,
|
|
57
|
-
d as normalizeOrderCustomerDetails
|
|
58
|
-
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { c as addressesMatch, r as emptyCustomerAddress, o as isCustomerAddressComplete, a as normalizeCustomerAddress, s as normalizeOrderCustomerDetails };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../_virtual/_rolldown/runtime.cjs");let t=require("papaparse");t=e.__toESM(t,1);function n(e,n){let r=t.default.unparse(e),i=new Blob([r],{type:`text/csv;charset=utf-8;`}),a=document.createElement(`a`);if(a.download!==void 0){let e=URL.createObjectURL(i);a.setAttribute(`href`,e),a.setAttribute(`download`,n),a.style.visibility=`hidden`,document.body.appendChild(a),a.click(),document.body.removeChild(a)}}function r(e){return e.map(e=>({"Order ID":e.id,Date:new Date(e.created_at).toLocaleDateString(),"Customer Name":e.customer?.full_name||e.customer_details?.name||`Guest`,"Customer Email":e.customer?.email||e.customer_details?.email||`N/A`,Subtotal:(e.subtotal/100).toFixed(2),"Tax Amount":(e.tax_total/100).toFixed(2),"Shipping Amount":(e.shipping_total/100).toFixed(2),Total:(e.total/100).toFixed(2),Currency:e.currency.toUpperCase(),"Payment Status":e.status,"Fulfillment Status":e.status===`shipped`?`Shipped`:e.status===`paid`?`Paid`:e.status===`trial`?`Trial`:`Pending`,"Payment Gateway":e.provider===`freemius`?`Freemius`:`Stripe`}))}function i(e){return e.filter(e=>e.status===`paid`).map(e=>{let t=e.customer_details?.shipping||e.customer_details?.billing,n=t?.country_code||`N/A`,r=t?.state||`N/A`,i=e.tax_details?.lines?.[0]?.rate?.display_name||`N/A`,a=e.tax_details?.lines?.[0]?.rate?.percentage||0;return{Date:e.paid_at?new Date(e.paid_at).toLocaleDateString():new Date(e.created_at).toLocaleDateString(),"Order ID":e.id,Destination:`${r}, ${n}`,"Tax Rate Applied":`${a}% (${i})`,"Total Taxable Amount":(e.subtotal/100).toFixed(2),"Tax Collected":(e.tax_total/100).toFixed(2),Currency:e.currency.toUpperCase()}})}function a(e){let t={};return e.filter(e=>e.status===`paid`).forEach(e=>{let n=e.currency.toUpperCase();t[n]||(t[n]={volume:0,subtotal:0,tax:0}),t[n].volume+=e.total,t[n].subtotal+=e.subtotal,t[n].tax+=e.tax_total}),Object.entries(t).map(([e,t])=>({Currency:e,"Total Transaction Volume":(t.volume/100).toFixed(2),"Total Subtotal":(t.subtotal/100).toFixed(2),"Total Tax Collected":(t.tax/100).toFixed(2)}))}exports.generateCSV=n,exports.mapGeneralSalesLedger=r,exports.mapMultiCurrencyRevenue=a,exports.mapTaxLiabilitySummary=i;
|
package/lib/export-helpers.es.js
CHANGED
|
@@ -1,56 +1,57 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import e from "papaparse";
|
|
2
|
+
//#region src/lib/export-helpers.ts
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
let r = e.unparse(t), i = new Blob([r], { type: "text/csv;charset=utf-8;" }), a = document.createElement("a");
|
|
5
|
+
if (a.download !== void 0) {
|
|
6
|
+
let e = URL.createObjectURL(i);
|
|
7
|
+
a.setAttribute("href", e), a.setAttribute("download", n), a.style.visibility = "hidden", document.body.appendChild(a), a.click(), document.body.removeChild(a);
|
|
8
|
+
}
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
52
|
-
|
|
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 };
|
package/lib/factory.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./providers/freemius.cjs"),t=require("./providers/stripe.cjs");function n(n){switch(n){case`freemius`:return new e.FreemiusProvider;default:return new t.StripeProvider}}exports.getPaymentProvider=n;
|
package/lib/factory.es.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { FreemiusProvider as e } from "./providers/freemius.es.js";
|
|
2
|
+
import { StripeProvider as t } from "./providers/stripe.es.js";
|
|
3
|
+
//#region src/lib/factory.ts
|
|
4
|
+
function n(n) {
|
|
5
|
+
switch (n) {
|
|
6
|
+
case "freemius": return new e();
|
|
7
|
+
default: return new t();
|
|
8
|
+
}
|
|
5
9
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { n as getPaymentProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./payment-config.cjs"),t=require("./providers/freemius.cjs");let n=require("@nextblock-cms/utils");function r(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().replace(`T`,` `).replace(/\.\d{3}Z$/,``)}function i(e){return e===`percent`?`percentage`:`dollar`}function a(e){return t.resolveFreemiusCheckoutCredentials(e).apiKey||t.readFreemiusEnvValue(`FREEMIUS_API_KEY`)}async function o(t){await e.hydrateFreemiusEnvFromDb();let n=a(t.productId);if(!n)throw Error(`Missing Freemius API bearer token for product ${t.productId}. Set FREEMIUS_API_KEY or FREEMIUS_CHECKOUT_PRODUCTS_JSON[${t.productId}].apiKey.`);let r=t.couponId?`/${t.couponId}`:``,i=await fetch(`https://api.freemius.com/v1/products/${t.productId}/coupons${r}.json`,{method:t.method,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`,Accept:`application/json`},body:t.method===`DELETE`?void 0:JSON.stringify(t.body||{})}),o=await i.text(),s=o?JSON.parse(o):null;if(!i.ok)throw Error(s?.message||s?.error?.message||`Freemius coupon request failed with ${i.status}`);return s}function s(e,t){return{code:e.code,discount:e.discount_type===`fixed`?(0,n.minorUnitAmountToMajor)(e.discount_amount,`USD`):e.discount_amount,discount_type:i(e.discount_type),plans:t.planIds.length>0?t.planIds.join(`,`):null,licenses:null,billing_cycles:null,start_date:r(e.starts_at),end_date:r(e.ends_at),redemptions_limit:e.redemption_limit??null,has_renewals_discount:!1,has_addons_discount:!1,is_one_per_user:!1,is_active:e.is_active,user_type:`all`}}async function c(e,t){if(t.provider_scope===`stripe`)return[];let{data:n,error:r}=await e.from(`coupon_products`).select(`product_id`).eq(`coupon_id`,t.id);if(r)throw Error(r.message);let i=(n||[]).map(e=>e.product_id),a=e.from(`products`).select(`id, freemius_product_id, freemius_plan_id`).eq(`payment_provider`,`freemius`).not(`freemius_product_id`,`is`,null);i.length>0&&(a=a.in(`id`,i));let{data:o,error:s}=await a;if(s)throw Error(s.message);let c=new Map;for(let e of o||[]){let t=String(e.freemius_product_id||``).trim();if(!t)continue;let n=c.get(t)??{freemiusProductId:t,productId:e.id,planIds:[]};i.length>0&&e.freemius_plan_id&&n.planIds.push(String(e.freemius_plan_id)),c.set(t,n)}return[...c.values()].map(e=>({...e,planIds:[...new Set(e.planIds)]}))}async function l(e,t){let{data:n}=await e.from(`coupon_freemius_mappings`).select(`sync_status, sync_error`).eq(`coupon_id`,t),r=n||[];if(r.length===0){await e.from(`coupons`).update({freemius_sync_status:`not_required`,freemius_sync_error:null}).eq(`id`,t);return}let i=r.find(e=>e.sync_status===`failed`);await e.from(`coupons`).update({freemius_sync_status:i?`failed`:`synced`,freemius_sync_error:i?.sync_error??null}).eq(`id`,t)}async function u(e){let{data:t,error:n}=await e.client.from(`coupons`).select(`id, code, name, internal_note, provider_scope, discount_type, discount_amount, is_active, starts_at, ends_at, redemption_limit`).eq(`id`,e.couponId).single();if(n||!t)return{success:!1,error:n?.message||`Coupon not found`};let r=t,i=await c(e.client,r);await e.client.from(`coupons`).update({freemius_sync_status:i.length>0?`pending`:`not_required`,freemius_sync_error:null}).eq(`id`,r.id);for(let t of i){let{data:n}=await e.client.from(`coupon_freemius_mappings`).select(`id, freemius_coupon_id`).eq(`coupon_id`,r.id).eq(`freemius_product_id`,t.freemiusProductId).maybeSingle(),i=s(r,t);try{let a=await o({productId:t.freemiusProductId,method:n?.freemius_coupon_id?`PUT`:`POST`,couponId:n?.freemius_coupon_id??null,body:i}),s=a?.coupon??a;await e.client.from(`coupon_freemius_mappings`).upsert({id:n?.id,coupon_id:r.id,product_id:t.productId,freemius_product_id:t.freemiusProductId,freemius_coupon_id:s?.id?String(s.id):n?.freemius_coupon_id??null,freemius_coupon_code:r.code,sync_status:`synced`,sync_error:null,remote_payload:a,last_synced_at:new Date().toISOString()},{onConflict:`coupon_id,freemius_product_id`})}catch(i){await e.client.from(`coupon_freemius_mappings`).upsert({id:n?.id,coupon_id:r.id,product_id:t.productId,freemius_product_id:t.freemiusProductId,freemius_coupon_id:n?.freemius_coupon_id??null,freemius_coupon_code:r.code,sync_status:`failed`,sync_error:i.message||`Freemius sync failed`,last_synced_at:new Date().toISOString()},{onConflict:`coupon_id,freemius_product_id`})}}return await l(e.client,r.id),{success:!0,targetCount:i.length}}function d(e){let t=(e.sku||``).toUpperCase().replace(/[^A-Z0-9]/g,``);return t?`SALE${t}`.slice(0,32):`SALE${e.productId.replace(/[^A-Za-z0-9]/g,``).toUpperCase()}`.slice(0,32)}function f(e,t){if(typeof e!=`number`||e<=0||typeof t!=`number`||t<0||t>=e)return null;let n=Math.round((1-t/e)*100);return n<=0||n>100?null:n}async function p(e){let{data:t,error:n}=await e.client.from(`products`).select(`id, sku, price, sale_price, sale_start_at, sale_end_at, payment_provider, freemius_product_id, freemius_plan_id`).eq(`id`,e.productId).maybeSingle();if(n||!t)return{success:!1,error:n?.message||`Product not found`};let r=t,i=String(r.freemius_product_id||``).trim();if(r.payment_provider!==`freemius`||!i)return{success:!0,skipped:!0,reason:`not_a_freemius_product`};let a=f(r.price,r.sale_price),c=a!==null,{data:l}=await e.client.from(`product_freemius_sale_coupons`).select(`id, freemius_coupon_id, freemius_coupon_code, discount_percent, is_active`).eq(`product_id`,r.id).maybeSingle();if(!c&&!l?.freemius_coupon_id)return l?.id&&await e.client.from(`product_freemius_sale_coupons`).update({is_active:!1,updated_at:new Date().toISOString()}).eq(`id`,l.id),{success:!0,active:!1};let u=l?.freemius_coupon_code||d({sku:r.sku,productId:r.id}),p=r.freemius_plan_id?[String(r.freemius_plan_id)]:[],m=a??l?.discount_percent??1,h=s({id:r.id,code:u,name:`Scheduled sale ${r.sku||r.id}`,provider_scope:`freemius`,discount_type:`percent`,discount_amount:m,is_active:c,starts_at:r.sale_start_at,ends_at:r.sale_end_at,redemption_limit:null},{freemiusProductId:i,productId:r.id,planIds:p});try{let t=await o({productId:i,method:l?.freemius_coupon_id?`PUT`:`POST`,couponId:l?.freemius_coupon_id??null,body:h}),n=t?.coupon??t;return await e.client.from(`product_freemius_sale_coupons`).upsert({id:l?.id,product_id:r.id,freemius_product_id:i,freemius_plan_id:r.freemius_plan_id?String(r.freemius_plan_id):null,freemius_coupon_id:n?.id?String(n.id):l?.freemius_coupon_id??null,freemius_coupon_code:u,discount_percent:a,starts_at:r.sale_start_at,ends_at:r.sale_end_at,is_active:c,sync_status:`synced`,sync_error:null,remote_payload:t,last_synced_at:new Date().toISOString()},{onConflict:`product_id`}),{success:!0,active:c,code:u}}catch(t){return await e.client.from(`product_freemius_sale_coupons`).upsert({id:l?.id,product_id:r.id,freemius_product_id:i,freemius_plan_id:r.freemius_plan_id?String(r.freemius_plan_id):null,freemius_coupon_id:l?.freemius_coupon_id??null,freemius_coupon_code:u,discount_percent:a,starts_at:r.sale_start_at,ends_at:r.sale_end_at,is_active:c,sync_status:`failed`,sync_error:t.message||`Freemius sale coupon sync failed`,last_synced_at:new Date().toISOString()},{onConflict:`product_id`}),{success:!1,error:t.message||`Freemius sale coupon sync failed`}}}async function m(e){let{data:t}=await e.client.from(`coupon_freemius_mappings`).select(`id, freemius_product_id, freemius_coupon_id`).eq(`coupon_id`,e.couponId).not(`freemius_coupon_id`,`is`,null);for(let n of t||[])try{await o({productId:n.freemius_product_id,couponId:n.freemius_coupon_id,method:`DELETE`}),await e.client.from(`coupon_freemius_mappings`).update({sync_status:`deleted`,sync_error:null,updated_at:new Date().toISOString()}).eq(`id`,n.id)}catch(t){await e.client.from(`coupon_freemius_mappings`).update({sync_status:`failed`,sync_error:t.message||`Freemius delete failed`,updated_at:new Date().toISOString()}).eq(`id`,n.id)}}exports.deleteCouponFromFreemius=m,exports.syncCouponToFreemius=u,exports.syncProductSaleCouponToFreemius=p;
|