@stacksjs/commerce 0.70.86 → 0.70.88
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/package.json +1 -1
- package/dist/coupons/destroy.d.ts +0 -17
- package/dist/coupons/fetch.d.ts +0 -59
- package/dist/coupons/index.d.ts +0 -27
- package/dist/coupons/store.d.ts +0 -9
- package/dist/coupons/update.d.ts +0 -46
- package/dist/customers/destroy.d.ts +0 -14
- package/dist/customers/fetch.d.ts +0 -9
- package/dist/customers/index.d.ts +0 -14
- package/dist/customers/store.d.ts +0 -9
- package/dist/customers/update.d.ts +0 -10
- package/dist/devices/destroy.d.ts +0 -14
- package/dist/devices/export.d.ts +0 -35
- package/dist/devices/fetch.d.ts +0 -38
- package/dist/devices/index.d.ts +0 -27
- package/dist/devices/store.d.ts +0 -16
- package/dist/devices/update.d.ts +0 -26
- package/dist/errors/destroy.d.ts +0 -12
- package/dist/errors/fetch.d.ts +0 -54
- package/dist/errors/index.d.ts +0 -25
- package/dist/errors/update.d.ts +0 -24
- package/dist/gift-cards/destroy.d.ts +0 -23
- package/dist/gift-cards/fetch.d.ts +0 -88
- package/dist/gift-cards/index.d.ts +0 -23
- package/dist/gift-cards/store.d.ts +0 -9
- package/dist/gift-cards/update.d.ts +0 -30
- package/dist/index.d.ts +0 -58
- package/dist/index.js +0 -2
- package/dist/orders/destroy.d.ts +0 -28
- package/dist/orders/events.d.ts +0 -46
- package/dist/orders/export.d.ts +0 -32
- package/dist/orders/fetch.d.ts +0 -76
- package/dist/orders/guards.d.ts +0 -93
- package/dist/orders/index.d.ts +0 -82
- package/dist/orders/place-order.d.ts +0 -18
- package/dist/orders/store.d.ts +0 -9
- package/dist/orders/totals.d.ts +0 -24
- package/dist/orders/update.d.ts +0 -28
- package/dist/orders/webhook.d.ts +0 -31
- package/dist/payments/destroy.d.ts +0 -14
- package/dist/payments/fetch.d.ts +0 -55
- package/dist/payments/index.d.ts +0 -13
- package/dist/payments/store.d.ts +0 -9
- package/dist/payments/update.d.ts +0 -18
- package/dist/products/categories/destroy.d.ts +0 -30
- package/dist/products/categories/fetch.d.ts +0 -49
- package/dist/products/categories/index.d.ts +0 -33
- package/dist/products/categories/store.d.ts +0 -21
- package/dist/products/categories/update.d.ts +0 -33
- package/dist/products/index.d.ts +0 -24
- package/dist/products/items/destroy.d.ts +0 -14
- package/dist/products/items/fetch.d.ts +0 -66
- package/dist/products/items/index.d.ts +0 -23
- package/dist/products/items/store.d.ts +0 -16
- package/dist/products/items/update.d.ts +0 -82
- package/dist/products/manufacturers/destroy.d.ts +0 -14
- package/dist/products/manufacturers/fetch.d.ts +0 -23
- package/dist/products/manufacturers/index.d.ts +0 -21
- package/dist/products/manufacturers/store.d.ts +0 -16
- package/dist/products/manufacturers/update.d.ts +0 -26
- package/dist/products/reviews/destroy.d.ts +0 -14
- package/dist/products/reviews/fetch.d.ts +0 -22
- package/dist/products/reviews/index.d.ts +0 -22
- package/dist/products/reviews/store.d.ts +0 -16
- package/dist/products/reviews/update.d.ts +0 -19
- package/dist/products/units/destroy.d.ts +0 -14
- package/dist/products/units/fetch.d.ts +0 -9
- package/dist/products/units/index.d.ts +0 -9
- package/dist/products/units/store.d.ts +0 -31
- package/dist/products/units/update.d.ts +0 -25
- package/dist/products/variants/destroy.d.ts +0 -14
- package/dist/products/variants/fetch.d.ts +0 -9
- package/dist/products/variants/index.d.ts +0 -18
- package/dist/products/variants/store.d.ts +0 -43
- package/dist/products/variants/update.d.ts +0 -25
- package/dist/receipts/destroy.d.ts +0 -14
- package/dist/receipts/fetch.d.ts +0 -80
- package/dist/receipts/index.d.ts +0 -21
- package/dist/receipts/store.d.ts +0 -16
- package/dist/receipts/update.d.ts +0 -28
- package/dist/shippings/delivery-routes/destroy.d.ts +0 -14
- package/dist/shippings/delivery-routes/fetch.d.ts +0 -17
- package/dist/shippings/delivery-routes/index.d.ts +0 -23
- package/dist/shippings/delivery-routes/store.d.ts +0 -16
- package/dist/shippings/delivery-routes/update.d.ts +0 -27
- package/dist/shippings/digital-deliveries/destroy.d.ts +0 -28
- package/dist/shippings/digital-deliveries/fetch.d.ts +0 -9
- package/dist/shippings/digital-deliveries/index.d.ts +0 -23
- package/dist/shippings/digital-deliveries/store.d.ts +0 -16
- package/dist/shippings/digital-deliveries/update.d.ts +0 -29
- package/dist/shippings/drivers/destroy.d.ts +0 -16
- package/dist/shippings/drivers/fetch.d.ts +0 -9
- package/dist/shippings/drivers/index.d.ts +0 -21
- package/dist/shippings/drivers/store.d.ts +0 -16
- package/dist/shippings/drivers/update.d.ts +0 -26
- package/dist/shippings/index.d.ts +0 -27
- package/dist/shippings/license-keys/destroy.d.ts +0 -28
- package/dist/shippings/license-keys/fetch.d.ts +0 -9
- package/dist/shippings/license-keys/index.d.ts +0 -23
- package/dist/shippings/license-keys/store.d.ts +0 -17
- package/dist/shippings/license-keys/update.d.ts +0 -26
- package/dist/shippings/shipping-methods/destroy.d.ts +0 -28
- package/dist/shippings/shipping-methods/fetch.d.ts +0 -9
- package/dist/shippings/shipping-methods/index.d.ts +0 -25
- package/dist/shippings/shipping-methods/store.d.ts +0 -28
- package/dist/shippings/shipping-methods/update.d.ts +0 -27
- package/dist/shippings/shipping-rates/destroy.d.ts +0 -28
- package/dist/shippings/shipping-rates/fetch.d.ts +0 -98
- package/dist/shippings/shipping-rates/index.d.ts +0 -33
- package/dist/shippings/shipping-rates/store.d.ts +0 -17
- package/dist/shippings/shipping-rates/update.d.ts +0 -36
- package/dist/shippings/shipping-zones/destroy.d.ts +0 -28
- package/dist/shippings/shipping-zones/fetch.d.ts +0 -28
- package/dist/shippings/shipping-zones/index.d.ts +0 -23
- package/dist/shippings/shipping-zones/store.d.ts +0 -17
- package/dist/shippings/shipping-zones/update.d.ts +0 -35
- package/dist/tax/destroy.d.ts +0 -14
- package/dist/tax/fetch.d.ts +0 -9
- package/dist/tax/index.d.ts +0 -21
- package/dist/tax/store.d.ts +0 -16
- package/dist/tax/update.d.ts +0 -26
- package/dist/types.d.ts +0 -265
- package/dist/utils/typed-stats.d.ts +0 -23
- package/dist/waitlists/index.d.ts +0 -12
- package/dist/waitlists/products/destroy.d.ts +0 -15
- package/dist/waitlists/products/fetch.d.ts +0 -100
- package/dist/waitlists/products/index.d.ts +0 -30
- package/dist/waitlists/products/store.d.ts +0 -16
- package/dist/waitlists/products/update.d.ts +0 -26
- package/dist/waitlists/restaurant/destroy.d.ts +0 -15
- package/dist/waitlists/restaurant/fetch.d.ts +0 -149
- package/dist/waitlists/restaurant/index.d.ts +0 -40
- package/dist/waitlists/restaurant/store.d.ts +0 -16
- package/dist/waitlists/restaurant/update.d.ts +0 -43
package/dist/orders/fetch.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { OrderStats } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Fetch all orders from the database with their items
|
|
4
|
-
* @param limit Optional limit on number of orders to fetch
|
|
5
|
-
*/
|
|
6
|
-
export declare function fetchAll(limit?: number): Promise<OrderJsonResponse[]>;
|
|
7
|
-
/**
|
|
8
|
-
* Fetch the most recent orders
|
|
9
|
-
* @param limit Number of recent orders to fetch (default: 10)
|
|
10
|
-
*/
|
|
11
|
-
export declare function fetchRecent(limit?: number): Promise<OrderJsonResponse[]>;
|
|
12
|
-
/**
|
|
13
|
-
* Fetch an order by ID
|
|
14
|
-
*/
|
|
15
|
-
export declare function fetchById(id: number): Promise<OrderJsonResponse | undefined>;
|
|
16
|
-
/**
|
|
17
|
-
* Get order statistics
|
|
18
|
-
*/
|
|
19
|
-
export declare function fetchStats(): Promise<OrderStats>;
|
|
20
|
-
/**
|
|
21
|
-
* Compare orders between different time periods
|
|
22
|
-
* @param daysRange Number of days to look back (7, 30, 60, etc.)
|
|
23
|
-
*/
|
|
24
|
-
export declare function compareOrdersByPeriod(_daysRange?: number): Promise<{
|
|
25
|
-
current_period: number
|
|
26
|
-
previous_period: number
|
|
27
|
-
difference: number
|
|
28
|
-
percentage_change: number
|
|
29
|
-
days_range: number
|
|
30
|
-
}>;
|
|
31
|
-
/**
|
|
32
|
-
* Calculate order values and metrics for different time periods
|
|
33
|
-
* @param daysRange Number of days to look back (7, 30, 60, etc.)
|
|
34
|
-
*/
|
|
35
|
-
export declare function calculateOrderMetrics(_daysRange?: number): Promise<{
|
|
36
|
-
current_period: {
|
|
37
|
-
total_orders: number
|
|
38
|
-
total_revenue: number
|
|
39
|
-
average_order_value: number
|
|
40
|
-
orders_by_status: { status: string, count: number }[]
|
|
41
|
-
orders_by_type: { order_type: string, count: number }[]
|
|
42
|
-
}
|
|
43
|
-
previous_period: {
|
|
44
|
-
total_orders: number
|
|
45
|
-
total_revenue: number
|
|
46
|
-
average_order_value: number
|
|
47
|
-
}
|
|
48
|
-
comparison: {
|
|
49
|
-
orders: {
|
|
50
|
-
difference: number
|
|
51
|
-
percentage: number
|
|
52
|
-
is_increase: boolean
|
|
53
|
-
}
|
|
54
|
-
revenue: {
|
|
55
|
-
difference: number
|
|
56
|
-
percentage: number
|
|
57
|
-
is_increase: boolean
|
|
58
|
-
}
|
|
59
|
-
average_order_value: {
|
|
60
|
-
difference: number
|
|
61
|
-
percentage: number
|
|
62
|
-
is_increase: boolean
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
days_range: number
|
|
66
|
-
}>;
|
|
67
|
-
/**
|
|
68
|
-
* Get daily order counts for a time period
|
|
69
|
-
* @param daysRange Number of days to look back
|
|
70
|
-
*/
|
|
71
|
-
export declare function fetchDailyOrderTrends(_daysRange?: number): Promise<{
|
|
72
|
-
date: string
|
|
73
|
-
order_count: number
|
|
74
|
-
revenue: number
|
|
75
|
-
}[]>;
|
|
76
|
-
declare type OrderJsonResponse = ModelRow<typeof Order>;
|
package/dist/orders/guards.d.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validate that a set of coupon ids satisfies the stacking policy
|
|
3
|
-
* (stacksjs/stacks#1879 Co-7). Pre-fix there was no enforcement
|
|
4
|
-
* anywhere — frontend could submit two coupons and double-discount
|
|
5
|
-
* the order with no signal. Default policy is single-coupon-only;
|
|
6
|
-
* apps that intentionally support stacking opt in.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* const stack = validateCouponStacking(cart.couponIds)
|
|
11
|
-
* if (!stack.ok)
|
|
12
|
-
* throw new HttpError(400, `Coupon stacking violation: ${stack.reason}`)
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare function validateCouponStacking(couponIds: ReadonlyArray<number>, policy?: CouponStackingPolicy): CouponStackingResult;
|
|
16
|
-
/**
|
|
17
|
-
* Validate that a cart line-item's quantity respects the product's
|
|
18
|
-
* `min_order_qty` / `max_order_qty` fields
|
|
19
|
-
* (stacksjs/stacks#1879 Co-14). Looks up the product server-side
|
|
20
|
-
* so the client can't bypass by lying about the bounds.
|
|
21
|
-
*
|
|
22
|
-
* Products without explicit bounds default to "any positive int."
|
|
23
|
-
* A quantity of 0 or negative always fails — the cart's UI is
|
|
24
|
-
* responsible for letting users remove items, not for passing
|
|
25
|
-
* sentinel zeros through the API.
|
|
26
|
-
*/
|
|
27
|
-
export declare function validateQuantityBounds(productId: number, quantity: number): Promise<QuantityBoundsResult>;
|
|
28
|
-
/**
|
|
29
|
-
* Batch variant — short-circuits on the first violation so the
|
|
30
|
-
* caller can surface a single useful "item X has min qty Y"
|
|
31
|
-
* error rather than a list of every failed line.
|
|
32
|
-
*/
|
|
33
|
-
export declare function validateCartQuantities(items: ReadonlyArray<{ productId: number, quantity: number }>): Promise<QuantityBoundsResult>;
|
|
34
|
-
/**
|
|
35
|
-
* Delete carts that have been untouched for more than
|
|
36
|
-
* `olderThanDays` days (stacksjs/stacks#1879 Co-15). Default 30.
|
|
37
|
-
* Capped at `limit` rows per call (default 1000) so the delete
|
|
38
|
-
* doesn't hold a long write lock on a busy database. Returns the
|
|
39
|
-
* count + cutoff so callers can log or loop.
|
|
40
|
-
*
|
|
41
|
-
* Schedule via `@stacksjs/scheduler` (now fully wired since
|
|
42
|
-
* #1877's scheduler audit closed) to run nightly:
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* // app/Scheduler.ts
|
|
47
|
-
* import { cleanupAbandonedCarts } from '@stacksjs/commerce'
|
|
48
|
-
*
|
|
49
|
-
* schedule.job(async () => {
|
|
50
|
-
* let total = 0
|
|
51
|
-
* while (true) {
|
|
52
|
-
* const r = await cleanupAbandonedCarts({ olderThanDays: 30, limit: 1000 })
|
|
53
|
-
* total += r.deleted
|
|
54
|
-
* if (r.deleted < 1000) break
|
|
55
|
-
* }
|
|
56
|
-
* log.info(`Cleaned up ${total} abandoned carts`)
|
|
57
|
-
* }).daily().setTimeZone('UTC').withName('CleanupAbandonedCarts')
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare function cleanupAbandonedCarts(options?: CleanupAbandonedCartsOptions): Promise<CleanupAbandonedCartsResult>;
|
|
61
|
-
// ============================================================================
|
|
62
|
-
// Co-7: coupon stacking guard
|
|
63
|
-
// ============================================================================
|
|
64
|
-
export declare interface CouponStackingPolicy {
|
|
65
|
-
allowMultiple?: boolean
|
|
66
|
-
maxStacked?: number
|
|
67
|
-
}
|
|
68
|
-
export declare interface CouponStackingResult {
|
|
69
|
-
ok: boolean
|
|
70
|
-
count: number
|
|
71
|
-
reason?: 'multiple-not-allowed' | 'exceeds-max-stacked'
|
|
72
|
-
}
|
|
73
|
-
// ============================================================================
|
|
74
|
-
// Co-14: min/max order quantity bounds
|
|
75
|
-
// ============================================================================
|
|
76
|
-
export declare interface QuantityBoundsResult {
|
|
77
|
-
ok: boolean
|
|
78
|
-
productId: number
|
|
79
|
-
quantity: number
|
|
80
|
-
reason?: 'below-min' | 'above-max' | 'non-positive' | 'product-missing'
|
|
81
|
-
bound?: number
|
|
82
|
-
}
|
|
83
|
-
// ============================================================================
|
|
84
|
-
// Co-15: abandoned cart cleanup
|
|
85
|
-
// ============================================================================
|
|
86
|
-
export declare interface CleanupAbandonedCartsOptions {
|
|
87
|
-
olderThanDays?: number
|
|
88
|
-
limit?: number
|
|
89
|
-
}
|
|
90
|
-
export declare interface CleanupAbandonedCartsResult {
|
|
91
|
-
deleted: number
|
|
92
|
-
cutoffAt: string
|
|
93
|
-
}
|
package/dist/orders/index.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
export type { PlaceOrderInput, PlaceOrderResult } from './place-order';
|
|
2
|
-
export type { OrderStatus } from './events';
|
|
3
|
-
export type {
|
|
4
|
-
RecomputeLineItem,
|
|
5
|
-
RecomputeOrderInput,
|
|
6
|
-
RecomputeOrderResult,
|
|
7
|
-
} from './totals';
|
|
8
|
-
export type {
|
|
9
|
-
CleanupAbandonedCartsOptions,
|
|
10
|
-
CleanupAbandonedCartsResult,
|
|
11
|
-
CouponStackingPolicy,
|
|
12
|
-
CouponStackingResult,
|
|
13
|
-
QuantityBoundsResult,
|
|
14
|
-
} from './guards';
|
|
15
|
-
export {
|
|
16
|
-
bulkDestroy,
|
|
17
|
-
bulkSoftDelete,
|
|
18
|
-
destroy,
|
|
19
|
-
softDelete,
|
|
20
|
-
} from './destroy';
|
|
21
|
-
export {
|
|
22
|
-
downloadOrders,
|
|
23
|
-
exportOrders,
|
|
24
|
-
storeOrdersExport,
|
|
25
|
-
} from './export';
|
|
26
|
-
export {
|
|
27
|
-
calculateOrderMetrics,
|
|
28
|
-
compareOrdersByPeriod,
|
|
29
|
-
fetchAll,
|
|
30
|
-
fetchById,
|
|
31
|
-
fetchDailyOrderTrends,
|
|
32
|
-
fetchStats,
|
|
33
|
-
} from './fetch';
|
|
34
|
-
export {
|
|
35
|
-
store,
|
|
36
|
-
} from './store';
|
|
37
|
-
// Atomic order placement (stacksjs/stacks#1879 Co-1).
|
|
38
|
-
// Wraps order + payment + inventory decrement in a single
|
|
39
|
-
// transaction so any failure rolls back the rest.
|
|
40
|
-
export { placeOrder } from './place-order';
|
|
41
|
-
// Event bus integration + status-transition state machine
|
|
42
|
-
// (stacksjs/stacks#1879 Co-18, Co-4). Emit helpers fire
|
|
43
|
-
// order:created / order:paid / order:shipped / order:delivered /
|
|
44
|
-
// order:cancelled / order:refunded for downstream subscribers;
|
|
45
|
-
// `canTransition` rejects illegal state changes.
|
|
46
|
-
export {
|
|
47
|
-
canTransition,
|
|
48
|
-
emitForStatus,
|
|
49
|
-
emitOrderCancelled,
|
|
50
|
-
emitOrderCreated,
|
|
51
|
-
emitOrderDelivered,
|
|
52
|
-
emitOrderPaid,
|
|
53
|
-
emitOrderRefunded,
|
|
54
|
-
emitOrderShipped,
|
|
55
|
-
} from './events';
|
|
56
|
-
export {
|
|
57
|
-
update,
|
|
58
|
-
updateDeliveryInfo,
|
|
59
|
-
updateStatus,
|
|
60
|
-
} from './update';
|
|
61
|
-
// Stripe webhook handlers (stacksjs/stacks#1879 Co-17). Call
|
|
62
|
-
// registerCommerceWebhookHandlers() once at boot; the payments
|
|
63
|
-
// package's processWebhook() verifies signatures + dispatches.
|
|
64
|
-
export {
|
|
65
|
-
handleChargeRefunded,
|
|
66
|
-
handlePaymentIntentFailed,
|
|
67
|
-
handlePaymentIntentSucceeded,
|
|
68
|
-
registerCommerceWebhookHandlers,
|
|
69
|
-
} from './webhook';
|
|
70
|
-
// Server-side cart-to-order total recompute (stacksjs/stacks#1879 Co-13).
|
|
71
|
-
// Apps pre-flight the cart through this before placeOrder to detect
|
|
72
|
-
// client-supplied drift and reject "price changed" cases.
|
|
73
|
-
export { recomputeOrderTotals } from './totals';
|
|
74
|
-
// Cart / order policy guards (stacksjs/stacks#1879 Co-7, Co-14, Co-15).
|
|
75
|
-
// Pre-flight the cart through these before placeOrder; abandoned-
|
|
76
|
-
// cart cleanup runs as a scheduled job.
|
|
77
|
-
export {
|
|
78
|
-
cleanupAbandonedCarts,
|
|
79
|
-
validateCartQuantities,
|
|
80
|
-
validateCouponStacking,
|
|
81
|
-
validateQuantityBounds,
|
|
82
|
-
} from './guards';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare function placeOrder(input: PlaceOrderInput): Promise<PlaceOrderResult>;
|
|
2
|
-
export declare interface PlaceOrderInput {
|
|
3
|
-
order: NewOrder
|
|
4
|
-
payment?: NewPayment
|
|
5
|
-
inventory?: ReadonlyArray<{ id: number, delta: number }>
|
|
6
|
-
idempotencyKey?: string
|
|
7
|
-
}
|
|
8
|
-
declare type OrderJsonResponse = ModelRow<typeof Order>;
|
|
9
|
-
declare type NewOrder = NewModelData<typeof Order>;
|
|
10
|
-
declare type PaymentJsonResponse = ModelRow<typeof Payment>;
|
|
11
|
-
declare type NewPayment = NewModelData<typeof Payment>;
|
|
12
|
-
/**
|
|
13
|
-
* Discriminated result. `ok: true` means the order, payment, and
|
|
14
|
-
* inventory all committed; `ok: false` carries a `reason` so the
|
|
15
|
-
* caller can surface a specific error to the user.
|
|
16
|
-
*/
|
|
17
|
-
export type PlaceOrderResult = | { ok: true, order: OrderJsonResponse, payment?: PaymentJsonResponse }
|
|
18
|
-
| { ok: false, reason: 'out-of-stock' | 'duplicate-payment' | 'duplicate-idempotency-key' | 'unknown', failedAt?: string, error?: unknown }
|
package/dist/orders/store.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a new order
|
|
3
|
-
*
|
|
4
|
-
* @param data The order data to store
|
|
5
|
-
* @returns The newly created order record
|
|
6
|
-
*/
|
|
7
|
-
export declare function store(data: NewOrder): Promise<OrderJsonResponse | undefined>;
|
|
8
|
-
declare type OrderJsonResponse = ModelRow<typeof Order>;
|
|
9
|
-
declare type NewOrder = NewModelData<typeof Order>;
|
package/dist/orders/totals.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export declare function recomputeOrderTotals(input: RecomputeOrderInput): Promise<RecomputeOrderResult>;
|
|
2
|
-
export declare interface RecomputeLineItem {
|
|
3
|
-
productId: number
|
|
4
|
-
quantity: number
|
|
5
|
-
unitPriceCents?: number
|
|
6
|
-
}
|
|
7
|
-
export declare interface RecomputeOrderInput {
|
|
8
|
-
items: ReadonlyArray<RecomputeLineItem>
|
|
9
|
-
taxRateId?: number
|
|
10
|
-
shippingCents?: number
|
|
11
|
-
discountCents?: number
|
|
12
|
-
clientTotalCents?: number
|
|
13
|
-
maxDriftCents?: number
|
|
14
|
-
}
|
|
15
|
-
export declare interface RecomputeOrderResult {
|
|
16
|
-
subtotalCents: number
|
|
17
|
-
discountCents: number
|
|
18
|
-
taxCents: number
|
|
19
|
-
shippingCents: number
|
|
20
|
-
totalCents: number
|
|
21
|
-
resolvedItems: Array<{ productId: number, quantity: number, unitPriceCents: number, lineCents: number }>
|
|
22
|
-
priceChanged: boolean
|
|
23
|
-
diffCents: number
|
|
24
|
-
}
|
package/dist/orders/update.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { OrderStatus } from './events';
|
|
2
|
-
/**
|
|
3
|
-
* Update an order by ID
|
|
4
|
-
*
|
|
5
|
-
* @param id The ID of the order to update
|
|
6
|
-
* @param data The updated order data
|
|
7
|
-
* @returns The updated order record
|
|
8
|
-
*/
|
|
9
|
-
export declare function update(id: number, data: Omit<OrderUpdate, 'id'>): Promise<OrderJsonResponse | undefined>;
|
|
10
|
-
/**
|
|
11
|
-
* Update an order's status
|
|
12
|
-
*
|
|
13
|
-
* @param id The ID of the order
|
|
14
|
-
* @param status The new order status
|
|
15
|
-
* @returns The updated order with the new status
|
|
16
|
-
*/
|
|
17
|
-
export declare function updateStatus(id: number, status: OrderStatus): Promise<OrderJsonResponse | undefined>;
|
|
18
|
-
/**
|
|
19
|
-
* Update delivery information for an order
|
|
20
|
-
*
|
|
21
|
-
* @param id The ID of the order
|
|
22
|
-
* @param delivery_address The updated delivery address
|
|
23
|
-
* @param estimated_delivery_time The updated estimated delivery time
|
|
24
|
-
* @returns The updated order
|
|
25
|
-
*/
|
|
26
|
-
export declare function updateDeliveryInfo(id: number, delivery_address?: string, estimated_delivery_time?: string): Promise<OrderJsonResponse | undefined>;
|
|
27
|
-
declare type OrderJsonResponse = ModelRow<typeof Order>;
|
|
28
|
-
declare type OrderUpdate = UpdateModelData<typeof Order>;
|
package/dist/orders/webhook.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Handler for `payment_intent.succeeded`. Marks the linked payment
|
|
3
|
-
* row + order row as paid in a single transaction. Idempotent via
|
|
4
|
-
* `recordEventOrSkip`.
|
|
5
|
-
*/
|
|
6
|
-
declare function handlePaymentIntentSucceeded(event: { id: string, data: { object: any } }): Promise<void>;
|
|
7
|
-
/**
|
|
8
|
-
* Handler for `payment_intent.payment_failed`. Marks the payment
|
|
9
|
-
* as failed and cancels the linked order. Records the failure
|
|
10
|
-
* reason on the payment row for ops triage.
|
|
11
|
-
*/
|
|
12
|
-
declare function handlePaymentIntentFailed(event: { id: string, data: { object: any } }): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Handler for `charge.refunded`. Marks the order REFUNDED and
|
|
15
|
-
* records the refund amount on the linked payment.
|
|
16
|
-
*/
|
|
17
|
-
declare function handleChargeRefunded(event: { id: string, data: { object: any } }): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Wire commerce's Stripe webhook handlers into the payments
|
|
20
|
-
* package's event router. Call once at boot.
|
|
21
|
-
*
|
|
22
|
-
* Returns an unregister callback for tests that want to swap the
|
|
23
|
-
* handler set between cases.
|
|
24
|
-
*/
|
|
25
|
-
export declare function registerCommerceWebhookHandlers(): Promise<() => void>;
|
|
26
|
-
// Export the individual handlers for direct testing.
|
|
27
|
-
export {
|
|
28
|
-
handleChargeRefunded,
|
|
29
|
-
handlePaymentIntentFailed,
|
|
30
|
-
handlePaymentIntentSucceeded,
|
|
31
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delete a payment by ID
|
|
3
|
-
*
|
|
4
|
-
* @param id The ID of the payment to delete
|
|
5
|
-
* @returns True if the payment was deleted, false otherwise
|
|
6
|
-
*/
|
|
7
|
-
export declare function destroy(id: number): Promise<boolean>;
|
|
8
|
-
/**
|
|
9
|
-
* Delete multiple payments by ID
|
|
10
|
-
*
|
|
11
|
-
* @param ids Array of order IDs to delete
|
|
12
|
-
* @returns Number of payments deleted
|
|
13
|
-
*/
|
|
14
|
-
export declare function bulkDestroy(ids: number[]): Promise<number>;
|
package/dist/payments/fetch.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export declare function fetchAll(): Promise<PaymentJsonResponse[]>;
|
|
2
|
-
export declare function fetchById(id: number): Promise<PaymentJsonResponse | undefined>;
|
|
3
|
-
/**
|
|
4
|
-
* Fetch payment statistics for a specific time period
|
|
5
|
-
*
|
|
6
|
-
* @param daysRange Number of days to look back (7, 30, 60, etc.)
|
|
7
|
-
*/
|
|
8
|
-
export declare function fetchPaymentStats(daysRange?: number): Promise<PaymentStats>;
|
|
9
|
-
/**
|
|
10
|
-
* Fetch payment statistics by payment method
|
|
11
|
-
*
|
|
12
|
-
* @param daysRange Number of days to look back
|
|
13
|
-
*/
|
|
14
|
-
export declare function fetchPaymentStatsByMethod(_daysRange?: number): Promise<Record<string, {
|
|
15
|
-
count: number
|
|
16
|
-
revenue: number
|
|
17
|
-
percentage_of_total: number
|
|
18
|
-
}>>;
|
|
19
|
-
/**
|
|
20
|
-
* Fetch monthly payment trends for the last 12 months
|
|
21
|
-
*/
|
|
22
|
-
export declare function fetchMonthlyPaymentTrends(): Promise<Array<{
|
|
23
|
-
month: string
|
|
24
|
-
year: number
|
|
25
|
-
transactions: number
|
|
26
|
-
revenue: number
|
|
27
|
-
average: number
|
|
28
|
-
}>>;
|
|
29
|
-
/**
|
|
30
|
-
* Payment statistics response interface
|
|
31
|
-
*/
|
|
32
|
-
export declare interface PaymentStats {
|
|
33
|
-
total_transactions: number
|
|
34
|
-
total_revenue: number
|
|
35
|
-
average_transaction: number
|
|
36
|
-
successful_rate: number
|
|
37
|
-
comparison: {
|
|
38
|
-
transactions: {
|
|
39
|
-
difference: number
|
|
40
|
-
percentage: number
|
|
41
|
-
is_increase: boolean
|
|
42
|
-
}
|
|
43
|
-
revenue: {
|
|
44
|
-
difference: number
|
|
45
|
-
percentage: number
|
|
46
|
-
is_increase: boolean
|
|
47
|
-
}
|
|
48
|
-
average: {
|
|
49
|
-
difference: number
|
|
50
|
-
percentage: number
|
|
51
|
-
is_increase: boolean
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
declare type PaymentJsonResponse = ModelRow<typeof Payment>;
|
package/dist/payments/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export { bulkDestroy, destroy } from './destroy';
|
|
2
|
-
// Fetch operations - from fetch.ts
|
|
3
|
-
export {
|
|
4
|
-
fetchAll,
|
|
5
|
-
fetchById,
|
|
6
|
-
fetchMonthlyPaymentTrends,
|
|
7
|
-
fetchPaymentStats,
|
|
8
|
-
fetchPaymentStatsByMethod,
|
|
9
|
-
} from './fetch';
|
|
10
|
-
// Store operations - from store.ts
|
|
11
|
-
export { store } from './store';
|
|
12
|
-
// Update operations - from update.ts
|
|
13
|
-
export { update } from './update';
|
package/dist/payments/store.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a new payment
|
|
3
|
-
*
|
|
4
|
-
* @param data The payment data to store
|
|
5
|
-
* @returns The newly created payment record
|
|
6
|
-
*/
|
|
7
|
-
export declare function store(data: NewPayment): Promise<PaymentJsonResponse | undefined>;
|
|
8
|
-
declare type PaymentJsonResponse = ModelRow<typeof Payment>;
|
|
9
|
-
declare type NewPayment = NewModelData<typeof Payment>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Update a payment by ID.
|
|
3
|
-
*
|
|
4
|
-
* Supports the lifecycle a payment row goes through after creation —
|
|
5
|
-
* status transitions (pending → completed/failed/refunded), refund
|
|
6
|
-
* amount tracking, processor metadata (transaction ID, card brand),
|
|
7
|
-
* and operator notes. The original `amount` is intentionally fillable
|
|
8
|
-
* via this path because partial captures and adjustments can rewrite
|
|
9
|
-
* it before settlement; if your processor never adjusts captured
|
|
10
|
-
* amounts, just don't pass `amount` in `data`.
|
|
11
|
-
*
|
|
12
|
-
* @param id The ID of the payment to update
|
|
13
|
-
* @param data The updated payment data (omit `id`)
|
|
14
|
-
* @returns The updated payment record
|
|
15
|
-
*/
|
|
16
|
-
export declare function update(id: number, data: Omit<PaymentUpdate, 'id'>): Promise<PaymentJsonResponse | undefined>;
|
|
17
|
-
declare type PaymentJsonResponse = ModelRow<typeof Payment>;
|
|
18
|
-
declare type PaymentUpdate = UpdateModelData<typeof Payment>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delete a category by ID
|
|
3
|
-
* @param id The ID of the category to delete
|
|
4
|
-
* @returns A boolean indicating whether the deletion was successful
|
|
5
|
-
*/
|
|
6
|
-
export declare function remove(id: number): Promise<boolean>;
|
|
7
|
-
/**
|
|
8
|
-
* Bulk delete multiple categories
|
|
9
|
-
* @param ids Array of category IDs to delete
|
|
10
|
-
* @returns Number of categories successfully deleted
|
|
11
|
-
*/
|
|
12
|
-
export declare function bulkRemove(ids: number[]): Promise<number>;
|
|
13
|
-
/**
|
|
14
|
-
* Delete child categories of a parent category
|
|
15
|
-
* @param parentId The ID of the parent category
|
|
16
|
-
* @returns Number of categories deleted
|
|
17
|
-
*/
|
|
18
|
-
export declare function removeChildCategories(parentId: string): Promise<number>;
|
|
19
|
-
/**
|
|
20
|
-
* Deactivate a category (set is_active to false)
|
|
21
|
-
* @param id The ID of the category to deactivate
|
|
22
|
-
* @returns A boolean indicating whether the deactivation was successful
|
|
23
|
-
*/
|
|
24
|
-
export declare function deactivate(id: number): Promise<boolean>;
|
|
25
|
-
/**
|
|
26
|
-
* Deactivate all child categories of a parent category
|
|
27
|
-
* @param parentId The ID of the parent category
|
|
28
|
-
* @returns Number of categories deactivated
|
|
29
|
-
*/
|
|
30
|
-
export declare function deactivateChildCategories(parentId: string): Promise<number>;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { CategoryStats } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Fetch all categories from the database
|
|
4
|
-
*/
|
|
5
|
-
export declare function fetchAll(): Promise<CategoryJsonResponse[]>;
|
|
6
|
-
/**
|
|
7
|
-
* Fetch a category by ID
|
|
8
|
-
*/
|
|
9
|
-
export declare function fetchById(id: number): Promise<CategoryJsonResponse | undefined>;
|
|
10
|
-
/**
|
|
11
|
-
* Fetch a category by name
|
|
12
|
-
*/
|
|
13
|
-
export declare function fetchByName(name: string): Promise<CategoryJsonResponse | undefined>;
|
|
14
|
-
/**
|
|
15
|
-
* Fetch active categories (is_active = true)
|
|
16
|
-
*/
|
|
17
|
-
export declare function fetchActive(): Promise<CategoryJsonResponse[]>;
|
|
18
|
-
/**
|
|
19
|
-
* Fetch root categories (parent_category_id is null)
|
|
20
|
-
*/
|
|
21
|
-
export declare function fetchRootCategories(): Promise<CategoryJsonResponse[]>;
|
|
22
|
-
/**
|
|
23
|
-
* Fetch child categories for a given parent category ID
|
|
24
|
-
*/
|
|
25
|
-
export declare function fetchChildCategories(parentId: string): Promise<CategoryJsonResponse[]>;
|
|
26
|
-
/**
|
|
27
|
-
* Fetch categories sorted by display order
|
|
28
|
-
*/
|
|
29
|
-
export declare function fetchByDisplayOrder(ascending?: boolean): Promise<CategoryJsonResponse[]>;
|
|
30
|
-
/**
|
|
31
|
-
* Get category statistics
|
|
32
|
-
*/
|
|
33
|
-
export declare function fetchStats(): Promise<CategoryStats>;
|
|
34
|
-
/**
|
|
35
|
-
* Compare category growth between different time periods
|
|
36
|
-
* @param daysRange Number of days to look back (7, 30, 60, etc.)
|
|
37
|
-
*/
|
|
38
|
-
export declare function compareCategoryGrowth(_daysRange?: number): Promise<{
|
|
39
|
-
current_period: number
|
|
40
|
-
previous_period: number
|
|
41
|
-
difference: number
|
|
42
|
-
percentage_change: number
|
|
43
|
-
days_range: number
|
|
44
|
-
}>;
|
|
45
|
-
/**
|
|
46
|
-
* Build category tree structure
|
|
47
|
-
*/
|
|
48
|
-
export declare function fetchCategoryTree(): Promise<any[]>;
|
|
49
|
-
declare type CategoryJsonResponse = ModelRow<typeof Category>;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Export all functions from destroy.ts
|
|
2
|
-
export {
|
|
3
|
-
bulkRemove,
|
|
4
|
-
deactivate,
|
|
5
|
-
deactivateChildCategories,
|
|
6
|
-
remove,
|
|
7
|
-
removeChildCategories,
|
|
8
|
-
} from './destroy';
|
|
9
|
-
// Export all functions from fetch.ts
|
|
10
|
-
export {
|
|
11
|
-
compareCategoryGrowth,
|
|
12
|
-
fetchActive,
|
|
13
|
-
fetchAll,
|
|
14
|
-
fetchByDisplayOrder,
|
|
15
|
-
fetchById,
|
|
16
|
-
fetchByName,
|
|
17
|
-
fetchCategoryTree,
|
|
18
|
-
fetchChildCategories,
|
|
19
|
-
fetchRootCategories,
|
|
20
|
-
fetchStats,
|
|
21
|
-
} from './fetch';
|
|
22
|
-
// Export all functions from store.ts
|
|
23
|
-
export {
|
|
24
|
-
findOrCreateByName,
|
|
25
|
-
store,
|
|
26
|
-
} from './store';
|
|
27
|
-
// Export all functions from update.ts
|
|
28
|
-
export {
|
|
29
|
-
update,
|
|
30
|
-
updateActiveStatus,
|
|
31
|
-
updateDisplayOrder,
|
|
32
|
-
updateParent,
|
|
33
|
-
} from './update';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { slug } from '@stacksjs/strings';
|
|
2
|
-
/**
|
|
3
|
-
* Create a new category
|
|
4
|
-
*
|
|
5
|
-
* @param data The category data to store
|
|
6
|
-
* @returns The newly created category record
|
|
7
|
-
*/
|
|
8
|
-
export declare function store(data: NewCategory): Promise<CategoryJsonResponse>;
|
|
9
|
-
export declare function findOrCreateByName(data: Partial<CategorizableTable>): Promise<CategoryJsonResponse>;
|
|
10
|
-
export declare interface CategorizableTable {
|
|
11
|
-
id: number
|
|
12
|
-
name: string
|
|
13
|
-
slug: string
|
|
14
|
-
description?: string
|
|
15
|
-
is_active: boolean
|
|
16
|
-
categorizable_type: string
|
|
17
|
-
created_at?: string
|
|
18
|
-
updated_at?: string
|
|
19
|
-
}
|
|
20
|
-
declare type CategoryJsonResponse = ModelRow<typeof Category>;
|
|
21
|
-
declare type NewCategory = NewModelData<typeof Category>;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Update a category by ID
|
|
3
|
-
*
|
|
4
|
-
* @param id The ID of the category to update
|
|
5
|
-
* @param request The updated category data
|
|
6
|
-
* @returns The updated category record
|
|
7
|
-
*/
|
|
8
|
-
export declare function update(id: number, request: RequestInstance<typeof Category>): Promise<CategoryRow | undefined>;
|
|
9
|
-
/**
|
|
10
|
-
* Update category display order
|
|
11
|
-
*
|
|
12
|
-
* @param id The ID of the category
|
|
13
|
-
* @param newOrder The new display order value
|
|
14
|
-
* @returns The updated category
|
|
15
|
-
*/
|
|
16
|
-
export declare function updateDisplayOrder(id: number, newOrder: number): Promise<CategoryRow | undefined>;
|
|
17
|
-
/**
|
|
18
|
-
* Update category active status
|
|
19
|
-
*
|
|
20
|
-
* @param id The ID of the category
|
|
21
|
-
* @param isActive Whether the category should be active
|
|
22
|
-
* @returns The updated category
|
|
23
|
-
*/
|
|
24
|
-
export declare function updateActiveStatus(id: number, isActive: boolean): Promise<CategoryRow | undefined>;
|
|
25
|
-
/**
|
|
26
|
-
* Move category to a different parent
|
|
27
|
-
*
|
|
28
|
-
* @param id The ID of the category to move
|
|
29
|
-
* @param newParentId The ID of the new parent category, or null to make it a root category
|
|
30
|
-
* @returns The updated category
|
|
31
|
-
*/
|
|
32
|
-
export declare function updateParent(id: number, newParentId: string | null): Promise<CategoryRow | undefined>;
|
|
33
|
-
declare type CategoryRow = ModelRow<typeof Category>;
|
package/dist/products/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as categories from './categories/index';
|
|
2
|
-
import * as items from './items/index';
|
|
3
|
-
import * as manufacturers from './manufacturers/index';
|
|
4
|
-
import * as reviews from './reviews/index';
|
|
5
|
-
import * as units from './units/index';
|
|
6
|
-
import * as variants from './variants/index';
|
|
7
|
-
declare const products: ProductsNamespace;
|
|
8
|
-
declare interface ProductsNamespace {
|
|
9
|
-
categories: typeof categories
|
|
10
|
-
items: typeof items
|
|
11
|
-
manufacturers: typeof manufacturers
|
|
12
|
-
reviews: typeof reviews
|
|
13
|
-
units: typeof units
|
|
14
|
-
variants: typeof variants
|
|
15
|
-
}
|
|
16
|
-
export {
|
|
17
|
-
categories,
|
|
18
|
-
items,
|
|
19
|
-
manufacturers,
|
|
20
|
-
reviews,
|
|
21
|
-
units,
|
|
22
|
-
variants,
|
|
23
|
-
};
|
|
24
|
-
export default products;
|