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