@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,546 +1,462 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { getDefaultCurrency as e, isSaleWindowActive as t, resolveEffectivePriceForCurrency as n } from "../currency.es.js";
|
|
2
|
+
import { getCouponQuote as r, recordCouponRedemption as i } from "../coupon-server.es.js";
|
|
3
|
+
import { normalizeOrderCustomerDetails as a } from "../customer.es.js";
|
|
4
|
+
import { fillMissingUserProfileCheckoutDetails as o, upsertDefaultUserAddresses as s } from "../customer-addresses.es.js";
|
|
5
|
+
import { hydrateFreemiusEnvFromDb as c } from "../payment-config.es.js";
|
|
6
|
+
import { createClient as l } from "@supabase/supabase-js";
|
|
7
|
+
import u from "crypto";
|
|
8
|
+
import { Freemius as d } from "@freemius/sdk";
|
|
9
|
+
//#region src/lib/providers/freemius.ts
|
|
10
|
+
function f(e) {
|
|
11
|
+
let t = process.env[e];
|
|
12
|
+
if (!t) return null;
|
|
13
|
+
let n = t.trim();
|
|
14
|
+
return n.startsWith("\"") && n.endsWith("\"") || n.startsWith("'") && n.endsWith("'") ? n.slice(1, -1).trim() : n;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
16
|
+
function p(e) {
|
|
17
|
+
let t = e?.trim();
|
|
18
|
+
if (!t) return {
|
|
19
|
+
firstName: null,
|
|
20
|
+
lastName: null
|
|
21
|
+
};
|
|
22
|
+
let [n, ...r] = t.split(/\s+/);
|
|
23
|
+
return {
|
|
24
|
+
firstName: n || null,
|
|
25
|
+
lastName: r.length > 0 ? r.join(" ") : null
|
|
26
|
+
};
|
|
28
27
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return !Number.isFinite(r) || r <= 0 ? 0 : Math.round(r);
|
|
28
|
+
function m(e) {
|
|
29
|
+
if (e == null || e === "") return 0;
|
|
30
|
+
let t = Number(e);
|
|
31
|
+
return !Number.isFinite(t) || t <= 0 ? 0 : Math.round(t);
|
|
34
32
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
33
|
+
function h(e) {
|
|
34
|
+
return e === !0 || e === 1 || e === "1" || e === "true";
|
|
37
35
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
function g(e, t) {
|
|
37
|
+
let n = e?.[t];
|
|
38
|
+
return Array.isArray(n) ? n : n && typeof n == "object" ? [n] : [];
|
|
41
39
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return Array.isArray(e) ? e : [];
|
|
40
|
+
function _(e, t) {
|
|
41
|
+
for (let n of t) {
|
|
42
|
+
let t = g(e, n);
|
|
43
|
+
if (t.length > 0) return t;
|
|
44
|
+
}
|
|
45
|
+
return Array.isArray(e) ? e : [];
|
|
49
46
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return Number.isFinite(r) ? r : null;
|
|
47
|
+
function v(e) {
|
|
48
|
+
if (e == null || e === "") return null;
|
|
49
|
+
let t = Number(e);
|
|
50
|
+
return Number.isFinite(t) ? t : null;
|
|
55
51
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
`[Freemius Sync] Suspiciously high price detected: ${e}. Assuming it is already in cents.`
|
|
59
|
-
), Math.round(e)) : Math.round(e * 100);
|
|
52
|
+
function y(e) {
|
|
53
|
+
return e === null ? 0 : e > 5e3 ? (console.warn(`[Freemius Sync] Suspiciously high price detected: ${e}. Assuming it is already in cents.`), Math.round(e)) : Math.round(e * 100);
|
|
60
54
|
}
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
function b(e) {
|
|
56
|
+
let t = Number(e);
|
|
57
|
+
return !Number.isFinite(t) || t < 1 ? 1 : Math.round(t);
|
|
64
58
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"[Freemius Checkout] Failed to parse FREEMIUS_CHECKOUT_PRODUCTS_JSON:",
|
|
75
|
-
r
|
|
76
|
-
), null;
|
|
77
|
-
}
|
|
59
|
+
function x() {
|
|
60
|
+
let e = f("FREEMIUS_CHECKOUT_PRODUCTS_JSON");
|
|
61
|
+
if (!e) return null;
|
|
62
|
+
try {
|
|
63
|
+
let t = JSON.parse(e);
|
|
64
|
+
return t && typeof t == "object" ? t : null;
|
|
65
|
+
} catch (e) {
|
|
66
|
+
return console.error("[Freemius Checkout] Failed to parse FREEMIUS_CHECKOUT_PRODUCTS_JSON:", e), null;
|
|
67
|
+
}
|
|
78
68
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
secretKey: o("FREEMIUS_SECRET_KEY"),
|
|
103
|
-
apiKey: o("FREEMIUS_API_KEY"),
|
|
104
|
-
source: "legacy-env"
|
|
105
|
-
};
|
|
69
|
+
function S(e) {
|
|
70
|
+
let t = x(), n = String(e), r = t?.[n], i = f("FREEMIUS_PRODUCT_ID"), a = f("FREEMIUS_ECOMMERCE_SANDBOX_PUBLIC_KEY"), o = f("FREEMIUS_ECOMMERCE_SANDBOX_SECRET_KEY");
|
|
71
|
+
return r?.publicKey ? {
|
|
72
|
+
publicKey: r.publicKey,
|
|
73
|
+
secretKey: r.secretKey ?? null,
|
|
74
|
+
apiKey: r.apiKey ?? null,
|
|
75
|
+
source: "product-map"
|
|
76
|
+
} : process.env.FREEMIUS_SANDBOX_ENABLED === "true" && i && i === n && a ? {
|
|
77
|
+
publicKey: a,
|
|
78
|
+
secretKey: o,
|
|
79
|
+
apiKey: f("FREEMIUS_API_KEY"),
|
|
80
|
+
source: "single-product-sandbox-env"
|
|
81
|
+
} : i && i === n && f("FREEMIUS_PUBLIC_KEY") ? {
|
|
82
|
+
publicKey: f("FREEMIUS_PUBLIC_KEY"),
|
|
83
|
+
secretKey: f("FREEMIUS_SECRET_KEY"),
|
|
84
|
+
apiKey: f("FREEMIUS_API_KEY"),
|
|
85
|
+
source: "single-product-env"
|
|
86
|
+
} : {
|
|
87
|
+
publicKey: f("FREEMIUS_PUBLIC_KEY"),
|
|
88
|
+
secretKey: f("FREEMIUS_SECRET_KEY"),
|
|
89
|
+
apiKey: f("FREEMIUS_API_KEY"),
|
|
90
|
+
source: "legacy-env"
|
|
91
|
+
};
|
|
106
92
|
}
|
|
107
|
-
async function
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}).checkout.getSandboxParams();
|
|
93
|
+
async function C(e) {
|
|
94
|
+
if (!e.apiKey) throw Error("Missing Freemius API key for SDK sandbox generation.");
|
|
95
|
+
return new d({
|
|
96
|
+
productId: Number(e.productId),
|
|
97
|
+
apiKey: e.apiKey,
|
|
98
|
+
secretKey: e.secretKey,
|
|
99
|
+
publicKey: e.publicKey
|
|
100
|
+
}).checkout.getSandboxParams();
|
|
116
101
|
}
|
|
117
|
-
class
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
trial: U,
|
|
331
|
-
trial_period_days: F,
|
|
332
|
-
trial_requires_payment_method: i.trial_requires_payment_method,
|
|
333
|
-
initial_order_status: B,
|
|
334
|
-
coupon: n?.code ?? null,
|
|
335
|
-
order_id: Y.id
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
async function Z(e, r, t, s) {
|
|
341
|
-
const d = (/* @__PURE__ */ new Date()).toUTCString().replace("GMT", "+0000"), f = `GET
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
${d}
|
|
345
|
-
${e}`, m = Q.createHmac("sha256", s).update(f).digest("hex"), b = Buffer.from(m).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""), E = `FS ${r}:${t}:${b}`, a = await fetch(`https://api.freemius.com${e}`, {
|
|
346
|
-
headers: {
|
|
347
|
-
Authorization: E,
|
|
348
|
-
Date: d,
|
|
349
|
-
Accept: "application/json"
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
if (!a.ok) {
|
|
353
|
-
const l = await a.text();
|
|
354
|
-
throw console.error(`[Freemius API] [ERROR] ${e} returned ${a.status}: ${l}`), new Error(`Freemius API failed on ${e}: ${a.status} - ${l}`);
|
|
355
|
-
}
|
|
356
|
-
return a.json();
|
|
102
|
+
var w = class {
|
|
103
|
+
getProviderName() {
|
|
104
|
+
return "Freemius";
|
|
105
|
+
}
|
|
106
|
+
async createCheckoutSession({ items: d, customerEmail: h, customerPhone: g, userId: _, billingAddress: v, shippingAddress: y, currencyCode: b, couponCode: x, couponContextItems: w }) {
|
|
107
|
+
let T = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, E = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY;
|
|
108
|
+
if (!T || !E) return {
|
|
109
|
+
error: "Missing Supabase credentials for checkout (Service Key required).",
|
|
110
|
+
url: null
|
|
111
|
+
};
|
|
112
|
+
let D = l(T, E);
|
|
113
|
+
if (!d || d.length === 0) return {
|
|
114
|
+
error: "Cart is empty",
|
|
115
|
+
url: null
|
|
116
|
+
};
|
|
117
|
+
if (d.length !== 1) return {
|
|
118
|
+
error: "Freemius items must be checked out one at a time.",
|
|
119
|
+
url: null
|
|
120
|
+
};
|
|
121
|
+
let { data: O, error: k } = await D.from("currencies").select("code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount").eq("is_active", !0).order("code", { ascending: !0 }), A = O ?? [];
|
|
122
|
+
if (k || A.length === 0) return {
|
|
123
|
+
error: "Failed to resolve store currencies",
|
|
124
|
+
url: null
|
|
125
|
+
};
|
|
126
|
+
let ee = e(A), j = A.find((e) => e.code === (b || "").toUpperCase()) ?? ee, M = d[0], { data: N, error: te } = await D.from("products").select("id, title, price, prices, sale_price, sale_prices, sale_start_at, sale_end_at, scheduled_price, scheduled_prices, scheduled_price_at, freemius_plan_id, freemius_product_id, trial_period_days, trial_requires_payment_method").eq("id", M.product_id).single();
|
|
127
|
+
if (te || !N) return {
|
|
128
|
+
error: "Product not found",
|
|
129
|
+
url: null
|
|
130
|
+
};
|
|
131
|
+
let P = N.freemius_plan_id, F = N.freemius_product_id;
|
|
132
|
+
if (!P || !F) return {
|
|
133
|
+
error: "Product is not configured for Freemius checkout (missing Plan ID or Product ID)",
|
|
134
|
+
url: null
|
|
135
|
+
};
|
|
136
|
+
let I = n({
|
|
137
|
+
prices: N.prices || {},
|
|
138
|
+
salePrices: N.sale_prices || {},
|
|
139
|
+
fallbackPrice: N.price,
|
|
140
|
+
fallbackSalePrice: N.sale_price,
|
|
141
|
+
saleStartAt: N.sale_start_at,
|
|
142
|
+
saleEndAt: N.sale_end_at,
|
|
143
|
+
scheduledPrice: N.scheduled_price,
|
|
144
|
+
scheduledPrices: N.scheduled_prices || {},
|
|
145
|
+
scheduledPriceAt: N.scheduled_price_at,
|
|
146
|
+
currencyCode: j.code,
|
|
147
|
+
currencies: A
|
|
148
|
+
}), L = I.sale_price ?? I.price, ne = t({
|
|
149
|
+
saleStartAt: N.sale_start_at,
|
|
150
|
+
saleEndAt: N.sale_end_at
|
|
151
|
+
}), R = L * M.quantity, z = null, B = 0;
|
|
152
|
+
if (x) {
|
|
153
|
+
let e = await r({
|
|
154
|
+
client: D,
|
|
155
|
+
code: x,
|
|
156
|
+
items: w && w.length > 0 ? w : d,
|
|
157
|
+
currencyCode: j.code
|
|
158
|
+
});
|
|
159
|
+
if (!e.success) return {
|
|
160
|
+
error: e.error,
|
|
161
|
+
errorKey: e.errorKey,
|
|
162
|
+
errorStatus: 400,
|
|
163
|
+
url: null
|
|
164
|
+
};
|
|
165
|
+
z = e.quote, B = Math.min(R, z.lineDiscounts.filter((e) => e.product_id === N.id).reduce((e, t) => e + t.discount, 0));
|
|
166
|
+
}
|
|
167
|
+
let V = m(N.trial_period_days), H = V > 0 ? M.trial_preference ? M.trial_preference : N.trial_requires_payment_method ? "paid" : "free" : null, U = "pending", W = p(v?.recipient_name ?? null), { data: G, error: K } = await D.from("orders").insert({
|
|
168
|
+
status: U,
|
|
169
|
+
total: Math.max(0, R - B),
|
|
170
|
+
currency: j.code,
|
|
171
|
+
exchange_rate_at_purchase: j.exchange_rate,
|
|
172
|
+
subtotal: R,
|
|
173
|
+
discount_total: B,
|
|
174
|
+
coupon_id: z?.couponId ?? null,
|
|
175
|
+
coupon_code: z?.code ?? null,
|
|
176
|
+
discount_details: z ? {
|
|
177
|
+
code: z.code,
|
|
178
|
+
discount_type: z.discountType,
|
|
179
|
+
discount_amount: z.discountAmount,
|
|
180
|
+
provider: "freemius",
|
|
181
|
+
provider_discounts: z.providerDiscounts,
|
|
182
|
+
line_discounts: z.lineDiscounts,
|
|
183
|
+
final_amount_owned_by: "freemius"
|
|
184
|
+
} : null,
|
|
185
|
+
provider: "freemius",
|
|
186
|
+
freemius_product_id: String(F),
|
|
187
|
+
freemius_plan_id: String(P),
|
|
188
|
+
user_id: _ || null,
|
|
189
|
+
customer_details: a({
|
|
190
|
+
email: h,
|
|
191
|
+
phone: g,
|
|
192
|
+
name: v?.recipient_name,
|
|
193
|
+
billing: v,
|
|
194
|
+
shipping: y
|
|
195
|
+
})
|
|
196
|
+
}).select("id").single();
|
|
197
|
+
if (K || !G) return console.error("Failed to create pending order:", K), {
|
|
198
|
+
error: "Failed to initiate order",
|
|
199
|
+
url: null
|
|
200
|
+
};
|
|
201
|
+
let { error: q } = await D.from("order_items").insert([{
|
|
202
|
+
order_id: G.id,
|
|
203
|
+
product_id: N.id,
|
|
204
|
+
quantity: M.quantity,
|
|
205
|
+
price_at_purchase: L
|
|
206
|
+
}]);
|
|
207
|
+
if (q && console.error("Failed to insert order items:", q), _) try {
|
|
208
|
+
await s({
|
|
209
|
+
userId: _,
|
|
210
|
+
billingAddress: v,
|
|
211
|
+
shippingAddress: y,
|
|
212
|
+
client: D
|
|
213
|
+
}), await o({
|
|
214
|
+
userId: _,
|
|
215
|
+
fullName: v?.recipient_name ?? y?.recipient_name ?? null,
|
|
216
|
+
phone: g,
|
|
217
|
+
client: D
|
|
218
|
+
});
|
|
219
|
+
} catch (e) {
|
|
220
|
+
console.error("Failed to sync checkout profile defaults before checkout:", e);
|
|
221
|
+
}
|
|
222
|
+
z && await i({
|
|
223
|
+
client: D,
|
|
224
|
+
quote: z,
|
|
225
|
+
orderId: G.id,
|
|
226
|
+
provider: "freemius",
|
|
227
|
+
discountTotal: B,
|
|
228
|
+
userId: _,
|
|
229
|
+
customerEmail: h,
|
|
230
|
+
metadata: {
|
|
231
|
+
currency: j.code,
|
|
232
|
+
subtotal: R,
|
|
233
|
+
final_amount_owned_by: "freemius"
|
|
234
|
+
}
|
|
235
|
+
}), await c();
|
|
236
|
+
let J = process.env.FREEMIUS_SANDBOX_ENABLED === "true", Y = S(F), X = Y.publicKey, Z = Y.secretKey, re = Y.apiKey;
|
|
237
|
+
if (!X || J && !Z) return console.error("Freemius checkout blocked: missing credentials (PUBLIC_KEY or SECRET_KEY) in CMS → Payments or environment."), {
|
|
238
|
+
error: "This store is not able to take payments right now. Please contact the seller to complete your purchase.",
|
|
239
|
+
errorKey: "ecommerce.checkout_payments_unavailable",
|
|
240
|
+
errorStatus: 503,
|
|
241
|
+
url: null
|
|
242
|
+
};
|
|
243
|
+
if (J && Y.source === "legacy-env") {
|
|
244
|
+
let e = f("FREEMIUS_PRODUCT_ID"), t = !!f("FREEMIUS_ECOMMERCE_SANDBOX_PUBLIC_KEY"), n = !!f("FREEMIUS_ECOMMERCE_SANDBOX_SECRET_KEY");
|
|
245
|
+
console.warn(`[Freemius Checkout] Sandbox is enabled for product ${F}, but no product-scoped checkout credentials were selected. Falling back to legacy FREEMIUS_PUBLIC_KEY/FREEMIUS_SECRET_KEY may open live checkout instead of sandbox.`, {
|
|
246
|
+
configuredProductId: e,
|
|
247
|
+
productIdsMatch: e === String(F),
|
|
248
|
+
hasSandboxOverridePublicKey: t,
|
|
249
|
+
hasSandboxOverrideSecretKey: n,
|
|
250
|
+
hasCheckoutProductsJson: !!f("FREEMIUS_CHECKOUT_PRODUCTS_JSON")
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
let Q = !1;
|
|
254
|
+
if (J && Z && X) try {
|
|
255
|
+
Q = await C({
|
|
256
|
+
productId: F,
|
|
257
|
+
publicKey: X,
|
|
258
|
+
secretKey: Z,
|
|
259
|
+
apiKey: re
|
|
260
|
+
});
|
|
261
|
+
} catch (e) {
|
|
262
|
+
console.warn("Freemius Checkout - SDK sandbox generation failed. Falling back to manual token generation.", e, {
|
|
263
|
+
credentialSource: Y.source,
|
|
264
|
+
hasApiKey: !!re
|
|
265
|
+
});
|
|
266
|
+
let t = Math.floor(Date.now() / 1e3).toString(), n = `${t}${F}${Z}${X}checkout`;
|
|
267
|
+
Q = {
|
|
268
|
+
ctx: t,
|
|
269
|
+
token: u.createHash("md5").update(n).digest("hex")
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
let $ = new URL(`https://checkout.freemius.com/app/${F}/plan/${P}/`);
|
|
273
|
+
if (J && Z && X ? ($.searchParams.append("sandbox", Q.token), $.searchParams.append("s_ctx_ts", Q.ctx)) : J && $.searchParams.append("sandbox", "true"), h && $.searchParams.append("user_email", h), W.firstName && $.searchParams.append("user_firstname", W.firstName), W.lastName && $.searchParams.append("user_lastname", W.lastName), $.searchParams.append("currency", j.code.toLowerCase()), M.billing_cycle && $.searchParams.append("billing_cycle", M.billing_cycle), H && $.searchParams.append("trial", H), z) $.searchParams.append("coupon", z.code);
|
|
274
|
+
else if (ne) {
|
|
275
|
+
let { data: e } = await D.from("product_freemius_sale_coupons").select("freemius_coupon_code, is_active, starts_at, ends_at, sync_status").eq("product_id", N.id).maybeSingle();
|
|
276
|
+
e?.is_active && e.sync_status === "synced" && e.freemius_coupon_code && t({
|
|
277
|
+
saleStartAt: e.starts_at,
|
|
278
|
+
saleEndAt: e.ends_at
|
|
279
|
+
}) && $.searchParams.append("coupon", e.freemius_coupon_code);
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
url: $.toString(),
|
|
283
|
+
customProps: {
|
|
284
|
+
provider: "freemius",
|
|
285
|
+
plugin_id: F,
|
|
286
|
+
plan_id: P,
|
|
287
|
+
public_key: X,
|
|
288
|
+
user_email: h,
|
|
289
|
+
user_firstname: W.firstName,
|
|
290
|
+
user_lastname: W.lastName,
|
|
291
|
+
credential_source: Y.source,
|
|
292
|
+
sandbox: Q,
|
|
293
|
+
billing_cycle: M.billing_cycle,
|
|
294
|
+
trial: H,
|
|
295
|
+
trial_period_days: V,
|
|
296
|
+
trial_requires_payment_method: N.trial_requires_payment_method,
|
|
297
|
+
initial_order_status: U,
|
|
298
|
+
coupon: z?.code ?? null,
|
|
299
|
+
order_id: G.id
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
async function T(e, t, n, r) {
|
|
305
|
+
let i = (/* @__PURE__ */ new Date()).toUTCString().replace("GMT", "+0000"), a = `GET\n\n\n${i}\n${e}`, o = u.createHmac("sha256", r).update(a).digest("hex"), s = `FS ${t}:${n}:${Buffer.from(o).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "")}`, c = await fetch(`https://api.freemius.com${e}`, { headers: {
|
|
306
|
+
Authorization: s,
|
|
307
|
+
Date: i,
|
|
308
|
+
Accept: "application/json"
|
|
309
|
+
} });
|
|
310
|
+
if (!c.ok) {
|
|
311
|
+
let t = await c.text();
|
|
312
|
+
throw console.error(`[Freemius API] [ERROR] ${e} returned ${c.status}: ${t}`), Error(`Freemius API failed on ${e}: ${c.status} - ${t}`);
|
|
313
|
+
}
|
|
314
|
+
return c.json();
|
|
357
315
|
}
|
|
358
|
-
async function
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
E += K;
|
|
388
|
-
}
|
|
389
|
-
return { success: !0, count: E };
|
|
390
|
-
} catch (m) {
|
|
391
|
-
throw console.error("[Freemius Sync] Global Error:", m), m;
|
|
392
|
-
}
|
|
316
|
+
async function E() {
|
|
317
|
+
let e = f("FREEMIUS_DEVELOPER_ID"), t = f("FREEMIUS_PUBLIC_KEY"), n = f("FREEMIUS_SECRET_KEY"), r = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, i = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY;
|
|
318
|
+
if (!e || !t || !n || !r || !i) throw Error("Missing necessary environment variables for Freemius Sync.");
|
|
319
|
+
let a = l(r, i, { auth: {
|
|
320
|
+
autoRefreshToken: !1,
|
|
321
|
+
persistSession: !1
|
|
322
|
+
} }), o = (r) => T(r, e, t, n);
|
|
323
|
+
try {
|
|
324
|
+
console.log(`[Freemius Sync] Fetching all plugins for developer ${e}...`);
|
|
325
|
+
let t = _(await o(`/v1/developers/${e}/plugins.json`), ["plugins", "plugin"]);
|
|
326
|
+
console.log(`[Freemius Sync] Found ${t.length} plugins. Syncing plans...`);
|
|
327
|
+
let n = 0, { data: r } = await a.from("languages").select("id").eq("code", "en").single(), i = r?.id;
|
|
328
|
+
if (!i) throw Error("English language not found in database. Cannot sync products.");
|
|
329
|
+
for (let r of t) {
|
|
330
|
+
let t = r.id?.toString();
|
|
331
|
+
if (!t) {
|
|
332
|
+
console.warn("[Freemius Sync] Skipping plugin without an id:", r);
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
let s = await O(a, e, t, r.title || r.name || `Freemius Product ${t}`, o, i);
|
|
336
|
+
n += s;
|
|
337
|
+
}
|
|
338
|
+
return {
|
|
339
|
+
success: !0,
|
|
340
|
+
count: n
|
|
341
|
+
};
|
|
342
|
+
} catch (e) {
|
|
343
|
+
throw console.error("[Freemius Sync] Global Error:", e), e;
|
|
344
|
+
}
|
|
393
345
|
}
|
|
394
|
-
async function
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
r,
|
|
405
|
-
e,
|
|
406
|
-
l.title || l.name || `Freemius Product ${e}`,
|
|
407
|
-
m,
|
|
408
|
-
E
|
|
409
|
-
) };
|
|
346
|
+
async function D(e) {
|
|
347
|
+
let t = f("FREEMIUS_DEVELOPER_ID"), n = f("FREEMIUS_PUBLIC_KEY"), r = f("FREEMIUS_SECRET_KEY"), i = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, a = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY;
|
|
348
|
+
if (!t || !n || !r || !i || !a) throw Error("Missing environment variables for Freemius Sync.");
|
|
349
|
+
let o = l(i, a), s = (e) => T(e, t, n, r), { data: c } = await o.from("languages").select("id").eq("code", "en").single(), u = c?.id;
|
|
350
|
+
if (!u) throw Error("English language not found in database. Cannot sync products.");
|
|
351
|
+
let d = await s(`/v1/developers/${t}/plugins/${e}.json`), p = d.plugin ?? d;
|
|
352
|
+
return {
|
|
353
|
+
success: !0,
|
|
354
|
+
count: await O(o, t, e, p.title || p.name || `Freemius Product ${e}`, s, u)
|
|
355
|
+
};
|
|
410
356
|
}
|
|
411
|
-
async function
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
if (F) {
|
|
515
|
-
const { error: h } = await e.from("freemius_pricing").update(B).eq("id", F.id);
|
|
516
|
-
h && console.warn(
|
|
517
|
-
`[Freemius Sync] Could not update pricing ${F.id}:`,
|
|
518
|
-
h.message || h
|
|
519
|
-
);
|
|
520
|
-
} else {
|
|
521
|
-
const { error: h } = await e.from("freemius_pricing").insert({
|
|
522
|
-
plan_id: S,
|
|
523
|
-
license_quota: _,
|
|
524
|
-
...B
|
|
525
|
-
});
|
|
526
|
-
h && console.warn(
|
|
527
|
-
`[Freemius Sync] Could not insert pricing for plan ${S}, quota ${_}:`,
|
|
528
|
-
h.message || h
|
|
529
|
-
);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
console.log(`[Freemius Sync] Successfully fully synced product ${I.sku}.`), f++;
|
|
533
|
-
}
|
|
534
|
-
} catch (m) {
|
|
535
|
-
console.error(`[Freemius Sync] Failed sync for plugin ${t}:`, m.message);
|
|
536
|
-
}
|
|
537
|
-
return f;
|
|
357
|
+
async function O(e, t, n, r, i, a) {
|
|
358
|
+
console.log(`[Freemius Sync] Fetching plans for plugin: ${r} (${n})...`);
|
|
359
|
+
let o = 0;
|
|
360
|
+
try {
|
|
361
|
+
let s = _(await i(`/v1/developers/${t}/plugins/${n}/plans.json`), ["plans", "plan"]);
|
|
362
|
+
console.log(`[Freemius Sync] Received ${s.length} plans for plugin ${n}.`);
|
|
363
|
+
for (let c of s) {
|
|
364
|
+
let s = c.id?.toString();
|
|
365
|
+
if (!s) {
|
|
366
|
+
console.warn("[Freemius Sync] Skipping plan without an id:", c);
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
let l = c.name || c.title || s, u = c.title || l;
|
|
370
|
+
console.log(`[Freemius Sync] Processing plan: ${u} (${s})...`);
|
|
371
|
+
let d = c;
|
|
372
|
+
if (d.trial_period === void 0 || d.is_require_subscription === void 0) try {
|
|
373
|
+
let e = await i(`/v1/developers/${t}/plugins/${n}/plans/${s}.json`), r = e.plan ?? e;
|
|
374
|
+
d = {
|
|
375
|
+
...d,
|
|
376
|
+
...r
|
|
377
|
+
};
|
|
378
|
+
} catch (e) {
|
|
379
|
+
console.warn(`[Freemius Sync] Could not fetch trial details for plan ${s}:`, e instanceof Error ? e.message : e);
|
|
380
|
+
}
|
|
381
|
+
let f = m(d.trial_period), p = f > 0 && h(d.is_require_subscription), g = 0, x = [];
|
|
382
|
+
try {
|
|
383
|
+
if (x = _(await i(`/v1/developers/${t}/plugins/${n}/plans/${s}/pricing.json`), [
|
|
384
|
+
"pricing",
|
|
385
|
+
"prices",
|
|
386
|
+
"pricings"
|
|
387
|
+
]), x.length > 0) {
|
|
388
|
+
let e = x[0];
|
|
389
|
+
g = y(v(e.annual_price) ?? v(e.monthly_price) ?? v(e.lifetime_price));
|
|
390
|
+
}
|
|
391
|
+
console.log(`[Freemius Sync] Plan: ${u} -> Resolved Price (cents): ${g}`);
|
|
392
|
+
} catch (e) {
|
|
393
|
+
console.warn(`[Freemius Sync] Could not fetch pricing for plan ${s}:`, e instanceof Error ? e.message : e);
|
|
394
|
+
}
|
|
395
|
+
let S = `${r}-${u}`.toLowerCase().replace(/[^\w\s-]/g, "").replace(/[\s_]+/g, "-").replace(/^-+|-+$/g, ""), C = {
|
|
396
|
+
title: `${r} - ${u}`,
|
|
397
|
+
slug: S,
|
|
398
|
+
short_description: c.description || "",
|
|
399
|
+
price: g,
|
|
400
|
+
product_type: "digital",
|
|
401
|
+
payment_provider: "freemius",
|
|
402
|
+
freemius_plan_id: s,
|
|
403
|
+
freemius_product_id: n,
|
|
404
|
+
trial_period_days: f,
|
|
405
|
+
trial_requires_payment_method: p,
|
|
406
|
+
status: "active",
|
|
407
|
+
stock: 999,
|
|
408
|
+
sku: `FM-${n}-${s}`,
|
|
409
|
+
language_id: a
|
|
410
|
+
}, { data: w, error: T } = await e.from("products").upsert(C, { onConflict: "language_id, sku" }).select();
|
|
411
|
+
if (T || !w || w.length === 0) {
|
|
412
|
+
console.error(`[Freemius Sync] Error upserting product ${C.sku}:`, T);
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
let E = w[0].id, { data: D, error: O } = await e.from("freemius_plans").select("id").eq("product_id", E).eq("name", l).maybeSingle();
|
|
416
|
+
O && console.warn(`[Freemius Sync] Could not check existing local plan for ${C.sku}:`, O.message || O);
|
|
417
|
+
let k = "";
|
|
418
|
+
if (D) {
|
|
419
|
+
k = D.id;
|
|
420
|
+
let { error: t } = await e.from("freemius_plans").update({
|
|
421
|
+
title: u,
|
|
422
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
423
|
+
}).eq("id", k);
|
|
424
|
+
t && console.warn(`[Freemius Sync] Could not update local plan ${k}:`, t.message || t);
|
|
425
|
+
} else {
|
|
426
|
+
let { data: t, error: n } = await e.from("freemius_plans").insert({
|
|
427
|
+
product_id: E,
|
|
428
|
+
name: l,
|
|
429
|
+
title: u
|
|
430
|
+
}).select("id").single();
|
|
431
|
+
n && console.warn(`[Freemius Sync] Could not insert local plan for ${C.sku}:`, n.message || n), t && (k = t.id);
|
|
432
|
+
}
|
|
433
|
+
if (k && x.length > 0) for (let t of x) {
|
|
434
|
+
let n = b(t.licenses ?? t.license_quota ?? t.quota), { data: r, error: i } = await e.from("freemius_pricing").select("id").eq("plan_id", k).eq("license_quota", n).maybeSingle();
|
|
435
|
+
i && console.warn(`[Freemius Sync] Could not check pricing for plan ${k}, quota ${n}:`, i.message || i);
|
|
436
|
+
let a = {
|
|
437
|
+
api_monthly_price: v(t.monthly_price),
|
|
438
|
+
api_annual_price: v(t.annual_price),
|
|
439
|
+
api_lifetime_price: v(t.lifetime_price),
|
|
440
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
441
|
+
};
|
|
442
|
+
if (r) {
|
|
443
|
+
let { error: t } = await e.from("freemius_pricing").update(a).eq("id", r.id);
|
|
444
|
+
t && console.warn(`[Freemius Sync] Could not update pricing ${r.id}:`, t.message || t);
|
|
445
|
+
} else {
|
|
446
|
+
let { error: t } = await e.from("freemius_pricing").insert({
|
|
447
|
+
plan_id: k,
|
|
448
|
+
license_quota: n,
|
|
449
|
+
...a
|
|
450
|
+
});
|
|
451
|
+
t && console.warn(`[Freemius Sync] Could not insert pricing for plan ${k}, quota ${n}:`, t.message || t);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
console.log(`[Freemius Sync] Successfully fully synced product ${C.sku}.`), o++;
|
|
455
|
+
}
|
|
456
|
+
} catch (e) {
|
|
457
|
+
console.error(`[Freemius Sync] Failed sync for plugin ${n}:`, e.message);
|
|
458
|
+
}
|
|
459
|
+
return o;
|
|
538
460
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
Ee as parseFreemiusCheckoutCredentialsMap,
|
|
542
|
-
o as readFreemiusEnvValue,
|
|
543
|
-
ge as resolveFreemiusCheckoutCredentials,
|
|
544
|
-
Re as syncFreemiusProductsToSupabase,
|
|
545
|
-
$e as syncSingleFreemiusProduct
|
|
546
|
-
};
|
|
461
|
+
//#endregion
|
|
462
|
+
export { w as FreemiusProvider, x as parseFreemiusCheckoutCredentialsMap, f as readFreemiusEnvValue, S as resolveFreemiusCheckoutCredentials, E as syncFreemiusProductsToSupabase, D as syncSingleFreemiusProduct };
|