@nextblock-cms/ecom 0.0.10 → 0.8.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.
Files changed (147) hide show
  1. package/actions.d.ts +2 -0
  2. package/currency-rest-client-CwoqdgAP.js +23 -0
  3. package/currency-rest-client-uolJxUkL.cjs +1 -0
  4. package/index.cjs.js +1 -0
  5. package/index.d.ts +35 -0
  6. package/index.es.js +3226 -0
  7. package/invoice-ui-BJZfedDd.cjs +332 -0
  8. package/invoice-ui-GJ1ADAjn.js +5759 -0
  9. package/lib/CurrencyProvider.d.ts +18 -0
  10. package/lib/cart-store.d.ts +47 -0
  11. package/lib/components/AccountNavigationMenu.d.ts +14 -0
  12. package/lib/components/AddToCartButton.d.ts +8 -0
  13. package/lib/components/Cart.d.ts +1 -0
  14. package/lib/components/CartDrawer.d.ts +1 -0
  15. package/lib/components/CartIcon.d.ts +1 -0
  16. package/lib/components/Checkout.d.ts +6 -0
  17. package/lib/components/CouponForm.d.ts +8 -0
  18. package/lib/components/CurrencySwitcher.d.ts +1 -0
  19. package/lib/components/CustomerProfileForm.d.ts +21 -0
  20. package/lib/components/FeaturedProduct.d.ts +8 -0
  21. package/lib/components/InvoiceDocument.d.ts +32 -0
  22. package/lib/components/InvoiceViewerShell.d.ts +26 -0
  23. package/lib/components/ProductCard.d.ts +7 -0
  24. package/lib/components/ProductDetailsLayout.d.ts +7 -0
  25. package/lib/components/ProductGallery.d.ts +9 -0
  26. package/lib/components/ProductGrid.d.ts +8 -0
  27. package/lib/components/ShippingEstimator.d.ts +5 -0
  28. package/lib/components/SimpleTiptapRenderer.d.ts +7 -0
  29. package/lib/components/SubscriptionSelector.d.ts +7 -0
  30. package/lib/components/media/MediaImage.d.ts +12 -0
  31. package/lib/components/media/MediaPickerDialog.d.ts +16 -0
  32. package/lib/components/media/MediaUploadForm.d.ts +10 -0
  33. package/lib/components/media/UploadFolderContext.d.ts +10 -0
  34. package/lib/countries.d.ts +5 -0
  35. package/lib/coupon-server.d.ts +22 -0
  36. package/lib/coupon-server.test.d.ts +1 -0
  37. package/lib/coupons.d.ts +41 -0
  38. package/lib/currency-constants.d.ts +1 -0
  39. package/lib/currency-rest-client.d.ts +1 -0
  40. package/lib/currency-sale-schedule.test.d.ts +1 -0
  41. package/lib/currency-store.d.ts +20 -0
  42. package/lib/currency-sync.d.ts +19 -0
  43. package/lib/currency.d.ts +116 -0
  44. package/lib/customer-addresses.d.ts +19 -0
  45. package/lib/customer-orders.d.ts +23 -0
  46. package/lib/customer.d.ts +51 -0
  47. package/lib/export-helpers.d.ts +48 -0
  48. package/lib/factory.d.ts +2 -0
  49. package/lib/freemius-coupons.d.ts +58 -0
  50. package/lib/freemius-order-sync.d.ts +133 -0
  51. package/lib/freemius-order-sync.test.d.ts +1 -0
  52. package/lib/inventory-settings.d.ts +16 -0
  53. package/lib/invoice-server.d.ts +18 -0
  54. package/lib/invoice-ui.d.ts +29 -0
  55. package/lib/invoice.d.ts +75 -0
  56. package/lib/order-inventory.d.ts +7 -0
  57. package/lib/order-tax-details.d.ts +57 -0
  58. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +23 -0
  59. package/lib/pages/cms/coupons/CouponsPage.d.ts +8 -0
  60. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +6 -0
  61. package/lib/pages/cms/coupons/EditCouponPage.d.ts +5 -0
  62. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +16 -0
  63. package/lib/pages/cms/coupons/actions.d.ts +5 -0
  64. package/lib/pages/cms/coupons/index.d.ts +2 -0
  65. package/lib/pages/cms/coupons/product-options.d.ts +2 -0
  66. package/lib/pages/cms/orders/ExportReportsDialog.d.ts +2 -0
  67. package/lib/pages/cms/orders/MarkPaidButton.d.ts +3 -0
  68. package/lib/pages/cms/orders/OrderDetailPage.d.ts +5 -0
  69. package/lib/pages/cms/orders/OrderPrintButton.d.ts +3 -0
  70. package/lib/pages/cms/orders/OrderStatusForm.d.ts +4 -0
  71. package/lib/pages/cms/orders/OrdersPage.d.ts +6 -0
  72. package/lib/pages/cms/orders/actions.d.ts +7 -0
  73. package/lib/pages/cms/orders/export-actions.d.ts +2 -0
  74. package/lib/pages/cms/orders/index.d.ts +6 -0
  75. package/lib/pages/cms/orders/server-actions.d.ts +11 -0
  76. package/lib/pages/cms/orders/types.d.ts +60 -0
  77. package/lib/pages/cms/payments/PaymentsClient.d.ts +19 -0
  78. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -0
  79. package/lib/pages/cms/payments/actions.d.ts +4 -0
  80. package/lib/pages/cms/payments/index.d.ts +2 -0
  81. package/lib/pages/cms/payments/queries.d.ts +12 -0
  82. package/lib/pages/cms/products/ProductsPage.d.ts +7 -0
  83. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +12 -0
  84. package/lib/pages/cms/products/actions.d.ts +18201 -0
  85. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -0
  86. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +50 -0
  87. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -0
  88. package/lib/pages/cms/products/categories/components/CategoryManager.d.ts +47 -0
  89. package/lib/pages/cms/products/components/CopyProductFromLanguage.d.ts +9 -0
  90. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +18 -0
  91. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +9 -0
  92. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +24 -0
  93. package/lib/pages/cms/products/components/ProductCategorySelector.d.ts +14 -0
  94. package/lib/pages/cms/products/components/ProductForm.d.ts +62 -0
  95. package/lib/pages/cms/products/components/ProductMediaManager.d.ts +17 -0
  96. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +32 -0
  97. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +16 -0
  98. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +3 -0
  99. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +5 -0
  100. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -0
  101. package/lib/pages/cms/products/components/VariationsEditor.d.ts +26 -0
  102. package/lib/pages/cms/products/index.d.ts +7 -0
  103. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -0
  104. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +6 -0
  105. package/lib/pages/cms/products/inventory/actions.d.ts +38 -0
  106. package/lib/pages/cms/products/new/NewProductPage.d.ts +9 -0
  107. package/lib/pages/cms/products/product-price-sync.d.ts +43 -0
  108. package/lib/pages/cms/products/server-actions.d.ts +125 -0
  109. package/lib/pages/cms/shipping/ShippingPage.d.ts +6 -0
  110. package/lib/pages/cms/shipping/components/RateForm.d.ts +26 -0
  111. package/lib/pages/cms/shipping/components/ZoneForm.d.ts +13 -0
  112. package/lib/pages/cms/shipping/index.d.ts +2 -0
  113. package/lib/pages/cms/shipping/server-actions.d.ts +80 -0
  114. package/lib/pages/cms/taxes/TaxesPage.d.ts +5 -0
  115. package/lib/pages/cms/taxes/actions.d.ts +3 -0
  116. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +8 -0
  117. package/lib/pages/cms/taxes/index.d.ts +2 -0
  118. package/lib/product-actions.d.ts +18457 -0
  119. package/lib/product-context.d.ts +7 -0
  120. package/lib/product-schema.d.ts +73 -0
  121. package/lib/providers/freemius.d.ts +49 -0
  122. package/lib/providers/stripe.d.ts +13 -0
  123. package/lib/server-actions/coupon-actions.d.ts +17 -0
  124. package/lib/server-actions/customer-actions.d.ts +18 -0
  125. package/lib/server-actions/product-actions.d.ts +69 -0
  126. package/lib/server-actions/shipping-actions.d.ts +10 -0
  127. package/lib/server-actions/tax-actions.d.ts +7 -0
  128. package/lib/shared-inventory.d.ts +38 -0
  129. package/lib/shipping/resolver.d.ts +16 -0
  130. package/lib/shipping-rate-currency.d.ts +39 -0
  131. package/lib/states.d.ts +9 -0
  132. package/lib/stripe/checkout.d.ts +6 -0
  133. package/lib/stripe/client.d.ts +2 -0
  134. package/lib/stripe/order-sync.d.ts +18 -0
  135. package/lib/stripe/webhooks.d.ts +4 -0
  136. package/lib/tax-calculation.d.ts +23 -0
  137. package/lib/trials.d.ts +15 -0
  138. package/lib/types.d.ts +245 -0
  139. package/lib/use-cart.d.ts +11 -0
  140. package/lib/variation-utils.d.ts +72 -0
  141. package/lib/zod-config.d.ts +2 -0
  142. package/package.json +47 -2
  143. package/server.cjs.js +110 -0
  144. package/server.d.ts +31 -0
  145. package/server.es.js +6039 -0
  146. package/index.ts +0 -12
  147. package/tsconfig.lib.json +0 -10
