@commercengine/storefront-sdk 0.3.3 → 0.3.5
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/lib/cart.d.ts +15 -1
- package/dist/lib/cart.js +22 -0
- package/dist/lib/client.js +5 -1
- package/dist/lib/shipping.d.ts +3 -3
- package/dist/lib/shipping.js +1 -1
- package/dist/types/storefront-api-types.d.ts +11 -12
- package/dist/types/storefront.d.ts +563 -209
- package/package.json +1 -1
package/dist/lib/cart.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StorefrontAPIClient } from "./client";
|
|
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";
|
|
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, ListCouponsContent, ListPromotionsContent, ListCouponsHeaderParams, ListPromotionsHeaderParams } from "../types/storefront-api-types";
|
|
3
3
|
/**
|
|
4
4
|
* Client for interacting with cart endpoints
|
|
5
5
|
*/
|
|
@@ -146,4 +146,18 @@ export declare class CartClient extends StorefrontAPIClient {
|
|
|
146
146
|
* @returns Promise with updated wishlist
|
|
147
147
|
*/
|
|
148
148
|
removeFromWishlist(userId: DeleteFromWishlistPathParams, body: DeleteFromWishlistBody): Promise<ApiResult<DeleteFromWishlistContent>>;
|
|
149
|
+
/**
|
|
150
|
+
* Get all available coupons
|
|
151
|
+
*
|
|
152
|
+
* @param customerGroupId - The ID of the customer group
|
|
153
|
+
* @returns Promise with all available coupons
|
|
154
|
+
*/
|
|
155
|
+
getAvailableCoupons(headers: ListCouponsHeaderParams): Promise<ApiResult<ListCouponsContent>>;
|
|
156
|
+
/**
|
|
157
|
+
* Get all available promotions
|
|
158
|
+
*
|
|
159
|
+
* @param customerGroupId - The ID of the customer group
|
|
160
|
+
* @returns Promise with all available promotions
|
|
161
|
+
*/
|
|
162
|
+
getAvailablePromotions(headers: ListPromotionsHeaderParams): Promise<ApiResult<ListPromotionsContent>>;
|
|
149
163
|
}
|
package/dist/lib/cart.js
CHANGED
|
@@ -271,4 +271,26 @@ export class CartClient extends StorefrontAPIClient {
|
|
|
271
271
|
body: body,
|
|
272
272
|
}));
|
|
273
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* Get all available coupons
|
|
276
|
+
*
|
|
277
|
+
* @param customerGroupId - The ID of the customer group
|
|
278
|
+
* @returns Promise with all available coupons
|
|
279
|
+
*/
|
|
280
|
+
async getAvailableCoupons(headers) {
|
|
281
|
+
return this.executeRequest(() => this.client.GET("/carts/available-coupons", {
|
|
282
|
+
headers: headers,
|
|
283
|
+
}));
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Get all available promotions
|
|
287
|
+
*
|
|
288
|
+
* @param customerGroupId - The ID of the customer group
|
|
289
|
+
* @returns Promise with all available promotions
|
|
290
|
+
*/
|
|
291
|
+
async getAvailablePromotions(headers) {
|
|
292
|
+
return this.executeRequest(() => this.client.GET("/carts/available-promotions", {
|
|
293
|
+
headers: headers,
|
|
294
|
+
}));
|
|
295
|
+
}
|
|
274
296
|
}
|
package/dist/lib/client.js
CHANGED
|
@@ -223,7 +223,11 @@ export class StorefrontAPIClient {
|
|
|
223
223
|
if (error) {
|
|
224
224
|
return { data: null, error };
|
|
225
225
|
}
|
|
226
|
-
//
|
|
226
|
+
// If response has content, return it directly
|
|
227
|
+
if (data && data.content !== undefined) {
|
|
228
|
+
return { data: data.content, error: null };
|
|
229
|
+
}
|
|
230
|
+
// If no content, return the response object (with message, success, etc.)
|
|
227
231
|
return { data: data, error: null };
|
|
228
232
|
}
|
|
229
233
|
catch (err) {
|
package/dist/lib/shipping.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApiResult,
|
|
1
|
+
import type { ApiResult, CheckPincodeServiceabilityContent, CheckPincodeServiceabilityPathParams, GetShippingMethodsBody, GetShippingMethodsContent } from "../types/storefront-api-types";
|
|
2
2
|
import { StorefrontAPIClient } from "./client";
|
|
3
3
|
/**
|
|
4
4
|
* Client for interacting with shipping endpoints
|
|
@@ -10,12 +10,12 @@ export declare class ShippingClient extends StorefrontAPIClient {
|
|
|
10
10
|
* @param body - Shipping methods body
|
|
11
11
|
* @returns Promise with shipping options
|
|
12
12
|
*/
|
|
13
|
-
getShippingMethods(body:
|
|
13
|
+
getShippingMethods(body: GetShippingMethodsBody): Promise<ApiResult<GetShippingMethodsContent>>;
|
|
14
14
|
/**
|
|
15
15
|
* Check pincode deliverability
|
|
16
16
|
*
|
|
17
17
|
* @param pathParams - Path parameters
|
|
18
18
|
* @returns Promise with pincode deliverability result
|
|
19
19
|
*/
|
|
20
|
-
checkPincodeDeliverability(pathParams:
|
|
20
|
+
checkPincodeDeliverability(pathParams: CheckPincodeServiceabilityPathParams): Promise<ApiResult<CheckPincodeServiceabilityContent>>;
|
|
21
21
|
}
|
package/dist/lib/shipping.js
CHANGED
|
@@ -21,7 +21,7 @@ export class ShippingClient extends StorefrontAPIClient {
|
|
|
21
21
|
* @returns Promise with pincode deliverability result
|
|
22
22
|
*/
|
|
23
23
|
async checkPincodeDeliverability(pathParams) {
|
|
24
|
-
return this.executeRequest(() => this.client.GET("/
|
|
24
|
+
return this.executeRequest(() => this.client.GET("/shipping/serviceability/{pincode}", {
|
|
25
25
|
params: {
|
|
26
26
|
path: pathParams,
|
|
27
27
|
},
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { paths } from './storefront';
|
|
2
2
|
export type ApiResult<T> = {
|
|
3
|
-
data:
|
|
4
|
-
message?: string;
|
|
5
|
-
success?: boolean;
|
|
6
|
-
content?: T;
|
|
7
|
-
};
|
|
3
|
+
data: T;
|
|
8
4
|
error: null;
|
|
9
5
|
} | {
|
|
10
6
|
data: null;
|
|
@@ -109,10 +105,12 @@ export type RedeemGiftCardBody = NonNullable<paths['/carts/{id}/gift-card']['pos
|
|
|
109
105
|
export type RemoveGiftCardResponse = paths['/carts/{id}/gift-card']['delete']['responses'][200]['content']['application/json'];
|
|
110
106
|
export type RemoveGiftCardContent = RemoveGiftCardResponse['content'];
|
|
111
107
|
export type RemoveGiftCardPathParams = paths['/carts/{id}/gift-card']['delete']['parameters']['path'];
|
|
112
|
-
export type ListCouponsResponse = paths['/
|
|
108
|
+
export type ListCouponsResponse = paths['/carts/available-coupons']['get']['responses'][200]['content']['application/json'];
|
|
113
109
|
export type ListCouponsContent = ListCouponsResponse['content'];
|
|
114
|
-
export type
|
|
110
|
+
export type ListCouponsHeaderParams = paths['/carts/available-coupons']['get']['parameters']['header'];
|
|
111
|
+
export type ListPromotionsResponse = paths['/carts/available-promotions']['get']['responses'][200]['content']['application/json'];
|
|
115
112
|
export type ListPromotionsContent = ListPromotionsResponse['content'];
|
|
113
|
+
export type ListPromotionsHeaderParams = paths['/carts/available-promotions']['get']['parameters']['header'];
|
|
116
114
|
export type GetWishlistResponse = paths['/wishlist/{user_id}']['get']['responses'][200]['content']['application/json'];
|
|
117
115
|
export type GetWishlistContent = GetWishlistResponse['content'];
|
|
118
116
|
export type GetWishlistPathParams = paths['/wishlist/{user_id}']['get']['parameters']['path'];
|
|
@@ -216,11 +214,12 @@ export type RetryOrderPaymentResponse = paths['/orders/{order_number}/retry-paym
|
|
|
216
214
|
export type RetryOrderPaymentContent = RetryOrderPaymentResponse['content'];
|
|
217
215
|
export type RetryOrderPaymentPathParams = paths['/orders/{order_number}/retry-payment']['post']['parameters']['path'];
|
|
218
216
|
export type RetryOrderPaymentBody = NonNullable<paths['/orders/{order_number}/retry-payment']['post']['requestBody']>['content']['application/json'];
|
|
219
|
-
export type
|
|
220
|
-
export type
|
|
221
|
-
export type
|
|
222
|
-
export type
|
|
223
|
-
export type
|
|
217
|
+
export type GetShippingMethodsResponse = paths['/shipping/shipping-methods']['post']['responses'][200]['content']['application/json'];
|
|
218
|
+
export type GetShippingMethodsContent = GetShippingMethodsResponse['content'];
|
|
219
|
+
export type GetShippingMethodsBody = NonNullable<paths['/shipping/shipping-methods']['post']['requestBody']>['content']['application/json'];
|
|
220
|
+
export type CheckPincodeServiceabilityResponse = paths['/shipping/serviceability/{pincode}']['get']['responses'][200]['content']['application/json'];
|
|
221
|
+
export type CheckPincodeServiceabilityContent = CheckPincodeServiceabilityResponse['content'];
|
|
222
|
+
export type CheckPincodeServiceabilityPathParams = paths['/shipping/serviceability/{pincode}']['get']['parameters']['path'];
|
|
224
223
|
export type GetAnonymousTokenResponse = paths['/auth/anonymous']['post']['responses'][200]['content']['application/json'];
|
|
225
224
|
export type GetAnonymousTokenContent = GetAnonymousTokenResponse['content'];
|
|
226
225
|
export type LoginWithPhoneResponse = paths['/auth/login/phone']['post']['responses'][200]['content']['application/json'];
|