@commercengine/storefront-sdk 0.3.0 → 0.3.2
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/index.d.ts +90 -39
- package/dist/index.js +156 -127
- package/dist/lib/auth-utils.d.ts +16 -0
- package/dist/lib/auth-utils.js +38 -0
- package/dist/lib/auth.d.ts +105 -195
- package/dist/lib/auth.js +221 -653
- package/dist/lib/cart.d.ts +77 -80
- package/dist/lib/cart.js +183 -221
- package/dist/lib/catalog.d.ts +36 -69
- package/dist/lib/catalog.js +109 -118
- package/dist/lib/client.d.ts +37 -84
- package/dist/lib/client.js +148 -173
- package/dist/lib/customer.d.ts +87 -0
- package/dist/lib/customer.js +153 -0
- package/dist/lib/helper.d.ts +27 -0
- package/dist/lib/helper.js +40 -0
- package/dist/lib/jwt-utils.d.ts +75 -0
- package/dist/lib/jwt-utils.js +84 -0
- package/dist/lib/middleware.d.ts +83 -0
- package/dist/lib/middleware.js +248 -0
- package/dist/lib/order.d.ts +72 -0
- package/dist/lib/order.js +125 -0
- package/dist/lib/shipping.d.ts +14 -0
- package/dist/lib/shipping.js +17 -0
- package/dist/types/storefront-api-types.d.ts +359 -0
- package/dist/types/storefront-api-types.js +3 -0
- package/dist/types/storefront.d.ts +7976 -7369
- package/package.json +21 -12
package/dist/lib/cart.d.ts
CHANGED
|
@@ -1,100 +1,52 @@
|
|
|
1
1
|
import { StorefrontAPIClient } from "./client";
|
|
2
|
-
import type {
|
|
3
|
-
import { ClientStorage } from "./auth";
|
|
2
|
+
import type { AddToWishlistBody, AddToWishlistContent, AddToWishlistPathParams, ApiResult, ApplyCouponBody, ApplyCouponContent, ApplyCouponPathParams, CreateCartContent, CreateCartAddressBody, CreateCartAddressContent, CreateCartAddressPathParams, CreateCartBody, DeleteCartPathParams, DeleteCartResponse, DeleteFromWishlistBody, DeleteFromWishlistContent, DeleteFromWishlistPathParams, DeleteUserCartPathParams, DeleteUserCartResponse, GetCartContent, GetCartPathParams, GetUserCartContent, GetUserCartPathParams, GetWishlistContent, GetWishlistPathParams, RedeemCreditBalanceBody, RedeemCreditBalanceContent, RedeemCreditBalancePathParams, RedeemGiftCardBody, RedeemGiftCardContent, RedeemGiftCardPathParams, RedeemLoyaltyPointsBody, RedeemLoyaltyPointsContent, RedeemLoyaltyPointsPathParams, RemoveCouponContent, RemoveCouponPathParams, RemoveCreditBalanceContent, RemoveCreditBalancePathParams, RemoveGiftCardContent, RemoveGiftCardPathParams, RemoveLoyaltyPointsContent, RemoveLoyaltyPointsPathParams, UpdateCartBody, UpdateCartContent, UpdateCartPathParams, UpdateShippingMethodBody, UpdateShippingMethodContent, UpdateShippingMethodPathParams } from "../types/storefront-api-types";
|
|
4
3
|
/**
|
|
5
4
|
* Client for interacting with cart endpoints
|
|
6
5
|
*/
|
|
7
6
|
export declare class CartClient extends StorefrontAPIClient {
|
|
8
|
-
private clientStorage;
|
|
9
|
-
/**
|
|
10
|
-
* Set the client storage implementation to use for cart ID management
|
|
11
|
-
*
|
|
12
|
-
* @param storage - The client storage instance
|
|
13
|
-
*/
|
|
14
|
-
setClientStorage(storage: ClientStorage): void;
|
|
15
|
-
/**
|
|
16
|
-
* Get the stored cart ID
|
|
17
|
-
*
|
|
18
|
-
* @returns Promise that resolves to the cart ID or null if not found
|
|
19
|
-
*/
|
|
20
|
-
getCartId(): Promise<string | null>;
|
|
21
|
-
/**
|
|
22
|
-
* Set the cart ID in storage
|
|
23
|
-
*
|
|
24
|
-
* @param cartId - The cart ID to store
|
|
25
|
-
*/
|
|
26
|
-
setCartId(cartId: string): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* Clear the stored cart ID
|
|
29
|
-
*/
|
|
30
|
-
clearCartId(): Promise<void>;
|
|
31
7
|
/**
|
|
32
8
|
* Create a new cart
|
|
33
9
|
*
|
|
34
10
|
* @param payload - Object containing the items to add to the cart
|
|
35
11
|
* @returns Promise with the created cart
|
|
36
12
|
*/
|
|
37
|
-
createCart(payload:
|
|
38
|
-
items: components["schemas"]["UpdateCartItem"][];
|
|
39
|
-
}): Promise<{
|
|
40
|
-
cart: components["schemas"]["Cart"];
|
|
41
|
-
}>;
|
|
13
|
+
createCart(payload: CreateCartBody): Promise<ApiResult<CreateCartContent>>;
|
|
42
14
|
/**
|
|
43
15
|
* Get cart details - either by ID or using the stored cart ID
|
|
44
16
|
*
|
|
45
|
-
* @param cartId -
|
|
17
|
+
* @param cartId - The ID of the cart
|
|
46
18
|
* @returns Promise with cart details
|
|
47
|
-
* @throws Error if no cartId is provided and none is stored
|
|
48
19
|
*/
|
|
49
|
-
getCart(cartId
|
|
50
|
-
cart: components["schemas"]["Cart"];
|
|
51
|
-
}>;
|
|
20
|
+
getCart(cartId: GetCartPathParams): Promise<ApiResult<GetCartContent>>;
|
|
52
21
|
/**
|
|
53
22
|
* Delete a cart - either by ID or using the stored cart ID
|
|
54
23
|
*
|
|
55
|
-
* @param cartId -
|
|
24
|
+
* @param cartId - The ID of the cart
|
|
56
25
|
* @returns Promise that resolves when the cart is deleted
|
|
57
|
-
* @throws Error if no cartId is provided and none is stored
|
|
58
26
|
*/
|
|
59
|
-
deleteCart(cartId
|
|
60
|
-
/**
|
|
61
|
-
* Add item to cart - either by specified ID or stored cart ID
|
|
62
|
-
* Will create a new cart if no cart ID is available
|
|
63
|
-
*
|
|
64
|
-
* @param item - The item to add to the cart
|
|
65
|
-
* @param cartId - Optional cart ID (if not provided, uses stored cart ID or creates a new cart)
|
|
66
|
-
* @returns Promise with updated or created cart
|
|
67
|
-
*/
|
|
68
|
-
addItem(item: components["schemas"]["UpdateCartItem"], cartId?: string): Promise<{
|
|
69
|
-
cart: components["schemas"]["Cart"];
|
|
70
|
-
}>;
|
|
27
|
+
deleteCart(cartId: DeleteCartPathParams): Promise<ApiResult<DeleteCartResponse>>;
|
|
71
28
|
/**
|
|
72
29
|
* Update cart items (add, update quantity, remove)
|
|
73
30
|
*
|
|
74
|
-
* @param cartId - The
|
|
75
|
-
* @param
|
|
31
|
+
* @param cartId - The cart id
|
|
32
|
+
* @param body - The body of the request
|
|
76
33
|
* @returns Promise with updated cart
|
|
77
|
-
* @throws Error if no cartId is provided and none is stored
|
|
78
34
|
*/
|
|
79
|
-
|
|
80
|
-
cart: components["schemas"]["Cart"];
|
|
81
|
-
}>;
|
|
35
|
+
addDeleteCartItem(cartId: UpdateCartPathParams, body: UpdateCartBody): Promise<ApiResult<UpdateCartContent>>;
|
|
82
36
|
/**
|
|
83
37
|
* Get cart details by user ID
|
|
84
38
|
*
|
|
85
39
|
* @param userId - The ID of the user
|
|
86
40
|
* @returns Promise with cart details
|
|
87
41
|
*/
|
|
88
|
-
getUserCart(userId:
|
|
89
|
-
cart: components["schemas"]["Cart"];
|
|
90
|
-
}>;
|
|
42
|
+
getUserCart(userId: GetUserCartPathParams): Promise<ApiResult<GetUserCartContent>>;
|
|
91
43
|
/**
|
|
92
44
|
* Delete a cart by user ID
|
|
93
45
|
*
|
|
94
46
|
* @param userId - The ID of the user
|
|
95
47
|
* @returns Promise that resolves when the cart is deleted
|
|
96
48
|
*/
|
|
97
|
-
deleteUserCart(userId:
|
|
49
|
+
deleteUserCart(userId: DeleteUserCartPathParams): Promise<ApiResult<DeleteUserCartResponse>>;
|
|
98
50
|
/**
|
|
99
51
|
* Update cart addresses
|
|
100
52
|
*
|
|
@@ -102,15 +54,7 @@ export declare class CartClient extends StorefrontAPIClient {
|
|
|
102
54
|
* @param addressData - The address data
|
|
103
55
|
* @returns Promise with updated cart
|
|
104
56
|
*/
|
|
105
|
-
updateCartAddress(cartId:
|
|
106
|
-
billing_address_id: string;
|
|
107
|
-
shipping_address_id: string;
|
|
108
|
-
} | {
|
|
109
|
-
billing_address: components["schemas"]["CustomerAddress"];
|
|
110
|
-
shipping_address: components["schemas"]["CustomerAddress"];
|
|
111
|
-
}): Promise<{
|
|
112
|
-
cart: components["schemas"]["Cart"];
|
|
113
|
-
}>;
|
|
57
|
+
updateCartAddress(cartId: CreateCartAddressPathParams, addressData: CreateCartAddressBody): Promise<ApiResult<CreateCartAddressContent>>;
|
|
114
58
|
/**
|
|
115
59
|
* Apply a coupon to the cart
|
|
116
60
|
*
|
|
@@ -118,18 +62,14 @@ export declare class CartClient extends StorefrontAPIClient {
|
|
|
118
62
|
* @param couponCode - The coupon code
|
|
119
63
|
* @returns Promise with updated cart
|
|
120
64
|
*/
|
|
121
|
-
applyCoupon(cartId:
|
|
122
|
-
cart: components["schemas"]["Cart"];
|
|
123
|
-
}>;
|
|
65
|
+
applyCoupon(cartId: ApplyCouponPathParams, couponCode: ApplyCouponBody): Promise<ApiResult<ApplyCouponContent>>;
|
|
124
66
|
/**
|
|
125
67
|
* Remove a coupon from the cart
|
|
126
68
|
*
|
|
127
69
|
* @param cartId - The ID of the cart
|
|
128
70
|
* @returns Promise with updated cart
|
|
129
71
|
*/
|
|
130
|
-
removeCoupon(cartId:
|
|
131
|
-
cart: components["schemas"]["Cart"];
|
|
132
|
-
}>;
|
|
72
|
+
removeCoupon(cartId: RemoveCouponPathParams): Promise<ApiResult<RemoveCouponContent>>;
|
|
133
73
|
/**
|
|
134
74
|
* Redeem loyalty points
|
|
135
75
|
*
|
|
@@ -137,16 +77,73 @@ export declare class CartClient extends StorefrontAPIClient {
|
|
|
137
77
|
* @param points - The number of points to redeem
|
|
138
78
|
* @returns Promise with updated cart
|
|
139
79
|
*/
|
|
140
|
-
redeemLoyaltyPoints(cartId:
|
|
141
|
-
cart: components["schemas"]["Cart"];
|
|
142
|
-
}>;
|
|
80
|
+
redeemLoyaltyPoints(cartId: RedeemLoyaltyPointsPathParams, points: RedeemLoyaltyPointsBody): Promise<ApiResult<RedeemLoyaltyPointsContent>>;
|
|
143
81
|
/**
|
|
144
82
|
* Remove loyalty points
|
|
145
83
|
*
|
|
146
84
|
* @param cartId - The ID of the cart
|
|
147
85
|
* @returns Promise with updated cart
|
|
148
86
|
*/
|
|
149
|
-
removeLoyaltyPoints(cartId:
|
|
150
|
-
|
|
151
|
-
|
|
87
|
+
removeLoyaltyPoints(cartId: RemoveLoyaltyPointsPathParams): Promise<ApiResult<RemoveLoyaltyPointsContent>>;
|
|
88
|
+
/**
|
|
89
|
+
* Update shipping method
|
|
90
|
+
*
|
|
91
|
+
* @param cartId - The ID of the cart
|
|
92
|
+
* @param body - The body of the request
|
|
93
|
+
* @returns Promise with updated cart
|
|
94
|
+
*/
|
|
95
|
+
updateShippingMethod(cartId: UpdateShippingMethodPathParams, body: UpdateShippingMethodBody): Promise<ApiResult<UpdateShippingMethodContent>>;
|
|
96
|
+
/**
|
|
97
|
+
* Use credit balance
|
|
98
|
+
*
|
|
99
|
+
* @param cartId - The ID of the cart
|
|
100
|
+
* @param body - The body of the request
|
|
101
|
+
* @returns Promise with updated cart
|
|
102
|
+
*/
|
|
103
|
+
redeemCreditBalance(cartId: RedeemCreditBalancePathParams, body: RedeemCreditBalanceBody): Promise<ApiResult<RedeemCreditBalanceContent>>;
|
|
104
|
+
/**
|
|
105
|
+
* Remove credit balance
|
|
106
|
+
*
|
|
107
|
+
* @param cartId - The ID of the cart
|
|
108
|
+
* @returns Promise with updated cart
|
|
109
|
+
*/
|
|
110
|
+
removeCreditBalance(cartId: RemoveCreditBalancePathParams): Promise<ApiResult<RemoveCreditBalanceContent>>;
|
|
111
|
+
/**
|
|
112
|
+
* Redeem gift card
|
|
113
|
+
*
|
|
114
|
+
* @param cartId - The ID of the cart
|
|
115
|
+
* @param body - The body of the request
|
|
116
|
+
* @returns Promise with updated cart
|
|
117
|
+
*/
|
|
118
|
+
redeemGiftCard(cartId: RedeemGiftCardPathParams, body: RedeemGiftCardBody): Promise<ApiResult<RedeemGiftCardContent>>;
|
|
119
|
+
/**
|
|
120
|
+
* Remove gift card
|
|
121
|
+
*
|
|
122
|
+
* @param cartId - The ID of the cart
|
|
123
|
+
* @returns Promise with updated cart
|
|
124
|
+
*/
|
|
125
|
+
removeGiftCard(cartId: RemoveGiftCardPathParams): Promise<ApiResult<RemoveGiftCardContent>>;
|
|
126
|
+
/**
|
|
127
|
+
* Get wishlist items
|
|
128
|
+
*
|
|
129
|
+
* @param userId - The ID of the user
|
|
130
|
+
* @returns Promise with wishlist items
|
|
131
|
+
*/
|
|
132
|
+
getWishlist(userId: GetWishlistPathParams): Promise<ApiResult<GetWishlistContent>>;
|
|
133
|
+
/**
|
|
134
|
+
* Add item to wishlist
|
|
135
|
+
*
|
|
136
|
+
* @param userId - The ID of the user
|
|
137
|
+
* @param itemId - The ID of the item
|
|
138
|
+
* @returns Promise with updated wishlist
|
|
139
|
+
*/
|
|
140
|
+
addToWishlist(userId: AddToWishlistPathParams, itemId: AddToWishlistBody): Promise<ApiResult<AddToWishlistContent>>;
|
|
141
|
+
/**
|
|
142
|
+
* Remove item from wishlist
|
|
143
|
+
*
|
|
144
|
+
* @param userId - The ID of the user
|
|
145
|
+
* @param itemId - The ID of the item
|
|
146
|
+
* @returns Promise with updated wishlist
|
|
147
|
+
*/
|
|
148
|
+
removeFromWishlist(userId: DeleteFromWishlistPathParams, body: DeleteFromWishlistBody): Promise<ApiResult<DeleteFromWishlistContent>>;
|
|
152
149
|
}
|