@@ -0,0 +1,18 @@
1
+ import { ReactNode } from 'react';
2
+ import { CurrencyRecord } from './currency';
3
+ interface CurrencyContextValue {
4
+ currencies: CurrencyRecord[];
5
+ defaultCurrency: CurrencyRecord;
6
+ activeCurrency: CurrencyRecord;
7
+ activeCurrencyCode: string;
8
+ isHydrated: boolean;
9
+ setActiveCurrencyCode: (currencyCode: string) => void;
10
+ }
11
+ export declare function CurrencyProvider({ children, initialCurrencies, initialCurrencyCode, locale, }: {
12
+ children: ReactNode;
13
+ initialCurrencies: CurrencyRecord[];
14
+ initialCurrencyCode?: string | null;
15
+ locale?: string | null;
16
+ }): import("react").JSX.Element;
17
+ export declare function useCurrency(): CurrencyContextValue;
18
+ export {};
@@ -0,0 +1,47 @@
1
+ import { CartItem } from './types';
2
+ import { useCurrency } from './CurrencyProvider';
3
+ import { AppliedCouponState } from './coupons';
4
+ export interface AddItemResult {
5
+ success: boolean;
6
+ error?: string;
7
+ }
8
+ interface CartState {
9
+ items: CartItem[];
10
+ appliedCoupon: AppliedCouponState | null;
11
+ isOpen: boolean;
12
+ addItem: (item: Omit<CartItem, 'quantity'> & {
13
+ quantity?: number;
14
+ }) => AddItemResult;
15
+ removeItem: (itemId: string) => void;
16
+ updateQuantity: (itemId: string, quantity: number) => void;
17
+ setAppliedCoupon: (coupon: AppliedCouponState | null) => void;
18
+ removeCoupon: () => void;
19
+ clearCart: () => void;
20
+ toggleCart: () => void;
21
+ setIsOpen: (isOpen: boolean) => void;
22
+ setItems: (items: CartItem[]) => void;
23
+ }
24
+ export declare const useCartStore: import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CartState>, "setState" | "persist"> & {
25
+ setState(partial: CartState | Partial<CartState> | ((state: CartState) => CartState | Partial<CartState>), replace?: false | undefined): unknown;
26
+ setState(state: CartState | ((state: CartState) => CartState), replace: true): unknown;
27
+ persist: {
28
+ setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CartState, unknown, unknown>>) => void;
29
+ clearStorage: () => void;
30
+ rehydrate: () => Promise<void> | void;
31
+ hasHydrated: () => boolean;
32
+ onHydrate: (fn: (state: CartState) => void) => () => void;
33
+ onFinishHydration: (fn: (state: CartState) => void) => () => void;
34
+ getOptions: () => Partial<import('zustand/middleware').PersistOptions<CartState, unknown, unknown>>;
35
+ };
36
+ }>;
37
+ export declare const useCartTotalItems: () => number;
38
+ export declare function getCartItemActivePrice(item: CartItem, params: {
39
+ currencyCode: string;
40
+ currencies: ReturnType<typeof useCurrency>['currencies'];
41
+ }): {
42
+ currencyCode: any;
43
+ price: any;
44
+ sale_price: any;
45
+ };
46
+ export declare const useCartSubtotal: () => number;
47
+ export {};
@@ -0,0 +1,14 @@
1
+ export type AccountNavigationIcon = 'orders' | 'password';
2
+ export interface AccountNavigationLink {
3
+ href: string;
4
+ labelKey: string;
5
+ fallbackLabel: string;
6
+ icon?: AccountNavigationIcon;
7
+ }
8
+ interface AccountNavigationMenuProps {
9
+ links: AccountNavigationLink[];
10
+ title?: string;
11
+ className?: string;
12
+ }
13
+ export declare function AccountNavigationMenu({ links, title, className, }: AccountNavigationMenuProps): import("react").JSX.Element | null;
14
+ export {};
@@ -0,0 +1,8 @@
1
+ import { Product } from '../types';
2
+ interface AddToCartButtonProps {
3
+ product: Product;
4
+ className?: string;
5
+ quantity?: number;
6
+ }
7
+ export declare const AddToCartButton: ({ product, className, quantity }: AddToCartButtonProps) => import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1 @@
1
+ export declare const Cart: () => import("react").JSX.Element | null;
@@ -0,0 +1 @@
1
+ export declare const CartDrawer: () => import("react").JSX.Element | null;
@@ -0,0 +1 @@
1
+ export declare const CartIcon: () => import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { CheckoutCustomerDefaults } from '../customer';
2
+ interface CheckoutProps {
3
+ initialCustomer?: CheckoutCustomerDefaults;
4
+ }
5
+ export declare const Checkout: ({ initialCustomer }: CheckoutProps) => import("react").JSX.Element | null;
6
+ export {};
@@ -0,0 +1,8 @@
1
+ import { CouponQuote } from '../coupons';
2
+ import { CartItem } from '../types';
3
+ export declare function CouponForm({ items, currencyCode, onQuoteChange, compact, }: {
4
+ items: CartItem[];
5
+ currencyCode: string;
6
+ onQuoteChange?: (quote: CouponQuote | null) => void;
7
+ compact?: boolean;
8
+ }): import("react").JSX.Element | null;
@@ -0,0 +1 @@
1
+ export declare function CurrencySwitcher(): import("react").JSX.Element | null;
@@ -0,0 +1,21 @@
1
+ import { default as React } from 'react';
2
+ import { AccountNavigationLink } from './AccountNavigationMenu';
3
+ import { ProfileUpdateData } from '../server-actions/customer-actions';
4
+ import { Database } from '../../../../db/src/index.ts';
5
+ type UserRole = Database['public']['Enums']['user_role'];
6
+ export interface ExtendedProfileUpdateData extends ProfileUpdateData {
7
+ role?: UserRole;
8
+ }
9
+ interface CustomerProfileFormProps {
10
+ initialData?: ExtendedProfileUpdateData;
11
+ MediaPickerComponent?: React.ComponentType<any>;
12
+ isAdmin?: boolean;
13
+ email?: string;
14
+ accountLinks?: AccountNavigationLink[];
15
+ onAction?: (data: ExtendedProfileUpdateData) => Promise<{
16
+ error?: string;
17
+ } | void>;
18
+ initialSuccessMessage?: string | null;
19
+ }
20
+ export declare function CustomerProfileForm({ initialData, MediaPickerComponent, isAdmin, email, accountLinks, onAction, initialSuccessMessage, }: CustomerProfileFormProps): React.JSX.Element;
21
+ export {};
@@ -0,0 +1,8 @@
1
+ import { Product } from '../types';
2
+ interface FeaturedProductProps {
3
+ product: Product;
4
+ className?: string;
5
+ imagePosition?: 'left' | 'right';
6
+ }
7
+ export declare const FeaturedProduct: ({ product, className, imagePosition }: FeaturedProductProps) => import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1,32 @@
1
+ import { default as React } from 'react';
2
+ import { InvoicePresentationData } from '../invoice';
3
+ export interface InvoiceDocumentLabels {
4
+ invoice: string;
5
+ invoiceNumber: string;
6
+ orderNumber: string;
7
+ paidOn: string;
8
+ status: string;
9
+ from: string;
10
+ billTo: string;
11
+ shipTo: string;
12
+ item: string;
13
+ details: string;
14
+ quantity: string;
15
+ price: string;
16
+ amount: string;
17
+ subtotal: string;
18
+ discount: string;
19
+ shipping: string;
20
+ tax: string;
21
+ total: string;
22
+ taxBreakdown: string;
23
+ taxRegistrations: string;
24
+ }
25
+ interface InvoiceDocumentProps {
26
+ data: InvoicePresentationData;
27
+ labels: InvoiceDocumentLabels;
28
+ locale?: string;
29
+ className?: string;
30
+ }
31
+ export declare function InvoiceDocument({ data, labels, locale, className, }: InvoiceDocumentProps): React.JSX.Element;
32
+ export {};
@@ -0,0 +1,26 @@
1
+ import { ReactNode } from 'react';
2
+ import { InvoiceDocumentLabels } from './InvoiceDocument';
3
+ import { InvoicePresentationData } from '../invoice';
4
+ interface InvoiceViewerAction {
5
+ href: string;
6
+ label: string;
7
+ variant?: 'default' | 'outline';
8
+ }
9
+ interface InvoiceViewerShellProps {
10
+ invoice?: InvoicePresentationData | null;
11
+ labels: InvoiceDocumentLabels;
12
+ locale: string;
13
+ title: string;
14
+ description?: string;
15
+ printLabel: string;
16
+ headerVisual?: ReactNode;
17
+ action?: InvoiceViewerAction;
18
+ loading?: boolean;
19
+ loadingMessage?: string;
20
+ error?: string | null;
21
+ emptyMessage?: string;
22
+ className?: string;
23
+ showHeader?: boolean;
24
+ }
25
+ export declare function InvoiceViewerShell({ invoice, labels, locale, title, description, printLabel, headerVisual, action, loading, loadingMessage, error, emptyMessage, className, showHeader, }: InvoiceViewerShellProps): import("react").JSX.Element;
26
+ export {};
@@ -0,0 +1,7 @@
1
+ import { Product } from '../types';
2
+ interface ProductCardProps {
3
+ product: Product;
4
+ className?: string;
5
+ }
6
+ export declare const ProductCard: ({ product, className }: ProductCardProps) => import("react").JSX.Element;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ interface ProductDetailsLayoutProps {
3
+ visualEditingEnabled?: boolean;
4
+ descriptionNode?: React.ReactNode;
5
+ }
6
+ export declare const ProductDetailsLayout: React.FC<ProductDetailsLayoutProps>;
7
+ export {};
@@ -0,0 +1,9 @@
1
+ interface ProductGalleryProps {
2
+ images?: {
3
+ url: string;
4
+ alt?: string;
5
+ }[];
6
+ className?: string;
7
+ }
8
+ export declare const ProductGallery: ({ images, className }: ProductGalleryProps) => import("react").JSX.Element;
9
+ export {};
@@ -0,0 +1,8 @@
1
+ import { Product } from '../types';
2
+ interface ProductGridProps {
3
+ products: Product[];
4
+ columns?: 2 | 3 | 4;
5
+ className?: string;
6
+ }
7
+ export declare const ProductGrid: ({ products, columns, className }: ProductGridProps) => import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1,5 @@
1
+ interface ShippingEstimatorProps {
2
+ physicalSubtotal: number;
3
+ }
4
+ export declare const ShippingEstimator: ({ physicalSubtotal }: ShippingEstimatorProps) => import("react").JSX.Element;
5
+ export {};
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ interface SimpleTiptapRendererProps {
3
+ content: unknown;
4
+ className?: string;
5
+ }
6
+ export declare const SimpleTiptapRenderer: React.FC<SimpleTiptapRendererProps>;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ import { Product } from '../types';
3
+ interface SubscriptionSelectorProps {
4
+ product: Product;
5
+ }
6
+ export declare const SubscriptionSelector: ({ product }: SubscriptionSelectorProps) => React.JSX.Element;
7
+ export {};
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ interface MediaImageProps {
3
+ src: string;
4
+ alt: string;
5
+ width?: number | null;
6
+ height?: number | null;
7
+ blurDataURL?: string | null;
8
+ className?: string;
9
+ priority?: boolean;
10
+ }
11
+ declare const MediaImage: React.FC<MediaImageProps>;
12
+ export default MediaImage;
@@ -0,0 +1,16 @@
1
+ import { default as React } from 'react';
2
+ import { Database } from '../../../../../db/src/index.ts';
3
+ type Media = Database["public"]["Tables"]["media"]["Row"];
4
+ interface MediaPickerDialogProps {
5
+ triggerLabel?: string;
6
+ triggerVariant?: "default" | "outline" | "secondary" | "destructive" | "ghost";
7
+ onSelect?: (media: Media) => void;
8
+ accept?: (m: Media) => boolean;
9
+ title?: string;
10
+ open?: boolean;
11
+ onOpenChange?: (open: boolean) => void;
12
+ hideTrigger?: boolean;
13
+ defaultFolder?: string;
14
+ }
15
+ export default function MediaPickerDialog({ triggerLabel, triggerVariant, onSelect, accept, title, open, onOpenChange, hideTrigger, defaultFolder, }: MediaPickerDialogProps): React.JSX.Element;
16
+ export {};
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ import { Database } from '../../../../../db/src/index.ts';
3
+ type Media = Database['public']['Tables']['media']['Row'];
4
+ interface MediaUploadFormProps {
5
+ onUploadSuccess?: (newMedia: Media) => void;
6
+ returnJustData?: boolean;
7
+ defaultFolder?: string;
8
+ }
9
+ export default function MediaUploadForm({ onUploadSuccess, returnJustData, defaultFolder }: MediaUploadFormProps): React.JSX.Element;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ type UploadFolderContextValue = {
3
+ defaultFolder?: string | null;
4
+ };
5
+ export declare function UploadFolderProvider({ defaultFolder, children }: {
6
+ defaultFolder?: string;
7
+ children: React.ReactNode;
8
+ }): React.JSX.Element;
9
+ export declare function useUploadFolder(): UploadFolderContextValue;
10
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare const countries: {
2
+ code: string;
3
+ name: string;
4
+ }[];
5
+ export declare function normalizeCountryCode(value?: string | null): string | null;
@@ -0,0 +1,22 @@
1
+ import { SupabaseClient } from '@supabase/supabase-js';
2
+ import { CouponQuote, CouponQuoteResult } from './coupons';
3
+ import { CartItem, EcommercePaymentProvider } from './types';
4
+ type SupabaseLikeClient = SupabaseClient<any>;
5
+ export declare function getCouponQuote(input: {
6
+ client: SupabaseLikeClient;
7
+ code?: string | null;
8
+ items: CartItem[];
9
+ currencyCode?: string | null;
10
+ }): Promise<CouponQuoteResult>;
11
+ export declare function getQuoteLineDiscountMap(quote?: CouponQuote | null): Map<string, number>;
12
+ export declare function recordCouponRedemption(input: {
13
+ client: SupabaseLikeClient;
14
+ quote: CouponQuote;
15
+ orderId: string;
16
+ provider: EcommercePaymentProvider;
17
+ discountTotal: number;
18
+ userId?: string | null;
19
+ customerEmail?: string | null;
20
+ metadata?: Record<string, unknown>;
21
+ }): Promise<void>;
22
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ import { CartItem, EcommercePaymentProvider } from './types';
2
+ export type CouponProviderScope = 'all' | EcommercePaymentProvider;
3
+ export type CouponDiscountType = 'percent' | 'fixed';
4
+ export type CouponSyncStatus = 'not_synced' | 'pending' | 'synced' | 'failed' | 'deleted' | 'not_required';
5
+ export interface AppliedCouponState {
6
+ code: string;
7
+ couponId?: string | null;
8
+ }
9
+ export interface CouponLineQuote {
10
+ key: string;
11
+ product_id: string;
12
+ variant_id?: string | null;
13
+ provider: EcommercePaymentProvider;
14
+ title: string;
15
+ quantity: number;
16
+ subtotal: number;
17
+ discount: number;
18
+ }
19
+ export interface CouponQuote {
20
+ couponId: string;
21
+ code: string;
22
+ name: string;
23
+ discountType: CouponDiscountType;
24
+ discountAmount: number;
25
+ providerScope: CouponProviderScope;
26
+ eligibleSubtotal: number;
27
+ discountTotal: number;
28
+ providerDiscounts: Record<EcommercePaymentProvider, number>;
29
+ lineDiscounts: CouponLineQuote[];
30
+ }
31
+ export type CouponQuoteResult = {
32
+ success: true;
33
+ quote: CouponQuote;
34
+ } | {
35
+ success: false;
36
+ error: string;
37
+ errorKey?: string;
38
+ };
39
+ export declare function normalizeCouponCode(code?: string | null): string;
40
+ export declare function getCartLineCouponKey(item: Pick<CartItem, 'product_id' | 'variant_id'>): string;
41
+ export declare function emptyProviderDiscounts(): Record<EcommercePaymentProvider, number>;
@@ -0,0 +1 @@
1
+ export declare const CURRENCY_COOKIE_NAME = "NEXTBLOCK_CURRENCY";
@@ -0,0 +1 @@
1
+ export declare function fetchActiveCurrenciesFromRest(): Promise<Array<Record<string, unknown>>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ interface CurrencyPreferenceState {
2
+ activeCurrencyCode: string | null;
3
+ hasHydrated: boolean;
4
+ setActiveCurrencyCode: (currencyCode: string) => void;
5
+ setHasHydrated: (hasHydrated: boolean) => void;
6
+ }
7
+ export declare const useCurrencyPreferenceStore: import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<CurrencyPreferenceState>, "setState" | "persist"> & {
8
+ setState(partial: CurrencyPreferenceState | Partial<CurrencyPreferenceState> | ((state: CurrencyPreferenceState) => CurrencyPreferenceState | Partial<CurrencyPreferenceState>), replace?: false | undefined): unknown;
9
+ setState(state: CurrencyPreferenceState | ((state: CurrencyPreferenceState) => CurrencyPreferenceState), replace: true): unknown;
10
+ persist: {
11
+ setOptions: (options: Partial<import('zustand/middleware').PersistOptions<CurrencyPreferenceState, unknown, unknown>>) => void;
12
+ clearStorage: () => void;
13
+ rehydrate: () => Promise<void> | void;
14
+ hasHydrated: () => boolean;
15
+ onHydrate: (fn: (state: CurrencyPreferenceState) => void) => () => void;
16
+ onFinishHydration: (fn: (state: CurrencyPreferenceState) => void) => () => void;
17
+ getOptions: () => Partial<import('zustand/middleware').PersistOptions<CurrencyPreferenceState, unknown, unknown>>;
18
+ };
19
+ }>;
20
+ export {};
@@ -0,0 +1,19 @@
1
+ export declare function rebaseStoreCurrencyExchangeRates(params: {
2
+ newDefaultCurrencyCode: string;
3
+ previousBaseRate: number;
4
+ }): Promise<{
5
+ rebasedAt: string;
6
+ newDefaultCurrencyCode: any;
7
+ updatedCurrencies: string[];
8
+ }>;
9
+ export declare function syncStoreCurrencyRates(): Promise<{
10
+ baseCurrencyCode: any;
11
+ fetchedAt: string;
12
+ provider: string;
13
+ providerUrl: string;
14
+ skippedCurrencies: string[];
15
+ updatedCurrencies: string[];
16
+ }>;
17
+ export declare function clearAutoSyncedCurrencyPriceOverrides(currencyCode: string): Promise<{
18
+ currencyCode: any;
19
+ }>;
@@ -0,0 +1,116 @@
1
+ export declare const CURRENCY_ROUNDING_MODES: readonly ["none", "nearest", "up", "down", "charm"];
2
+ export type CurrencyRoundingMode = (typeof CURRENCY_ROUNDING_MODES)[number];
3
+ export interface CurrencyRecord {
4
+ code: string;
5
+ symbol: string;
6
+ exchange_rate: number;
7
+ is_default: boolean;
8
+ is_active: boolean;
9
+ auto_sync_product_prices?: boolean | null;
10
+ rounding_mode?: CurrencyRoundingMode | null;
11
+ rounding_increment?: number | null;
12
+ rounding_charm_amount?: number | null;
13
+ auto_update_exchange_rate?: boolean | null;
14
+ exchange_rate_source?: string | null;
15
+ exchange_rate_updated_at?: string | null;
16
+ }
17
+ export type PriceMap = Record<string, number>;
18
+ export type SalePriceMap = Record<string, number | null>;
19
+ export declare function normalizeCurrencyRoundingMode(value: unknown): CurrencyRoundingMode;
20
+ export declare function normalizeCurrencyRecord(value: Partial<CurrencyRecord> | Record<string, unknown> | null | undefined): CurrencyRecord;
21
+ export declare function normalizePriceMap(value: unknown): PriceMap;
22
+ export declare function normalizeSalePriceMap(value: unknown): SalePriceMap;
23
+ export declare function getDefaultCurrency(currencies: CurrencyRecord[]): CurrencyRecord;
24
+ export declare function getCurrencyLookup(currencies: CurrencyRecord[]): Record<string, CurrencyRecord>;
25
+ export declare function getExchangeRateForCurrency(currencies: CurrencyRecord[], currencyCode?: string | null): number;
26
+ export declare function convertMinorUnitAmount(params: {
27
+ amount: number;
28
+ fromCurrencyCode?: string | null;
29
+ toCurrencyCode?: string | null;
30
+ currencies: CurrencyRecord[];
31
+ applyRounding?: boolean;
32
+ }): any;
33
+ export declare function applyCurrencyRounding(params: {
34
+ amount: number;
35
+ currencyCode?: string | null;
36
+ currencies: CurrencyRecord[];
37
+ }): number;
38
+ export declare function describeCurrencyRoundingRule(currency: CurrencyRecord): string;
39
+ export declare function resolvePriceForCurrency(params: {
40
+ prices?: PriceMap | null;
41
+ salePrices?: SalePriceMap | null;
42
+ fallbackPrice?: number | null;
43
+ fallbackSalePrice?: number | null;
44
+ currencyCode?: string | null;
45
+ currencies: CurrencyRecord[];
46
+ }): {
47
+ currencyCode: any;
48
+ price: any;
49
+ sale_price: any;
50
+ };
51
+ /**
52
+ * Returns whether a scheduled sale window is active at `now` (defaults to the
53
+ * current instant). A null bound means "open ended"; both bounds null means the
54
+ * sale is always-on (preserves the behaviour of pre-schedule static sales).
55
+ * Window is [start, end): inclusive start, exclusive end. All comparisons are
56
+ * absolute instants, so this is timezone-safe.
57
+ */
58
+ export declare function isSaleWindowActive(params: {
59
+ saleStartAt?: string | null;
60
+ saleEndAt?: string | null;
61
+ now?: Date;
62
+ }): boolean;
63
+ /**
64
+ * Returns whether a pending regular-price change has reached its effective time.
65
+ */
66
+ export declare function isScheduledPriceDue(params: {
67
+ scheduledPriceAt?: string | null;
68
+ now?: Date;
69
+ }): boolean;
70
+ /**
71
+ * Window-aware wrapper around {@link resolvePriceForCurrency}. Resolves the
72
+ * effective regular/sale price for a product or variant at `now`:
73
+ * - a due scheduled regular-price change replaces the regular price inputs;
74
+ * - the sale price only applies while its window is active.
75
+ * The existing `sale_price <= regularPrice` guard is preserved by delegating to
76
+ * `resolvePriceForCurrency`, so an out-of-window or invalid sale returns null.
77
+ */
78
+ export declare function resolveEffectivePriceForCurrency(params: {
79
+ prices?: PriceMap | null;
80
+ salePrices?: SalePriceMap | null;
81
+ fallbackPrice?: number | null;
82
+ fallbackSalePrice?: number | null;
83
+ saleStartAt?: string | null;
84
+ saleEndAt?: string | null;
85
+ scheduledPrice?: number | null;
86
+ scheduledPrices?: PriceMap | null;
87
+ scheduledPriceAt?: string | null;
88
+ currencyCode?: string | null;
89
+ currencies: CurrencyRecord[];
90
+ now?: Date;
91
+ }): {
92
+ currencyCode: any;
93
+ price: any;
94
+ sale_price: any;
95
+ };
96
+ export declare function resolvePriceRangeForCurrency(params: {
97
+ entries: Array<{
98
+ price: number;
99
+ prices?: PriceMap | null;
100
+ sale_price?: number | null;
101
+ sale_prices?: SalePriceMap | null;
102
+ sale_start_at?: string | null;
103
+ sale_end_at?: string | null;
104
+ scheduled_price?: number | null;
105
+ scheduled_prices?: PriceMap | null;
106
+ scheduled_price_at?: string | null;
107
+ }>;
108
+ currencyCode?: string | null;
109
+ currencies: CurrencyRecord[];
110
+ now?: Date;
111
+ }): {
112
+ min: number;
113
+ max: number;
114
+ } | null;
115
+ export declare function inferCurrencyCodeFromLocale(locale: string | null | undefined, currencies: CurrencyRecord[]): string;
116
+ export declare function sortCurrencies(currencies: CurrencyRecord[]): CurrencyRecord[];
@@ -0,0 +1,19 @@
1
+ import { CustomerAddressInput } from './customer';
2
+ type SupabaseLikeClient = any;
3
+ export declare function getDefaultUserAddresses(userId: string, client?: SupabaseLikeClient): Promise<{
4
+ billingAddress: CustomerAddressInput | null;
5
+ shippingAddress: CustomerAddressInput | null;
6
+ }>;
7
+ export declare function upsertDefaultUserAddresses(input: {
8
+ userId: string;
9
+ billingAddress?: CustomerAddressInput | null;
10
+ shippingAddress?: CustomerAddressInput | null;
11
+ client?: SupabaseLikeClient;
12
+ }): Promise<void>;
13
+ export declare function fillMissingUserProfileCheckoutDetails(input: {
14
+ userId: string;
15
+ fullName?: string | null;
16
+ phone?: string | null;
17
+ client?: SupabaseLikeClient;
18
+ }): Promise<void>;
19
+ export {};
@@ -0,0 +1,23 @@
1
+ import { SupabaseClient } from '@supabase/supabase-js';
2
+ import { InvoicePresentationData } from './invoice';
3
+ type SupabaseLikeClient = SupabaseClient<any>;
4
+ export interface CustomerOrderSummary {
5
+ id: string;
6
+ invoice_number: string | null;
7
+ paid_at: string | null;
8
+ created_at: string | null;
9
+ currency: string | null;
10
+ status: string;
11
+ provider: string | null;
12
+ subtotal: number | null;
13
+ shipping_total: number | null;
14
+ tax_total: number | null;
15
+ total: number;
16
+ }
17
+ export declare function getCurrentCustomerOrders(client?: SupabaseLikeClient): Promise<CustomerOrderSummary[]>;
18
+ export declare function getCurrentCustomerOrder(orderId: string, client?: SupabaseLikeClient): Promise<CustomerOrderSummary | null>;
19
+ export declare function getCurrentCustomerOrderInvoice(orderId: string, client?: SupabaseLikeClient): Promise<{
20
+ order: CustomerOrderSummary;
21
+ invoice: InvoicePresentationData | null;
22
+ } | null>;
23
+ export {};