@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.
- package/actions.d.ts +2 -0
- package/currency-rest-client-CwoqdgAP.js +23 -0
- package/currency-rest-client-uolJxUkL.cjs +1 -0
- package/index.cjs.js +1 -0
- package/index.d.ts +35 -0
- package/index.es.js +3226 -0
- package/invoice-ui-BJZfedDd.cjs +332 -0
- package/invoice-ui-GJ1ADAjn.js +5759 -0
- package/lib/CurrencyProvider.d.ts +18 -0
- package/lib/cart-store.d.ts +47 -0
- package/lib/components/AccountNavigationMenu.d.ts +14 -0
- package/lib/components/AddToCartButton.d.ts +8 -0
- package/lib/components/Cart.d.ts +1 -0
- package/lib/components/CartDrawer.d.ts +1 -0
- package/lib/components/CartIcon.d.ts +1 -0
- package/lib/components/Checkout.d.ts +6 -0
- package/lib/components/CouponForm.d.ts +8 -0
- package/lib/components/CurrencySwitcher.d.ts +1 -0
- package/lib/components/CustomerProfileForm.d.ts +21 -0
- package/lib/components/FeaturedProduct.d.ts +8 -0
- package/lib/components/InvoiceDocument.d.ts +32 -0
- package/lib/components/InvoiceViewerShell.d.ts +26 -0
- package/lib/components/ProductCard.d.ts +7 -0
- package/lib/components/ProductDetailsLayout.d.ts +7 -0
- package/lib/components/ProductGallery.d.ts +9 -0
- package/lib/components/ProductGrid.d.ts +8 -0
- package/lib/components/ShippingEstimator.d.ts +5 -0
- package/lib/components/SimpleTiptapRenderer.d.ts +7 -0
- package/lib/components/SubscriptionSelector.d.ts +7 -0
- package/lib/components/media/MediaImage.d.ts +12 -0
- package/lib/components/media/MediaPickerDialog.d.ts +16 -0
- package/lib/components/media/MediaUploadForm.d.ts +10 -0
- package/lib/components/media/UploadFolderContext.d.ts +10 -0
- package/lib/countries.d.ts +5 -0
- package/lib/coupon-server.d.ts +22 -0
- package/lib/coupon-server.test.d.ts +1 -0
- package/lib/coupons.d.ts +41 -0
- package/lib/currency-constants.d.ts +1 -0
- package/lib/currency-rest-client.d.ts +1 -0
- package/lib/currency-sale-schedule.test.d.ts +1 -0
- package/lib/currency-store.d.ts +20 -0
- package/lib/currency-sync.d.ts +19 -0
- package/lib/currency.d.ts +116 -0
- package/lib/customer-addresses.d.ts +19 -0
- package/lib/customer-orders.d.ts +23 -0
- package/lib/customer.d.ts +51 -0
- package/lib/export-helpers.d.ts +48 -0
- package/lib/factory.d.ts +2 -0
- package/lib/freemius-coupons.d.ts +58 -0
- package/lib/freemius-order-sync.d.ts +133 -0
- package/lib/freemius-order-sync.test.d.ts +1 -0
- package/lib/inventory-settings.d.ts +16 -0
- package/lib/invoice-server.d.ts +18 -0
- package/lib/invoice-ui.d.ts +29 -0
- package/lib/invoice.d.ts +75 -0
- package/lib/order-inventory.d.ts +7 -0
- package/lib/order-tax-details.d.ts +57 -0
- package/lib/pages/cms/coupons/CouponEditorForm.d.ts +23 -0
- package/lib/pages/cms/coupons/CouponsPage.d.ts +8 -0
- package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +6 -0
- package/lib/pages/cms/coupons/EditCouponPage.d.ts +5 -0
- package/lib/pages/cms/coupons/ProductScopePicker.d.ts +16 -0
- package/lib/pages/cms/coupons/actions.d.ts +5 -0
- package/lib/pages/cms/coupons/index.d.ts +2 -0
- package/lib/pages/cms/coupons/product-options.d.ts +2 -0
- package/lib/pages/cms/orders/ExportReportsDialog.d.ts +2 -0
- package/lib/pages/cms/orders/MarkPaidButton.d.ts +3 -0
- package/lib/pages/cms/orders/OrderDetailPage.d.ts +5 -0
- package/lib/pages/cms/orders/OrderPrintButton.d.ts +3 -0
- package/lib/pages/cms/orders/OrderStatusForm.d.ts +4 -0
- package/lib/pages/cms/orders/OrdersPage.d.ts +6 -0
- package/lib/pages/cms/orders/actions.d.ts +7 -0
- package/lib/pages/cms/orders/export-actions.d.ts +2 -0
- package/lib/pages/cms/orders/index.d.ts +6 -0
- package/lib/pages/cms/orders/server-actions.d.ts +11 -0
- package/lib/pages/cms/orders/types.d.ts +60 -0
- package/lib/pages/cms/payments/PaymentsClient.d.ts +19 -0
- package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -0
- package/lib/pages/cms/payments/actions.d.ts +4 -0
- package/lib/pages/cms/payments/index.d.ts +2 -0
- package/lib/pages/cms/payments/queries.d.ts +12 -0
- package/lib/pages/cms/products/ProductsPage.d.ts +7 -0
- package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +12 -0
- package/lib/pages/cms/products/actions.d.ts +18201 -0
- package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -0
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +50 -0
- package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -0
- package/lib/pages/cms/products/categories/components/CategoryManager.d.ts +47 -0
- package/lib/pages/cms/products/components/CopyProductFromLanguage.d.ts +9 -0
- package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +18 -0
- package/lib/pages/cms/products/components/DeleteProductButton.d.ts +9 -0
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +24 -0
- package/lib/pages/cms/products/components/ProductCategorySelector.d.ts +14 -0
- package/lib/pages/cms/products/components/ProductForm.d.ts +62 -0
- package/lib/pages/cms/products/components/ProductMediaManager.d.ts +17 -0
- package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +32 -0
- package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +16 -0
- package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +3 -0
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +5 -0
- package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -0
- package/lib/pages/cms/products/components/VariationsEditor.d.ts +26 -0
- package/lib/pages/cms/products/index.d.ts +7 -0
- package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -0
- package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +6 -0
- package/lib/pages/cms/products/inventory/actions.d.ts +38 -0
- package/lib/pages/cms/products/new/NewProductPage.d.ts +9 -0
- package/lib/pages/cms/products/product-price-sync.d.ts +43 -0
- package/lib/pages/cms/products/server-actions.d.ts +125 -0
- package/lib/pages/cms/shipping/ShippingPage.d.ts +6 -0
- package/lib/pages/cms/shipping/components/RateForm.d.ts +26 -0
- package/lib/pages/cms/shipping/components/ZoneForm.d.ts +13 -0
- package/lib/pages/cms/shipping/index.d.ts +2 -0
- package/lib/pages/cms/shipping/server-actions.d.ts +80 -0
- package/lib/pages/cms/taxes/TaxesPage.d.ts +5 -0
- package/lib/pages/cms/taxes/actions.d.ts +3 -0
- package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +8 -0
- package/lib/pages/cms/taxes/index.d.ts +2 -0
- package/lib/product-actions.d.ts +18457 -0
- package/lib/product-context.d.ts +7 -0
- package/lib/product-schema.d.ts +73 -0
- package/lib/providers/freemius.d.ts +49 -0
- package/lib/providers/stripe.d.ts +13 -0
- package/lib/server-actions/coupon-actions.d.ts +17 -0
- package/lib/server-actions/customer-actions.d.ts +18 -0
- package/lib/server-actions/product-actions.d.ts +69 -0
- package/lib/server-actions/shipping-actions.d.ts +10 -0
- package/lib/server-actions/tax-actions.d.ts +7 -0
- package/lib/shared-inventory.d.ts +38 -0
- package/lib/shipping/resolver.d.ts +16 -0
- package/lib/shipping-rate-currency.d.ts +39 -0
- package/lib/states.d.ts +9 -0
- package/lib/stripe/checkout.d.ts +6 -0
- package/lib/stripe/client.d.ts +2 -0
- package/lib/stripe/order-sync.d.ts +18 -0
- package/lib/stripe/webhooks.d.ts +4 -0
- package/lib/tax-calculation.d.ts +23 -0
- package/lib/trials.d.ts +15 -0
- package/lib/types.d.ts +245 -0
- package/lib/use-cart.d.ts +11 -0
- package/lib/variation-utils.d.ts +72 -0
- package/lib/zod-config.d.ts +2 -0
- package/package.json +47 -2
- package/server.cjs.js +110 -0
- package/server.d.ts +31 -0
- package/server.es.js +6039 -0
- package/index.ts +0 -12
- package/tsconfig.lib.json +0 -10
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CartItem } from './types';
|
|
2
|
+
export type CustomerAddressType = 'billing' | 'shipping';
|
|
3
|
+
export interface CustomerAddressInput {
|
|
4
|
+
company_name?: string | null;
|
|
5
|
+
recipient_name?: string | null;
|
|
6
|
+
line1?: string | null;
|
|
7
|
+
line2?: string | null;
|
|
8
|
+
city?: string | null;
|
|
9
|
+
state?: string | null;
|
|
10
|
+
postal_code?: string | null;
|
|
11
|
+
country_code?: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface OrderCustomerDetails {
|
|
14
|
+
email: string | null;
|
|
15
|
+
name: string | null;
|
|
16
|
+
phone: string | null;
|
|
17
|
+
billing: CustomerAddressInput | null;
|
|
18
|
+
shipping: CustomerAddressInput | null;
|
|
19
|
+
}
|
|
20
|
+
export interface CheckoutSessionInput {
|
|
21
|
+
items: CartItem[];
|
|
22
|
+
couponCode?: string | null;
|
|
23
|
+
couponContextItems?: CartItem[];
|
|
24
|
+
customerEmail?: string | null;
|
|
25
|
+
customerPhone?: string | null;
|
|
26
|
+
billingAddress: CustomerAddressInput;
|
|
27
|
+
shippingAddress?: CustomerAddressInput | null;
|
|
28
|
+
shippingMethodId?: string | null;
|
|
29
|
+
currencyCode?: string | null;
|
|
30
|
+
locale?: string | null;
|
|
31
|
+
userId?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface CheckoutCustomerDefaults {
|
|
34
|
+
isAuthenticated: boolean;
|
|
35
|
+
email?: string | null;
|
|
36
|
+
fullName?: string | null;
|
|
37
|
+
phone?: string | null;
|
|
38
|
+
billingAddress?: CustomerAddressInput | null;
|
|
39
|
+
shippingAddress?: CustomerAddressInput | null;
|
|
40
|
+
}
|
|
41
|
+
export declare const emptyCustomerAddress: () => CustomerAddressInput;
|
|
42
|
+
export declare function normalizeCustomerAddress(address?: CustomerAddressInput | null): CustomerAddressInput | null;
|
|
43
|
+
export declare function isCustomerAddressComplete(address?: CustomerAddressInput | null): boolean;
|
|
44
|
+
export declare function normalizeOrderCustomerDetails(input: {
|
|
45
|
+
email?: string | null;
|
|
46
|
+
name?: string | null;
|
|
47
|
+
phone?: string | null;
|
|
48
|
+
billing?: CustomerAddressInput | null;
|
|
49
|
+
shipping?: CustomerAddressInput | null;
|
|
50
|
+
}): OrderCustomerDetails;
|
|
51
|
+
export declare function addressesMatch(first?: CustomerAddressInput | null, second?: CustomerAddressInput | null): boolean;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface ReportData {
|
|
2
|
+
id: string;
|
|
3
|
+
created_at: string;
|
|
4
|
+
paid_at: string | null;
|
|
5
|
+
status: string;
|
|
6
|
+
total: number;
|
|
7
|
+
subtotal: number;
|
|
8
|
+
shipping_total: number;
|
|
9
|
+
tax_total: number;
|
|
10
|
+
currency: string;
|
|
11
|
+
provider: string;
|
|
12
|
+
customer_details: any;
|
|
13
|
+
tax_details: any;
|
|
14
|
+
customer?: {
|
|
15
|
+
full_name: string | null;
|
|
16
|
+
email: string | null;
|
|
17
|
+
} | null;
|
|
18
|
+
}
|
|
19
|
+
export declare function generateCSV(data: any[], filename: string): void;
|
|
20
|
+
export declare function mapGeneralSalesLedger(orders: ReportData[]): {
|
|
21
|
+
'Order ID': string;
|
|
22
|
+
Date: string;
|
|
23
|
+
'Customer Name': any;
|
|
24
|
+
'Customer Email': any;
|
|
25
|
+
Subtotal: string;
|
|
26
|
+
'Tax Amount': string;
|
|
27
|
+
'Shipping Amount': string;
|
|
28
|
+
Total: string;
|
|
29
|
+
Currency: string;
|
|
30
|
+
'Payment Status': string;
|
|
31
|
+
'Fulfillment Status': string;
|
|
32
|
+
'Payment Gateway': string;
|
|
33
|
+
}[];
|
|
34
|
+
export declare function mapTaxLiabilitySummary(orders: ReportData[]): {
|
|
35
|
+
Date: string;
|
|
36
|
+
'Order ID': string;
|
|
37
|
+
Destination: string;
|
|
38
|
+
'Tax Rate Applied': string;
|
|
39
|
+
'Total Taxable Amount': string;
|
|
40
|
+
'Tax Collected': string;
|
|
41
|
+
Currency: string;
|
|
42
|
+
}[];
|
|
43
|
+
export declare function mapMultiCurrencyRevenue(orders: ReportData[]): {
|
|
44
|
+
Currency: string;
|
|
45
|
+
'Total Transaction Volume': string;
|
|
46
|
+
'Total Subtotal': string;
|
|
47
|
+
'Total Tax Collected': string;
|
|
48
|
+
}[];
|
package/lib/factory.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
type SupabaseLikeClient = SupabaseClient<any>;
|
|
3
|
+
export declare function syncCouponToFreemius(input: {
|
|
4
|
+
couponId: string;
|
|
5
|
+
client: SupabaseLikeClient;
|
|
6
|
+
}): Promise<{
|
|
7
|
+
success: boolean;
|
|
8
|
+
error: any;
|
|
9
|
+
targetCount?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
success: boolean;
|
|
12
|
+
targetCount: number;
|
|
13
|
+
error?: undefined;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Reconciles the auto-generated, time-bounded Freemius sale coupon for a single
|
|
17
|
+
* product with the product's current scheduled-sale configuration. Creating the
|
|
18
|
+
* coupon with the sale window's start/end dates lets Freemius enforce the window
|
|
19
|
+
* natively at its hosted checkout. Safe to call repeatedly (idempotent upsert
|
|
20
|
+
* keyed by product_id). Never throws — failures are recorded on the mapping row.
|
|
21
|
+
*/
|
|
22
|
+
export declare function syncProductSaleCouponToFreemius(input: {
|
|
23
|
+
productId: string;
|
|
24
|
+
client: SupabaseLikeClient;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
success: boolean;
|
|
27
|
+
error: any;
|
|
28
|
+
skipped?: undefined;
|
|
29
|
+
reason?: undefined;
|
|
30
|
+
active?: undefined;
|
|
31
|
+
code?: undefined;
|
|
32
|
+
} | {
|
|
33
|
+
success: boolean;
|
|
34
|
+
skipped: boolean;
|
|
35
|
+
reason: string;
|
|
36
|
+
error?: undefined;
|
|
37
|
+
active?: undefined;
|
|
38
|
+
code?: undefined;
|
|
39
|
+
} | {
|
|
40
|
+
success: boolean;
|
|
41
|
+
active: boolean;
|
|
42
|
+
error?: undefined;
|
|
43
|
+
skipped?: undefined;
|
|
44
|
+
reason?: undefined;
|
|
45
|
+
code?: undefined;
|
|
46
|
+
} | {
|
|
47
|
+
success: boolean;
|
|
48
|
+
active: boolean;
|
|
49
|
+
code: any;
|
|
50
|
+
error?: undefined;
|
|
51
|
+
skipped?: undefined;
|
|
52
|
+
reason?: undefined;
|
|
53
|
+
}>;
|
|
54
|
+
export declare function deleteCouponFromFreemius(input: {
|
|
55
|
+
couponId: string;
|
|
56
|
+
client: SupabaseLikeClient;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
export type FreemiusTrackedOrderStatus = 'pending' | 'trial' | 'paid' | 'shipped' | 'cancelled' | 'refunded';
|
|
3
|
+
type SupabaseLikeClient = SupabaseClient<any>;
|
|
4
|
+
type FreemiusCheckoutPurchase = {
|
|
5
|
+
initial_amount?: number | string | null;
|
|
6
|
+
initialAmount?: number | string | null;
|
|
7
|
+
gross?: number | string | null;
|
|
8
|
+
total_gross?: number | string | null;
|
|
9
|
+
totalGross?: number | string | null;
|
|
10
|
+
trial_ends?: string | null;
|
|
11
|
+
trialEnds?: string | null;
|
|
12
|
+
canceled_at?: string | null;
|
|
13
|
+
canceledAt?: string | null;
|
|
14
|
+
license_id?: string | number | null;
|
|
15
|
+
licenseId?: string | number | null;
|
|
16
|
+
subscription_id?: string | number | null;
|
|
17
|
+
subscriptionId?: string | number | null;
|
|
18
|
+
user_id?: string | number | null;
|
|
19
|
+
userId?: string | number | null;
|
|
20
|
+
plugin_id?: string | number | null;
|
|
21
|
+
product_id?: string | number | null;
|
|
22
|
+
productId?: string | number | null;
|
|
23
|
+
plan_id?: string | number | null;
|
|
24
|
+
planId?: string | number | null;
|
|
25
|
+
pricing_id?: string | number | null;
|
|
26
|
+
pricingId?: string | number | null;
|
|
27
|
+
};
|
|
28
|
+
type FreemiusCheckoutTrial = {
|
|
29
|
+
id?: string | number | null;
|
|
30
|
+
license_id?: string | number | null;
|
|
31
|
+
licenseId?: string | number | null;
|
|
32
|
+
payment_id?: string | number | null;
|
|
33
|
+
plugin_id?: string | number | null;
|
|
34
|
+
product_id?: string | number | null;
|
|
35
|
+
productId?: string | number | null;
|
|
36
|
+
subscription_id?: string | number | null;
|
|
37
|
+
subscriptionId?: string | number | null;
|
|
38
|
+
user_id?: string | number | null;
|
|
39
|
+
userId?: string | number | null;
|
|
40
|
+
canceled_at?: string | null;
|
|
41
|
+
canceledAt?: string | null;
|
|
42
|
+
converted_at?: string | null;
|
|
43
|
+
convertedAt?: string | null;
|
|
44
|
+
trial_ends_at?: string | null;
|
|
45
|
+
trialEndsAt?: string | null;
|
|
46
|
+
with_payment_method?: boolean | null;
|
|
47
|
+
};
|
|
48
|
+
export type FreemiusCheckoutResponse = {
|
|
49
|
+
purchase?: FreemiusCheckoutPurchase | null;
|
|
50
|
+
trial?: FreemiusCheckoutTrial | null;
|
|
51
|
+
user?: {
|
|
52
|
+
id?: string | number | null;
|
|
53
|
+
email?: string | null;
|
|
54
|
+
} | null;
|
|
55
|
+
};
|
|
56
|
+
type FreemiusOrderMetadata = {
|
|
57
|
+
freemius_product_id?: string | null;
|
|
58
|
+
freemius_plan_id?: string | null;
|
|
59
|
+
freemius_license_id?: string | null;
|
|
60
|
+
freemius_subscription_id?: string | null;
|
|
61
|
+
freemius_trial_id?: string | null;
|
|
62
|
+
freemius_user_id?: string | null;
|
|
63
|
+
freemius_trial_ends_at?: string | null;
|
|
64
|
+
};
|
|
65
|
+
type FreemiusWebhookEvent = {
|
|
66
|
+
id?: string | number | null;
|
|
67
|
+
type?: string;
|
|
68
|
+
data?: Record<string, any> | null;
|
|
69
|
+
objects?: Record<string, any> | null;
|
|
70
|
+
};
|
|
71
|
+
export declare function extractFreemiusCheckoutMetadata(response: FreemiusCheckoutResponse | null | undefined): FreemiusOrderMetadata;
|
|
72
|
+
export declare function resolveFreemiusStatusFromCheckoutResponse(response: FreemiusCheckoutResponse | null | undefined, currentStatus?: string): FreemiusTrackedOrderStatus;
|
|
73
|
+
export declare function resolveFreemiusStatusFromWebhookEvent(input: {
|
|
74
|
+
event: FreemiusWebhookEvent;
|
|
75
|
+
currentStatus: string;
|
|
76
|
+
purchaseData?: Record<string, any> | null;
|
|
77
|
+
}): FreemiusTrackedOrderStatus;
|
|
78
|
+
export declare function syncFreemiusCheckoutOrder(input: {
|
|
79
|
+
orderId: string;
|
|
80
|
+
checkoutResponse?: FreemiusCheckoutResponse | null;
|
|
81
|
+
client?: SupabaseLikeClient;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
success: boolean;
|
|
84
|
+
error: string;
|
|
85
|
+
orderId?: undefined;
|
|
86
|
+
status?: undefined;
|
|
87
|
+
metadata?: undefined;
|
|
88
|
+
} | {
|
|
89
|
+
success: boolean;
|
|
90
|
+
orderId: string;
|
|
91
|
+
status: FreemiusTrackedOrderStatus;
|
|
92
|
+
metadata: {
|
|
93
|
+
freemius_product_id: string | null;
|
|
94
|
+
freemius_plan_id: string | null;
|
|
95
|
+
freemius_license_id: string | null;
|
|
96
|
+
freemius_subscription_id: string | null;
|
|
97
|
+
freemius_trial_id: string | null;
|
|
98
|
+
freemius_user_id: string | null;
|
|
99
|
+
freemius_trial_ends_at: string | null;
|
|
100
|
+
};
|
|
101
|
+
error?: undefined;
|
|
102
|
+
}>;
|
|
103
|
+
export declare function syncFreemiusOrderFromWebhookEvent(input: {
|
|
104
|
+
event: FreemiusWebhookEvent;
|
|
105
|
+
client?: SupabaseLikeClient;
|
|
106
|
+
}): Promise<{
|
|
107
|
+
success: boolean;
|
|
108
|
+
ignored: boolean;
|
|
109
|
+
reason: string;
|
|
110
|
+
type: string | undefined;
|
|
111
|
+
licenseId?: undefined;
|
|
112
|
+
orderId?: undefined;
|
|
113
|
+
status?: undefined;
|
|
114
|
+
} | {
|
|
115
|
+
success: boolean;
|
|
116
|
+
ignored: boolean;
|
|
117
|
+
reason: string;
|
|
118
|
+
licenseId: string;
|
|
119
|
+
type: string | undefined;
|
|
120
|
+
orderId?: undefined;
|
|
121
|
+
status?: undefined;
|
|
122
|
+
} | {
|
|
123
|
+
success: boolean;
|
|
124
|
+
orderId: string;
|
|
125
|
+
status: FreemiusTrackedOrderStatus;
|
|
126
|
+
type: string | undefined;
|
|
127
|
+
ignored?: undefined;
|
|
128
|
+
reason?: undefined;
|
|
129
|
+
licenseId?: undefined;
|
|
130
|
+
}>;
|
|
131
|
+
export declare function getFreemiusWebhookSecretCandidates(): string[];
|
|
132
|
+
export declare function verifyFreemiusWebhookSignature(rawBody: string, signature: string | null): boolean;
|
|
133
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { EcommerceSettings } from './types';
|
|
3
|
+
export declare const ECOMMERCE_INVENTORY_SETTINGS_KEY = "ecommerce_inventory_settings";
|
|
4
|
+
export type EcommerceInventorySettings = EcommerceSettings;
|
|
5
|
+
export interface CheckoutErrorPayload {
|
|
6
|
+
error: string;
|
|
7
|
+
errorKey?: string;
|
|
8
|
+
errorParams?: Record<string, string | number>;
|
|
9
|
+
errorStatus?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const DEFAULT_ECOMMERCE_INVENTORY_SETTINGS: EcommerceInventorySettings;
|
|
12
|
+
export declare function normalizeEcommerceInventorySettings(value: unknown): EcommerceInventorySettings;
|
|
13
|
+
export declare function getEcommerceInventorySettings(supabase: SupabaseClient<any>): Promise<EcommerceInventorySettings>;
|
|
14
|
+
export declare function upsertEcommerceInventorySettings(supabase: SupabaseClient<any>, settings: EcommerceInventorySettings): Promise<import('@supabase/postgrest-js').PostgrestSingleResponse<null>>;
|
|
15
|
+
export declare function createInventoryUnavailableError(item: string): CheckoutErrorPayload;
|
|
16
|
+
export declare function createInventoryInsufficientError(item: string, count: number): CheckoutErrorPayload;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { InvoiceLogo, InvoiceOrder, InvoicePresentationData } from './invoice';
|
|
3
|
+
type SupabaseLikeClient = SupabaseClient<any>;
|
|
4
|
+
export declare function getInvoiceBrandingData(client?: SupabaseLikeClient): Promise<{
|
|
5
|
+
settings: import('./invoice').InvoiceSettings;
|
|
6
|
+
logo: InvoiceLogo | null;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function assignInvoiceMetadata(input: {
|
|
9
|
+
orderId: string;
|
|
10
|
+
paidAt?: string | null;
|
|
11
|
+
client?: SupabaseLikeClient;
|
|
12
|
+
}): Promise<{
|
|
13
|
+
invoiceNumber: any;
|
|
14
|
+
paidAt: any;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function getInvoiceOrder(orderId: string, client?: SupabaseLikeClient): Promise<InvoiceOrder>;
|
|
17
|
+
export declare function getInvoicePresentationData(orderId: string, client?: SupabaseLikeClient): Promise<InvoicePresentationData>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { InvoiceDocumentLabels } from './components/InvoiceDocument';
|
|
2
|
+
import { InvoicePresentationData } from './invoice';
|
|
3
|
+
export type InvoiceTranslationFn = (key: string, params?: Record<string, string | number>) => string;
|
|
4
|
+
export declare function translateOrFallback(t: InvoiceTranslationFn, key: string, fallback: string): string;
|
|
5
|
+
export declare function buildInvoiceDocumentLabels(t: InvoiceTranslationFn): InvoiceDocumentLabels;
|
|
6
|
+
export declare function getInvoiceLocale(lang?: string | null): "en-US" | "fr-CA";
|
|
7
|
+
export declare function translateOrderStatus(status: string | null | undefined, t: InvoiceTranslationFn): string;
|
|
8
|
+
export declare function localizeInvoicePresentationData(invoice: InvoicePresentationData | null, t: InvoiceTranslationFn): {
|
|
9
|
+
order: {
|
|
10
|
+
status: string;
|
|
11
|
+
id: string;
|
|
12
|
+
invoice_number: string | null;
|
|
13
|
+
paid_at: string | null;
|
|
14
|
+
created_at: string | null;
|
|
15
|
+
currency: string;
|
|
16
|
+
provider: string | null;
|
|
17
|
+
subtotal: number;
|
|
18
|
+
shipping_total: number;
|
|
19
|
+
discount_total: number;
|
|
20
|
+
coupon_code?: string | null;
|
|
21
|
+
tax_total: number;
|
|
22
|
+
total: number;
|
|
23
|
+
customer_details: import('./customer').OrderCustomerDetails | null;
|
|
24
|
+
tax_details: import('./order-tax-details').OrderTaxDetails | null;
|
|
25
|
+
items: import('./invoice').InvoiceOrderItem[];
|
|
26
|
+
};
|
|
27
|
+
settings: import('./invoice').InvoiceSettings;
|
|
28
|
+
logo: import('./invoice').InvoiceLogo | null;
|
|
29
|
+
} | null;
|
package/lib/invoice.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { OrderCustomerDetails } from './customer';
|
|
2
|
+
import { OrderTaxDetails } from './order-tax-details';
|
|
3
|
+
export declare const INVOICE_SETTINGS_KEY = "invoice_settings";
|
|
4
|
+
export interface InvoiceTaxRegistration {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
export interface InvoiceAddress {
|
|
9
|
+
line1?: string | null;
|
|
10
|
+
line2?: string | null;
|
|
11
|
+
city?: string | null;
|
|
12
|
+
state?: string | null;
|
|
13
|
+
postal_code?: string | null;
|
|
14
|
+
country_code?: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface InvoiceSettings {
|
|
17
|
+
businessName: string;
|
|
18
|
+
email: string;
|
|
19
|
+
phone: string;
|
|
20
|
+
address: InvoiceAddress;
|
|
21
|
+
taxRegistrations: InvoiceTaxRegistration[];
|
|
22
|
+
}
|
|
23
|
+
export interface InvoiceLogo {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string | null;
|
|
26
|
+
url: string | null;
|
|
27
|
+
width: number | null;
|
|
28
|
+
height: number | null;
|
|
29
|
+
}
|
|
30
|
+
export interface InvoiceOrderItem {
|
|
31
|
+
id: string;
|
|
32
|
+
product_id?: string | null;
|
|
33
|
+
variant_id?: string | null;
|
|
34
|
+
title: string;
|
|
35
|
+
description?: string | null;
|
|
36
|
+
quantity: number;
|
|
37
|
+
unit_amount: number;
|
|
38
|
+
total_amount: number;
|
|
39
|
+
sku?: string | null;
|
|
40
|
+
}
|
|
41
|
+
export interface InvoiceOrder {
|
|
42
|
+
id: string;
|
|
43
|
+
invoice_number: string | null;
|
|
44
|
+
paid_at: string | null;
|
|
45
|
+
created_at: string | null;
|
|
46
|
+
currency: string;
|
|
47
|
+
status: string;
|
|
48
|
+
provider: string | null;
|
|
49
|
+
subtotal: number;
|
|
50
|
+
shipping_total: number;
|
|
51
|
+
discount_total: number;
|
|
52
|
+
coupon_code?: string | null;
|
|
53
|
+
tax_total: number;
|
|
54
|
+
total: number;
|
|
55
|
+
customer_details: OrderCustomerDetails | null;
|
|
56
|
+
tax_details: OrderTaxDetails | null;
|
|
57
|
+
items: InvoiceOrderItem[];
|
|
58
|
+
}
|
|
59
|
+
export interface InvoicePresentationData {
|
|
60
|
+
order: InvoiceOrder;
|
|
61
|
+
settings: InvoiceSettings;
|
|
62
|
+
logo: InvoiceLogo | null;
|
|
63
|
+
}
|
|
64
|
+
export declare const DEFAULT_INVOICE_SETTINGS: InvoiceSettings;
|
|
65
|
+
export declare function normalizeInvoiceSettings(value: unknown): InvoiceSettings;
|
|
66
|
+
export declare function serializeInvoiceSettings(settings: InvoiceSettings): {
|
|
67
|
+
business_name: string;
|
|
68
|
+
email: string;
|
|
69
|
+
phone: string;
|
|
70
|
+
address: InvoiceAddress;
|
|
71
|
+
tax_registrations: InvoiceTaxRegistration[];
|
|
72
|
+
};
|
|
73
|
+
export declare function formatInvoiceCurrency(amount: number, currency?: string, locale?: string): string;
|
|
74
|
+
export declare function formatInvoiceDate(value?: string | null, locale?: string): string;
|
|
75
|
+
export declare function getInvoiceAddressLines(address?: InvoiceAddress | OrderCustomerDetails['billing']): string[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { Database } from '../../../db/src/index.ts';
|
|
3
|
+
export declare function applyOrderInventoryDeduction(supabase: SupabaseClient<Database>, orderId: string): Promise<{
|
|
4
|
+
method: "rpc";
|
|
5
|
+
} | {
|
|
6
|
+
method: "sql-fallback";
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { default as Stripe } from 'stripe';
|
|
2
|
+
import { TaxCalculationResult, TaxCalculationMode } from './types';
|
|
3
|
+
export interface OrderTaxRateDetails {
|
|
4
|
+
id?: string | null;
|
|
5
|
+
display_name: string;
|
|
6
|
+
percentage?: number | null;
|
|
7
|
+
effective_percentage?: number | null;
|
|
8
|
+
jurisdiction?: string | null;
|
|
9
|
+
jurisdiction_level?: string | null;
|
|
10
|
+
country?: string | null;
|
|
11
|
+
state?: string | null;
|
|
12
|
+
tax_type?: string | null;
|
|
13
|
+
inclusive?: boolean | null;
|
|
14
|
+
description?: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface OrderTaxLine {
|
|
17
|
+
scope: 'aggregate' | 'line_item' | 'shipping';
|
|
18
|
+
source: 'manual' | 'stripe_checkout';
|
|
19
|
+
amount: number;
|
|
20
|
+
taxable_amount?: number | null;
|
|
21
|
+
description?: string | null;
|
|
22
|
+
line_item_id?: string | null;
|
|
23
|
+
taxability_reason?: string | null;
|
|
24
|
+
rate: OrderTaxRateDetails;
|
|
25
|
+
}
|
|
26
|
+
export interface OrderTaxDetails {
|
|
27
|
+
source: 'manual' | 'stripe_checkout' | 'none';
|
|
28
|
+
mode: TaxCalculationMode;
|
|
29
|
+
currency: string;
|
|
30
|
+
subtotal: number;
|
|
31
|
+
shipping_total: number;
|
|
32
|
+
tax_total: number;
|
|
33
|
+
total: number;
|
|
34
|
+
is_finalized: boolean;
|
|
35
|
+
lines: OrderTaxLine[];
|
|
36
|
+
updated_at: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function getOrderTaxRateLabel(rate: Pick<OrderTaxRateDetails, 'display_name' | 'tax_type'>): string;
|
|
39
|
+
export declare function getOrderTaxRatePercentage(rate: Pick<OrderTaxRateDetails, 'effective_percentage' | 'percentage'>): number | null;
|
|
40
|
+
export declare function getOrderTaxRateJurisdiction(rate: Pick<OrderTaxRateDetails, 'jurisdiction' | 'state' | 'country'>): string | null;
|
|
41
|
+
export declare function aggregateOrderTaxLines(lines: OrderTaxLine[]): OrderTaxLine[];
|
|
42
|
+
export declare function normalizeOrderTaxDetails(value: unknown): OrderTaxDetails | null;
|
|
43
|
+
export declare function buildOrderTaxDetailsFromCalculation(input: {
|
|
44
|
+
calculation: TaxCalculationResult;
|
|
45
|
+
subtotal: number;
|
|
46
|
+
shippingTotal: number;
|
|
47
|
+
total: number;
|
|
48
|
+
currency?: string;
|
|
49
|
+
}): OrderTaxDetails;
|
|
50
|
+
export declare function buildOrderTaxDetailsFromStripeSession(input: {
|
|
51
|
+
session: Stripe.Checkout.Session;
|
|
52
|
+
lineItems: Stripe.LineItem[];
|
|
53
|
+
subtotal: number;
|
|
54
|
+
shippingTotal: number;
|
|
55
|
+
fallbackMode?: TaxCalculationMode;
|
|
56
|
+
currency?: string | null;
|
|
57
|
+
}): OrderTaxDetails;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CouponProductOption } from './ProductScopePicker';
|
|
2
|
+
type CouponFormValues = {
|
|
3
|
+
id?: string;
|
|
4
|
+
code?: string | null;
|
|
5
|
+
name?: string | null;
|
|
6
|
+
internal_note?: string | null;
|
|
7
|
+
provider_scope?: string | null;
|
|
8
|
+
discount_type?: string | null;
|
|
9
|
+
discount_amount?: number | null;
|
|
10
|
+
is_active?: boolean | null;
|
|
11
|
+
starts_at?: string | null;
|
|
12
|
+
ends_at?: string | null;
|
|
13
|
+
redemption_limit?: number | null;
|
|
14
|
+
};
|
|
15
|
+
export declare function CouponEditorForm({ action, products, coupon, selectedProductIds, submitLabel, currencyCode, }: {
|
|
16
|
+
action: (formData: FormData) => Promise<void>;
|
|
17
|
+
products: CouponProductOption[];
|
|
18
|
+
coupon?: CouponFormValues | null;
|
|
19
|
+
selectedProductIds?: string[];
|
|
20
|
+
submitLabel: string;
|
|
21
|
+
currencyCode?: string;
|
|
22
|
+
}): import("react").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CouponProductOption } from './ProductScopePicker';
|
|
2
|
+
export declare function CreateCouponDialog({ action, products, currencyCode, }: {
|
|
3
|
+
action: (formData: FormData) => Promise<void>;
|
|
4
|
+
products: CouponProductOption[];
|
|
5
|
+
currencyCode: string;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type CouponProductOption = {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
sku?: string | null;
|
|
5
|
+
payment_provider: string;
|
|
6
|
+
freemius_product_id?: string | null;
|
|
7
|
+
thumbnailUrl?: string | null;
|
|
8
|
+
language?: {
|
|
9
|
+
code?: string | null;
|
|
10
|
+
name?: string | null;
|
|
11
|
+
} | null;
|
|
12
|
+
};
|
|
13
|
+
export declare function ProductScopePicker({ products, selectedProductIds, }: {
|
|
14
|
+
products: CouponProductOption[];
|
|
15
|
+
selectedProductIds?: string[];
|
|
16
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function createCouponAction(formData: FormData): Promise<void>;
|
|
2
|
+
export declare function updateCouponAction(couponId: string, formData: FormData): Promise<void>;
|
|
3
|
+
export declare function toggleCouponActiveAction(couponId: string, isActive: boolean): Promise<void>;
|
|
4
|
+
export declare function syncCouponAction(couponId: string): Promise<void>;
|
|
5
|
+
export declare function deleteCouponAction(couponId: string): Promise<void>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OrderWithDetails } from './types';
|
|
2
|
+
export declare function getOrders(page?: number, status?: string, search?: string): Promise<{
|
|
3
|
+
data: OrderWithDetails[];
|
|
4
|
+
total: number;
|
|
5
|
+
totalPages: number;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function getOrderDetails(orderId: string): Promise<OrderWithDetails | null>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const MANAGEABLE_ORDER_STATUSES: readonly ["pending", "trial", "paid", "shipped", "cancelled", "refunded"];
|
|
2
|
+
export type ManageableOrderStatus = (typeof MANAGEABLE_ORDER_STATUSES)[number];
|
|
3
|
+
export declare function markOrderAsPaid(orderId: string): Promise<{
|
|
4
|
+
success: boolean;
|
|
5
|
+
error?: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function updateOrderStatus(orderId: string, nextStatus: ManageableOrderStatus): Promise<{
|
|
8
|
+
success: boolean;
|
|
9
|
+
error?: string;
|
|
10
|
+
}>;
|
|
11
|
+
export {};
|