@stacksjs/commerce 0.70.88 → 0.70.90
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/coupons/destroy.d.ts +17 -0
- package/dist/coupons/fetch.d.ts +59 -0
- package/dist/coupons/index.d.ts +27 -0
- package/dist/coupons/store.d.ts +9 -0
- package/dist/coupons/update.d.ts +46 -0
- package/dist/customers/destroy.d.ts +14 -0
- package/dist/customers/fetch.d.ts +9 -0
- package/dist/customers/index.d.ts +14 -0
- package/dist/customers/store.d.ts +9 -0
- package/dist/customers/update.d.ts +10 -0
- package/dist/devices/destroy.d.ts +14 -0
- package/dist/devices/export.d.ts +35 -0
- package/dist/devices/fetch.d.ts +38 -0
- package/dist/devices/index.d.ts +27 -0
- package/dist/devices/store.d.ts +16 -0
- package/dist/devices/update.d.ts +26 -0
- package/dist/errors/destroy.d.ts +12 -0
- package/dist/errors/fetch.d.ts +54 -0
- package/dist/errors/index.d.ts +25 -0
- package/dist/errors/update.d.ts +24 -0
- package/dist/gift-cards/destroy.d.ts +23 -0
- package/dist/gift-cards/fetch.d.ts +88 -0
- package/dist/gift-cards/index.d.ts +23 -0
- package/dist/gift-cards/store.d.ts +9 -0
- package/dist/gift-cards/update.d.ts +30 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +2 -0
- package/dist/orders/destroy.d.ts +28 -0
- package/dist/orders/events.d.ts +46 -0
- package/dist/orders/export.d.ts +32 -0
- package/dist/orders/fetch.d.ts +76 -0
- package/dist/orders/guards.d.ts +93 -0
- package/dist/orders/index.d.ts +82 -0
- package/dist/orders/place-order.d.ts +18 -0
- package/dist/orders/store.d.ts +9 -0
- package/dist/orders/totals.d.ts +24 -0
- package/dist/orders/update.d.ts +28 -0
- package/dist/orders/webhook.d.ts +31 -0
- package/dist/payments/destroy.d.ts +14 -0
- package/dist/payments/fetch.d.ts +55 -0
- package/dist/payments/index.d.ts +13 -0
- package/dist/payments/store.d.ts +9 -0
- package/dist/payments/update.d.ts +18 -0
- package/dist/products/categories/destroy.d.ts +30 -0
- package/dist/products/categories/fetch.d.ts +49 -0
- package/dist/products/categories/index.d.ts +33 -0
- package/dist/products/categories/store.d.ts +21 -0
- package/dist/products/categories/update.d.ts +33 -0
- package/dist/products/index.d.ts +24 -0
- package/dist/products/items/destroy.d.ts +14 -0
- package/dist/products/items/fetch.d.ts +66 -0
- package/dist/products/items/index.d.ts +23 -0
- package/dist/products/items/store.d.ts +16 -0
- package/dist/products/items/update.d.ts +82 -0
- package/dist/products/manufacturers/destroy.d.ts +14 -0
- package/dist/products/manufacturers/fetch.d.ts +23 -0
- package/dist/products/manufacturers/index.d.ts +21 -0
- package/dist/products/manufacturers/store.d.ts +16 -0
- package/dist/products/manufacturers/update.d.ts +26 -0
- package/dist/products/reviews/destroy.d.ts +14 -0
- package/dist/products/reviews/fetch.d.ts +22 -0
- package/dist/products/reviews/index.d.ts +22 -0
- package/dist/products/reviews/store.d.ts +16 -0
- package/dist/products/reviews/update.d.ts +19 -0
- package/dist/products/units/destroy.d.ts +14 -0
- package/dist/products/units/fetch.d.ts +9 -0
- package/dist/products/units/index.d.ts +9 -0
- package/dist/products/units/store.d.ts +31 -0
- package/dist/products/units/update.d.ts +25 -0
- package/dist/products/variants/destroy.d.ts +14 -0
- package/dist/products/variants/fetch.d.ts +9 -0
- package/dist/products/variants/index.d.ts +18 -0
- package/dist/products/variants/store.d.ts +43 -0
- package/dist/products/variants/update.d.ts +25 -0
- package/dist/receipts/destroy.d.ts +14 -0
- package/dist/receipts/fetch.d.ts +80 -0
- package/dist/receipts/index.d.ts +21 -0
- package/dist/receipts/store.d.ts +16 -0
- package/dist/receipts/update.d.ts +28 -0
- package/dist/shippings/delivery-routes/destroy.d.ts +14 -0
- package/dist/shippings/delivery-routes/fetch.d.ts +17 -0
- package/dist/shippings/delivery-routes/index.d.ts +23 -0
- package/dist/shippings/delivery-routes/store.d.ts +16 -0
- package/dist/shippings/delivery-routes/update.d.ts +27 -0
- package/dist/shippings/digital-deliveries/destroy.d.ts +28 -0
- package/dist/shippings/digital-deliveries/fetch.d.ts +9 -0
- package/dist/shippings/digital-deliveries/index.d.ts +23 -0
- package/dist/shippings/digital-deliveries/store.d.ts +16 -0
- package/dist/shippings/digital-deliveries/update.d.ts +29 -0
- package/dist/shippings/drivers/destroy.d.ts +16 -0
- package/dist/shippings/drivers/fetch.d.ts +9 -0
- package/dist/shippings/drivers/index.d.ts +21 -0
- package/dist/shippings/drivers/store.d.ts +16 -0
- package/dist/shippings/drivers/update.d.ts +26 -0
- package/dist/shippings/index.d.ts +27 -0
- package/dist/shippings/license-keys/destroy.d.ts +28 -0
- package/dist/shippings/license-keys/fetch.d.ts +9 -0
- package/dist/shippings/license-keys/index.d.ts +23 -0
- package/dist/shippings/license-keys/store.d.ts +17 -0
- package/dist/shippings/license-keys/update.d.ts +26 -0
- package/dist/shippings/shipping-methods/destroy.d.ts +28 -0
- package/dist/shippings/shipping-methods/fetch.d.ts +9 -0
- package/dist/shippings/shipping-methods/index.d.ts +25 -0
- package/dist/shippings/shipping-methods/store.d.ts +28 -0
- package/dist/shippings/shipping-methods/update.d.ts +27 -0
- package/dist/shippings/shipping-rates/destroy.d.ts +28 -0
- package/dist/shippings/shipping-rates/fetch.d.ts +98 -0
- package/dist/shippings/shipping-rates/index.d.ts +33 -0
- package/dist/shippings/shipping-rates/store.d.ts +17 -0
- package/dist/shippings/shipping-rates/update.d.ts +36 -0
- package/dist/shippings/shipping-zones/destroy.d.ts +28 -0
- package/dist/shippings/shipping-zones/fetch.d.ts +28 -0
- package/dist/shippings/shipping-zones/index.d.ts +23 -0
- package/dist/shippings/shipping-zones/store.d.ts +17 -0
- package/dist/shippings/shipping-zones/update.d.ts +35 -0
- package/dist/tax/destroy.d.ts +14 -0
- package/dist/tax/fetch.d.ts +9 -0
- package/dist/tax/index.d.ts +21 -0
- package/dist/tax/store.d.ts +16 -0
- package/dist/tax/update.d.ts +26 -0
- package/dist/types.d.ts +265 -0
- package/dist/utils/typed-stats.d.ts +23 -0
- package/dist/waitlists/index.d.ts +12 -0
- package/dist/waitlists/products/destroy.d.ts +15 -0
- package/dist/waitlists/products/fetch.d.ts +100 -0
- package/dist/waitlists/products/index.d.ts +30 -0
- package/dist/waitlists/products/store.d.ts +16 -0
- package/dist/waitlists/products/update.d.ts +26 -0
- package/dist/waitlists/restaurant/destroy.d.ts +15 -0
- package/dist/waitlists/restaurant/fetch.d.ts +149 -0
- package/dist/waitlists/restaurant/index.d.ts +40 -0
- package/dist/waitlists/restaurant/store.d.ts +16 -0
- package/dist/waitlists/restaurant/update.d.ts +43 -0
- package/package.json +1 -1
|
@@ -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>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update a product item
|
|
3
|
+
*
|
|
4
|
+
* @param id The ID of the product item to update
|
|
5
|
+
* @param data The product item data to update
|
|
6
|
+
* @returns The updated product item record
|
|
7
|
+
*/
|
|
8
|
+
export declare function update(id: number, data: Omit<ProductUpdate, 'id'>): Promise<ProductJsonResponse>;
|
|
9
|
+
/**
|
|
10
|
+
* Update multiple product items at once
|
|
11
|
+
*
|
|
12
|
+
* @param data Array of product item updates
|
|
13
|
+
* @returns Number of product items updated
|
|
14
|
+
*/
|
|
15
|
+
export declare function bulkUpdate(data: ProductUpdate[]): Promise<number>;
|
|
16
|
+
/**
|
|
17
|
+
* Update a product item's availability status
|
|
18
|
+
*
|
|
19
|
+
* @param id The ID of the product item
|
|
20
|
+
* @param isAvailable The new availability status
|
|
21
|
+
* @returns The updated product item with the new availability status
|
|
22
|
+
*/
|
|
23
|
+
export declare function updateAvailability(id: number, isAvailable: boolean): Promise<ProductJsonResponse | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Atomically decrement (or increment) a product's inventory count by `delta`.
|
|
26
|
+
*
|
|
27
|
+
* Returns the updated row, or `null` if the requested decrement would push
|
|
28
|
+
* inventory below zero — that's how callers detect "we sold the last one"
|
|
29
|
+
* during checkout. The conditional UPDATE means two parallel checkout
|
|
30
|
+
* requests can't both observe stock=1 and both succeed; the second one
|
|
31
|
+
* matches zero rows and the function returns null. Existing
|
|
32
|
+
* `updateInventory(id, count)` keeps the previous "set absolute count"
|
|
33
|
+
* semantics for admin tooling.
|
|
34
|
+
*/
|
|
35
|
+
export declare function adjustInventory(id: number, delta: number): Promise<ProductJsonResponse | null>;
|
|
36
|
+
/**
|
|
37
|
+
* Atomic batch inventory adjustment (stacksjs/stacks#1879 Co-2).
|
|
38
|
+
*
|
|
39
|
+
* Pre-fix: a multi-item cart called `adjustInventory(id, delta)` N
|
|
40
|
+
* times sequentially. If item 2 failed (out of stock), item 1's
|
|
41
|
+
* decrement was already committed with no rollback — the order
|
|
42
|
+
* persisted with partial stock reservation and the customer saw
|
|
43
|
+
* a refund-on-next-page-load surprise.
|
|
44
|
+
*
|
|
45
|
+
* Post-fix: wraps the per-item loop in `db.transaction`. Any item
|
|
46
|
+
* that can't be adjusted (the existing `adjustInventory` returns
|
|
47
|
+
* null on insufficient stock) throws inside the transaction; the
|
|
48
|
+
* driver rolls every prior decrement back. Returns a discriminated
|
|
49
|
+
* result so the cart handler can surface "item X was out of stock"
|
|
50
|
+
* specifically instead of a generic transaction-failed error.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const result = await adjustInventoryMany([
|
|
55
|
+
* { id: cart.itemA, delta: -2 },
|
|
56
|
+
* { id: cart.itemB, delta: -1 },
|
|
57
|
+
* ])
|
|
58
|
+
* if (!result.ok) {
|
|
59
|
+
* throw new HttpError(409, `Item ${result.productId} is out of stock`)
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function adjustInventoryMany(updates: ReadonlyArray<{ id: number, delta: number }>): Promise<InventoryBatchResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Update inventory information for a product item
|
|
66
|
+
*
|
|
67
|
+
* @param id The ID of the product item
|
|
68
|
+
* @param inventoryCount The updated inventory count
|
|
69
|
+
* @returns The updated product item
|
|
70
|
+
*/
|
|
71
|
+
export declare function updateInventory(id: number, inventoryCount?: number): Promise<ProductJsonResponse | undefined>;
|
|
72
|
+
declare type ProductJsonResponse = ModelRow<typeof Product>;
|
|
73
|
+
declare type ProductUpdate = UpdateModelData<typeof Product>;
|
|
74
|
+
/**
|
|
75
|
+
* Discriminated result for `adjustInventoryMany` — `ok: true` when
|
|
76
|
+
* every per-item adjustment succeeded; `ok: false` with `failedAt`
|
|
77
|
+
* (the index in the input array that triggered the rollback) when
|
|
78
|
+
* any single item couldn't be adjusted (out of stock, missing,
|
|
79
|
+
* etc.). All adjustments roll back as a unit on failure.
|
|
80
|
+
*/
|
|
81
|
+
export type InventoryBatchResult = | { ok: true, products: ProductJsonResponse[] }
|
|
82
|
+
| { ok: false, failedAt: number, productId: number, reason: 'out-of-stock' | 'not-found' }
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
* Delete multiple orders by ID
|
|
10
|
+
*
|
|
11
|
+
* @param ids Array of order IDs to delete
|
|
12
|
+
* @returns Number of orders deleted
|
|
13
|
+
*/
|
|
14
|
+
export declare function bulkDestroy(ids: number[]): Promise<number>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FetchManufacturersOptions, ManufacturerResponse } from '../../types';
|
|
2
|
+
export declare function fetchAll(): Promise<ManufacturerJsonResponse[]>;
|
|
3
|
+
/**
|
|
4
|
+
* Fetch a product manufacturer by ID
|
|
5
|
+
*/
|
|
6
|
+
export declare function fetchById(id: number): Promise<ManufacturerJsonResponse | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Fetch a product manufacturer by UUID
|
|
9
|
+
*/
|
|
10
|
+
export declare function fetchByUuid(uuid: string): Promise<ManufacturerJsonResponse | undefined>;
|
|
11
|
+
/**
|
|
12
|
+
* Fetch featured manufacturers
|
|
13
|
+
*/
|
|
14
|
+
export declare function fetchFeatured(limit?: number): Promise<ManufacturerJsonResponse[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetch manufacturers by country
|
|
17
|
+
*/
|
|
18
|
+
export declare function fetchByCountry(country: string, options?: FetchManufacturersOptions): Promise<ManufacturerResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch manufacturers with their product count
|
|
21
|
+
*/
|
|
22
|
+
export declare function fetchWithProductCount(options?: FetchManufacturersOptions): Promise<ManufacturerJsonResponse[]>;
|
|
23
|
+
declare type ManufacturerJsonResponse = ModelRow<typeof Manufacturer>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export {
|
|
2
|
+
bulkDestroy,
|
|
3
|
+
destroy,
|
|
4
|
+
} from './destroy';
|
|
5
|
+
export {
|
|
6
|
+
fetchAll,
|
|
7
|
+
fetchByCountry,
|
|
8
|
+
fetchById,
|
|
9
|
+
fetchByUuid,
|
|
10
|
+
fetchFeatured,
|
|
11
|
+
fetchWithProductCount,
|
|
12
|
+
} from './fetch';
|
|
13
|
+
export {
|
|
14
|
+
bulkStore,
|
|
15
|
+
store,
|
|
16
|
+
} from './store';
|
|
17
|
+
export {
|
|
18
|
+
update,
|
|
19
|
+
updateByUuid,
|
|
20
|
+
updateFeaturedStatus,
|
|
21
|
+
} from './update';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new product manufacturer
|
|
3
|
+
*
|
|
4
|
+
* @param data The manufacturer data to store
|
|
5
|
+
* @returns The newly created manufacturer record
|
|
6
|
+
*/
|
|
7
|
+
export declare function store(data: NewManufacturer): Promise<ManufacturerJsonResponse>;
|
|
8
|
+
/**
|
|
9
|
+
* Create multiple manufacturers at once
|
|
10
|
+
*
|
|
11
|
+
* @param data Array of manufacturer data to store
|
|
12
|
+
* @returns Number of manufacturers created
|
|
13
|
+
*/
|
|
14
|
+
export declare function bulkStore(data: NewManufacturer[]): Promise<number>;
|
|
15
|
+
declare type ManufacturerJsonResponse = ModelRow<typeof Manufacturer>;
|
|
16
|
+
declare type NewManufacturer = NewModelData<typeof Manufacturer>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update a manufacturer
|
|
3
|
+
*
|
|
4
|
+
* @param id The ID of the manufacturer to update
|
|
5
|
+
* @param data The manufacturer data to update
|
|
6
|
+
* @returns The updated manufacturer record
|
|
7
|
+
*/
|
|
8
|
+
export declare function update(id: number, data: ManufacturerUpdate): Promise<ManufacturerJsonResponse>;
|
|
9
|
+
/**
|
|
10
|
+
* Toggle the featured status of a manufacturer
|
|
11
|
+
*
|
|
12
|
+
* @param id The ID of the manufacturer
|
|
13
|
+
* @param featured The new featured status (or toggle if not provided)
|
|
14
|
+
* @returns The updated manufacturer with the new featured status
|
|
15
|
+
*/
|
|
16
|
+
export declare function updateFeaturedStatus(id: number, featured?: boolean): Promise<ManufacturerJsonResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Update a manufacturer by UUID
|
|
19
|
+
*
|
|
20
|
+
* @param uuid The UUID of the manufacturer to update
|
|
21
|
+
* @param data The updated manufacturer data
|
|
22
|
+
* @returns The updated manufacturer record
|
|
23
|
+
*/
|
|
24
|
+
export declare function updateByUuid(uuid: string, data: Omit<ManufacturerUpdate, 'id'>): Promise<ManufacturerJsonResponse>;
|
|
25
|
+
declare type ManufacturerJsonResponse = ModelRow<typeof Manufacturer>;
|
|
26
|
+
declare type ManufacturerUpdate = UpdateModelData<typeof Manufacturer>;
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
* Delete multiple orders by ID
|
|
10
|
+
*
|
|
11
|
+
* @param ids Array of order IDs to delete
|
|
12
|
+
* @returns Number of orders deleted
|
|
13
|
+
*/
|
|
14
|
+
export declare function bulkDestroy(ids: number[]): Promise<number>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch a product review by ID
|
|
3
|
+
*/
|
|
4
|
+
export declare function fetchById(id: number): Promise<ReviewJsonResponse | undefined>;
|
|
5
|
+
/**
|
|
6
|
+
* Fetch all product reviews
|
|
7
|
+
*/
|
|
8
|
+
export declare function fetchAll(): Promise<ReviewJsonResponse[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Fetch reviews for a specific product
|
|
11
|
+
*/
|
|
12
|
+
export declare function fetchByProductId(productId: number): Promise<ReviewJsonResponse[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Fetch reviews by user ID
|
|
15
|
+
*/
|
|
16
|
+
export declare function fetchByUserId(userId: number): Promise<ReviewJsonResponse[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Fetch approved reviews for a product
|
|
19
|
+
*/
|
|
20
|
+
export declare function fetchApprovedByProductId(productId: number): Promise<ReviewJsonResponse[]>;
|
|
21
|
+
export declare function fetchMostHelpfulByProductId(productId: number): Promise<ReviewJsonResponse[]>;
|
|
22
|
+
declare type ReviewJsonResponse = ModelRow<typeof Review>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export {
|
|
2
|
+
bulkDestroy,
|
|
3
|
+
destroy,
|
|
4
|
+
} from './destroy';
|
|
5
|
+
// Functions from fetch.ts
|
|
6
|
+
export {
|
|
7
|
+
fetchAll,
|
|
8
|
+
fetchApprovedByProductId,
|
|
9
|
+
fetchById,
|
|
10
|
+
fetchByProductId,
|
|
11
|
+
fetchByUserId,
|
|
12
|
+
fetchMostHelpfulByProductId,
|
|
13
|
+
} from './fetch';
|
|
14
|
+
// Functions from store.ts
|
|
15
|
+
export {
|
|
16
|
+
store,
|
|
17
|
+
} from './store';
|
|
18
|
+
// Functions from update.ts
|
|
19
|
+
export {
|
|
20
|
+
update,
|
|
21
|
+
updateVotes,
|
|
22
|
+
} from './update';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new product review
|
|
3
|
+
*
|
|
4
|
+
* @param data The review data to store
|
|
5
|
+
* @returns The newly created review record
|
|
6
|
+
*/
|
|
7
|
+
export declare function store(data: NewReviewInput): Promise<ReviewJsonResponse>;
|
|
8
|
+
declare type ReviewJsonResponse = ModelRow<typeof Review>;
|
|
9
|
+
declare type NewReview = NewModelData<typeof Review>;
|
|
10
|
+
declare type NewReviewInput = NewReview & Partial<{
|
|
11
|
+
is_verified_purchase: boolean
|
|
12
|
+
is_approved: boolean
|
|
13
|
+
helpful_votes: number
|
|
14
|
+
unhelpful_votes: number
|
|
15
|
+
is_featured: boolean
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update a review
|
|
3
|
+
*
|
|
4
|
+
* @param id The id of the review to update
|
|
5
|
+
* @param data The review data to update
|
|
6
|
+
* @returns The updated review record
|
|
7
|
+
*/
|
|
8
|
+
export declare function update(id: number, data: ReviewUpdate): Promise<ReviewJsonResponse>;
|
|
9
|
+
/**
|
|
10
|
+
* Update a review's vote counts
|
|
11
|
+
*
|
|
12
|
+
* @param id The ID of the review
|
|
13
|
+
* @param voteType The type of vote ('helpful' or 'unhelpful')
|
|
14
|
+
* @param increment Whether to increment (true) or decrement (false) the vote count
|
|
15
|
+
* @returns The updated review with new vote counts
|
|
16
|
+
*/
|
|
17
|
+
export declare function updateVotes(id: number, voteType: 'helpful' | 'unhelpful', increment?: boolean): Promise<ReviewJsonResponse>;
|
|
18
|
+
declare type ReviewJsonResponse = ModelRow<typeof Review>;
|
|
19
|
+
declare type ReviewUpdate = UpdateModelData<typeof Review>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delete a product unit by ID
|
|
3
|
+
*
|
|
4
|
+
* @param id The ID of the product unit to delete
|
|
5
|
+
* @returns True if the product unit was deleted, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export declare function destroy(id: number): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Delete multiple product units by ID
|
|
10
|
+
*
|
|
11
|
+
* @param ids Array of product unit IDs to delete
|
|
12
|
+
* @returns Number of product units deleted
|
|
13
|
+
*/
|
|
14
|
+
export declare function bulkDestroy(ids: number[]): Promise<number>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch a product unit by ID
|
|
3
|
+
*/
|
|
4
|
+
export declare function fetchById(id: number): Promise<ProductUnitJsonResponse | undefined>;
|
|
5
|
+
/**
|
|
6
|
+
* Fetch all product units
|
|
7
|
+
*/
|
|
8
|
+
export declare function fetchAll(): Promise<ProductUnitJsonResponse[]>;
|
|
9
|
+
declare type ProductUnitJsonResponse = ModelRow<typeof ProductUnit>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Export all functions from the unit modules
|
|
2
|
+
// Destroy functions
|
|
3
|
+
export { bulkDestroy, destroy } from './destroy';
|
|
4
|
+
// Fetch functions
|
|
5
|
+
export { fetchAll, fetchById } from './fetch';
|
|
6
|
+
// Store functions
|
|
7
|
+
export { bulkStore, formatUnitOptions, getDefaultUnit, store } from './store';
|
|
8
|
+
// Update functions
|
|
9
|
+
export { bulkUpdate, update, updateDefaultStatus } from './update';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new product unit
|
|
3
|
+
*
|
|
4
|
+
* @param data The product unit data to store
|
|
5
|
+
* @returns The newly created product unit record
|
|
6
|
+
*/
|
|
7
|
+
export declare function store(data: NewProductUnit): Promise<ProductUnitJsonResponse>;
|
|
8
|
+
/**
|
|
9
|
+
* Create multiple product units at once
|
|
10
|
+
*
|
|
11
|
+
* @param data Array of product unit data to store
|
|
12
|
+
* @returns Number of product units created
|
|
13
|
+
*/
|
|
14
|
+
export declare function bulkStore(data: NewProductUnit[]): Promise<number>;
|
|
15
|
+
/**
|
|
16
|
+
* Format product unit options for dropdown menus or selectors
|
|
17
|
+
*
|
|
18
|
+
* @param type Optional filter by unit type
|
|
19
|
+
* @returns Array of formatted unit options with id, name, and abbreviation
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatUnitOptions(type?: string): Promise<{ id: string, name: string, abbreviation: string, is_default: boolean | undefined }[] | []>;
|
|
22
|
+
/**
|
|
23
|
+
* Get the default unit for a specific type
|
|
24
|
+
*
|
|
25
|
+
* @param type The unit type to get the default for
|
|
26
|
+
* @returns The default unit or undefined if none found
|
|
27
|
+
*/
|
|
28
|
+
export declare function getDefaultUnit(type: string): Promise<ProductUnitJsonResponse | undefined>;
|
|
29
|
+
// Import dependencies
|
|
30
|
+
declare type ProductUnitJsonResponse = ModelRow<typeof ProductUnit>;
|
|
31
|
+
declare type NewProductUnit = NewModelData<typeof ProductUnit>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update a product unit
|
|
3
|
+
*
|
|
4
|
+
* @param id The ID of the product unit
|
|
5
|
+
* @param data The product unit data to update
|
|
6
|
+
* @returns The updated product unit record
|
|
7
|
+
*/
|
|
8
|
+
export declare function update(id: number, data: ProductUnitUpdate): Promise<ProductUnitJsonResponse>;
|
|
9
|
+
/**
|
|
10
|
+
* Update multiple product units at once
|
|
11
|
+
*
|
|
12
|
+
* @param data Array of product unit updates
|
|
13
|
+
* @returns Number of product units updated
|
|
14
|
+
*/
|
|
15
|
+
export declare function bulkUpdate(data: ProductUnitUpdate[]): Promise<number>;
|
|
16
|
+
/**
|
|
17
|
+
* Update the default status of a product unit
|
|
18
|
+
*
|
|
19
|
+
* @param id The ID of the product unit
|
|
20
|
+
* @param isDefault The new default status value
|
|
21
|
+
* @returns True if the status was updated successfully
|
|
22
|
+
*/
|
|
23
|
+
export declare function updateDefaultStatus(id: number, isDefault: boolean): Promise<boolean>;
|
|
24
|
+
declare type ProductUnitJsonResponse = ModelRow<typeof ProductUnit>;
|
|
25
|
+
declare type ProductUnitUpdate = UpdateModelData<typeof ProductUnit>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delete a product variant by ID
|
|
3
|
+
*
|
|
4
|
+
* @param id The ID of the product variant to delete
|
|
5
|
+
* @returns True if the product variant was deleted, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export declare function destroy(id: number): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Delete multiple product variants by ID
|
|
10
|
+
*
|
|
11
|
+
* @param ids Array of product variant IDs to delete
|
|
12
|
+
* @returns Number of product variants deleted
|
|
13
|
+
*/
|
|
14
|
+
export declare function bulkDestroy(ids: number[]): Promise<number>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch a product variant by ID
|
|
3
|
+
*/
|
|
4
|
+
export declare function fetchById(id: number): Promise<ProductVariantJsonResponse | undefined>;
|
|
5
|
+
/**
|
|
6
|
+
* Fetch all product variants
|
|
7
|
+
*/
|
|
8
|
+
export declare function fetchAll(): Promise<ProductVariantJsonResponse[]>;
|
|
9
|
+
declare type ProductVariantJsonResponse = ModelRow<typeof ProductVariant>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export {
|
|
2
|
+
bulkDestroy,
|
|
3
|
+
destroy,
|
|
4
|
+
} from './destroy';
|
|
5
|
+
export {
|
|
6
|
+
fetchAll,
|
|
7
|
+
fetchById,
|
|
8
|
+
} from './fetch';
|
|
9
|
+
export {
|
|
10
|
+
bulkStore,
|
|
11
|
+
formatVariantOptions,
|
|
12
|
+
generateVariantCombinations,
|
|
13
|
+
store,
|
|
14
|
+
} from './store';
|
|
15
|
+
export {
|
|
16
|
+
bulkUpdate,
|
|
17
|
+
update,
|
|
18
|
+
} from './update';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new product variant
|
|
3
|
+
*
|
|
4
|
+
* @param data The product variant data to store
|
|
5
|
+
* @returns The newly created product variant record
|
|
6
|
+
*/
|
|
7
|
+
export declare function store(data: NewProductVariant): Promise<ProductVariantJsonResponse>;
|
|
8
|
+
/**
|
|
9
|
+
* Create multiple product variants at once
|
|
10
|
+
*
|
|
11
|
+
* @param data Array of product variant data to store
|
|
12
|
+
* @returns Number of product variants created
|
|
13
|
+
*/
|
|
14
|
+
export declare function bulkStore(data: NewProductVariant[]): Promise<number>;
|
|
15
|
+
/**
|
|
16
|
+
* Generate product variant options from raw input
|
|
17
|
+
*
|
|
18
|
+
* @param rawOptions String array of options
|
|
19
|
+
* @returns Formatted JSON string of options
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatVariantOptions(rawOptions: string[]): string;
|
|
22
|
+
/**
|
|
23
|
+
* Create a set of common variant combinations from different option types
|
|
24
|
+
*
|
|
25
|
+
* @param optionSets Object containing option types and their values
|
|
26
|
+
* @returns Array of variant combinations
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Generate combinations for a t-shirt product
|
|
30
|
+
* const options = {
|
|
31
|
+
* size: ['S', 'M', 'L'],
|
|
32
|
+
* color: ['Red', 'Blue']
|
|
33
|
+
* }
|
|
34
|
+
* // Returns: [
|
|
35
|
+
* // { size: 'S', color: 'Red' },
|
|
36
|
+
* // { size: 'S', color: 'Blue' },
|
|
37
|
+
* // { size: 'M', color: 'Red' },
|
|
38
|
+
* // ...
|
|
39
|
+
* // ]
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateVariantCombinations(optionSets: Record<string, string[]>): Record<string, string>[];
|
|
42
|
+
declare type ProductVariantJsonResponse = ModelRow<typeof ProductVariant>;
|
|
43
|
+
declare type NewProductVariant = NewModelData<typeof ProductVariant>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update a product variant
|
|
3
|
+
*
|
|
4
|
+
* @param id The ID of the product variant to update
|
|
5
|
+
* @param data The product variant data to update
|
|
6
|
+
* @returns The updated product variant record
|
|
7
|
+
*/
|
|
8
|
+
export declare function update(id: number, data: Omit<ProductVariantUpdate, 'id'>): Promise<ProductVariantJsonResponse>;
|
|
9
|
+
/**
|
|
10
|
+
* Update multiple product variants at once
|
|
11
|
+
*
|
|
12
|
+
* @param data Array of objects containing variant ID and update data
|
|
13
|
+
* @returns Number of product variants updated
|
|
14
|
+
*/
|
|
15
|
+
export declare function bulkUpdate(data: ProductVariantUpdate[]): Promise<number>;
|
|
16
|
+
/**
|
|
17
|
+
* Update the status of a product variant
|
|
18
|
+
*
|
|
19
|
+
* @param id The ID of the product variant
|
|
20
|
+
* @param status The new status value
|
|
21
|
+
* @returns True if the status was updated successfully
|
|
22
|
+
*/
|
|
23
|
+
export declare function updateStatus(id: number, status: string): Promise<boolean>;
|
|
24
|
+
declare type ProductVariantJsonResponse = ModelRow<typeof ProductVariant>;
|
|
25
|
+
declare type ProductVariantUpdate = UpdateModelData<typeof ProductVariant>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delete a print log by ID
|
|
3
|
+
*
|
|
4
|
+
* @param id The ID of the print log to delete
|
|
5
|
+
* @returns True if the print log was deleted, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export declare function destroy(id: number): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Delete multiple print logs by ID
|
|
10
|
+
*
|
|
11
|
+
* @param ids Array of print log IDs to delete
|
|
12
|
+
* @returns Number of print logs deleted
|
|
13
|
+
*/
|
|
14
|
+
export declare function bulkDestroy(ids: number[]): Promise<number>;
|