@stacksjs/commerce 0.72.103 → 0.73.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/carts/destroy.d.ts +14 -0
- package/dist/carts/fetch.d.ts +10 -0
- package/dist/carts/index.d.ts +16 -0
- package/dist/carts/store.d.ts +17 -0
- package/dist/carts/update.d.ts +18 -0
- package/dist/gift-cards/index.d.ts +2 -0
- package/dist/gift-cards/update.d.ts +9 -3
- package/dist/index.d.ts +4 -0
- package/dist/index.js +17 -16
- package/dist/orders/index.d.ts +1 -0
- package/dist/shippings/couriers/destroy.d.ts +14 -0
- package/dist/shippings/couriers/fetch.d.ts +10 -0
- package/dist/shippings/couriers/store.d.ts +17 -0
- package/dist/shippings/couriers/update.d.ts +27 -0
- package/dist/shippings/delivery-routes/fetch.d.ts +2 -2
- package/dist/shippings/delivery-routes/index.d.ts +1 -1
- package/dist/shippings/index.d.ts +3 -3
- package/dist/shippings/tracking/events.d.ts +6 -6
- package/dist/shippings/tracking/geo.d.ts +1 -1
- package/dist/shippings/tracking/index.d.ts +3 -3
- package/dist/shippings/tracking/ping.d.ts +9 -9
- package/dist/shippings/tracking/stops.d.ts +16 -14
- package/dist/shippings/write-data.d.ts +1 -1
- package/dist/tax/breakdown.d.ts +22 -14
- package/dist/types.d.ts +2 -0
- package/dist/utils/inserted-id.d.ts +20 -0
- package/package.json +1 -1
- package/dist/shippings/drivers/destroy.d.ts +0 -14
- package/dist/shippings/drivers/fetch.d.ts +0 -10
- package/dist/shippings/drivers/store.d.ts +0 -17
- package/dist/shippings/drivers/update.d.ts +0 -27
- /package/dist/shippings/{drivers → couriers}/index.d.ts +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delete a cart by ID
|
|
3
|
+
*
|
|
4
|
+
* @param id The ID of the cart to delete
|
|
5
|
+
* @returns True if the cart was deleted, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export declare function destroy(id: number): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Delete multiple carts by ID
|
|
10
|
+
*
|
|
11
|
+
* @param ids Array of cart IDs to delete
|
|
12
|
+
* @returns Number of carts deleted
|
|
13
|
+
*/
|
|
14
|
+
export declare function bulkDestroy(ids: number[]): Promise<number>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Cart, ModelRow } from '@stacksjs/orm';
|
|
2
|
+
/**
|
|
3
|
+
* Fetch a cart by ID
|
|
4
|
+
*/
|
|
5
|
+
export declare function fetchById(id: number): Promise<CartJsonResponse | undefined>;
|
|
6
|
+
/**
|
|
7
|
+
* Fetch all carts
|
|
8
|
+
*/
|
|
9
|
+
export declare function fetchAll(): Promise<CartJsonResponse[]>;
|
|
10
|
+
declare type CartJsonResponse = ModelRow<typeof Cart>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Cart, ModelRow, NewModelData } from '@stacksjs/orm';
|
|
2
|
+
/**
|
|
3
|
+
* Create a new cart
|
|
4
|
+
*
|
|
5
|
+
* @param data Cart data to store
|
|
6
|
+
* @returns The newly created cart record
|
|
7
|
+
*/
|
|
8
|
+
export declare function store(data: NewCart): Promise<CartJsonResponse>;
|
|
9
|
+
/**
|
|
10
|
+
* Create multiple carts at once
|
|
11
|
+
*
|
|
12
|
+
* @param data Array of cart data to store
|
|
13
|
+
* @returns Number of carts created
|
|
14
|
+
*/
|
|
15
|
+
export declare function bulkStore(data: NewCart[]): Promise<number>;
|
|
16
|
+
declare type CartJsonResponse = ModelRow<typeof Cart>;
|
|
17
|
+
declare type NewCart = NewModelData<typeof Cart>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Cart, ModelRow, UpdateModelData } from '@stacksjs/orm';
|
|
2
|
+
/**
|
|
3
|
+
* Update a cart
|
|
4
|
+
*
|
|
5
|
+
* @param id The ID of the cart to update
|
|
6
|
+
* @param data The cart data to update
|
|
7
|
+
* @returns The updated cart record
|
|
8
|
+
*/
|
|
9
|
+
export declare function update(id: number, data: Omit<CartUpdate, 'id'>): Promise<CartJsonResponse>;
|
|
10
|
+
/**
|
|
11
|
+
* Update multiple carts at once
|
|
12
|
+
*
|
|
13
|
+
* @param data Array of objects containing cart ID and update data
|
|
14
|
+
* @returns Number of carts updated
|
|
15
|
+
*/
|
|
16
|
+
export declare function bulkUpdate(data: CartUpdate[]): Promise<number>;
|
|
17
|
+
declare type CartJsonResponse = ModelRow<typeof Cart>;
|
|
18
|
+
declare type CartUpdate = UpdateModelData<typeof Cart>;
|
|
@@ -10,7 +10,7 @@ export declare function update(id: number, data: Omit<GiftCardUpdate, 'id'>): Pr
|
|
|
10
10
|
/**
|
|
11
11
|
* Update a gift card's balance atomically (stacksjs/stacks#1879 Co-8).
|
|
12
12
|
*
|
|
13
|
-
* Pre-fix: read balance
|
|
13
|
+
* Pre-fix: read balance -> compute new -> write. Two parallel $50
|
|
14
14
|
* redemptions of a $100 card both saw `current_balance = 100`,
|
|
15
15
|
* both wrote `50`, leaving `50` instead of `0`. The post-read
|
|
16
16
|
* negative-balance guard only caught single-threaded misuse.
|
|
@@ -19,8 +19,14 @@ export declare function update(id: number, data: Omit<GiftCardUpdate, 'id'>): Pr
|
|
|
19
19
|
* enforces every precondition in the WHERE clause. The database
|
|
20
20
|
* guarantees only one writer wins the race. Throws when the row
|
|
21
21
|
* was found but the precondition failed (insufficient balance,
|
|
22
|
-
* inactive,
|
|
23
|
-
* not-found row.
|
|
22
|
+
* inactive, expired, not reloadable) so the caller can distinguish
|
|
23
|
+
* from a not-found row.
|
|
24
|
+
*
|
|
25
|
+
* A negative `amount` is a redemption and a positive one a reload.
|
|
26
|
+
* The two are not symmetric, so the statement is shaped per direction:
|
|
27
|
+
* only a redemption stamps `last_used_date`, and only a reload may
|
|
28
|
+
* touch a card already spent down to `USED` (and then only when the
|
|
29
|
+
* card is `is_reloadable`, which is otherwise a field nothing honours).
|
|
24
30
|
*
|
|
25
31
|
* @param id The ID of the gift card
|
|
26
32
|
* @param amount The amount to adjust (positive to add, negative to deduct)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as auctions from './auctions/index';
|
|
2
|
+
import * as carts from './carts/index';
|
|
2
3
|
import * as coupons from './coupons/index';
|
|
3
4
|
import * as customers from './customers/index';
|
|
4
5
|
import * as devices from './devices/index';
|
|
@@ -15,6 +16,7 @@ import * as waitlists from './waitlists/index';
|
|
|
15
16
|
export declare const commerce: CommerceNamespace;
|
|
16
17
|
export declare interface CommerceNamespace {
|
|
17
18
|
auctions: AuctionsModule
|
|
19
|
+
carts: CartsModule
|
|
18
20
|
coupons: CouponsModule
|
|
19
21
|
customers: CustomersModule
|
|
20
22
|
errors: ErrorsModule
|
|
@@ -30,6 +32,7 @@ export declare interface CommerceNamespace {
|
|
|
30
32
|
receipts: ReceiptsModule
|
|
31
33
|
}
|
|
32
34
|
declare type AuctionsModule = typeof auctions;
|
|
35
|
+
declare type CartsModule = typeof carts;
|
|
33
36
|
declare type CouponsModule = typeof coupons;
|
|
34
37
|
declare type CustomersModule = typeof customers;
|
|
35
38
|
declare type ErrorsModule = typeof errors;
|
|
@@ -45,6 +48,7 @@ declare type DevicesModule = typeof devices;
|
|
|
45
48
|
declare type ReceiptsModule = typeof receipts;
|
|
46
49
|
export {
|
|
47
50
|
auctions,
|
|
51
|
+
carts,
|
|
48
52
|
coupons,
|
|
49
53
|
customers,
|
|
50
54
|
devices,
|