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