@nextblock-cms/ecom 0.20.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_virtual/_rolldown/runtime.cjs.js +1 -0
- package/index.cjs.js +1 -1
- package/index.es.js +38 -146
- package/lib/CurrencyProvider.cjs.js +1 -1
- package/lib/CurrencyProvider.d.ts +1 -1
- package/lib/CurrencyProvider.es.js +85 -95
- package/lib/PaymentReadinessProvider.cjs.js +1 -1
- package/lib/PaymentReadinessProvider.d.ts +1 -1
- package/lib/PaymentReadinessProvider.es.js +24 -27
- package/lib/cart-store.cjs.js +1 -1
- package/lib/cart-store.es.js +109 -121
- package/lib/components/AccountNavigationMenu.cjs.js +1 -1
- package/lib/components/AccountNavigationMenu.d.ts +1 -1
- package/lib/components/AccountNavigationMenu.es.js +36 -50
- package/lib/components/AddToCartButton.cjs.js +1 -1
- package/lib/components/AddToCartButton.d.ts +1 -1
- package/lib/components/AddToCartButton.es.js +94 -89
- package/lib/components/Cart.cjs.js +1 -1
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +261 -180
- package/lib/components/CartDrawer.cjs.js +1 -1
- package/lib/components/CartDrawer.d.ts +1 -1
- package/lib/components/CartDrawer.es.js +218 -148
- package/lib/components/CartIcon.cjs.js +1 -1
- package/lib/components/CartIcon.d.ts +1 -1
- package/lib/components/CartIcon.es.js +33 -35
- package/lib/components/Checkout.cjs.js +1 -1
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +1092 -1108
- package/lib/components/CouponForm.cjs.js +1 -1
- package/lib/components/CouponForm.d.ts +1 -1
- package/lib/components/CouponForm.es.js +136 -148
- package/lib/components/CurrencySwitcher.cjs.js +1 -1
- package/lib/components/CurrencySwitcher.d.ts +1 -1
- package/lib/components/CurrencySwitcher.es.js +22 -18
- package/lib/components/CustomerProfileForm.cjs.js +1 -1
- package/lib/components/CustomerProfileForm.es.js +454 -313
- package/lib/components/FeaturedProduct.cjs.js +1 -1
- package/lib/components/FeaturedProduct.d.ts +1 -1
- package/lib/components/FeaturedProduct.es.js +98 -83
- package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
- package/lib/components/FreemiusLicensePanel.d.ts +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +70 -65
- package/lib/components/InvoiceDocument.cjs.js +1 -1
- package/lib/components/InvoiceDocument.es.js +256 -192
- package/lib/components/InvoiceViewerShell.cjs.js +2 -2
- package/lib/components/InvoiceViewerShell.d.ts +1 -1
- package/lib/components/InvoiceViewerShell.es.js +75 -106
- package/lib/components/ProductCard.cjs.js +1 -1
- package/lib/components/ProductCard.d.ts +1 -1
- package/lib/components/ProductCard.es.js +186 -171
- package/lib/components/ProductDetailsLayout.cjs.js +1 -1
- package/lib/components/ProductDetailsLayout.es.js +405 -404
- package/lib/components/ProductGallery.cjs.js +1 -1
- package/lib/components/ProductGallery.d.ts +1 -1
- package/lib/components/ProductGallery.es.js +51 -54
- package/lib/components/ProductGrid.cjs.js +1 -1
- package/lib/components/ProductGrid.d.ts +1 -1
- package/lib/components/ProductGrid.es.js +23 -25
- package/lib/components/ShippingEstimator.cjs.js +1 -1
- package/lib/components/ShippingEstimator.d.ts +1 -1
- package/lib/components/ShippingEstimator.es.js +158 -153
- package/lib/components/ShortDescription.cjs.js +1 -1
- package/lib/components/ShortDescription.es.js +17 -17
- package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
- package/lib/components/SimpleTiptapRenderer.es.js +238 -211
- package/lib/components/SubscriptionSelector.cjs.js +1 -1
- package/lib/components/SubscriptionSelector.es.js +159 -154
- package/lib/countries.cjs.js +1 -1
- package/lib/countries.es.js +232 -75
- package/lib/coupon-server.cjs.js +1 -1
- package/lib/coupon-server.es.js +180 -224
- package/lib/coupons.cjs.js +1 -1
- package/lib/coupons.es.js +12 -14
- package/lib/currency-constants.cjs.js +1 -1
- package/lib/currency-constants.es.js +4 -4
- package/lib/currency-rest-client.cjs.js +1 -1
- package/lib/currency-rest-client.es.js +15 -22
- package/lib/currency-store.cjs.js +1 -1
- package/lib/currency-store.es.js +20 -27
- package/lib/currency-sync.cjs.js +1 -1
- package/lib/currency-sync.es.js +124 -170
- package/lib/currency.cjs.js +1 -1
- package/lib/currency.es.js +242 -310
- package/lib/customer-addresses.cjs.js +1 -1
- package/lib/customer-addresses.es.js +80 -109
- package/lib/customer-orders.cjs.js +1 -1
- package/lib/customer-orders.es.js +31 -43
- package/lib/customer.cjs.js +1 -1
- package/lib/customer.es.js +43 -52
- package/lib/export-helpers.cjs.js +1 -1
- package/lib/export-helpers.es.js +53 -52
- package/lib/factory.cjs.js +1 -1
- package/lib/factory.es.js +10 -7
- package/lib/freemius-coupons.cjs.js +1 -1
- package/lib/freemius-coupons.es.js +245 -262
- package/lib/freemius-license-claim.cjs.js +1 -1
- package/lib/freemius-license-claim.es.js +87 -71
- package/lib/freemius-license.cjs.js +1 -1
- package/lib/freemius-license.es.js +32 -39
- package/lib/freemius-order-sync.cjs.js +1 -1
- package/lib/freemius-order-sync.es.js +226 -290
- package/lib/freemius-trial-provision.cjs.js +1 -1
- package/lib/freemius-trial-provision.es.js +136 -130
- package/lib/inventory-settings.cjs.js +1 -1
- package/lib/inventory-settings.es.js +69 -77
- package/lib/invoice-server.cjs.js +3 -3
- package/lib/invoice-server.es.js +94 -141
- package/lib/invoice-ui.cjs.js +1 -1
- package/lib/invoice-ui.es.js +50 -66
- package/lib/invoice.cjs.js +1 -1
- package/lib/invoice.es.js +85 -94
- package/lib/order-inventory.cjs.js +25 -25
- package/lib/order-inventory.es.js +67 -79
- package/lib/order-tax-details.cjs.js +1 -1
- package/lib/order-tax-details.es.js +142 -153
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
- 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.js +2 -2
- 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.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- package/lib/pages/cms/coupons/actions.es.js +112 -115
- package/lib/pages/cms/coupons/index.cjs.js +1 -0
- package/lib/pages/cms/coupons/index.es.js +3 -0
- package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
- package/lib/pages/cms/coupons/product-options.es.js +21 -23
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- 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.js +3 -3
- package/lib/pages/cms/orders/actions.es.js +53 -69
- package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/export-actions.es.js +23 -26
- package/lib/pages/cms/orders/index.cjs.js +1 -0
- package/lib/pages/cms/orders/index.es.js +6 -0
- package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/server-actions.es.js +60 -51
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- package/lib/pages/cms/payments/actions.es.js +38 -48
- package/lib/pages/cms/payments/index.cjs.js +1 -0
- package/lib/pages/cms/payments/index.es.js +3 -0
- package/lib/pages/cms/payments/queries.cjs.js +1 -1
- package/lib/pages/cms/payments/queries.es.js +38 -48
- package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
- 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.d.ts +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
- package/lib/pages/cms/products/actions.cjs.js +4 -4
- package/lib/pages/cms/products/actions.es.js +121 -162
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- 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.js +2 -2
- 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.js +1 -1
- 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.js +1 -0
- package/lib/pages/cms/products/index.es.js +8 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
- 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.js +2 -2
- 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.js +3 -3
- package/lib/pages/cms/products/inventory/actions.es.js +83 -91
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
- 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.js +1 -1
- package/lib/pages/cms/products/product-price-sync.es.js +74 -89
- package/lib/pages/cms/products/server-actions.cjs.js +1 -1
- package/lib/pages/cms/products/server-actions.es.js +250 -233
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
- package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
- 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.js +1 -1
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
- package/lib/pages/cms/shipping/index.cjs.js +1 -0
- package/lib/pages/cms/shipping/index.es.js +3 -0
- package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
- package/lib/pages/cms/shipping/server-actions.es.js +131 -149
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
- 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.js +1 -1
- package/lib/pages/cms/taxes/actions.es.js +41 -53
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
- 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.js +1 -0
- package/lib/pages/cms/taxes/index.es.js +3 -0
- package/lib/payment-config.cjs.js +1 -1
- package/lib/payment-config.es.js +110 -126
- package/lib/product-actions.cjs.js +4 -4
- package/lib/product-actions.es.js +289 -544
- package/lib/product-context.cjs.js +1 -1
- package/lib/product-context.es.js +13 -15
- package/lib/product-schema.cjs.js +1 -1
- package/lib/product-schema.es.js +99 -134
- package/lib/providers/freemius.cjs.js +1 -5
- package/lib/providers/freemius.es.js +446 -530
- package/lib/providers/stripe.cjs.js +1 -1
- package/lib/providers/stripe.es.js +417 -477
- package/lib/server-actions/coupon-actions.cjs.js +1 -1
- package/lib/server-actions/coupon-actions.es.js +22 -22
- package/lib/server-actions/customer-actions.cjs.js +1 -1
- package/lib/server-actions/customer-actions.es.js +26 -28
- package/lib/server-actions/product-actions.cjs.js +1 -1
- package/lib/server-actions/product-actions.es.js +9 -15
- package/lib/server-actions/shipping-actions.cjs.js +1 -1
- package/lib/server-actions/shipping-actions.es.js +27 -24
- package/lib/server-actions/tax-actions.cjs.js +1 -1
- package/lib/server-actions/tax-actions.es.js +33 -39
- package/lib/shared-inventory.cjs.js +2 -2
- package/lib/shared-inventory.es.js +111 -160
- package/lib/shipping/resolver.cjs.js +2 -2
- package/lib/shipping/resolver.es.js +44 -61
- package/lib/shipping-rate-currency.cjs.js +1 -1
- package/lib/shipping-rate-currency.es.js +52 -67
- package/lib/states.cjs.js +1 -1
- package/lib/states.es.js +333 -154
- package/lib/stripe/checkout.cjs.js +1 -1
- package/lib/stripe/checkout.es.js +125 -181
- package/lib/stripe/client.cjs.js +1 -1
- package/lib/stripe/client.es.js +14 -19
- package/lib/stripe/order-sync.cjs.js +1 -1
- package/lib/stripe/order-sync.es.js +106 -126
- package/lib/stripe/webhooks.cjs.js +1 -1
- package/lib/stripe/webhooks.es.js +37 -31
- package/lib/tax-calculation.cjs.js +1 -1
- package/lib/tax-calculation.es.js +84 -98
- package/lib/trials.cjs.js +1 -1
- package/lib/trials.es.js +24 -30
- package/lib/types.cjs.js +1 -1
- package/lib/types.es.js +21 -27
- package/lib/use-cart.cjs.js +1 -1
- package/lib/use-cart.es.js +38 -40
- package/lib/use-price-formatter.cjs.js +1 -1
- package/lib/use-price-formatter.es.js +10 -11
- package/lib/variation-utils.cjs.js +1 -1
- package/lib/variation-utils.es.js +199 -261
- package/lib/zod-config.cjs.js +1 -1
- package/lib/zod-config.es.js +5 -6
- package/package.json +16 -16
- package/server.cjs.js +1 -1
- package/server.es.js +56 -211
|
@@ -1,136 +1,142 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { hydrateFreemiusEnvFromDb as e } from "./payment-config.es.js";
|
|
2
|
+
import { resolveFreemiusCheckoutCredentials as t } from "./providers/freemius.es.js";
|
|
3
|
+
import { Freemius as n } from "@freemius/sdk";
|
|
4
|
+
//#region libs/ecommerce/src/lib/freemius-trial-provision.ts
|
|
5
|
+
var r = "A NextBlock license or trial already exists for this email. Activate that key from CMS Settings → Packages, or purchase a license at nextblock.dev.", i = "The trial could not be provisioned automatically. Start it from CMS Settings → Packages instead.";
|
|
6
|
+
function a(e) {
|
|
7
|
+
return e.toISOString().slice(0, 19).replace("T", " ");
|
|
7
8
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
function o(e, t) {
|
|
10
|
+
let n = Number.isFinite(t) && t > 0 ? Math.floor(t) : 30;
|
|
11
|
+
return new Date(e.getTime() + n * 24 * 60 * 60 * 1e3);
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return [...i.length > 0 ? i : n].sort((t, s) => {
|
|
18
|
-
const l = t.licenses === null || t.licenses === void 0 ? Number.POSITIVE_INFINITY : t.licenses, u = s.licenses === null || s.licenses === void 0 ? Number.POSITIVE_INFINITY : s.licenses;
|
|
19
|
-
return l - u;
|
|
20
|
-
})[0];
|
|
13
|
+
function s(e) {
|
|
14
|
+
let t = e.filter((e) => e.id !== null && e.id !== void 0);
|
|
15
|
+
if (t.length === 0) return null;
|
|
16
|
+
let n = t.filter((e) => !e.is_hidden);
|
|
17
|
+
return [...n.length > 0 ? n : t].sort((e, t) => (e.licenses === null || e.licenses === void 0 ? Infinity : e.licenses) - (t.licenses === null || t.licenses === void 0 ? Infinity : t.licenses))[0];
|
|
21
18
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
function c(e) {
|
|
20
|
+
return e.existingLicenses.some((t) => t.plugin_id === null || t.plugin_id === void 0 || String(t.plugin_id).trim() === String(e.productId).trim()) ? {
|
|
21
|
+
ok: !1,
|
|
22
|
+
reason: "already_licensed"
|
|
23
|
+
} : { ok: !0 };
|
|
26
24
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
25
|
+
function l(e) {
|
|
26
|
+
return e.trim().toLowerCase();
|
|
29
27
|
}
|
|
30
|
-
async function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
28
|
+
async function u(u, d) {
|
|
29
|
+
await e();
|
|
30
|
+
let f = t(u.productId);
|
|
31
|
+
if (!f.apiKey || !f.secretKey || !f.publicKey) return {
|
|
32
|
+
error: "The license service is not configured for this product.",
|
|
33
|
+
ok: !1,
|
|
34
|
+
reason: "not_configured",
|
|
35
|
+
status: 503
|
|
36
|
+
};
|
|
37
|
+
let p = new n({
|
|
38
|
+
apiKey: f.apiKey,
|
|
39
|
+
productId: Number(u.productId),
|
|
40
|
+
publicKey: f.publicKey,
|
|
41
|
+
secretKey: f.secretKey
|
|
42
|
+
}), m = l(u.email), h = p.api.__unstable_ApiClient, g = { product_id: u.productId }, _ = [];
|
|
43
|
+
try {
|
|
44
|
+
let e = await p.api.user.retrieveByEmail(m);
|
|
45
|
+
e?.id !== null && e?.id !== void 0 && (_ = await p.api.user.retrieveLicenses(e.id));
|
|
46
|
+
} catch (e) {
|
|
47
|
+
return console.error("[Freemius trial] user lookup failed:", e), {
|
|
48
|
+
error: "Freemius could not be reached to verify eligibility.",
|
|
49
|
+
ok: !1,
|
|
50
|
+
reason: "upstream_error",
|
|
51
|
+
status: 502
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (!c({
|
|
55
|
+
existingLicenses: _,
|
|
56
|
+
productId: u.productId
|
|
57
|
+
}).ok) return {
|
|
58
|
+
error: r,
|
|
59
|
+
ok: !1,
|
|
60
|
+
reason: "already_licensed",
|
|
61
|
+
status: 409
|
|
62
|
+
};
|
|
63
|
+
let v = null;
|
|
64
|
+
try {
|
|
65
|
+
let { data: e, error: t } = await h.GET("/products/{product_id}/plans/{plan_id}/pricing.json", { params: { path: {
|
|
66
|
+
...g,
|
|
67
|
+
plan_id: u.planId
|
|
68
|
+
} } });
|
|
69
|
+
if (t) throw Error(JSON.stringify(t));
|
|
70
|
+
let n = s(e?.pricing ?? []);
|
|
71
|
+
v = n?.id !== null && n?.id !== void 0 ? String(n.id) : null;
|
|
72
|
+
} catch (e) {
|
|
73
|
+
return console.error("[Freemius trial] pricing lookup failed:", e), {
|
|
74
|
+
error: "Freemius could not be reached to resolve the plan pricing.",
|
|
75
|
+
ok: !1,
|
|
76
|
+
reason: "upstream_error",
|
|
77
|
+
status: 502
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (!v) return {
|
|
81
|
+
error: i,
|
|
82
|
+
ok: !1,
|
|
83
|
+
reason: "no_pricing",
|
|
84
|
+
status: 502
|
|
85
|
+
};
|
|
86
|
+
let y = a(o(d?.now ?? /* @__PURE__ */ new Date(), u.trialDays)), b = null, x = null;
|
|
87
|
+
try {
|
|
88
|
+
let { data: e, error: t } = await h.POST("/products/{product_id}/plans/{plan_id}/pricing/{pricing_id}/licenses.json", {
|
|
89
|
+
body: {
|
|
90
|
+
expires_at: y,
|
|
91
|
+
is_block_features: !0,
|
|
92
|
+
send_email: !1
|
|
93
|
+
},
|
|
94
|
+
params: { path: {
|
|
95
|
+
...g,
|
|
96
|
+
plan_id: u.planId,
|
|
97
|
+
pricing_id: v
|
|
98
|
+
} }
|
|
99
|
+
});
|
|
100
|
+
if (t) throw Error(JSON.stringify(t));
|
|
101
|
+
let n = e?.license;
|
|
102
|
+
b = n?.secret_key?.trim() || null, x = n?.id !== null && n?.id !== void 0 ? String(n.id) : null;
|
|
103
|
+
} catch (e) {
|
|
104
|
+
return console.error("[Freemius trial] license creation failed:", e), {
|
|
105
|
+
error: "Freemius could not create the trial license.",
|
|
106
|
+
ok: !1,
|
|
107
|
+
reason: "upstream_error",
|
|
108
|
+
status: 502
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (!b) return {
|
|
112
|
+
error: i,
|
|
113
|
+
ok: !1,
|
|
114
|
+
reason: "no_key",
|
|
115
|
+
status: 502
|
|
116
|
+
};
|
|
117
|
+
let S = !1;
|
|
118
|
+
try {
|
|
119
|
+
let { error: e } = await h.PUT("/products/{product_id}/licenses.json", {
|
|
120
|
+
body: {
|
|
121
|
+
email: m,
|
|
122
|
+
license_key: b,
|
|
123
|
+
name: u.name.trim()
|
|
124
|
+
},
|
|
125
|
+
params: { path: g }
|
|
126
|
+
});
|
|
127
|
+
S = !e, e && console.warn("[Freemius trial] license assignment refused:", JSON.stringify(e));
|
|
128
|
+
} catch (e) {
|
|
129
|
+
console.warn("[Freemius trial] license assignment failed:", e);
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
assigned: S,
|
|
133
|
+
expiresAt: y,
|
|
134
|
+
licenseId: x,
|
|
135
|
+
licenseKey: b,
|
|
136
|
+
ok: !0,
|
|
137
|
+
planId: u.planId,
|
|
138
|
+
pricingId: v
|
|
139
|
+
};
|
|
127
140
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
g as FREEMIUS_TRIAL_PROVISION_FAILED_MESSAGE,
|
|
131
|
-
v as computeTrialExpiry,
|
|
132
|
-
F as evaluateTrialEligibility,
|
|
133
|
-
E as formatFreemiusTimestamp,
|
|
134
|
-
w as pickTrialPricing,
|
|
135
|
-
x as provisionFreemiusTrialLicense
|
|
136
|
-
};
|
|
141
|
+
//#endregion
|
|
142
|
+
export { r as FREEMIUS_TRIAL_ALREADY_USED_MESSAGE, i as FREEMIUS_TRIAL_PROVISION_FAILED_MESSAGE, o as computeTrialExpiry, c as evaluateTrialEligibility, a as formatFreemiusTimestamp, s as pickTrialPricing, u as provisionFreemiusTrialLicense };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var e=`ecommerce_inventory_settings`,t={trackQuantities:!0,enableTaxes:!1,taxCalculationMode:`manual`};function n(e,t=!0){if(typeof e==`boolean`)return e;if(typeof e==`string`){let t=e.trim().toLowerCase();if([`true`,`1`,`yes`,`on`].includes(t))return!0;if([`false`,`0`,`no`,`off`].includes(t))return!1}return t}function r(e,n=t.taxCalculationMode){return e===`automatic`?`automatic`:e===`manual`?`manual`:n}function i(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let i=e;return{trackQuantities:n(i.trackQuantities??i.track_quantities,t.trackQuantities),enableTaxes:n(i.enableTaxes??i.enable_taxes,t.enableTaxes),taxCalculationMode:r(i.taxCalculationMode??i.tax_calculation_mode,t.taxCalculationMode)}}return{trackQuantities:n(e,t.trackQuantities),enableTaxes:t.enableTaxes,taxCalculationMode:t.taxCalculationMode}}async function a(n){let{data:r,error:a}=await n.from(`site_settings`).select(`value`).eq(`key`,e).maybeSingle();return a||!r?t:i(r.value)}async function o(t,n){return t.from(`site_settings`).upsert({key:e,value:{track_quantities:n.trackQuantities,enable_taxes:n.enableTaxes,tax_calculation_mode:n.taxCalculationMode}})}function s(e){return{error:`${e} is no longer available.`,errorKey:`ecommerce.inventory_item_unavailable`,errorParams:{item:e},errorStatus:409}}function c(e,t){return{error:`Only ${t} units remain for ${e}.`,errorKey:`ecommerce.inventory_insufficient`,errorParams:{item:e,count:t},errorStatus:409}}exports.DEFAULT_ECOMMERCE_INVENTORY_SETTINGS=t,exports.ECOMMERCE_INVENTORY_SETTINGS_KEY=e,exports.createInventoryInsufficientError=c,exports.createInventoryUnavailableError=s,exports.getEcommerceInventorySettings=a,exports.normalizeEcommerceInventorySettings=i,exports.upsertEcommerceInventorySettings=o;
|
|
@@ -1,86 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//#region libs/ecommerce/src/lib/inventory-settings.ts
|
|
2
|
+
var e = "ecommerce_inventory_settings", t = {
|
|
3
|
+
trackQuantities: !0,
|
|
4
|
+
enableTaxes: !1,
|
|
5
|
+
taxCalculationMode: "manual"
|
|
5
6
|
};
|
|
6
7
|
function n(e, t = !0) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
if (typeof e == "boolean") return e;
|
|
9
|
+
if (typeof e == "string") {
|
|
10
|
+
let t = e.trim().toLowerCase();
|
|
11
|
+
if ([
|
|
12
|
+
"true",
|
|
13
|
+
"1",
|
|
14
|
+
"yes",
|
|
15
|
+
"on"
|
|
16
|
+
].includes(t)) return !0;
|
|
17
|
+
if ([
|
|
18
|
+
"false",
|
|
19
|
+
"0",
|
|
20
|
+
"no",
|
|
21
|
+
"off"
|
|
22
|
+
].includes(t)) return !1;
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
17
25
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
26
|
+
function r(e, n = t.taxCalculationMode) {
|
|
27
|
+
return e === "automatic" ? "automatic" : e === "manual" ? "manual" : n;
|
|
20
28
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
a.taxCalculationMode
|
|
36
|
-
)
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
trackQuantities: n(
|
|
41
|
-
e,
|
|
42
|
-
a.trackQuantities
|
|
43
|
-
),
|
|
44
|
-
enableTaxes: a.enableTaxes,
|
|
45
|
-
taxCalculationMode: a.taxCalculationMode
|
|
46
|
-
};
|
|
29
|
+
function i(e) {
|
|
30
|
+
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
31
|
+
let i = e;
|
|
32
|
+
return {
|
|
33
|
+
trackQuantities: n(i.trackQuantities ?? i.track_quantities, t.trackQuantities),
|
|
34
|
+
enableTaxes: n(i.enableTaxes ?? i.enable_taxes, t.enableTaxes),
|
|
35
|
+
taxCalculationMode: r(i.taxCalculationMode ?? i.tax_calculation_mode, t.taxCalculationMode)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
trackQuantities: n(e, t.trackQuantities),
|
|
40
|
+
enableTaxes: t.enableTaxes,
|
|
41
|
+
taxCalculationMode: t.taxCalculationMode
|
|
42
|
+
};
|
|
47
43
|
}
|
|
48
|
-
async function
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
async function a(n) {
|
|
45
|
+
let { data: r, error: a } = await n.from("site_settings").select("value").eq("key", e).maybeSingle();
|
|
46
|
+
return a || !r ? t : i(r.value);
|
|
51
47
|
}
|
|
52
|
-
async function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
async function o(t, n) {
|
|
49
|
+
return t.from("site_settings").upsert({
|
|
50
|
+
key: e,
|
|
51
|
+
value: {
|
|
52
|
+
track_quantities: n.trackQuantities,
|
|
53
|
+
enable_taxes: n.enableTaxes,
|
|
54
|
+
tax_calculation_mode: n.taxCalculationMode
|
|
55
|
+
}
|
|
56
|
+
});
|
|
61
57
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
function s(e) {
|
|
59
|
+
return {
|
|
60
|
+
error: `${e} is no longer available.`,
|
|
61
|
+
errorKey: "ecommerce.inventory_item_unavailable",
|
|
62
|
+
errorParams: { item: e },
|
|
63
|
+
errorStatus: 409
|
|
64
|
+
};
|
|
69
65
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
function c(e, t) {
|
|
67
|
+
return {
|
|
68
|
+
error: `Only ${t} units remain for ${e}.`,
|
|
69
|
+
errorKey: "ecommerce.inventory_insufficient",
|
|
70
|
+
errorParams: {
|
|
71
|
+
item: e,
|
|
72
|
+
count: t
|
|
73
|
+
},
|
|
74
|
+
errorStatus: 409
|
|
75
|
+
};
|
|
77
76
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
o as ECOMMERCE_INVENTORY_SETTINGS_KEY,
|
|
81
|
-
f as createInventoryInsufficientError,
|
|
82
|
-
l as createInventoryUnavailableError,
|
|
83
|
-
u as getEcommerceInventorySettings,
|
|
84
|
-
c as normalizeEcommerceInventorySettings,
|
|
85
|
-
s as upsertEcommerceInventorySettings
|
|
86
|
-
};
|
|
77
|
+
//#endregion
|
|
78
|
+
export { t as DEFAULT_ECOMMERCE_INVENTORY_SETTINGS, e as ECOMMERCE_INVENTORY_SETTINGS_KEY, c as createInventoryInsufficientError, s as createInventoryUnavailableError, a as getEcommerceInventorySettings, i as normalizeEcommerceInventorySettings, o as upsertEcommerceInventorySettings };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./customer.cjs.js"),t=require("./invoice.cjs.js"),n=require("./order-tax-details.cjs.js");let r=require("@nextblock-cms/db/server");function i(e){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}function a(e){return e??(0,r.getServiceRoleSupabaseClient)()}function o(e){if(!e)return null;let t=e.media?.object_key??e.media?.file_path??null;return{id:e.id,name:e.name??null,url:i(t),width:e.media?.width??null,height:e.media?.height??null}}var s=`active_logo_id`,c=`
|
|
2
2
|
id,
|
|
3
3
|
name,
|
|
4
4
|
media:media_id (
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
width,
|
|
8
8
|
height
|
|
9
9
|
)
|
|
10
|
-
`;async function
|
|
10
|
+
`;async function l(e){let{data:t}=await e.from(`site_settings`).select(`value`).eq(`key`,s).maybeSingle(),n=t?.value,r=typeof n==`string`&&n.length>0?n:null;if(r){let{data:t}=await e.from(`logos`).select(c).eq(`id`,r).maybeSingle();if(t)return t}let{data:i}=await e.from(`logos`).select(c).order(`created_at`,{ascending:!1}).limit(1).maybeSingle();return i??null}async function u(e){let n=a(e),[r,i]=await Promise.all([n.from(`site_settings`).select(`value`).eq(`key`,t.INVOICE_SETTINGS_KEY).maybeSingle(),l(n)]);return{settings:t.normalizeInvoiceSettings(r.data?.value??t.DEFAULT_INVOICE_SETTINGS),logo:o(i)}}async function d(e){let{data:t,error:n}=await a(e.client).rpc(`assign_order_invoice_metadata`,{p_order_id:e.orderId,p_paid_at:e.paidAt??null}).single();if(n)throw Error(n.message);return{invoiceNumber:t?.invoice_number??null,paidAt:t?.paid_at??null}}async function f(t,r){let i=a(r),{data:o,error:s}=await i.from(`orders`).select(`
|
|
11
11
|
id,
|
|
12
12
|
invoice_number,
|
|
13
13
|
paid_at,
|
|
@@ -30,4 +30,4 @@
|
|
|
30
30
|
quantity,
|
|
31
31
|
price_at_purchase
|
|
32
32
|
)
|
|
33
|
-
`).eq(
|
|
33
|
+
`).eq(`id`,t).single();if(s||!o)throw Error(s?.message||`Order not found`);let c=(o.order_items||[]).map(e=>e.product_id).filter(Boolean),l=(o.order_items||[]).map(e=>e.variant_id).filter(Boolean),[u,d]=await Promise.all([c.length?i.from(`products`).select(`id, title, sku`).in(`id`,c):Promise.resolve({data:[],error:null}),l.length?i.from(`product_variants`).select(`id, sku`).in(`id`,l):Promise.resolve({data:[],error:null})]),f=new Map((u.data||[]).map(e=>[e.id,e])),p=new Map((d.data||[]).map(e=>[e.id,e])),m=(o.order_items||[]).map(e=>{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;return{id:e.id,product_id:e.product_id??null,variant_id:e.variant_id??null,title:r,description:i,quantity:e.quantity,unit_amount:e.price_at_purchase,total_amount:e.price_at_purchase*e.quantity,sku:n?.sku??t?.sku??null}});return{id:o.id,invoice_number:o.invoice_number??null,paid_at:o.paid_at??null,created_at:o.created_at??null,currency:o.currency||`usd`,status:o.status,provider:o.provider??null,subtotal:typeof o.subtotal==`number`?o.subtotal:m.reduce((e,t)=>e+t.total_amount,0),shipping_total:typeof o.shipping_total==`number`?o.shipping_total:0,discount_total:typeof o.discount_total==`number`?o.discount_total:0,coupon_code:o.coupon_code??null,tax_total:typeof o.tax_total==`number`?o.tax_total:0,total:o.total,customer_details:e.normalizeOrderCustomerDetails(o.customer_details??{}),tax_details:n.normalizeOrderTaxDetails(o.tax_details),items:m}}async function p(e,t){let n=a(t),[r,i]=await Promise.all([f(e,n),u(n)]);return{order:r,settings:i.settings,logo:i.logo}}exports.assignInvoiceMetadata=d,exports.getInvoiceBrandingData=u,exports.getInvoiceOrder=f,exports.getInvoicePresentationData=p;
|