@commercengine/storefront-sdk 0.12.6 → 0.13.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.mts +2310 -3495
- package/dist/index.iife.js +186 -163
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +151 -137
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -10
package/dist/index.mjs
CHANGED
|
@@ -513,6 +513,14 @@ function isUserAnonymous(token) {
|
|
|
513
513
|
return extractUserInfoFromToken(token)?.isAnonymous ?? true;
|
|
514
514
|
}
|
|
515
515
|
|
|
516
|
+
//#endregion
|
|
517
|
+
//#region src/types/api-key-endpoints.ts
|
|
518
|
+
const API_KEY_ENDPOINTS = [
|
|
519
|
+
"/auth/anonymous",
|
|
520
|
+
"/store/check",
|
|
521
|
+
"/store/config"
|
|
522
|
+
];
|
|
523
|
+
|
|
516
524
|
//#endregion
|
|
517
525
|
//#region src/lib/auth-utils.ts
|
|
518
526
|
/**
|
|
@@ -522,6 +530,12 @@ function isAnonymousAuthEndpoint(pathname) {
|
|
|
522
530
|
return pathname.endsWith("/auth/anonymous");
|
|
523
531
|
}
|
|
524
532
|
/**
|
|
533
|
+
* Check if a URL path requires API key authentication (auto-generated from OpenAPI spec)
|
|
534
|
+
*/
|
|
535
|
+
function isApiKeyRequiredEndpoint(pathname) {
|
|
536
|
+
return API_KEY_ENDPOINTS.some((endpoint) => pathname.endsWith(endpoint));
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
525
539
|
* Check if a URL path is a login/register endpoint that returns tokens
|
|
526
540
|
*/
|
|
527
541
|
function isTokenReturningEndpoint(pathname) {
|
|
@@ -741,6 +755,10 @@ function createAuthMiddleware(config) {
|
|
|
741
755
|
if (existingToken) request.headers.set("Authorization", `Bearer ${existingToken}`);
|
|
742
756
|
return request;
|
|
743
757
|
}
|
|
758
|
+
if (isApiKeyRequiredEndpoint(pathname)) {
|
|
759
|
+
if (config.apiKey) request.headers.set("X-Api-Key", config.apiKey);
|
|
760
|
+
return request;
|
|
761
|
+
}
|
|
744
762
|
let accessToken = await config.tokenStorage.getAccessToken();
|
|
745
763
|
if (!accessToken) try {
|
|
746
764
|
const response = await fetch(`${config.baseUrl}/auth/anonymous`, {
|
|
@@ -823,16 +841,16 @@ function createDefaultAuthMiddleware(options) {
|
|
|
823
841
|
/**
|
|
824
842
|
* Available API environments for Commerce Engine
|
|
825
843
|
*/
|
|
826
|
-
let Environment = /* @__PURE__ */ function(Environment
|
|
844
|
+
let Environment = /* @__PURE__ */ function(Environment) {
|
|
827
845
|
/**
|
|
828
846
|
* Staging environment
|
|
829
847
|
*/
|
|
830
|
-
Environment
|
|
848
|
+
Environment["Staging"] = "staging";
|
|
831
849
|
/**
|
|
832
850
|
* Production environment
|
|
833
851
|
*/
|
|
834
|
-
Environment
|
|
835
|
-
return Environment
|
|
852
|
+
Environment["Production"] = "production";
|
|
853
|
+
return Environment;
|
|
836
854
|
}({});
|
|
837
855
|
/**
|
|
838
856
|
* Build base URL for Storefront API
|
|
@@ -1035,7 +1053,7 @@ var CatalogClient = class extends StorefrontAPIClient {
|
|
|
1035
1053
|
* }
|
|
1036
1054
|
*
|
|
1037
1055
|
* filteredData.products?.forEach(product => {
|
|
1038
|
-
* console.log(`Product: ${product.name} - ${product.
|
|
1056
|
+
* console.log(`Product: ${product.name} - ${product.pricing?.selling_price}`);
|
|
1039
1057
|
* });
|
|
1040
1058
|
* ```
|
|
1041
1059
|
*/
|
|
@@ -1120,8 +1138,8 @@ var CatalogClient = class extends StorefrontAPIClient {
|
|
|
1120
1138
|
* }
|
|
1121
1139
|
*
|
|
1122
1140
|
* console.log("Product:", data.product.name);
|
|
1123
|
-
* console.log("Price:", data.product.
|
|
1124
|
-
* console.log("Description:", data.product.
|
|
1141
|
+
* console.log("Price:", data.product.pricing?.selling_price);
|
|
1142
|
+
* console.log("Description:", data.product.short_description);
|
|
1125
1143
|
*
|
|
1126
1144
|
* // Get product by slug
|
|
1127
1145
|
* const { data: slugData, error: slugError } = await sdk.catalog.getProductDetail({
|
|
@@ -1141,7 +1159,7 @@ var CatalogClient = class extends StorefrontAPIClient {
|
|
|
1141
1159
|
* return;
|
|
1142
1160
|
* }
|
|
1143
1161
|
*
|
|
1144
|
-
* console.log("Product with custom pricing:", slugData.product.
|
|
1162
|
+
* console.log("Product with custom pricing:", slugData.product.pricing?.selling_price);
|
|
1145
1163
|
* ```
|
|
1146
1164
|
*/
|
|
1147
1165
|
async getProductDetail(pathParams, options, headers) {
|
|
@@ -1173,7 +1191,7 @@ var CatalogClient = class extends StorefrontAPIClient {
|
|
|
1173
1191
|
* console.log("Variants found:", data.variants?.length || 0);
|
|
1174
1192
|
*
|
|
1175
1193
|
* data.variants?.forEach(variant => {
|
|
1176
|
-
* console.log(`Variant: ${variant.name} - SKU: ${variant.sku} - Price: ${variant.
|
|
1194
|
+
* console.log(`Variant: ${variant.name} - SKU: ${variant.sku} - Price: ${variant.pricing?.selling_price}`);
|
|
1177
1195
|
* });
|
|
1178
1196
|
*
|
|
1179
1197
|
* // Override customer group ID for this specific request
|
|
@@ -1216,8 +1234,8 @@ var CatalogClient = class extends StorefrontAPIClient {
|
|
|
1216
1234
|
*
|
|
1217
1235
|
* console.log("Variant:", data.variant.name);
|
|
1218
1236
|
* console.log("SKU:", data.variant.sku);
|
|
1219
|
-
* console.log("Price:", data.variant.
|
|
1220
|
-
* console.log("Stock:", data.variant.
|
|
1237
|
+
* console.log("Price:", data.variant.pricing?.selling_price);
|
|
1238
|
+
* console.log("Stock available:", data.variant.stock_available);
|
|
1221
1239
|
* ```
|
|
1222
1240
|
*/
|
|
1223
1241
|
async getVariantDetail(pathParams, options, headers) {
|
|
@@ -1281,8 +1299,8 @@ var CatalogClient = class extends StorefrontAPIClient {
|
|
|
1281
1299
|
* console.log("Reviews found:", data.reviews?.length || 0);
|
|
1282
1300
|
*
|
|
1283
1301
|
* data.reviews?.forEach(review => {
|
|
1284
|
-
* console.log(`Review by ${review.
|
|
1285
|
-
* console.log("
|
|
1302
|
+
* console.log(`Review by ${review.name}: ${review.rating}/5`);
|
|
1303
|
+
* console.log("Review text:", review.review_text);
|
|
1286
1304
|
* });
|
|
1287
1305
|
*
|
|
1288
1306
|
* // With pagination
|
|
@@ -1313,8 +1331,10 @@ var CatalogClient = class extends StorefrontAPIClient {
|
|
|
1313
1331
|
* const { data, error } = await sdk.catalog.createProductReview(
|
|
1314
1332
|
* { product_id: "prod_123" },
|
|
1315
1333
|
* {
|
|
1334
|
+
* user_id: "user_123",
|
|
1335
|
+
* order_number: "ORD-001",
|
|
1316
1336
|
* rating: 5,
|
|
1317
|
-
*
|
|
1337
|
+
* review_text: "Excellent product! Highly recommended.",
|
|
1318
1338
|
* images: [
|
|
1319
1339
|
* new File(["image data"], "review1.jpg", { type: "image/jpeg" }),
|
|
1320
1340
|
* new File(["image data"], "review2.jpg", { type: "image/jpeg" })
|
|
@@ -1372,7 +1392,7 @@ var CatalogClient = class extends StorefrontAPIClient {
|
|
|
1372
1392
|
* console.log("Price range:", data.facet_stats.price_range);
|
|
1373
1393
|
*
|
|
1374
1394
|
* data.skus?.forEach(sku => {
|
|
1375
|
-
* console.log(`Found: ${sku.
|
|
1395
|
+
* console.log(`Found: ${sku.product_name} - ${sku.pricing?.selling_price}`);
|
|
1376
1396
|
* });
|
|
1377
1397
|
*
|
|
1378
1398
|
* // Override customer group ID for this specific request
|
|
@@ -1434,7 +1454,7 @@ var CatalogClient = class extends StorefrontAPIClient {
|
|
|
1434
1454
|
* console.log("Pagination:", data.pagination);
|
|
1435
1455
|
*
|
|
1436
1456
|
* data.products.forEach(product => {
|
|
1437
|
-
* console.log(`Product: ${product.name} - ${product.
|
|
1457
|
+
* console.log(`Product: ${product.name} - ${product.pricing?.selling_price}`);
|
|
1438
1458
|
* });
|
|
1439
1459
|
* }
|
|
1440
1460
|
* ```
|
|
@@ -1486,7 +1506,7 @@ var CatalogClient = class extends StorefrontAPIClient {
|
|
|
1486
1506
|
* console.log("Pagination:", data.pagination);
|
|
1487
1507
|
*
|
|
1488
1508
|
* data.products.forEach(product => {
|
|
1489
|
-
* console.log(`Up-sell: ${product.name} - ${product.
|
|
1509
|
+
* console.log(`Up-sell: ${product.name} - ${product.pricing?.selling_price}`);
|
|
1490
1510
|
* });
|
|
1491
1511
|
* }
|
|
1492
1512
|
* ```
|
|
@@ -1538,7 +1558,7 @@ var CatalogClient = class extends StorefrontAPIClient {
|
|
|
1538
1558
|
* console.log("Pagination:", data.pagination);
|
|
1539
1559
|
*
|
|
1540
1560
|
* data.products.forEach(product => {
|
|
1541
|
-
* console.log(`Similar: ${product.name} - ${product.
|
|
1561
|
+
* console.log(`Similar: ${product.name} - ${product.pricing?.selling_price}`);
|
|
1542
1562
|
* });
|
|
1543
1563
|
* }
|
|
1544
1564
|
* ```
|
|
@@ -1694,7 +1714,7 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1694
1714
|
* console.error("Failed to get user cart:", error.message);
|
|
1695
1715
|
* } else {
|
|
1696
1716
|
* console.log("User cart ID:", data.cart.id);
|
|
1697
|
-
* console.log("Cart value:", data.cart.
|
|
1717
|
+
* console.log("Cart value:", data.cart.subtotal);
|
|
1698
1718
|
* }
|
|
1699
1719
|
* ```
|
|
1700
1720
|
*/
|
|
@@ -1745,7 +1765,7 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1745
1765
|
* if (error) {
|
|
1746
1766
|
* console.error("Failed to update cart address:", error.message);
|
|
1747
1767
|
* } else {
|
|
1748
|
-
* console.log("Addresses updated:", data.
|
|
1768
|
+
* console.log("Addresses updated:", data.cart);
|
|
1749
1769
|
* }
|
|
1750
1770
|
*
|
|
1751
1771
|
* // For guest checkout with new addresses
|
|
@@ -1861,7 +1881,7 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1861
1881
|
* const coupons = data.coupons || [];
|
|
1862
1882
|
* console.log("Available coupons:", coupons.length);
|
|
1863
1883
|
* coupons.forEach(coupon => {
|
|
1864
|
-
* console.log("Coupon:", coupon.
|
|
1884
|
+
* console.log("Coupon:", coupon.coupon_code, "Name:", coupon.name);
|
|
1865
1885
|
* });
|
|
1866
1886
|
* }
|
|
1867
1887
|
*
|
|
@@ -1956,12 +1976,12 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1956
1976
|
*
|
|
1957
1977
|
* console.log("Applicable coupons:", applicable.length);
|
|
1958
1978
|
* applicable.forEach(coupon => {
|
|
1959
|
-
* console.log(`- ${coupon.
|
|
1979
|
+
* console.log(`- ${coupon.coupon_code?.join(", ")}: Save $${coupon.estimated_discount}`);
|
|
1960
1980
|
* });
|
|
1961
1981
|
*
|
|
1962
1982
|
* console.log("Inapplicable coupons:", inapplicable.length);
|
|
1963
1983
|
* inapplicable.forEach(coupon => {
|
|
1964
|
-
* console.log(`- ${coupon.
|
|
1984
|
+
* console.log(`- ${coupon.coupon_code?.join(", ")}: ${coupon.reason}`);
|
|
1965
1985
|
* });
|
|
1966
1986
|
* }
|
|
1967
1987
|
* ```
|
|
@@ -2218,6 +2238,7 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
2218
2238
|
* Get wishlist items
|
|
2219
2239
|
*
|
|
2220
2240
|
* @param userId - The ID of the user
|
|
2241
|
+
* @param options - Optional query parameters for filtering by seller_id (only for multi-seller marketplace stores)
|
|
2221
2242
|
* @returns Promise with wishlist items
|
|
2222
2243
|
* @example
|
|
2223
2244
|
* ```typescript
|
|
@@ -2231,13 +2252,16 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
2231
2252
|
* const products = data.products;
|
|
2232
2253
|
* console.log("Wishlist items:", products.length);
|
|
2233
2254
|
* products.forEach(product => {
|
|
2234
|
-
* console.log("Product:", product.
|
|
2255
|
+
* console.log("Product:", product.product_name, "Price:", product.pricing?.selling_price);
|
|
2235
2256
|
* });
|
|
2236
2257
|
* }
|
|
2237
2258
|
* ```
|
|
2238
2259
|
*/
|
|
2239
|
-
async getWishlist(userId) {
|
|
2240
|
-
return this.executeRequest(() => this.client.GET("/wishlist/{user_id}", { params: {
|
|
2260
|
+
async getWishlist(userId, options) {
|
|
2261
|
+
return this.executeRequest(() => this.client.GET("/wishlist/{user_id}", { params: {
|
|
2262
|
+
path: userId,
|
|
2263
|
+
query: options
|
|
2264
|
+
} }));
|
|
2241
2265
|
}
|
|
2242
2266
|
/**
|
|
2243
2267
|
* Add item to wishlist
|
|
@@ -2335,16 +2359,16 @@ var AuthClient = class extends StorefrontAPIClient {
|
|
|
2335
2359
|
* ```typescript
|
|
2336
2360
|
* // Login with phone number
|
|
2337
2361
|
* const { data, error } = await sdk.auth.loginWithPhone({
|
|
2338
|
-
*
|
|
2339
|
-
*
|
|
2340
|
-
*
|
|
2362
|
+
* phone: "9876543210",
|
|
2363
|
+
* country_code: "+91",
|
|
2364
|
+
* register_if_not_exists: true
|
|
2341
2365
|
* });
|
|
2342
2366
|
*
|
|
2343
2367
|
* if (error) {
|
|
2344
2368
|
* console.error("Login failed:", error.message);
|
|
2345
2369
|
* } else {
|
|
2346
|
-
* console.log("OTP sent. Token:", data.
|
|
2347
|
-
* console.log("Action:", data.
|
|
2370
|
+
* console.log("OTP sent. Token:", data.otp_token);
|
|
2371
|
+
* console.log("Action:", data.otp_action); // "login" or "register"
|
|
2348
2372
|
* // Redirect user to OTP verification screen
|
|
2349
2373
|
* }
|
|
2350
2374
|
* ```
|
|
@@ -2395,14 +2419,14 @@ var AuthClient = class extends StorefrontAPIClient {
|
|
|
2395
2419
|
* // Login with email address
|
|
2396
2420
|
* const { data, error } = await sdk.auth.loginWithEmail({
|
|
2397
2421
|
* email: "customer@example.com",
|
|
2398
|
-
*
|
|
2422
|
+
* register_if_not_exists: true
|
|
2399
2423
|
* });
|
|
2400
2424
|
*
|
|
2401
2425
|
* if (error) {
|
|
2402
2426
|
* console.error("Email login failed:", error.message);
|
|
2403
2427
|
* } else {
|
|
2404
|
-
* console.log("OTP sent to email. Token:", data.
|
|
2405
|
-
* console.log("Action:", data.
|
|
2428
|
+
* console.log("OTP sent to email. Token:", data.otp_token);
|
|
2429
|
+
* console.log("Action:", data.otp_action); // "login" or "register"
|
|
2406
2430
|
* // Show OTP input form
|
|
2407
2431
|
* }
|
|
2408
2432
|
* ```
|
|
@@ -2521,8 +2545,8 @@ var AuthClient = class extends StorefrontAPIClient {
|
|
|
2521
2545
|
* // Verify OTP after login attempt
|
|
2522
2546
|
* const { data, error } = await sdk.auth.verifyOtp({
|
|
2523
2547
|
* otp: "1234",
|
|
2524
|
-
*
|
|
2525
|
-
*
|
|
2548
|
+
* otp_token: "56895455",
|
|
2549
|
+
* otp_action: "login" // or "register"
|
|
2526
2550
|
* });
|
|
2527
2551
|
*
|
|
2528
2552
|
* if (error) {
|
|
@@ -2653,8 +2677,8 @@ var AuthClient = class extends StorefrontAPIClient {
|
|
|
2653
2677
|
* } else {
|
|
2654
2678
|
* console.log("User details:", data.user);
|
|
2655
2679
|
* console.log("Email:", data.user.email);
|
|
2656
|
-
* console.log("Phone:", data.user.
|
|
2657
|
-
* console.log("Created:", data.user.
|
|
2680
|
+
* console.log("Phone:", data.user.phone);
|
|
2681
|
+
* console.log("Created:", data.user.created_at);
|
|
2658
2682
|
* }
|
|
2659
2683
|
* ```
|
|
2660
2684
|
*/
|
|
@@ -2695,6 +2719,34 @@ var AuthClient = class extends StorefrontAPIClient {
|
|
|
2695
2719
|
}));
|
|
2696
2720
|
}
|
|
2697
2721
|
/**
|
|
2722
|
+
* Delete user account
|
|
2723
|
+
*
|
|
2724
|
+
* @description Deletes a user account. If the user is a primary user, deletes the associated
|
|
2725
|
+
* customer and all linked users. If the user is a normal user, deletes only that user without
|
|
2726
|
+
* affecting the customer or other users.
|
|
2727
|
+
*
|
|
2728
|
+
* @param pathParams - Path parameters containing user ID
|
|
2729
|
+
* @returns Promise with deletion confirmation
|
|
2730
|
+
* @example
|
|
2731
|
+
* ```typescript
|
|
2732
|
+
* // Delete a user account
|
|
2733
|
+
* const { data, error } = await sdk.auth.deleteUser({
|
|
2734
|
+
* id: "01H9XYZ12345USERID"
|
|
2735
|
+
* });
|
|
2736
|
+
*
|
|
2737
|
+
* if (error) {
|
|
2738
|
+
* console.error("Failed to delete user:", error.message);
|
|
2739
|
+
* } else {
|
|
2740
|
+
* console.log("User deleted successfully");
|
|
2741
|
+
* console.log("Success:", data.success);
|
|
2742
|
+
* console.log("Message:", data.message);
|
|
2743
|
+
* }
|
|
2744
|
+
* ```
|
|
2745
|
+
*/
|
|
2746
|
+
async deleteUser(pathParams) {
|
|
2747
|
+
return this.executeRequest(() => this.client.DELETE("/auth/user/{id}", { params: { path: pathParams } }));
|
|
2748
|
+
}
|
|
2749
|
+
/**
|
|
2698
2750
|
* Add profile image
|
|
2699
2751
|
*
|
|
2700
2752
|
* @param pathParams - Path parameters containing user ID
|
|
@@ -3180,9 +3232,9 @@ var OrderClient = class extends StorefrontAPIClient {
|
|
|
3180
3232
|
* console.log("Shipments found:", data.shipments?.length || 0);
|
|
3181
3233
|
*
|
|
3182
3234
|
* data.shipments?.forEach(shipment => {
|
|
3183
|
-
* console.log(`Shipment ${shipment.
|
|
3184
|
-
* console.log("
|
|
3185
|
-
* console.log("
|
|
3235
|
+
* console.log(`Shipment ${shipment.reference_number}: ${shipment.status}`);
|
|
3236
|
+
* console.log("AWB:", shipment.awb_no);
|
|
3237
|
+
* console.log("Courier:", shipment.courier_company_name);
|
|
3186
3238
|
* });
|
|
3187
3239
|
* }
|
|
3188
3240
|
* ```
|
|
@@ -3207,10 +3259,9 @@ var OrderClient = class extends StorefrontAPIClient {
|
|
|
3207
3259
|
* console.log("Payments found:", data.payments?.length || 0);
|
|
3208
3260
|
*
|
|
3209
3261
|
* data.payments?.forEach(payment => {
|
|
3210
|
-
* console.log(`Payment ${payment.
|
|
3262
|
+
* console.log(`Payment ${payment.request_number}: ${payment.payment_status}`);
|
|
3211
3263
|
* console.log("Amount:", payment.amount);
|
|
3212
|
-
* console.log("
|
|
3213
|
-
* console.log("Transaction ID:", payment.transaction_id);
|
|
3264
|
+
* console.log("Reference:", payment.payment_reference_number);
|
|
3214
3265
|
* });
|
|
3215
3266
|
* }
|
|
3216
3267
|
* ```
|
|
@@ -3235,7 +3286,7 @@ var OrderClient = class extends StorefrontAPIClient {
|
|
|
3235
3286
|
* console.log("Refunds found:", data.refunds?.length || 0);
|
|
3236
3287
|
*
|
|
3237
3288
|
* data.refunds?.forEach(refund => {
|
|
3238
|
-
* console.log(`Refund ${refund.
|
|
3289
|
+
* console.log(`Refund ${refund.request_number}: ${refund.status}`);
|
|
3239
3290
|
* console.log("Amount:", refund.refund_amount);
|
|
3240
3291
|
* console.log("Reason:", refund.refund_remarks);
|
|
3241
3292
|
* console.log("Processed at:", refund.refund_date);
|
|
@@ -3279,6 +3330,35 @@ var OrderClient = class extends StorefrontAPIClient {
|
|
|
3279
3330
|
}));
|
|
3280
3331
|
}
|
|
3281
3332
|
/**
|
|
3333
|
+
* Cancel a payment request for an order
|
|
3334
|
+
*
|
|
3335
|
+
* @description Use when the express checkout payment flow is used and the user wants to switch
|
|
3336
|
+
* payment methods (e.g. started with UPI, then chose another). Without this call, the user must
|
|
3337
|
+
* wait until the payment-status API returns `status: failed` and `is_retry_available: true`
|
|
3338
|
+
* (typically ~3 minutes). Calling this endpoint cancels the existing payment request so the user
|
|
3339
|
+
* can retry payment immediately.
|
|
3340
|
+
*
|
|
3341
|
+
* @param pathParams - Path parameters containing the order number
|
|
3342
|
+
* @returns Promise with cancellation confirmation
|
|
3343
|
+
* @example
|
|
3344
|
+
* ```typescript
|
|
3345
|
+
* // Cancel an in-progress payment request to switch payment methods
|
|
3346
|
+
* const { data, error } = await sdk.order.cancelPaymentRequest({
|
|
3347
|
+
* order_number: "ORD-2024-001"
|
|
3348
|
+
* });
|
|
3349
|
+
*
|
|
3350
|
+
* if (error) {
|
|
3351
|
+
* console.error("Failed to cancel payment request:", error.message);
|
|
3352
|
+
* } else {
|
|
3353
|
+
* console.log("Payment request cancelled:", data.success);
|
|
3354
|
+
* console.log("Message:", data.message);
|
|
3355
|
+
* }
|
|
3356
|
+
* ```
|
|
3357
|
+
*/
|
|
3358
|
+
async cancelPaymentRequest(pathParams) {
|
|
3359
|
+
return this.executeRequest(() => this.client.POST("/orders/{order_number}/cancel-payment-request", { params: { path: pathParams } }));
|
|
3360
|
+
}
|
|
3361
|
+
/**
|
|
3282
3362
|
* Retry payment for an order
|
|
3283
3363
|
*
|
|
3284
3364
|
* @param pathParams - Order number path parameters
|
|
@@ -3391,7 +3471,7 @@ var PaymentsClient = class extends StorefrontAPIClient {
|
|
|
3391
3471
|
* console.log("VPA:", data.vpa);
|
|
3392
3472
|
* console.log("Status:", data.status);
|
|
3393
3473
|
*
|
|
3394
|
-
* if (data.status === "
|
|
3474
|
+
* if (data.status === "valid") {
|
|
3395
3475
|
* console.log("VPA is valid and can be used for UPI payments");
|
|
3396
3476
|
* } else {
|
|
3397
3477
|
* console.log("VPA is invalid, please check and try again");
|
|
@@ -3507,9 +3587,8 @@ var HelpersClient = class extends StorefrontAPIClient {
|
|
|
3507
3587
|
* console.log("Countries found:", data.countries?.length || 0);
|
|
3508
3588
|
*
|
|
3509
3589
|
* data.countries?.forEach(country => {
|
|
3510
|
-
* console.log(`Country: ${country.
|
|
3511
|
-
* console.log("
|
|
3512
|
-
* console.log("Currency:", country.currency?.code);
|
|
3590
|
+
* console.log(`Country: ${country.country_name} (${country.country_iso_code})`);
|
|
3591
|
+
* console.log("Currency:", country.currency_code);
|
|
3513
3592
|
* });
|
|
3514
3593
|
* ```
|
|
3515
3594
|
*/
|
|
@@ -3537,7 +3616,6 @@ var HelpersClient = class extends StorefrontAPIClient {
|
|
|
3537
3616
|
*
|
|
3538
3617
|
* data.states?.forEach(state => {
|
|
3539
3618
|
* console.log(`State: ${state.name} (${state.iso_code})`);
|
|
3540
|
-
* console.log("Type:", state.type);
|
|
3541
3619
|
* });
|
|
3542
3620
|
*
|
|
3543
3621
|
* // Get states for different country
|
|
@@ -3576,9 +3654,7 @@ var HelpersClient = class extends StorefrontAPIClient {
|
|
|
3576
3654
|
* console.log("Pincodes found:", data.pincodes?.length || 0);
|
|
3577
3655
|
*
|
|
3578
3656
|
* data.pincodes?.forEach(pincode => {
|
|
3579
|
-
* console.log(`Pincode: ${pincode.pincode} - ${pincode.city}, ${pincode.
|
|
3580
|
-
* console.log("District:", pincode.district);
|
|
3581
|
-
* console.log("Area:", pincode.area);
|
|
3657
|
+
* console.log(`Pincode: ${pincode.pincode} - ${pincode.city}, ${pincode.state_name}`);
|
|
3582
3658
|
* });
|
|
3583
3659
|
*
|
|
3584
3660
|
* // Get pincodes for different country
|
|
@@ -3608,88 +3684,6 @@ var HelpersClient = class extends StorefrontAPIClient {
|
|
|
3608
3684
|
* Client for interacting with customer endpoints
|
|
3609
3685
|
*/
|
|
3610
3686
|
var CustomerClient = class extends StorefrontAPIClient {
|
|
3611
|
-
/**
|
|
3612
|
-
* Create a customer
|
|
3613
|
-
*
|
|
3614
|
-
* @param body - Customer creation body
|
|
3615
|
-
* @returns Promise with customer details
|
|
3616
|
-
*
|
|
3617
|
-
* @example
|
|
3618
|
-
* ```typescript
|
|
3619
|
-
* const { data, error } = await sdk.customer.createCustomer({
|
|
3620
|
-
* first_name: "John",
|
|
3621
|
-
* last_name: "Doe",
|
|
3622
|
-
* email: "john.doe@example.com",
|
|
3623
|
-
* phone: "+1234567890",
|
|
3624
|
-
* password: "securePassword123"
|
|
3625
|
-
* });
|
|
3626
|
-
*
|
|
3627
|
-
* if (error) {
|
|
3628
|
-
* console.error("Failed to create customer:", error);
|
|
3629
|
-
* return;
|
|
3630
|
-
* }
|
|
3631
|
-
*
|
|
3632
|
-
* console.log("Customer created:", data.customer_detail);
|
|
3633
|
-
* ```
|
|
3634
|
-
*/
|
|
3635
|
-
async createCustomer(body) {
|
|
3636
|
-
return this.executeRequest(() => this.client.POST("/customers", { body }));
|
|
3637
|
-
}
|
|
3638
|
-
/**
|
|
3639
|
-
* Get customer details
|
|
3640
|
-
*
|
|
3641
|
-
* @param pathParams - Path parameters
|
|
3642
|
-
* @returns Promise with customer details
|
|
3643
|
-
*
|
|
3644
|
-
* @example
|
|
3645
|
-
* ```typescript
|
|
3646
|
-
* const { data, error } = await sdk.customer.getCustomer({
|
|
3647
|
-
* id: "customer_123"
|
|
3648
|
-
* });
|
|
3649
|
-
*
|
|
3650
|
-
* if (error) {
|
|
3651
|
-
* console.error("Failed to get customer:", error);
|
|
3652
|
-
* return;
|
|
3653
|
-
* }
|
|
3654
|
-
*
|
|
3655
|
-
* console.log("Customer details:", data.customer_detail);
|
|
3656
|
-
* ```
|
|
3657
|
-
*/
|
|
3658
|
-
async getCustomer(pathParams) {
|
|
3659
|
-
return this.executeRequest(() => this.client.GET("/customers/{id}", { params: { path: pathParams } }));
|
|
3660
|
-
}
|
|
3661
|
-
/**
|
|
3662
|
-
* Update a customer
|
|
3663
|
-
*
|
|
3664
|
-
* @param pathParams - Path parameters
|
|
3665
|
-
* @param body - Customer update body
|
|
3666
|
-
* @returns Promise with customer details
|
|
3667
|
-
*
|
|
3668
|
-
* @example
|
|
3669
|
-
* ```typescript
|
|
3670
|
-
* const { data, error } = await sdk.customer.updateCustomer(
|
|
3671
|
-
* { id: "customer_123" },
|
|
3672
|
-
* {
|
|
3673
|
-
* first_name: "John",
|
|
3674
|
-
* last_name: "Smith",
|
|
3675
|
-
* email: "john.smith@example.com"
|
|
3676
|
-
* }
|
|
3677
|
-
* );
|
|
3678
|
-
*
|
|
3679
|
-
* if (error) {
|
|
3680
|
-
* console.error("Failed to update customer:", error);
|
|
3681
|
-
* return;
|
|
3682
|
-
* }
|
|
3683
|
-
*
|
|
3684
|
-
* console.log("Customer updated:", data.customer_detail);
|
|
3685
|
-
* ```
|
|
3686
|
-
*/
|
|
3687
|
-
async updateCustomer(pathParams, body) {
|
|
3688
|
-
return this.executeRequest(() => this.client.PUT("/customers/{id}", {
|
|
3689
|
-
params: { path: pathParams },
|
|
3690
|
-
body
|
|
3691
|
-
}));
|
|
3692
|
-
}
|
|
3693
3687
|
/**
|
|
3694
3688
|
* Get all saved addresses for a customer
|
|
3695
3689
|
*
|
|
@@ -3984,6 +3978,27 @@ var CustomerClient = class extends StorefrontAPIClient {
|
|
|
3984
3978
|
* Client for interacting with store config endpoints
|
|
3985
3979
|
*/
|
|
3986
3980
|
var StoreConfigClient = class extends StorefrontAPIClient {
|
|
3981
|
+
/**
|
|
3982
|
+
* Check store existence
|
|
3983
|
+
*
|
|
3984
|
+
* @description Checks whether a store with the configured store ID exists.
|
|
3985
|
+
* Returns `success: true` if the store exists, `false` otherwise.
|
|
3986
|
+
*
|
|
3987
|
+
* @returns Promise with store existence check result
|
|
3988
|
+
* @example
|
|
3989
|
+
* ```typescript
|
|
3990
|
+
* const { data, error } = await sdk.storeConfig.checkStore();
|
|
3991
|
+
*
|
|
3992
|
+
* if (error) {
|
|
3993
|
+
* console.error("Failed to check store:", error.message);
|
|
3994
|
+
* } else {
|
|
3995
|
+
* console.log("Store exists:", data.success);
|
|
3996
|
+
* }
|
|
3997
|
+
* ```
|
|
3998
|
+
*/
|
|
3999
|
+
async checkStore() {
|
|
4000
|
+
return this.executeRequest(() => this.client.GET("/store/check"));
|
|
4001
|
+
}
|
|
3987
4002
|
/**
|
|
3988
4003
|
* Get store config
|
|
3989
4004
|
*
|
|
@@ -4236,8 +4251,7 @@ var StorefrontSDK = class {
|
|
|
4236
4251
|
return this.defaultHeaders;
|
|
4237
4252
|
}
|
|
4238
4253
|
};
|
|
4239
|
-
var src_default = StorefrontSDK;
|
|
4240
4254
|
|
|
4241
4255
|
//#endregion
|
|
4242
|
-
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, PaymentsClient, ResponseUtils, StoreConfigClient, StorefrontAPIClient, StorefrontSDK,
|
|
4256
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, PaymentsClient, ResponseUtils, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, StorefrontSDK as default };
|
|
4243
4257
|
//# sourceMappingURL=index.mjs.map
|