@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.
@@ -1,8 +1,8 @@
1
1
  var CE_SDK = (function(exports) {
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
3
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
 
5
- //#region ../../node_modules/.pnpm/openapi-fetch@0.14.1/node_modules/openapi-fetch/dist/index.mjs
5
+ //#region ../../node_modules/.pnpm/openapi-fetch@0.17.0/node_modules/openapi-fetch/dist/index.mjs
6
6
  const PATH_PARAM_RE = /\{[^{}]+\}/g;
7
7
  const supportsRequestInitExt = () => {
8
8
  return typeof process === "object" && Number.parseInt(process?.versions?.node?.substring(0, 2)) >= 18 && process.versions.undici;
@@ -11,12 +11,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
11
11
  return Math.random().toString(36).slice(2, 11);
12
12
  }
13
13
  function createClient(clientOptions) {
14
- let { baseUrl = "", Request: CustomRequest = globalThis.Request, fetch: baseFetch = globalThis.fetch, querySerializer: globalQuerySerializer, bodySerializer: globalBodySerializer, headers: baseHeaders, requestInitExt = void 0, ...baseOptions } = { ...clientOptions };
14
+ let { baseUrl = "", Request: CustomRequest = globalThis.Request, fetch: baseFetch = globalThis.fetch, querySerializer: globalQuerySerializer, bodySerializer: globalBodySerializer, pathSerializer: globalPathSerializer, headers: baseHeaders, requestInitExt = void 0, ...baseOptions } = { ...clientOptions };
15
15
  requestInitExt = supportsRequestInitExt() ? requestInitExt : void 0;
16
16
  baseUrl = removeTrailingSlash(baseUrl);
17
- const middlewares = [];
17
+ const globalMiddlewares = [];
18
18
  async function coreFetch(schemaPath, fetchOptions) {
19
- const { baseUrl: localBaseUrl, fetch: fetch$1 = baseFetch, Request: Request$1 = CustomRequest, headers, params = {}, parseAs = "json", querySerializer: requestQuerySerializer, bodySerializer = globalBodySerializer ?? defaultBodySerializer, body, ...init } = fetchOptions || {};
19
+ const { baseUrl: localBaseUrl, fetch = baseFetch, Request = CustomRequest, headers, params = {}, parseAs = "json", querySerializer: requestQuerySerializer, bodySerializer = globalBodySerializer ?? defaultBodySerializer, pathSerializer: requestPathSerializer, body, middleware: requestMiddlewares = [], ...init } = fetchOptions || {};
20
20
  let finalBaseUrl = baseUrl;
21
21
  if (localBaseUrl) finalBaseUrl = removeTrailingSlash(localBaseUrl) ?? baseUrl;
22
22
  let querySerializer = typeof globalQuerySerializer === "function" ? globalQuerySerializer : createQuerySerializer(globalQuerySerializer);
@@ -24,8 +24,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
24
24
  ...typeof globalQuerySerializer === "object" ? globalQuerySerializer : {},
25
25
  ...requestQuerySerializer
26
26
  });
27
+ const pathSerializer = requestPathSerializer || globalPathSerializer || defaultPathSerializer;
27
28
  const serializedBody = body === void 0 ? void 0 : bodySerializer(body, mergeHeaders(baseHeaders, headers, params.header));
28
29
  const finalHeaders = mergeHeaders(serializedBody === void 0 || serializedBody instanceof FormData ? {} : { "Content-Type": "application/json" }, baseHeaders, headers, params.header);
30
+ const finalMiddlewares = [...globalMiddlewares, ...requestMiddlewares];
29
31
  const requestInit = {
30
32
  redirect: "follow",
31
33
  ...baseOptions,
@@ -35,23 +37,25 @@ Object.defineProperty(exports, '__esModule', { value: true });
35
37
  };
36
38
  let id;
37
39
  let options;
38
- let request = new Request$1(createFinalURL(schemaPath, {
40
+ let request = new Request(createFinalURL(schemaPath, {
39
41
  baseUrl: finalBaseUrl,
40
42
  params,
41
- querySerializer
43
+ querySerializer,
44
+ pathSerializer
42
45
  }), requestInit);
43
46
  let response;
44
47
  for (const key in init) if (!(key in request)) request[key] = init[key];
45
- if (middlewares.length) {
48
+ if (finalMiddlewares.length) {
46
49
  id = randomID();
47
50
  options = Object.freeze({
48
51
  baseUrl: finalBaseUrl,
49
- fetch: fetch$1,
52
+ fetch,
50
53
  parseAs,
51
54
  querySerializer,
52
- bodySerializer
55
+ bodySerializer,
56
+ pathSerializer
53
57
  });
54
- for (const m of middlewares) if (m && typeof m === "object" && typeof m.onRequest === "function") {
58
+ for (const m of finalMiddlewares) if (m && typeof m === "object" && typeof m.onRequest === "function") {
55
59
  const result = await m.onRequest({
56
60
  request,
57
61
  schemaPath,
@@ -59,7 +63,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
59
63
  options,
60
64
  id
61
65
  });
62
- if (result) if (result instanceof Request$1) request = result;
66
+ if (result) if (result instanceof Request) request = result;
63
67
  else if (result instanceof Response) {
64
68
  response = result;
65
69
  break;
@@ -68,11 +72,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
68
72
  }
69
73
  if (!response) {
70
74
  try {
71
- response = await fetch$1(request, requestInitExt);
75
+ response = await fetch(request, requestInitExt);
72
76
  } catch (error2) {
73
77
  let errorAfterMiddleware = error2;
74
- if (middlewares.length) for (let i = middlewares.length - 1; i >= 0; i--) {
75
- const m = middlewares[i];
78
+ if (finalMiddlewares.length) for (let i = finalMiddlewares.length - 1; i >= 0; i--) {
79
+ const m = finalMiddlewares[i];
76
80
  if (m && typeof m === "object" && typeof m.onError === "function") {
77
81
  const result = await m.onError({
78
82
  request,
@@ -98,8 +102,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
98
102
  }
99
103
  if (errorAfterMiddleware) throw errorAfterMiddleware;
100
104
  }
101
- if (middlewares.length) for (let i = middlewares.length - 1; i >= 0; i--) {
102
- const m = middlewares[i];
105
+ if (finalMiddlewares.length) for (let i = finalMiddlewares.length - 1; i >= 0; i--) {
106
+ const m = finalMiddlewares[i];
103
107
  if (m && typeof m === "object" && typeof m.onResponse === "function") {
104
108
  const result = await m.onResponse({
105
109
  request,
@@ -116,7 +120,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
116
120
  }
117
121
  }
118
122
  }
119
- if (response.status === 204 || request.method === "HEAD" || response.headers.get("Content-Length") === "0") return response.ok ? {
123
+ const contentLength = response.headers.get("Content-Length");
124
+ if (response.status === 204 || request.method === "HEAD" || contentLength === "0" && !response.headers.get("Transfer-Encoding")?.includes("chunked")) return response.ok ? {
120
125
  data: void 0,
121
126
  response
122
127
  } : {
@@ -124,12 +129,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
124
129
  response
125
130
  };
126
131
  if (response.ok) {
127
- if (parseAs === "stream") return {
128
- data: response.body,
129
- response
132
+ const getResponseData = async () => {
133
+ if (parseAs === "stream") return response.body;
134
+ if (parseAs === "json" && !contentLength) {
135
+ const raw = await response.text();
136
+ return raw ? JSON.parse(raw) : void 0;
137
+ }
138
+ return await response[parseAs]();
130
139
  };
131
140
  return {
132
- data: await response[parseAs](),
141
+ data: await getResponseData(),
133
142
  response
134
143
  };
135
144
  }
@@ -201,13 +210,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
201
210
  for (const m of middleware) {
202
211
  if (!m) continue;
203
212
  if (typeof m !== "object" || !("onRequest" in m || "onResponse" in m || "onError" in m)) throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");
204
- middlewares.push(m);
213
+ globalMiddlewares.push(m);
205
214
  }
206
215
  },
207
216
  eject(...middleware) {
208
217
  for (const m of middleware) {
209
- const i = middlewares.indexOf(m);
210
- if (i !== -1) middlewares.splice(i, 1);
218
+ const i = globalMiddlewares.indexOf(m);
219
+ if (i !== -1) globalMiddlewares.splice(i, 1);
211
220
  }
212
221
  }
213
222
  };
@@ -348,7 +357,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
348
357
  }
349
358
  function createFinalURL(pathname, options) {
350
359
  let finalURL = `${options.baseUrl}${pathname}`;
351
- if (options.params?.path) finalURL = defaultPathSerializer(finalURL, options.params.path);
360
+ if (options.params?.path) finalURL = options.pathSerializer(finalURL, options.params.path);
352
361
  let search = options.querySerializer(options.params.query ?? {});
353
362
  if (search.startsWith("?")) search = search.substring(1);
354
363
  if (search) finalURL += `?${search}`;
@@ -884,6 +893,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
884
893
  return extractUserInfoFromToken(token)?.isAnonymous ?? true;
885
894
  }
886
895
 
896
+ //#endregion
897
+ //#region src/types/api-key-endpoints.ts
898
+ const API_KEY_ENDPOINTS = [
899
+ "/auth/anonymous",
900
+ "/store/check",
901
+ "/store/config"
902
+ ];
903
+
887
904
  //#endregion
888
905
  //#region src/lib/auth-utils.ts
889
906
  /**
@@ -893,6 +910,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
893
910
  return pathname.endsWith("/auth/anonymous");
894
911
  }
895
912
  /**
913
+ * Check if a URL path requires API key authentication (auto-generated from OpenAPI spec)
914
+ */
915
+ function isApiKeyRequiredEndpoint(pathname) {
916
+ return API_KEY_ENDPOINTS.some((endpoint) => pathname.endsWith(endpoint));
917
+ }
918
+ /**
896
919
  * Check if a URL path is a login/register endpoint that returns tokens
897
920
  */
898
921
  function isTokenReturningEndpoint(pathname) {
@@ -1112,6 +1135,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
1112
1135
  if (existingToken) request.headers.set("Authorization", `Bearer ${existingToken}`);
1113
1136
  return request;
1114
1137
  }
1138
+ if (isApiKeyRequiredEndpoint(pathname)) {
1139
+ if (config.apiKey) request.headers.set("X-Api-Key", config.apiKey);
1140
+ return request;
1141
+ }
1115
1142
  let accessToken = await config.tokenStorage.getAccessToken();
1116
1143
  if (!accessToken) try {
1117
1144
  const response = await fetch(`${config.baseUrl}/auth/anonymous`, {
@@ -1194,16 +1221,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
1194
1221
  /**
1195
1222
  * Available API environments for Commerce Engine
1196
1223
  */
1197
- let Environment = /* @__PURE__ */ function(Environment$1) {
1224
+ let Environment = /* @__PURE__ */ function(Environment) {
1198
1225
  /**
1199
1226
  * Staging environment
1200
1227
  */
1201
- Environment$1["Staging"] = "staging";
1228
+ Environment["Staging"] = "staging";
1202
1229
  /**
1203
1230
  * Production environment
1204
1231
  */
1205
- Environment$1["Production"] = "production";
1206
- return Environment$1;
1232
+ Environment["Production"] = "production";
1233
+ return Environment;
1207
1234
  }({});
1208
1235
  /**
1209
1236
  * Build base URL for Storefront API
@@ -1406,7 +1433,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
1406
1433
  * }
1407
1434
  *
1408
1435
  * filteredData.products?.forEach(product => {
1409
- * console.log(`Product: ${product.name} - ${product.price}`);
1436
+ * console.log(`Product: ${product.name} - ${product.pricing?.selling_price}`);
1410
1437
  * });
1411
1438
  * ```
1412
1439
  */
@@ -1491,8 +1518,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
1491
1518
  * }
1492
1519
  *
1493
1520
  * console.log("Product:", data.product.name);
1494
- * console.log("Price:", data.product.price);
1495
- * console.log("Description:", data.product.description);
1521
+ * console.log("Price:", data.product.pricing?.selling_price);
1522
+ * console.log("Description:", data.product.short_description);
1496
1523
  *
1497
1524
  * // Get product by slug
1498
1525
  * const { data: slugData, error: slugError } = await sdk.catalog.getProductDetail({
@@ -1512,7 +1539,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
1512
1539
  * return;
1513
1540
  * }
1514
1541
  *
1515
- * console.log("Product with custom pricing:", slugData.product.price);
1542
+ * console.log("Product with custom pricing:", slugData.product.pricing?.selling_price);
1516
1543
  * ```
1517
1544
  */
1518
1545
  async getProductDetail(pathParams, options, headers) {
@@ -1544,7 +1571,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
1544
1571
  * console.log("Variants found:", data.variants?.length || 0);
1545
1572
  *
1546
1573
  * data.variants?.forEach(variant => {
1547
- * console.log(`Variant: ${variant.name} - SKU: ${variant.sku} - Price: ${variant.price}`);
1574
+ * console.log(`Variant: ${variant.name} - SKU: ${variant.sku} - Price: ${variant.pricing?.selling_price}`);
1548
1575
  * });
1549
1576
  *
1550
1577
  * // Override customer group ID for this specific request
@@ -1587,8 +1614,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
1587
1614
  *
1588
1615
  * console.log("Variant:", data.variant.name);
1589
1616
  * console.log("SKU:", data.variant.sku);
1590
- * console.log("Price:", data.variant.price);
1591
- * console.log("Stock:", data.variant.stock);
1617
+ * console.log("Price:", data.variant.pricing?.selling_price);
1618
+ * console.log("Stock available:", data.variant.stock_available);
1592
1619
  * ```
1593
1620
  */
1594
1621
  async getVariantDetail(pathParams, options, headers) {
@@ -1652,8 +1679,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
1652
1679
  * console.log("Reviews found:", data.reviews?.length || 0);
1653
1680
  *
1654
1681
  * data.reviews?.forEach(review => {
1655
- * console.log(`Review by ${review.customer_name}: ${review.rating}/5`);
1656
- * console.log("Comment:", review.comment);
1682
+ * console.log(`Review by ${review.name}: ${review.rating}/5`);
1683
+ * console.log("Review text:", review.review_text);
1657
1684
  * });
1658
1685
  *
1659
1686
  * // With pagination
@@ -1684,8 +1711,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
1684
1711
  * const { data, error } = await sdk.catalog.createProductReview(
1685
1712
  * { product_id: "prod_123" },
1686
1713
  * {
1714
+ * user_id: "user_123",
1715
+ * order_number: "ORD-001",
1687
1716
  * rating: 5,
1688
- * comment: "Excellent product! Highly recommended.",
1717
+ * review_text: "Excellent product! Highly recommended.",
1689
1718
  * images: [
1690
1719
  * new File(["image data"], "review1.jpg", { type: "image/jpeg" }),
1691
1720
  * new File(["image data"], "review2.jpg", { type: "image/jpeg" })
@@ -1743,7 +1772,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
1743
1772
  * console.log("Price range:", data.facet_stats.price_range);
1744
1773
  *
1745
1774
  * data.skus?.forEach(sku => {
1746
- * console.log(`Found: ${sku.name} - ${sku.price}`);
1775
+ * console.log(`Found: ${sku.product_name} - ${sku.pricing?.selling_price}`);
1747
1776
  * });
1748
1777
  *
1749
1778
  * // Override customer group ID for this specific request
@@ -1805,7 +1834,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
1805
1834
  * console.log("Pagination:", data.pagination);
1806
1835
  *
1807
1836
  * data.products.forEach(product => {
1808
- * console.log(`Product: ${product.name} - ${product.price}`);
1837
+ * console.log(`Product: ${product.name} - ${product.pricing?.selling_price}`);
1809
1838
  * });
1810
1839
  * }
1811
1840
  * ```
@@ -1857,7 +1886,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
1857
1886
  * console.log("Pagination:", data.pagination);
1858
1887
  *
1859
1888
  * data.products.forEach(product => {
1860
- * console.log(`Up-sell: ${product.name} - ${product.price}`);
1889
+ * console.log(`Up-sell: ${product.name} - ${product.pricing?.selling_price}`);
1861
1890
  * });
1862
1891
  * }
1863
1892
  * ```
@@ -1909,7 +1938,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
1909
1938
  * console.log("Pagination:", data.pagination);
1910
1939
  *
1911
1940
  * data.products.forEach(product => {
1912
- * console.log(`Similar: ${product.name} - ${product.price}`);
1941
+ * console.log(`Similar: ${product.name} - ${product.pricing?.selling_price}`);
1913
1942
  * });
1914
1943
  * }
1915
1944
  * ```
@@ -2065,7 +2094,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
2065
2094
  * console.error("Failed to get user cart:", error.message);
2066
2095
  * } else {
2067
2096
  * console.log("User cart ID:", data.cart.id);
2068
- * console.log("Cart value:", data.cart.subtotal_amount);
2097
+ * console.log("Cart value:", data.cart.subtotal);
2069
2098
  * }
2070
2099
  * ```
2071
2100
  */
@@ -2116,7 +2145,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
2116
2145
  * if (error) {
2117
2146
  * console.error("Failed to update cart address:", error.message);
2118
2147
  * } else {
2119
- * console.log("Addresses updated:", data.message);
2148
+ * console.log("Addresses updated:", data.cart);
2120
2149
  * }
2121
2150
  *
2122
2151
  * // For guest checkout with new addresses
@@ -2232,7 +2261,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
2232
2261
  * const coupons = data.coupons || [];
2233
2262
  * console.log("Available coupons:", coupons.length);
2234
2263
  * coupons.forEach(coupon => {
2235
- * console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
2264
+ * console.log("Coupon:", coupon.coupon_code, "Name:", coupon.name);
2236
2265
  * });
2237
2266
  * }
2238
2267
  *
@@ -2327,12 +2356,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
2327
2356
  *
2328
2357
  * console.log("Applicable coupons:", applicable.length);
2329
2358
  * applicable.forEach(coupon => {
2330
- * console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
2359
+ * console.log(`- ${coupon.coupon_code?.join(", ")}: Save $${coupon.estimated_discount}`);
2331
2360
  * });
2332
2361
  *
2333
2362
  * console.log("Inapplicable coupons:", inapplicable.length);
2334
2363
  * inapplicable.forEach(coupon => {
2335
- * console.log(`- ${coupon.code}: ${coupon.reason}`);
2364
+ * console.log(`- ${coupon.coupon_code?.join(", ")}: ${coupon.reason}`);
2336
2365
  * });
2337
2366
  * }
2338
2367
  * ```
@@ -2589,6 +2618,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
2589
2618
  * Get wishlist items
2590
2619
  *
2591
2620
  * @param userId - The ID of the user
2621
+ * @param options - Optional query parameters for filtering by seller_id (only for multi-seller marketplace stores)
2592
2622
  * @returns Promise with wishlist items
2593
2623
  * @example
2594
2624
  * ```typescript
@@ -2602,13 +2632,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
2602
2632
  * const products = data.products;
2603
2633
  * console.log("Wishlist items:", products.length);
2604
2634
  * products.forEach(product => {
2605
- * console.log("Product:", product.name, "Price:", product.price);
2635
+ * console.log("Product:", product.product_name, "Price:", product.pricing?.selling_price);
2606
2636
  * });
2607
2637
  * }
2608
2638
  * ```
2609
2639
  */
2610
- async getWishlist(userId) {
2611
- return this.executeRequest(() => this.client.GET("/wishlist/{user_id}", { params: { path: userId } }));
2640
+ async getWishlist(userId, options) {
2641
+ return this.executeRequest(() => this.client.GET("/wishlist/{user_id}", { params: {
2642
+ path: userId,
2643
+ query: options
2644
+ } }));
2612
2645
  }
2613
2646
  /**
2614
2647
  * Add item to wishlist
@@ -2706,16 +2739,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
2706
2739
  * ```typescript
2707
2740
  * // Login with phone number
2708
2741
  * const { data, error } = await sdk.auth.loginWithPhone({
2709
- * phoneNumber: "9876543210",
2710
- * countryCode: "+91",
2711
- * registerIfNotExists: true
2742
+ * phone: "9876543210",
2743
+ * country_code: "+91",
2744
+ * register_if_not_exists: true
2712
2745
  * });
2713
2746
  *
2714
2747
  * if (error) {
2715
2748
  * console.error("Login failed:", error.message);
2716
2749
  * } else {
2717
- * console.log("OTP sent. Token:", data.otpToken);
2718
- * console.log("Action:", data.action); // "login" or "register"
2750
+ * console.log("OTP sent. Token:", data.otp_token);
2751
+ * console.log("Action:", data.otp_action); // "login" or "register"
2719
2752
  * // Redirect user to OTP verification screen
2720
2753
  * }
2721
2754
  * ```
@@ -2766,14 +2799,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
2766
2799
  * // Login with email address
2767
2800
  * const { data, error } = await sdk.auth.loginWithEmail({
2768
2801
  * email: "customer@example.com",
2769
- * registerIfNotExists: true
2802
+ * register_if_not_exists: true
2770
2803
  * });
2771
2804
  *
2772
2805
  * if (error) {
2773
2806
  * console.error("Email login failed:", error.message);
2774
2807
  * } else {
2775
- * console.log("OTP sent to email. Token:", data.otpToken);
2776
- * console.log("Action:", data.action); // "login" or "register"
2808
+ * console.log("OTP sent to email. Token:", data.otp_token);
2809
+ * console.log("Action:", data.otp_action); // "login" or "register"
2777
2810
  * // Show OTP input form
2778
2811
  * }
2779
2812
  * ```
@@ -2892,8 +2925,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
2892
2925
  * // Verify OTP after login attempt
2893
2926
  * const { data, error } = await sdk.auth.verifyOtp({
2894
2927
  * otp: "1234",
2895
- * otpToken: "56895455",
2896
- * otpAction: "login" // or "register"
2928
+ * otp_token: "56895455",
2929
+ * otp_action: "login" // or "register"
2897
2930
  * });
2898
2931
  *
2899
2932
  * if (error) {
@@ -3024,8 +3057,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
3024
3057
  * } else {
3025
3058
  * console.log("User details:", data.user);
3026
3059
  * console.log("Email:", data.user.email);
3027
- * console.log("Phone:", data.user.phoneNumber);
3028
- * console.log("Created:", data.user.createdAt);
3060
+ * console.log("Phone:", data.user.phone);
3061
+ * console.log("Created:", data.user.created_at);
3029
3062
  * }
3030
3063
  * ```
3031
3064
  */
@@ -3066,6 +3099,34 @@ Object.defineProperty(exports, '__esModule', { value: true });
3066
3099
  }));
3067
3100
  }
3068
3101
  /**
3102
+ * Delete user account
3103
+ *
3104
+ * @description Deletes a user account. If the user is a primary user, deletes the associated
3105
+ * customer and all linked users. If the user is a normal user, deletes only that user without
3106
+ * affecting the customer or other users.
3107
+ *
3108
+ * @param pathParams - Path parameters containing user ID
3109
+ * @returns Promise with deletion confirmation
3110
+ * @example
3111
+ * ```typescript
3112
+ * // Delete a user account
3113
+ * const { data, error } = await sdk.auth.deleteUser({
3114
+ * id: "01H9XYZ12345USERID"
3115
+ * });
3116
+ *
3117
+ * if (error) {
3118
+ * console.error("Failed to delete user:", error.message);
3119
+ * } else {
3120
+ * console.log("User deleted successfully");
3121
+ * console.log("Success:", data.success);
3122
+ * console.log("Message:", data.message);
3123
+ * }
3124
+ * ```
3125
+ */
3126
+ async deleteUser(pathParams) {
3127
+ return this.executeRequest(() => this.client.DELETE("/auth/user/{id}", { params: { path: pathParams } }));
3128
+ }
3129
+ /**
3069
3130
  * Add profile image
3070
3131
  *
3071
3132
  * @param pathParams - Path parameters containing user ID
@@ -3551,9 +3612,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
3551
3612
  * console.log("Shipments found:", data.shipments?.length || 0);
3552
3613
  *
3553
3614
  * data.shipments?.forEach(shipment => {
3554
- * console.log(`Shipment ${shipment.id}: ${shipment.status}`);
3555
- * console.log("Tracking number:", shipment.tracking_number);
3556
- * console.log("Carrier:", shipment.carrier);
3615
+ * console.log(`Shipment ${shipment.reference_number}: ${shipment.status}`);
3616
+ * console.log("AWB:", shipment.awb_no);
3617
+ * console.log("Courier:", shipment.courier_company_name);
3557
3618
  * });
3558
3619
  * }
3559
3620
  * ```
@@ -3578,10 +3639,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
3578
3639
  * console.log("Payments found:", data.payments?.length || 0);
3579
3640
  *
3580
3641
  * data.payments?.forEach(payment => {
3581
- * console.log(`Payment ${payment.id}: ${payment.status}`);
3642
+ * console.log(`Payment ${payment.request_number}: ${payment.payment_status}`);
3582
3643
  * console.log("Amount:", payment.amount);
3583
- * console.log("Gateway:", payment.payment_gateway);
3584
- * console.log("Transaction ID:", payment.transaction_id);
3644
+ * console.log("Reference:", payment.payment_reference_number);
3585
3645
  * });
3586
3646
  * }
3587
3647
  * ```
@@ -3606,7 +3666,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
3606
3666
  * console.log("Refunds found:", data.refunds?.length || 0);
3607
3667
  *
3608
3668
  * data.refunds?.forEach(refund => {
3609
- * console.log(`Refund ${refund.id}: ${refund.status}`);
3669
+ * console.log(`Refund ${refund.request_number}: ${refund.status}`);
3610
3670
  * console.log("Amount:", refund.refund_amount);
3611
3671
  * console.log("Reason:", refund.refund_remarks);
3612
3672
  * console.log("Processed at:", refund.refund_date);
@@ -3650,6 +3710,35 @@ Object.defineProperty(exports, '__esModule', { value: true });
3650
3710
  }));
3651
3711
  }
3652
3712
  /**
3713
+ * Cancel a payment request for an order
3714
+ *
3715
+ * @description Use when the express checkout payment flow is used and the user wants to switch
3716
+ * payment methods (e.g. started with UPI, then chose another). Without this call, the user must
3717
+ * wait until the payment-status API returns `status: failed` and `is_retry_available: true`
3718
+ * (typically ~3 minutes). Calling this endpoint cancels the existing payment request so the user
3719
+ * can retry payment immediately.
3720
+ *
3721
+ * @param pathParams - Path parameters containing the order number
3722
+ * @returns Promise with cancellation confirmation
3723
+ * @example
3724
+ * ```typescript
3725
+ * // Cancel an in-progress payment request to switch payment methods
3726
+ * const { data, error } = await sdk.order.cancelPaymentRequest({
3727
+ * order_number: "ORD-2024-001"
3728
+ * });
3729
+ *
3730
+ * if (error) {
3731
+ * console.error("Failed to cancel payment request:", error.message);
3732
+ * } else {
3733
+ * console.log("Payment request cancelled:", data.success);
3734
+ * console.log("Message:", data.message);
3735
+ * }
3736
+ * ```
3737
+ */
3738
+ async cancelPaymentRequest(pathParams) {
3739
+ return this.executeRequest(() => this.client.POST("/orders/{order_number}/cancel-payment-request", { params: { path: pathParams } }));
3740
+ }
3741
+ /**
3653
3742
  * Retry payment for an order
3654
3743
  *
3655
3744
  * @param pathParams - Order number path parameters
@@ -3762,7 +3851,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
3762
3851
  * console.log("VPA:", data.vpa);
3763
3852
  * console.log("Status:", data.status);
3764
3853
  *
3765
- * if (data.status === "VALID") {
3854
+ * if (data.status === "valid") {
3766
3855
  * console.log("VPA is valid and can be used for UPI payments");
3767
3856
  * } else {
3768
3857
  * console.log("VPA is invalid, please check and try again");
@@ -3878,9 +3967,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
3878
3967
  * console.log("Countries found:", data.countries?.length || 0);
3879
3968
  *
3880
3969
  * data.countries?.forEach(country => {
3881
- * console.log(`Country: ${country.name} (${country.iso_code})`);
3882
- * console.log("Phone code:", country.phone_code);
3883
- * console.log("Currency:", country.currency?.code);
3970
+ * console.log(`Country: ${country.country_name} (${country.country_iso_code})`);
3971
+ * console.log("Currency:", country.currency_code);
3884
3972
  * });
3885
3973
  * ```
3886
3974
  */
@@ -3908,7 +3996,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
3908
3996
  *
3909
3997
  * data.states?.forEach(state => {
3910
3998
  * console.log(`State: ${state.name} (${state.iso_code})`);
3911
- * console.log("Type:", state.type);
3912
3999
  * });
3913
4000
  *
3914
4001
  * // Get states for different country
@@ -3947,9 +4034,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
3947
4034
  * console.log("Pincodes found:", data.pincodes?.length || 0);
3948
4035
  *
3949
4036
  * data.pincodes?.forEach(pincode => {
3950
- * console.log(`Pincode: ${pincode.pincode} - ${pincode.city}, ${pincode.state}`);
3951
- * console.log("District:", pincode.district);
3952
- * console.log("Area:", pincode.area);
4037
+ * console.log(`Pincode: ${pincode.pincode} - ${pincode.city}, ${pincode.state_name}`);
3953
4038
  * });
3954
4039
  *
3955
4040
  * // Get pincodes for different country
@@ -3979,88 +4064,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
3979
4064
  * Client for interacting with customer endpoints
3980
4065
  */
3981
4066
  var CustomerClient = class extends StorefrontAPIClient {
3982
- /**
3983
- * Create a customer
3984
- *
3985
- * @param body - Customer creation body
3986
- * @returns Promise with customer details
3987
- *
3988
- * @example
3989
- * ```typescript
3990
- * const { data, error } = await sdk.customer.createCustomer({
3991
- * first_name: "John",
3992
- * last_name: "Doe",
3993
- * email: "john.doe@example.com",
3994
- * phone: "+1234567890",
3995
- * password: "securePassword123"
3996
- * });
3997
- *
3998
- * if (error) {
3999
- * console.error("Failed to create customer:", error);
4000
- * return;
4001
- * }
4002
- *
4003
- * console.log("Customer created:", data.customer_detail);
4004
- * ```
4005
- */
4006
- async createCustomer(body) {
4007
- return this.executeRequest(() => this.client.POST("/customers", { body }));
4008
- }
4009
- /**
4010
- * Get customer details
4011
- *
4012
- * @param pathParams - Path parameters
4013
- * @returns Promise with customer details
4014
- *
4015
- * @example
4016
- * ```typescript
4017
- * const { data, error } = await sdk.customer.getCustomer({
4018
- * id: "customer_123"
4019
- * });
4020
- *
4021
- * if (error) {
4022
- * console.error("Failed to get customer:", error);
4023
- * return;
4024
- * }
4025
- *
4026
- * console.log("Customer details:", data.customer_detail);
4027
- * ```
4028
- */
4029
- async getCustomer(pathParams) {
4030
- return this.executeRequest(() => this.client.GET("/customers/{id}", { params: { path: pathParams } }));
4031
- }
4032
- /**
4033
- * Update a customer
4034
- *
4035
- * @param pathParams - Path parameters
4036
- * @param body - Customer update body
4037
- * @returns Promise with customer details
4038
- *
4039
- * @example
4040
- * ```typescript
4041
- * const { data, error } = await sdk.customer.updateCustomer(
4042
- * { id: "customer_123" },
4043
- * {
4044
- * first_name: "John",
4045
- * last_name: "Smith",
4046
- * email: "john.smith@example.com"
4047
- * }
4048
- * );
4049
- *
4050
- * if (error) {
4051
- * console.error("Failed to update customer:", error);
4052
- * return;
4053
- * }
4054
- *
4055
- * console.log("Customer updated:", data.customer_detail);
4056
- * ```
4057
- */
4058
- async updateCustomer(pathParams, body) {
4059
- return this.executeRequest(() => this.client.PUT("/customers/{id}", {
4060
- params: { path: pathParams },
4061
- body
4062
- }));
4063
- }
4064
4067
  /**
4065
4068
  * Get all saved addresses for a customer
4066
4069
  *
@@ -4355,6 +4358,27 @@ Object.defineProperty(exports, '__esModule', { value: true });
4355
4358
  * Client for interacting with store config endpoints
4356
4359
  */
4357
4360
  var StoreConfigClient = class extends StorefrontAPIClient {
4361
+ /**
4362
+ * Check store existence
4363
+ *
4364
+ * @description Checks whether a store with the configured store ID exists.
4365
+ * Returns `success: true` if the store exists, `false` otherwise.
4366
+ *
4367
+ * @returns Promise with store existence check result
4368
+ * @example
4369
+ * ```typescript
4370
+ * const { data, error } = await sdk.storeConfig.checkStore();
4371
+ *
4372
+ * if (error) {
4373
+ * console.error("Failed to check store:", error.message);
4374
+ * } else {
4375
+ * console.log("Store exists:", data.success);
4376
+ * }
4377
+ * ```
4378
+ */
4379
+ async checkStore() {
4380
+ return this.executeRequest(() => this.client.GET("/store/check"));
4381
+ }
4358
4382
  /**
4359
4383
  * Get store config
4360
4384
  *
@@ -4607,7 +4631,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4607
4631
  return this.defaultHeaders;
4608
4632
  }
4609
4633
  };
4610
- var src_default = StorefrontSDK;
4611
4634
 
4612
4635
  //#endregion
4613
4636
  exports.AuthClient = AuthClient;
@@ -4625,7 +4648,7 @@ exports.ResponseUtils = ResponseUtils;
4625
4648
  exports.StoreConfigClient = StoreConfigClient;
4626
4649
  exports.StorefrontAPIClient = StorefrontAPIClient;
4627
4650
  exports.StorefrontSDK = StorefrontSDK;
4628
- exports.default = src_default;
4651
+ exports.default = StorefrontSDK;
4629
4652
  return exports;
4630
4653
  })({});
4631
4654
  //# sourceMappingURL=index.iife.js.map