@stacksjs/commerce 0.70.36 → 0.70.42
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/dist/src/coupons/destroy.d.ts +17 -0
- package/dist/src/coupons/fetch.d.ts +59 -0
- package/dist/src/coupons/index.d.ts +25 -0
- package/dist/src/coupons/store.d.ts +9 -0
- package/dist/src/coupons/update.d.ts +10 -0
- package/dist/src/customers/destroy.d.ts +14 -0
- package/dist/src/customers/fetch.d.ts +9 -0
- package/dist/src/customers/index.d.ts +14 -0
- package/dist/src/customers/store.d.ts +9 -0
- package/dist/src/customers/update.d.ts +10 -0
- package/dist/src/devices/destroy.d.ts +14 -0
- package/dist/src/devices/export.d.ts +35 -0
- package/dist/src/devices/fetch.d.ts +38 -0
- package/dist/src/devices/index.d.ts +27 -0
- package/dist/src/devices/store.d.ts +16 -0
- package/dist/src/devices/update.d.ts +26 -0
- package/dist/src/errors/destroy.d.ts +12 -0
- package/dist/src/errors/fetch.d.ts +54 -0
- package/dist/src/errors/index.d.ts +25 -0
- package/dist/src/errors/update.d.ts +24 -0
- package/dist/src/gift-cards/destroy.d.ts +23 -0
- package/dist/src/gift-cards/fetch.d.ts +88 -0
- package/dist/src/gift-cards/index.d.ts +23 -0
- package/dist/src/gift-cards/store.d.ts +9 -0
- package/dist/src/gift-cards/update.d.ts +18 -0
- package/dist/src/index.d.ts +13 -13
- package/dist/src/orders/destroy.d.ts +28 -0
- package/dist/src/orders/export.d.ts +32 -0
- package/dist/src/orders/fetch.d.ts +76 -0
- package/dist/src/orders/index.d.ts +27 -0
- package/dist/src/orders/store.d.ts +9 -0
- package/dist/src/orders/update.d.ts +27 -0
- package/dist/src/payments/destroy.d.ts +14 -0
- package/dist/src/payments/fetch.d.ts +55 -0
- package/dist/src/payments/index.d.ts +13 -0
- package/dist/src/payments/store.d.ts +9 -0
- package/dist/src/payments/update.d.ts +18 -0
- package/dist/src/products/categories/destroy.d.ts +30 -0
- package/dist/src/products/categories/fetch.d.ts +49 -0
- package/dist/src/products/categories/index.d.ts +33 -0
- package/dist/src/products/categories/store.d.ts +21 -0
- package/dist/src/products/categories/update.d.ts +33 -0
- package/dist/src/products/index.d.ts +24 -0
- package/dist/src/products/items/destroy.d.ts +14 -0
- package/dist/src/products/items/fetch.d.ts +66 -0
- package/dist/src/products/items/index.d.ts +23 -0
- package/dist/src/products/items/store.d.ts +16 -0
- package/dist/src/products/items/update.d.ts +45 -0
- package/dist/src/products/manufacturers/destroy.d.ts +14 -0
- package/dist/src/products/manufacturers/fetch.d.ts +23 -0
- package/dist/src/products/manufacturers/index.d.ts +21 -0
- package/dist/src/products/manufacturers/store.d.ts +16 -0
- package/dist/src/products/manufacturers/update.d.ts +26 -0
- package/dist/src/products/reviews/destroy.d.ts +14 -0
- package/dist/src/products/reviews/fetch.d.ts +22 -0
- package/dist/src/products/reviews/index.d.ts +22 -0
- package/dist/src/products/reviews/store.d.ts +9 -0
- package/dist/src/products/reviews/update.d.ts +19 -0
- package/dist/src/products/units/destroy.d.ts +14 -0
- package/dist/src/products/units/fetch.d.ts +9 -0
- package/dist/src/products/units/index.d.ts +9 -0
- package/dist/src/products/units/store.d.ts +31 -0
- package/dist/src/products/units/update.d.ts +25 -0
- package/dist/src/products/variants/destroy.d.ts +14 -0
- package/dist/src/products/variants/fetch.d.ts +9 -0
- package/dist/src/products/variants/index.d.ts +18 -0
- package/dist/src/products/variants/store.d.ts +43 -0
- package/dist/src/products/variants/update.d.ts +25 -0
- package/dist/src/receipts/destroy.d.ts +14 -0
- package/dist/src/receipts/fetch.d.ts +80 -0
- package/dist/src/receipts/index.d.ts +21 -0
- package/dist/src/receipts/store.d.ts +16 -0
- package/dist/src/receipts/update.d.ts +28 -0
- package/dist/src/shippings/delivery-routes/destroy.d.ts +14 -0
- package/dist/src/shippings/delivery-routes/fetch.d.ts +17 -0
- package/dist/src/shippings/delivery-routes/index.d.ts +23 -0
- package/dist/src/shippings/delivery-routes/store.d.ts +16 -0
- package/dist/src/shippings/delivery-routes/update.d.ts +27 -0
- package/dist/src/shippings/digital-deliveries/destroy.d.ts +28 -0
- package/dist/src/shippings/digital-deliveries/fetch.d.ts +9 -0
- package/dist/src/shippings/digital-deliveries/index.d.ts +23 -0
- package/dist/src/shippings/digital-deliveries/store.d.ts +16 -0
- package/dist/src/shippings/digital-deliveries/update.d.ts +29 -0
- package/dist/src/shippings/drivers/destroy.d.ts +16 -0
- package/dist/src/shippings/drivers/fetch.d.ts +9 -0
- package/dist/src/shippings/drivers/index.d.ts +21 -0
- package/dist/src/shippings/drivers/store.d.ts +16 -0
- package/dist/src/shippings/drivers/update.d.ts +26 -0
- package/dist/src/shippings/index.d.ts +27 -0
- package/dist/src/shippings/license-keys/destroy.d.ts +28 -0
- package/dist/src/shippings/license-keys/fetch.d.ts +9 -0
- package/dist/src/shippings/license-keys/index.d.ts +23 -0
- package/dist/src/shippings/license-keys/store.d.ts +17 -0
- package/dist/src/shippings/license-keys/update.d.ts +26 -0
- package/dist/src/shippings/shipping-methods/destroy.d.ts +28 -0
- package/dist/src/shippings/shipping-methods/fetch.d.ts +9 -0
- package/dist/src/shippings/shipping-methods/index.d.ts +25 -0
- package/dist/src/shippings/shipping-methods/store.d.ts +28 -0
- package/dist/src/shippings/shipping-methods/update.d.ts +27 -0
- package/dist/src/shippings/shipping-rates/destroy.d.ts +28 -0
- package/dist/src/shippings/shipping-rates/fetch.d.ts +37 -0
- package/dist/src/shippings/shipping-rates/index.d.ts +27 -0
- package/dist/src/shippings/shipping-rates/store.d.ts +17 -0
- package/dist/src/shippings/shipping-rates/update.d.ts +36 -0
- package/dist/src/shippings/shipping-zones/destroy.d.ts +28 -0
- package/dist/src/shippings/shipping-zones/fetch.d.ts +28 -0
- package/dist/src/shippings/shipping-zones/index.d.ts +23 -0
- package/dist/src/shippings/shipping-zones/store.d.ts +17 -0
- package/dist/src/shippings/shipping-zones/update.d.ts +35 -0
- package/dist/src/tax/destroy.d.ts +14 -0
- package/dist/src/tax/fetch.d.ts +9 -0
- package/dist/src/tax/index.d.ts +21 -0
- package/dist/src/tax/store.d.ts +16 -0
- package/dist/src/tax/update.d.ts +26 -0
- package/dist/src/types.d.ts +265 -0
- package/dist/src/utils/typed-stats.d.ts +23 -0
- package/dist/src/waitlists/index.d.ts +12 -0
- package/dist/src/waitlists/products/destroy.d.ts +15 -0
- package/dist/src/waitlists/products/fetch.d.ts +100 -0
- package/dist/src/waitlists/products/index.d.ts +30 -0
- package/dist/src/waitlists/products/store.d.ts +16 -0
- package/dist/src/waitlists/products/update.d.ts +26 -0
- package/dist/src/waitlists/restaurant/destroy.d.ts +15 -0
- package/dist/src/waitlists/restaurant/fetch.d.ts +149 -0
- package/dist/src/waitlists/restaurant/index.d.ts +40 -0
- package/dist/src/waitlists/restaurant/store.d.ts +16 -0
- package/dist/src/waitlists/restaurant/update.d.ts +43 -0
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delete an order by ID
|
|
3
|
+
*
|
|
4
|
+
* @param id The ID of the order to delete
|
|
5
|
+
* @returns True if the order was deleted, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export declare function destroy(id: number): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Soft delete an order by ID (updates status to CANCELED)
|
|
10
|
+
*
|
|
11
|
+
* @param id The ID of the order to soft delete
|
|
12
|
+
* @returns True if the order was soft deleted, false otherwise
|
|
13
|
+
*/
|
|
14
|
+
export declare function softDelete(id: number): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Delete multiple orders by ID
|
|
17
|
+
*
|
|
18
|
+
* @param ids Array of order IDs to delete
|
|
19
|
+
* @returns Number of orders deleted
|
|
20
|
+
*/
|
|
21
|
+
export declare function bulkDestroy(ids: number[]): Promise<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Soft delete multiple orders by ID (updates status to CANCELED)
|
|
24
|
+
*
|
|
25
|
+
* @param ids Array of order IDs to soft delete
|
|
26
|
+
* @returns Number of orders soft deleted
|
|
27
|
+
*/
|
|
28
|
+
export declare function bulkSoftDelete(ids: number[]): Promise<number>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SpreadsheetWrapper } from 'ts-spreadsheets';
|
|
2
|
+
/**
|
|
3
|
+
* Export orders to a spreadsheet
|
|
4
|
+
* @param format The format of the spreadsheet (default is CSV)
|
|
5
|
+
* @returns Spreadsheet object ready for download or storage
|
|
6
|
+
*/
|
|
7
|
+
export declare function exportOrders(format?: 'csv' | 'excel'): Promise<SpreadsheetWrapper>;
|
|
8
|
+
/**
|
|
9
|
+
* Export orders and automatically download
|
|
10
|
+
* @param format The format of the spreadsheet (default is CSV)
|
|
11
|
+
* @param filename Optional filename for the download
|
|
12
|
+
* @returns Download response
|
|
13
|
+
*/
|
|
14
|
+
export declare function downloadOrders(format?: 'csv' | 'excel', filename?: string): Promise<Response>;
|
|
15
|
+
/**
|
|
16
|
+
* Store orders export to disk
|
|
17
|
+
* @param format The format of the spreadsheet (default is CSV)
|
|
18
|
+
* @param path Optional path to store the file
|
|
19
|
+
* @returns Path where the file is stored
|
|
20
|
+
*/
|
|
21
|
+
export declare function storeOrdersExport(format?: 'csv' | 'excel', path?: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Represents the structure of an exported order
|
|
24
|
+
*/
|
|
25
|
+
export declare interface ExportedOrder {
|
|
26
|
+
'Order ID': number
|
|
27
|
+
'Customer': string
|
|
28
|
+
'Date': string
|
|
29
|
+
'Total': number
|
|
30
|
+
'Status': string
|
|
31
|
+
'Items': string
|
|
32
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export {
|
|
2
|
+
bulkDestroy,
|
|
3
|
+
bulkSoftDelete,
|
|
4
|
+
destroy,
|
|
5
|
+
softDelete,
|
|
6
|
+
} from './destroy';
|
|
7
|
+
export {
|
|
8
|
+
downloadOrders,
|
|
9
|
+
exportOrders,
|
|
10
|
+
storeOrdersExport,
|
|
11
|
+
} from './export';
|
|
12
|
+
export {
|
|
13
|
+
calculateOrderMetrics,
|
|
14
|
+
compareOrdersByPeriod,
|
|
15
|
+
fetchAll,
|
|
16
|
+
fetchById,
|
|
17
|
+
fetchDailyOrderTrends,
|
|
18
|
+
fetchStats,
|
|
19
|
+
} from './fetch';
|
|
20
|
+
export {
|
|
21
|
+
store,
|
|
22
|
+
} from './store';
|
|
23
|
+
export {
|
|
24
|
+
update,
|
|
25
|
+
updateDeliveryInfo,
|
|
26
|
+
updateStatus,
|
|
27
|
+
} from './update';
|
|
@@ -0,0 +1,9 @@
|
|
|
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>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update an order by ID
|
|
3
|
+
*
|
|
4
|
+
* @param id The ID of the order to update
|
|
5
|
+
* @param data The updated order data
|
|
6
|
+
* @returns The updated order record
|
|
7
|
+
*/
|
|
8
|
+
export declare function update(id: number, data: Omit<OrderUpdate, 'id'>): Promise<OrderJsonResponse | undefined>;
|
|
9
|
+
/**
|
|
10
|
+
* Update an order's status
|
|
11
|
+
*
|
|
12
|
+
* @param id The ID of the order
|
|
13
|
+
* @param status The new order status
|
|
14
|
+
* @returns The updated order with the new status
|
|
15
|
+
*/
|
|
16
|
+
export declare function updateStatus(id: number, status: 'PENDING' | 'PROCESSING' | 'SHIPPED' | 'DELIVERED' | 'CANCELLED' | 'REFUNDED'): Promise<OrderJsonResponse | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Update delivery information for an order
|
|
19
|
+
*
|
|
20
|
+
* @param id The ID of the order
|
|
21
|
+
* @param delivery_address The updated delivery address
|
|
22
|
+
* @param estimated_delivery_time The updated estimated delivery time
|
|
23
|
+
* @returns The updated order
|
|
24
|
+
*/
|
|
25
|
+
export declare function updateDeliveryInfo(id: number, delivery_address?: string, estimated_delivery_time?: string): Promise<OrderJsonResponse | undefined>;
|
|
26
|
+
declare type OrderJsonResponse = ModelRow<typeof Order>;
|
|
27
|
+
declare type OrderUpdate = UpdateModelData<typeof Order>;
|
|
@@ -0,0 +1,14 @@
|
|
|
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>;
|
|
@@ -0,0 +1,55 @@
|
|
|
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>;
|
|
@@ -0,0 +1,13 @@
|
|
|
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';
|
|
@@ -0,0 +1,9 @@
|
|
|
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>;
|
|
@@ -0,0 +1,18 @@
|
|
|
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>;
|
|
@@ -0,0 +1,30 @@
|
|
|
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>;
|
|
@@ -0,0 +1,49 @@
|
|
|
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>;
|
|
@@ -0,0 +1,33 @@
|
|
|
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';
|
|
@@ -0,0 +1,21 @@
|
|
|
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>;
|
|
@@ -0,0 +1,33 @@
|
|
|
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>;
|
|
@@ -0,0 +1,24 @@
|
|
|
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;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delete a product item by ID
|
|
3
|
+
*
|
|
4
|
+
* @param id The ID of the product item to delete
|
|
5
|
+
* @returns True if the product item was deleted, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export declare function destroy(id: number): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Delete multiple product items by ID
|
|
10
|
+
*
|
|
11
|
+
* @param ids Array of product item IDs to delete
|
|
12
|
+
* @returns Number of product items deleted
|
|
13
|
+
*/
|
|
14
|
+
export declare function bulkDestroy(ids: number[]): Promise<number>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch a product item by ID
|
|
3
|
+
*/
|
|
4
|
+
export declare function fetchById(id: number): Promise<ProductJsonResponse | undefined>;
|
|
5
|
+
/**
|
|
6
|
+
* Fetch all product items with their manufacturers and categories
|
|
7
|
+
*/
|
|
8
|
+
export declare function fetchAll(): Promise<ProductJsonResponse[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Get products by manufacturer
|
|
11
|
+
*
|
|
12
|
+
* @param manufacturerId Manufacturer identifier
|
|
13
|
+
* @returns List of products for the specified manufacturer
|
|
14
|
+
*/
|
|
15
|
+
export declare function getProductsByManufacturer(manufacturerId: number): Promise<ProductJsonResponse[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Get products by category
|
|
18
|
+
*
|
|
19
|
+
* @param categoryId Category identifier
|
|
20
|
+
* @returns List of products for the specified category
|
|
21
|
+
*/
|
|
22
|
+
export declare function getProductsByCategory(categoryId: number): Promise<ProductJsonResponse[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Get product by UUID
|
|
25
|
+
*
|
|
26
|
+
* @param uuid Product UUID
|
|
27
|
+
* @returns Matching product or undefined
|
|
28
|
+
*/
|
|
29
|
+
export declare function getProductByUuid(uuid: string): Promise<ProductJsonResponse | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* Format product options for dropdown menus or selectors
|
|
32
|
+
*
|
|
33
|
+
* @returns Array of formatted product options with id, name, uuid, and price
|
|
34
|
+
*/
|
|
35
|
+
export declare function formatProductOptions(): Promise<{ id: number, name: string, uuid: string, price: number }[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Get products by price range
|
|
38
|
+
*
|
|
39
|
+
* @param minPrice Minimum price
|
|
40
|
+
* @param maxPrice Maximum price
|
|
41
|
+
* @returns List of products within the specified price range
|
|
42
|
+
*/
|
|
43
|
+
export declare function getProductsByPriceRange(minPrice: number, maxPrice: number): Promise<ProductJsonResponse[]>;
|
|
44
|
+
export declare function fetchTopProducts(limit?: number): Promise<TopProductRow[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Top-selling products by units sold.
|
|
47
|
+
*
|
|
48
|
+
* Aggregates `order_items` (the line-item table — each row is one
|
|
49
|
+
* product on one order) grouping by product, summing quantity for the
|
|
50
|
+
* "units sold" rank and the line-item revenue (price × quantity) for
|
|
51
|
+
* the revenue side. Joins back to `products` so we can return the
|
|
52
|
+
* product name + current inventory inline; if a product was deleted
|
|
53
|
+
* after sales were recorded, that row is skipped (INNER JOIN).
|
|
54
|
+
*
|
|
55
|
+
* Revenue uses the price stored on `order_items` (price-at-sale)
|
|
56
|
+
* rather than the current `products.price`, so historical numbers
|
|
57
|
+
* stay correct even when prices change.
|
|
58
|
+
*/
|
|
59
|
+
export declare interface TopProductRow {
|
|
60
|
+
id: number
|
|
61
|
+
name: string
|
|
62
|
+
units_sold: number
|
|
63
|
+
revenue: number
|
|
64
|
+
inventory_count: number
|
|
65
|
+
}
|
|
66
|
+
declare type ProductJsonResponse = ModelRow<typeof Product>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Functions from fetch.ts
|
|
2
|
+
export type { TopProductRow } from './fetch';
|
|
3
|
+
// Functions from destroy.ts
|
|
4
|
+
export {
|
|
5
|
+
bulkDestroy,
|
|
6
|
+
destroy,
|
|
7
|
+
} from './destroy';
|
|
8
|
+
export {
|
|
9
|
+
fetchAll,
|
|
10
|
+
fetchById,
|
|
11
|
+
fetchTopProducts,
|
|
12
|
+
} from './fetch';
|
|
13
|
+
// Functions from store.ts
|
|
14
|
+
export {
|
|
15
|
+
bulkStore,
|
|
16
|
+
store,
|
|
17
|
+
} from './store';
|
|
18
|
+
// Functions from update.ts
|
|
19
|
+
export {
|
|
20
|
+
update,
|
|
21
|
+
updateAvailability,
|
|
22
|
+
updateInventory,
|
|
23
|
+
} from './update';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new product item
|
|
3
|
+
*
|
|
4
|
+
* @param data The product item data to store
|
|
5
|
+
* @returns The newly created product item record
|
|
6
|
+
*/
|
|
7
|
+
export declare function store(data: NewProduct): Promise<ProductJsonResponse>;
|
|
8
|
+
/**
|
|
9
|
+
* Create multiple product items at once
|
|
10
|
+
*
|
|
11
|
+
* @param data Array of product item data to store
|
|
12
|
+
* @returns Number of product items created
|
|
13
|
+
*/
|
|
14
|
+
export declare function bulkStore(data: NewProduct[]): Promise<number>;
|
|
15
|
+
declare type ProductJsonResponse = ModelRow<typeof Product>;
|
|
16
|
+
declare type NewProduct = NewModelData<typeof Product>;
|