@nextblock-cms/ecom 0.20.3 → 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,171 +1,122 @@
|
|
|
1
|
+
import { getServiceRoleSupabaseClient as e } from "@nextblock-cms/db/server";
|
|
1
2
|
import "server-only";
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
3
|
+
//#region libs/ecommerce/src/lib/shared-inventory.ts
|
|
4
|
+
function t(t) {
|
|
5
|
+
return t ?? e();
|
|
5
6
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
7
|
+
function n(e) {
|
|
8
|
+
return e ? (Array.isArray(e) ? e : [e]).map((e) => e?.code?.toUpperCase().trim()).filter((e) => !!e) : [];
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
10
|
+
function r(e) {
|
|
11
|
+
return [...new Set(e)].sort((e, t) => e.localeCompare(t));
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
13
|
+
function i(e, t) {
|
|
14
|
+
return !e || e === t ? t : "mixed";
|
|
14
15
|
}
|
|
15
|
-
async function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return;
|
|
27
|
-
const { error: o } = await a.from("inventory_items").upsert(r, { onConflict: "sku" });
|
|
28
|
-
if (o)
|
|
29
|
-
throw new Error(o.message);
|
|
16
|
+
async function a(e, t) {
|
|
17
|
+
let n = Array.from(t.reduce((e, t) => {
|
|
18
|
+
let n = t.sku.trim();
|
|
19
|
+
return n && e.set(n, {
|
|
20
|
+
sku: n,
|
|
21
|
+
quantity: Math.max(0, Math.trunc(t.quantity))
|
|
22
|
+
}), e;
|
|
23
|
+
}, /* @__PURE__ */ new Map()).values());
|
|
24
|
+
if (n.length === 0) return;
|
|
25
|
+
let { error: r } = await e.from("inventory_items").upsert(n, { onConflict: "sku" });
|
|
26
|
+
if (r) throw Error(r.message);
|
|
30
27
|
}
|
|
31
|
-
async function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const { data: o, error: u } = await a.from("inventory_items").select("sku, quantity").in("sku", r);
|
|
38
|
-
if (u)
|
|
39
|
-
throw new Error(u.message);
|
|
40
|
-
return new Map(
|
|
41
|
-
(o || []).map((s) => [
|
|
42
|
-
s.sku,
|
|
43
|
-
Math.max(0, s.quantity ?? 0)
|
|
44
|
-
])
|
|
45
|
-
);
|
|
28
|
+
async function o(e, t) {
|
|
29
|
+
let n = r(t.map((e) => e.trim()).filter(Boolean));
|
|
30
|
+
if (n.length === 0) return /* @__PURE__ */ new Map();
|
|
31
|
+
let { data: i, error: a } = await e.from("inventory_items").select("sku, quantity").in("sku", n);
|
|
32
|
+
if (a) throw Error(a.message);
|
|
33
|
+
return new Map((i || []).map((e) => [e.sku, Math.max(0, e.quantity ?? 0)]));
|
|
46
34
|
}
|
|
47
|
-
async function
|
|
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
|
-
usageType: t,
|
|
80
|
-
productTitles: /* @__PURE__ */ new Set([c.title]),
|
|
81
|
-
parentProductSkus: /* @__PURE__ */ new Set([c.sku]),
|
|
82
|
-
languages: new Set(y),
|
|
83
|
-
statuses: /* @__PURE__ */ new Set([c.status]),
|
|
84
|
-
productIds: /* @__PURE__ */ new Set([c.id]),
|
|
85
|
-
variantIds: d ? /* @__PURE__ */ new Set([d]) : /* @__PURE__ */ new Set()
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
for (const s of n || []) {
|
|
89
|
-
const t = s.product_variants || [];
|
|
90
|
-
if (t.length > 0) {
|
|
91
|
-
for (const e of t)
|
|
92
|
-
u(
|
|
93
|
-
e.sku,
|
|
94
|
-
"variant",
|
|
95
|
-
Math.max(0, e.stock_quantity ?? 0),
|
|
96
|
-
s,
|
|
97
|
-
e.id
|
|
98
|
-
);
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
u(
|
|
102
|
-
s.sku,
|
|
103
|
-
"product",
|
|
104
|
-
Math.max(0, s.stock ?? 0),
|
|
105
|
-
s
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
return o;
|
|
35
|
+
async function s(e) {
|
|
36
|
+
let { data: t, error: r } = await e.from("products").select("\n id,\n title,\n sku,\n stock,\n status,\n languages (\n code\n ),\n product_variants (\n id,\n sku,\n stock_quantity\n )\n ").order("title", { ascending: !0 });
|
|
37
|
+
if (r) throw Error(r.message);
|
|
38
|
+
let a = /* @__PURE__ */ new Map(), o = (e, t, r, o, s) => {
|
|
39
|
+
let c = e.trim();
|
|
40
|
+
if (!c) return;
|
|
41
|
+
let l = n(o.languages), u = a.get(c);
|
|
42
|
+
if (u) {
|
|
43
|
+
u.usageType = i(u.usageType, t), u.stockFallback = Math.min(u.stockFallback, r), u.productTitles.add(o.title), u.parentProductSkus.add(o.sku), u.languages = /* @__PURE__ */ new Set([...u.languages, ...l]), u.statuses.add(o.status), u.productIds.add(o.id), s && u.variantIds.add(s);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
a.set(c, {
|
|
47
|
+
sku: c,
|
|
48
|
+
stockFallback: r,
|
|
49
|
+
usageType: t,
|
|
50
|
+
productTitles: /* @__PURE__ */ new Set([o.title]),
|
|
51
|
+
parentProductSkus: /* @__PURE__ */ new Set([o.sku]),
|
|
52
|
+
languages: new Set(l),
|
|
53
|
+
statuses: /* @__PURE__ */ new Set([o.status]),
|
|
54
|
+
productIds: /* @__PURE__ */ new Set([o.id]),
|
|
55
|
+
variantIds: s ? /* @__PURE__ */ new Set([s]) : /* @__PURE__ */ new Set()
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
for (let e of t || []) {
|
|
59
|
+
let t = e.product_variants || [];
|
|
60
|
+
if (t.length > 0) {
|
|
61
|
+
for (let n of t) o(n.sku, "variant", Math.max(0, n.stock_quantity ?? 0), e, n.id);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
o(e.sku, "product", Math.max(0, e.stock ?? 0), e);
|
|
65
|
+
}
|
|
66
|
+
return a;
|
|
109
67
|
}
|
|
110
|
-
async function
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
productIds: g(e.productIds),
|
|
136
|
-
variantIds: g(e.variantIds)
|
|
137
|
-
} : [];
|
|
138
|
-
}).sort((t, e) => t.sku.localeCompare(e.sku) || t.usageType.localeCompare(e.usageType) || t.productTitles.join(", ").localeCompare(e.productTitles.join(", ")));
|
|
68
|
+
async function c(e) {
|
|
69
|
+
let n = t(e), i = await s(n), c = [...i.keys()];
|
|
70
|
+
if (c.length === 0) return [];
|
|
71
|
+
let l = await o(n, c), u = c.filter((e) => !l.has(e)).flatMap((e) => {
|
|
72
|
+
let t = i.get(e);
|
|
73
|
+
return t ? [{
|
|
74
|
+
sku: e,
|
|
75
|
+
quantity: t.stockFallback
|
|
76
|
+
}] : [];
|
|
77
|
+
});
|
|
78
|
+
return u.length > 0 && (await a(n, u), l = await o(n, c)), c.flatMap((e) => {
|
|
79
|
+
let t = i.get(e);
|
|
80
|
+
return t ? {
|
|
81
|
+
key: e,
|
|
82
|
+
sku: e,
|
|
83
|
+
stock: l.get(e) ?? t.stockFallback,
|
|
84
|
+
usageType: t.usageType,
|
|
85
|
+
productTitles: r(t.productTitles),
|
|
86
|
+
parentProductSkus: r(t.parentProductSkus),
|
|
87
|
+
languages: r(t.languages),
|
|
88
|
+
statuses: r(t.statuses),
|
|
89
|
+
productIds: r(t.productIds),
|
|
90
|
+
variantIds: r(t.variantIds)
|
|
91
|
+
} : [];
|
|
92
|
+
}).sort((e, t) => e.sku.localeCompare(t.sku) || e.usageType.localeCompare(t.usageType) || e.productTitles.join(", ").localeCompare(t.productTitles.join(", ")));
|
|
139
93
|
}
|
|
140
|
-
async function
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
94
|
+
async function l(e, n) {
|
|
95
|
+
let r = t(n), i = e.sku.trim(), o = Math.max(0, Math.trunc(e.stock));
|
|
96
|
+
if (!i) throw Error("SKU is required to update inventory.");
|
|
97
|
+
await a(r, [{
|
|
98
|
+
sku: i,
|
|
99
|
+
quantity: o
|
|
100
|
+
}]);
|
|
101
|
+
let c = (await s(r)).get(i);
|
|
102
|
+
return {
|
|
103
|
+
stock: o,
|
|
104
|
+
affectedCount: (c?.productIds.size ?? 0) + (c?.variantIds.size ?? 0)
|
|
105
|
+
};
|
|
147
106
|
}
|
|
148
|
-
async function
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
{
|
|
162
|
-
sku: n.sku,
|
|
163
|
-
quantity: Math.max(0, Math.trunc(n.stock))
|
|
164
|
-
}
|
|
165
|
-
]);
|
|
107
|
+
async function u(e, n, r) {
|
|
108
|
+
let i = t(r);
|
|
109
|
+
if (n.variants && n.variants.length > 0) {
|
|
110
|
+
await a(i, Array.from(n.variants.reduce((e, t) => (e.set(t.sku.trim(), Math.max(0, Math.trunc(t.stock_quantity))), e), /* @__PURE__ */ new Map()).entries()).map(([e, t]) => ({
|
|
111
|
+
sku: e,
|
|
112
|
+
quantity: t
|
|
113
|
+
})));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
await a(i, [{
|
|
117
|
+
sku: n.sku,
|
|
118
|
+
quantity: Math.max(0, Math.trunc(n.stock))
|
|
119
|
+
}]);
|
|
166
120
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
q as setSharedInventoryQuantity,
|
|
170
|
-
T as syncSharedInventoryForSavedProduct
|
|
171
|
-
};
|
|
121
|
+
//#endregion
|
|
122
|
+
export { c as getInventoryItems, l as setSharedInventoryQuantity, u as syncSharedInventoryForSavedProduct };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("../currency.cjs.js"),t=require("../shipping-rate-currency.cjs.js"),n=require("../variation-utils.cjs.js");let r=require("@nextblock-cms/db/server");async function i(i,a,o,s){let c=(0,r.getSsgSupabaseClient)(),{data:l}=await c.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}),u=l??[],d=e.getDefaultCurrency(u),f=s||d.code,{data:p,error:m}=await c.from(`shipping_zone_locations`).select(`
|
|
2
2
|
zone_id,
|
|
3
3
|
country_code,
|
|
4
4
|
state_code,
|
|
5
5
|
postal_code,
|
|
6
6
|
shipping_zones!inner(priority_order)
|
|
7
|
-
`).eq(
|
|
7
|
+
`).eq(`country_code`,a.country).order(`shipping_zones(priority_order)`,{ascending:!0});if(m||!p||p.length===0)return[];let h=null;if(a.state){let e=p.find(e=>e.state_code===a.state);e&&(h=e.zone_id)}if(!h){let e=p.find(e=>!e.state_code&&!e.postal_code);e&&(h=e.zone_id)}h||=p[0].zone_id;let{data:g,error:_}=await c.from(`shipping_zone_methods`).select(`id, zone_id, method_type, cost_amount, cost_amounts, cost_currency, currency_pricing_mode, min_order_amount, min_order_amounts, name, name_translations`).eq(`zone_id`,h);if(_||!g)return[];let v=g.filter(e=>i>=t.resolveShippingRateAmountForCurrency({amountMap:e.min_order_amounts||{},fallbackAmount:e.min_order_amount||0,sourceCurrencyCode:e.cost_currency||d.code,mode:e.currency_pricing_mode,currencyCode:f,currencies:u})).map(e=>({id:e.id,name:n.resolveTranslatedText(e.name,e.name_translations||null,o),amount:t.resolveShippingRateAmountForCurrency({amountMap:e.cost_amounts||{},fallbackAmount:e.cost_amount||0,sourceCurrencyCode:e.cost_currency||d.code,mode:e.currency_pricing_mode,currencyCode:f,currencies:u}),currency:f,type:e.method_type})).sort((e,t)=>e.amount-t.amount)[0];return v?[v]:[]}exports.resolveShippingOptions=i;
|
|
@@ -1,62 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
e.name,
|
|
44
|
-
e.name_translations || null,
|
|
45
|
-
p
|
|
46
|
-
),
|
|
47
|
-
amount: d({
|
|
48
|
-
amountMap: e.cost_amounts || {},
|
|
49
|
-
fallbackAmount: e.cost_amount || 0,
|
|
50
|
-
sourceCurrencyCode: e.cost_currency || s.code,
|
|
51
|
-
mode: e.currency_pricing_mode,
|
|
52
|
-
currencyCode: i,
|
|
53
|
-
currencies: a
|
|
54
|
-
}),
|
|
55
|
-
currency: i,
|
|
56
|
-
type: e.method_type
|
|
57
|
-
})).sort((e, o) => e.amount - o.amount)[0];
|
|
58
|
-
return _ ? [_] : [];
|
|
1
|
+
import { getDefaultCurrency as e } from "../currency.es.js";
|
|
2
|
+
import { resolveShippingRateAmountForCurrency as t } from "../shipping-rate-currency.es.js";
|
|
3
|
+
import { resolveTranslatedText as n } from "../variation-utils.es.js";
|
|
4
|
+
import { getSsgSupabaseClient as r } from "@nextblock-cms/db/server";
|
|
5
|
+
//#region libs/ecommerce/src/lib/shipping/resolver.ts
|
|
6
|
+
async function i(i, a, o, s) {
|
|
7
|
+
let c = r(), { data: l } = await c.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 }), u = l ?? [], d = e(u), f = s || d.code, { data: p, error: m } = await c.from("shipping_zone_locations").select("\n zone_id,\n country_code,\n state_code,\n postal_code,\n shipping_zones!inner(priority_order)\n ").eq("country_code", a.country).order("shipping_zones(priority_order)", { ascending: !0 });
|
|
8
|
+
if (m || !p || p.length === 0) return [];
|
|
9
|
+
let h = null;
|
|
10
|
+
if (a.state) {
|
|
11
|
+
let e = p.find((e) => e.state_code === a.state);
|
|
12
|
+
e && (h = e.zone_id);
|
|
13
|
+
}
|
|
14
|
+
if (!h) {
|
|
15
|
+
let e = p.find((e) => !e.state_code && !e.postal_code);
|
|
16
|
+
e && (h = e.zone_id);
|
|
17
|
+
}
|
|
18
|
+
h ||= p[0].zone_id;
|
|
19
|
+
let { data: g, error: _ } = await c.from("shipping_zone_methods").select("id, zone_id, method_type, cost_amount, cost_amounts, cost_currency, currency_pricing_mode, min_order_amount, min_order_amounts, name, name_translations").eq("zone_id", h);
|
|
20
|
+
if (_ || !g) return [];
|
|
21
|
+
let v = g.filter((e) => i >= t({
|
|
22
|
+
amountMap: e.min_order_amounts || {},
|
|
23
|
+
fallbackAmount: e.min_order_amount || 0,
|
|
24
|
+
sourceCurrencyCode: e.cost_currency || d.code,
|
|
25
|
+
mode: e.currency_pricing_mode,
|
|
26
|
+
currencyCode: f,
|
|
27
|
+
currencies: u
|
|
28
|
+
})).map((e) => ({
|
|
29
|
+
id: e.id,
|
|
30
|
+
name: n(e.name, e.name_translations || null, o),
|
|
31
|
+
amount: t({
|
|
32
|
+
amountMap: e.cost_amounts || {},
|
|
33
|
+
fallbackAmount: e.cost_amount || 0,
|
|
34
|
+
sourceCurrencyCode: e.cost_currency || d.code,
|
|
35
|
+
mode: e.currency_pricing_mode,
|
|
36
|
+
currencyCode: f,
|
|
37
|
+
currencies: u
|
|
38
|
+
}),
|
|
39
|
+
currency: f,
|
|
40
|
+
type: e.method_type
|
|
41
|
+
})).sort((e, t) => e.amount - t.amount)[0];
|
|
42
|
+
return v ? [v] : [];
|
|
59
43
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { i as resolveShippingOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./currency.cjs.js");let t=require("@nextblock-cms/utils");var n=[`auto`,`manual`];function r(e){if(typeof e==`string`){let t=e.trim().toLowerCase();if(n.includes(t))return t}return`auto`}function i(e,t=0){return typeof e==`number`&&Number.isFinite(e)&&e>=0?Math.round(e):t}function a(n){let r=(0,t.normalizeCurrencyCode)(n.sourceCurrencyCode),i=e.normalizePriceMap(n.amountMap);if(i[r]!==void 0)return r;let a=Object.keys(i)[0];return a?(0,t.normalizeCurrencyCode)(a):e.getDefaultCurrency(n.currencies).code}function o(t){let n=r(t.mode),o=e.normalizePriceMap(t.costAmounts),s=e.normalizePriceMap(t.minOrderAmounts),c=a({amountMap:Object.keys(o).length>0?o:s,sourceCurrencyCode:t.sourceCurrencyCode,currencies:t.currencies}),l=o[c]??i(t.fallbackCostAmount),u=s[c]??i(t.fallbackMinOrderAmount);if(n===`auto`)return{mode:n,sourceCurrencyCode:c,costAmounts:{[c]:l},minOrderAmounts:{[c]:u}};let d=Object.keys(o).length>0?{...o}:{[c]:l},f=Object.keys(s).length>0?{...s}:{[c]:u};return d[c]===void 0&&(d[c]=l),f[c]===void 0&&(f[c]=u),{mode:n,sourceCurrencyCode:c,costAmounts:d,minOrderAmounts:f}}function s(n){let o=r(n.mode),s=e.normalizePriceMap(n.amountMap),c=(0,t.normalizeCurrencyCode)(n.currencyCode);if(o===`manual`&&s[c]!==void 0)return s[c];let l=a({amountMap:s,sourceCurrencyCode:n.sourceCurrencyCode,currencies:n.currencies}),u=s[l]??i(n.fallbackAmount);return c===l?u:e.convertMinorUnitAmount({amount:u,fromCurrencyCode:l,toCurrencyCode:c,currencies:n.currencies})}exports.SHIPPING_RATE_CURRENCY_MODES=n,exports.normalizeShippingRateCurrencyMode=r,exports.resolveShippingRateAmountForCurrency=s,exports.sanitizeShippingRateAmountMaps=o;
|
|
@@ -1,72 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return "auto";
|
|
1
|
+
import { convertMinorUnitAmount as e, getDefaultCurrency as t, normalizePriceMap as n } from "./currency.es.js";
|
|
2
|
+
import { normalizeCurrencyCode as r } from "@nextblock-cms/utils";
|
|
3
|
+
//#region libs/ecommerce/src/lib/shipping-rate-currency.ts
|
|
4
|
+
var i = ["auto", "manual"];
|
|
5
|
+
function a(e) {
|
|
6
|
+
if (typeof e == "string") {
|
|
7
|
+
let t = e.trim().toLowerCase();
|
|
8
|
+
if (i.includes(t)) return t;
|
|
9
|
+
}
|
|
10
|
+
return "auto";
|
|
13
11
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
12
|
+
function o(e, t = 0) {
|
|
13
|
+
return typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.round(e) : t;
|
|
16
14
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return o;
|
|
23
|
-
const t = Object.keys(r)[0];
|
|
24
|
-
return t ? m(t) : A(n.currencies).code;
|
|
15
|
+
function s(e) {
|
|
16
|
+
let i = r(e.sourceCurrencyCode), a = n(e.amountMap);
|
|
17
|
+
if (a[i] !== void 0) return i;
|
|
18
|
+
let o = Object.keys(a)[0];
|
|
19
|
+
return o ? r(o) : t(e.currencies).code;
|
|
25
20
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
mode: o,
|
|
46
|
-
sourceCurrencyCode: e,
|
|
47
|
-
costAmounts: s,
|
|
48
|
-
minOrderAmounts: d
|
|
49
|
-
};
|
|
21
|
+
function c(e) {
|
|
22
|
+
let t = a(e.mode), r = n(e.costAmounts), i = n(e.minOrderAmounts), c = s({
|
|
23
|
+
amountMap: Object.keys(r).length > 0 ? r : i,
|
|
24
|
+
sourceCurrencyCode: e.sourceCurrencyCode,
|
|
25
|
+
currencies: e.currencies
|
|
26
|
+
}), l = r[c] ?? o(e.fallbackCostAmount), u = i[c] ?? o(e.fallbackMinOrderAmount);
|
|
27
|
+
if (t === "auto") return {
|
|
28
|
+
mode: t,
|
|
29
|
+
sourceCurrencyCode: c,
|
|
30
|
+
costAmounts: { [c]: l },
|
|
31
|
+
minOrderAmounts: { [c]: u }
|
|
32
|
+
};
|
|
33
|
+
let d = Object.keys(r).length > 0 ? { ...r } : { [c]: l }, f = Object.keys(i).length > 0 ? { ...i } : { [c]: u };
|
|
34
|
+
return d[c] === void 0 && (d[c] = l), f[c] === void 0 && (f[c] = u), {
|
|
35
|
+
mode: t,
|
|
36
|
+
sourceCurrencyCode: c,
|
|
37
|
+
costAmounts: d,
|
|
38
|
+
minOrderAmounts: f
|
|
39
|
+
};
|
|
50
40
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
41
|
+
function l(t) {
|
|
42
|
+
let i = a(t.mode), c = n(t.amountMap), l = r(t.currencyCode);
|
|
43
|
+
if (i === "manual" && c[l] !== void 0) return c[l];
|
|
44
|
+
let u = s({
|
|
45
|
+
amountMap: c,
|
|
46
|
+
sourceCurrencyCode: t.sourceCurrencyCode,
|
|
47
|
+
currencies: t.currencies
|
|
48
|
+
}), d = c[u] ?? o(t.fallbackAmount);
|
|
49
|
+
return l === u ? d : e({
|
|
50
|
+
amount: d,
|
|
51
|
+
fromCurrencyCode: u,
|
|
52
|
+
toCurrencyCode: l,
|
|
53
|
+
currencies: t.currencies
|
|
54
|
+
});
|
|
66
55
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
f as normalizeShippingRateCurrencyMode,
|
|
70
|
-
g as resolveShippingRateAmountForCurrency,
|
|
71
|
-
O as sanitizeShippingRateAmountMaps
|
|
72
|
-
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { i as SHIPPING_RATE_CURRENCY_MODES, a as normalizeShippingRateCurrencyMode, l as resolveShippingRateAmountForCurrency, c as sanitizeShippingRateAmountMaps };
|
package/lib/states.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./countries.cjs.js");var t={US:[{code:`AL`,name:`Alabama`},{code:`AK`,name:`Alaska`},{code:`AZ`,name:`Arizona`},{code:`AR`,name:`Arkansas`},{code:`CA`,name:`California`},{code:`CO`,name:`Colorado`},{code:`CT`,name:`Connecticut`},{code:`DE`,name:`Delaware`},{code:`DC`,name:`District of Columbia`},{code:`FL`,name:`Florida`},{code:`GA`,name:`Georgia`},{code:`HI`,name:`Hawaii`},{code:`ID`,name:`Idaho`},{code:`IL`,name:`Illinois`},{code:`IN`,name:`Indiana`},{code:`IA`,name:`Iowa`},{code:`KS`,name:`Kansas`},{code:`KY`,name:`Kentucky`},{code:`LA`,name:`Louisiana`},{code:`ME`,name:`Maine`},{code:`MD`,name:`Maryland`},{code:`MA`,name:`Massachusetts`},{code:`MI`,name:`Michigan`},{code:`MN`,name:`Minnesota`},{code:`MS`,name:`Mississippi`},{code:`MO`,name:`Missouri`},{code:`MT`,name:`Montana`},{code:`NE`,name:`Nebraska`},{code:`NV`,name:`Nevada`},{code:`NH`,name:`New Hampshire`},{code:`NJ`,name:`New Jersey`},{code:`NM`,name:`New Mexico`},{code:`NY`,name:`New York`},{code:`NC`,name:`North Carolina`},{code:`ND`,name:`North Dakota`},{code:`OH`,name:`Ohio`},{code:`OK`,name:`Oklahoma`},{code:`OR`,name:`Oregon`},{code:`PA`,name:`Pennsylvania`},{code:`RI`,name:`Rhode Island`},{code:`SC`,name:`South Carolina`},{code:`SD`,name:`South Dakota`},{code:`TN`,name:`Tennessee`},{code:`TX`,name:`Texas`},{code:`UT`,name:`Utah`},{code:`VT`,name:`Vermont`},{code:`VA`,name:`Virginia`},{code:`WA`,name:`Washington`},{code:`WV`,name:`West Virginia`},{code:`WI`,name:`Wisconsin`},{code:`WY`,name:`Wyoming`}],CA:[{code:`AB`,name:`Alberta`},{code:`BC`,name:`British Columbia`},{code:`MB`,name:`Manitoba`},{code:`NB`,name:`New Brunswick`},{code:`NL`,name:`Newfoundland and Labrador`},{code:`NS`,name:`Nova Scotia`},{code:`NT`,name:`Northwest Territories`},{code:`NU`,name:`Nunavut`},{code:`ON`,name:`Ontario`},{code:`PE`,name:`Prince Edward Island`},{code:`QC`,name:`Quebec`},{code:`SK`,name:`Saskatchewan`},{code:`YT`,name:`Yukon`}]},n={CA:{BC:`Colombie-Britannique`,NB:`Nouveau-Brunswick`,NL:`Terre-Neuve-et-Labrador`,NS:`Nouvelle-Écosse`,NT:`Territoires du Nord-Ouest`,PE:`Île-du-Prince-Édouard`,QC:`Québec`},US:{CA:`Californie`,DC:`District de Columbia`,FL:`Floride`,GA:`Géorgie`,HI:`Hawaï`,LA:`Louisiane`,NC:`Caroline du Nord`,ND:`Dakota du Nord`,NM:`Nouveau-Mexique`,PA:`Pennsylvanie`,SC:`Caroline du Sud`,SD:`Dakota du Sud`,VA:`Virginie`,WV:`Virginie-Occidentale`}};function r(t,r,i){if(!i||!i.toLowerCase().startsWith(`fr`))return r.name;let a=e.normalizeCountryCode(t);return a&&n[a]?.[r.code]||r.name}var i={US:{CALIFORNIA:`CA`,NEWYORK:`NY`,"NEW YORK":`NY`,DISTRICTOFCOLUMBIA:`DC`,"DISTRICT OF COLUMBIA":`DC`},CA:{QUEBEC:`QC`,ONTARIO:`ON`,"BRITISH COLUMBIA":`BC`,BRITISHCOLUMBIA:`BC`,"NEWFOUNDLAND AND LABRADOR":`NL`,NEWFOUNDLANDANDLABRADOR:`NL`,"NORTHWEST TERRITORIES":`NT`,NORTHWESTTERRITORIES:`NT`,"PRINCE EDWARD ISLAND":`PE`,PRINCEEDWARDISLAND:`PE`}};function a(n){let r=e.normalizeCountryCode(n);return r?t[r]??[]:[]}function o(e){return a(e).length>0}function s(n,r){let a=e.normalizeCountryCode(n),o=r?.trim();if(!a||!o)return o||null;let s=t[a];if(!s?.length)return o.toUpperCase();let c=o.toUpperCase(),l=s.find(e=>e.code===c);if(l)return l.code;let u=s.find(e=>e.name.toUpperCase()===c);if(u)return u.code;let d=c.replace(/\s+/g,``);return i[a]?.[c]??i[a]?.[d]??c}function c(n,r){let i=e.normalizeCountryCode(n),a=s(n,r);return!i||!a?r??null:t[i]?.find(e=>e.code===a)?.name??a}exports.STATES_BY_COUNTRY=t,exports.countryUsesStructuredStates=o,exports.getStatesForCountry=a,exports.getSubdivisionLabel=r,exports.normalizeSubdivisionCode=s,exports.resolveSubdivisionName=c;
|