@commercengine/storefront-sdk 0.14.3 → 0.14.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/index.d.mts +1680 -175
- package/dist/index.iife.js +231 -128
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +124 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import createClient from "openapi-fetch";
|
|
2
|
-
|
|
3
2
|
//#region ../sdk-core/dist/index.mjs
|
|
4
3
|
/**
|
|
5
4
|
* Response utilities for debugging and working with Response objects
|
|
@@ -427,7 +426,6 @@ function getPathnameFromUrl(url) {
|
|
|
427
426
|
return url.split("?")[0] || url;
|
|
428
427
|
}
|
|
429
428
|
}
|
|
430
|
-
|
|
431
429
|
//#endregion
|
|
432
430
|
//#region src/lib/shared/url-utils.ts
|
|
433
431
|
/**
|
|
@@ -452,13 +450,11 @@ let Environment = /* @__PURE__ */ function(Environment) {
|
|
|
452
450
|
*/
|
|
453
451
|
function buildStorefrontURL(config) {
|
|
454
452
|
if (config.baseUrl) return config.baseUrl;
|
|
455
|
-
switch (config.environment ||
|
|
456
|
-
case
|
|
457
|
-
case Environment.Production:
|
|
453
|
+
switch (config.environment || "production") {
|
|
454
|
+
case "staging": return `https://staging.api.commercengine.io/api/v1/${config.storeId}/storefront`;
|
|
458
455
|
default: return `https://prod.api.commercengine.io/api/v1/${config.storeId}/storefront`;
|
|
459
456
|
}
|
|
460
457
|
}
|
|
461
|
-
|
|
462
458
|
//#endregion
|
|
463
459
|
//#region src/lib/shared/client.ts
|
|
464
460
|
/**
|
|
@@ -498,7 +494,6 @@ var StorefrontAPIClientBase = class extends BaseAPIClient {
|
|
|
498
494
|
this.client.use(middleware);
|
|
499
495
|
}
|
|
500
496
|
};
|
|
501
|
-
|
|
502
497
|
//#endregion
|
|
503
498
|
//#region src/lib/session/client.ts
|
|
504
499
|
function attachSessionAuth(client, sessionManager) {
|
|
@@ -629,7 +624,6 @@ var SessionStorefrontAPIClient = class extends StorefrontAPIClientBase {
|
|
|
629
624
|
};
|
|
630
625
|
}
|
|
631
626
|
};
|
|
632
|
-
|
|
633
627
|
//#endregion
|
|
634
628
|
//#region src/lib/shared/catalog.ts
|
|
635
629
|
/**
|
|
@@ -1205,7 +1199,6 @@ var BaseCatalogClient = class extends StorefrontAPIClientBase {
|
|
|
1205
1199
|
} }));
|
|
1206
1200
|
}
|
|
1207
1201
|
};
|
|
1208
|
-
|
|
1209
1202
|
//#endregion
|
|
1210
1203
|
//#region src/lib/public/client.ts
|
|
1211
1204
|
/**
|
|
@@ -1227,7 +1220,6 @@ function attachPublicAuth(client) {
|
|
|
1227
1220
|
return request;
|
|
1228
1221
|
} });
|
|
1229
1222
|
}
|
|
1230
|
-
|
|
1231
1223
|
//#endregion
|
|
1232
1224
|
//#region src/lib/public/catalog.ts
|
|
1233
1225
|
/**
|
|
@@ -1239,7 +1231,6 @@ var PublicCatalogClient = class extends BaseCatalogClient {
|
|
|
1239
1231
|
attachPublicAuth(this);
|
|
1240
1232
|
}
|
|
1241
1233
|
};
|
|
1242
|
-
|
|
1243
1234
|
//#endregion
|
|
1244
1235
|
//#region src/lib/catalog.ts
|
|
1245
1236
|
/**
|
|
@@ -1294,7 +1285,6 @@ var CatalogClient = class extends BaseCatalogClient {
|
|
|
1294
1285
|
}));
|
|
1295
1286
|
}
|
|
1296
1287
|
};
|
|
1297
|
-
|
|
1298
1288
|
//#endregion
|
|
1299
1289
|
//#region src/lib/cart.ts
|
|
1300
1290
|
/**
|
|
@@ -1951,7 +1941,6 @@ var CartClient = class extends SessionStorefrontAPIClient {
|
|
|
1951
1941
|
}));
|
|
1952
1942
|
}
|
|
1953
1943
|
};
|
|
1954
|
-
|
|
1955
1944
|
//#endregion
|
|
1956
1945
|
//#region src/lib/auth.ts
|
|
1957
1946
|
/**
|
|
@@ -2637,7 +2626,6 @@ var AuthClient = class extends SessionStorefrontAPIClient {
|
|
|
2637
2626
|
return this.executeRequest(() => this.client.POST("/auth/verified-email-phone", { body }));
|
|
2638
2627
|
}
|
|
2639
2628
|
};
|
|
2640
|
-
|
|
2641
2629
|
//#endregion
|
|
2642
2630
|
//#region src/lib/order.ts
|
|
2643
2631
|
/**
|
|
@@ -3001,7 +2989,6 @@ var OrderClient = class extends SessionStorefrontAPIClient {
|
|
|
3001
2989
|
}));
|
|
3002
2990
|
}
|
|
3003
2991
|
};
|
|
3004
|
-
|
|
3005
2992
|
//#endregion
|
|
3006
2993
|
//#region src/lib/payments.ts
|
|
3007
2994
|
/**
|
|
@@ -3147,8 +3134,34 @@ var PaymentsClient = class extends SessionStorefrontAPIClient {
|
|
|
3147
3134
|
async resendDirectOtp(body) {
|
|
3148
3135
|
return this.executeRequest(() => this.client.POST("/payments/resend-direct-otp", { body }));
|
|
3149
3136
|
}
|
|
3137
|
+
/**
|
|
3138
|
+
* Verify an IFSC code and resolve its bank branch details
|
|
3139
|
+
*
|
|
3140
|
+
* @description Resolves an 11-character Indian Financial System Code (IFSC) to bank,
|
|
3141
|
+
* branch, and supported payment rail details. Useful for validating user-entered IFSC
|
|
3142
|
+
* codes before creating bank accounts or mandates.
|
|
3143
|
+
*
|
|
3144
|
+
* @param pathParams - Path parameters containing the IFSC code
|
|
3145
|
+
* @returns Promise with IFSC details
|
|
3146
|
+
* @example
|
|
3147
|
+
* ```typescript
|
|
3148
|
+
* const { data, error } = await sdk.payments.verifyIfscCode({
|
|
3149
|
+
* ifsc_code: "HDFC0001234"
|
|
3150
|
+
* });
|
|
3151
|
+
*
|
|
3152
|
+
* if (error) {
|
|
3153
|
+
* console.error("Failed to verify IFSC:", error.message);
|
|
3154
|
+
* } else {
|
|
3155
|
+
* console.log("Bank:", data.ifsc.bank);
|
|
3156
|
+
* console.log("Branch:", data.ifsc.branch);
|
|
3157
|
+
* console.log("Supports UPI:", data.ifsc.upi);
|
|
3158
|
+
* }
|
|
3159
|
+
* ```
|
|
3160
|
+
*/
|
|
3161
|
+
async verifyIfscCode(pathParams) {
|
|
3162
|
+
return this.executeRequest(() => this.client.GET("/payments/ifsc-lookup/{ifsc_code}", { params: { path: pathParams } }));
|
|
3163
|
+
}
|
|
3150
3164
|
};
|
|
3151
|
-
|
|
3152
3165
|
//#endregion
|
|
3153
3166
|
//#region src/lib/shared/helper.ts
|
|
3154
3167
|
/**
|
|
@@ -3262,7 +3275,6 @@ var BaseHelpersClient = class extends StorefrontAPIClientBase {
|
|
|
3262
3275
|
} }));
|
|
3263
3276
|
}
|
|
3264
3277
|
};
|
|
3265
|
-
|
|
3266
3278
|
//#endregion
|
|
3267
3279
|
//#region src/lib/public/helper.ts
|
|
3268
3280
|
/**
|
|
@@ -3274,7 +3286,6 @@ var PublicHelpersClient = class extends BaseHelpersClient {
|
|
|
3274
3286
|
attachPublicAuth(this);
|
|
3275
3287
|
}
|
|
3276
3288
|
};
|
|
3277
|
-
|
|
3278
3289
|
//#endregion
|
|
3279
3290
|
//#region src/lib/helper.ts
|
|
3280
3291
|
/**
|
|
@@ -3286,7 +3297,6 @@ var HelpersClient = class extends BaseHelpersClient {
|
|
|
3286
3297
|
attachSessionAuth(this, config.sessionManager);
|
|
3287
3298
|
}
|
|
3288
3299
|
};
|
|
3289
|
-
|
|
3290
3300
|
//#endregion
|
|
3291
3301
|
//#region src/lib/customer.ts
|
|
3292
3302
|
/**
|
|
@@ -3356,8 +3366,101 @@ var CustomerClient = class extends SessionStorefrontAPIClient {
|
|
|
3356
3366
|
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3357
3367
|
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/cards", { params: { path: resolvedPathParams } }));
|
|
3358
3368
|
}
|
|
3369
|
+
async listBankAccounts(pathParamsOrQuery, queryParams) {
|
|
3370
|
+
const hasPathParams = queryParams !== void 0 || !!pathParamsOrQuery && typeof pathParamsOrQuery === "object" && "customer_id" in pathParamsOrQuery;
|
|
3371
|
+
const pathParams = hasPathParams ? pathParamsOrQuery : {};
|
|
3372
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3373
|
+
const resolvedQueryParams = hasPathParams ? queryParams : pathParamsOrQuery;
|
|
3374
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/bank-accounts", { params: {
|
|
3375
|
+
path: resolvedPathParams,
|
|
3376
|
+
query: resolvedQueryParams
|
|
3377
|
+
} }));
|
|
3378
|
+
}
|
|
3379
|
+
async createBankAccount(pathParamsOrBody, maybeBody) {
|
|
3380
|
+
const pathParams = maybeBody ? pathParamsOrBody : {};
|
|
3381
|
+
const body = maybeBody ?? pathParamsOrBody;
|
|
3382
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3383
|
+
return this.executeRequest(() => this.client.POST("/customers/{customer_id}/bank-accounts", {
|
|
3384
|
+
params: { path: resolvedPathParams },
|
|
3385
|
+
body
|
|
3386
|
+
}));
|
|
3387
|
+
}
|
|
3388
|
+
async getBankAccount(pathParams) {
|
|
3389
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3390
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/bank-accounts/{account_id}", { params: { path: resolvedPathParams } }));
|
|
3391
|
+
}
|
|
3392
|
+
async updateBankAccount(pathParams, body) {
|
|
3393
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3394
|
+
return this.executeRequest(() => this.client.PUT("/customers/{customer_id}/bank-accounts/{account_id}", {
|
|
3395
|
+
params: { path: resolvedPathParams },
|
|
3396
|
+
body
|
|
3397
|
+
}));
|
|
3398
|
+
}
|
|
3399
|
+
async deleteBankAccount(pathParams) {
|
|
3400
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3401
|
+
return this.executeRequest(() => this.client.DELETE("/customers/{customer_id}/bank-accounts/{account_id}", { params: { path: resolvedPathParams } }));
|
|
3402
|
+
}
|
|
3403
|
+
async verifyBankAccount(pathParams, body) {
|
|
3404
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3405
|
+
return this.executeRequest(() => this.client.POST("/customers/{customer_id}/bank-accounts/{account_id}/verify", {
|
|
3406
|
+
params: { path: resolvedPathParams },
|
|
3407
|
+
body
|
|
3408
|
+
}));
|
|
3409
|
+
}
|
|
3410
|
+
async getCreditLineBalance(pathParams = {}) {
|
|
3411
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3412
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/credit-line-balance", { params: { path: resolvedPathParams } }));
|
|
3413
|
+
}
|
|
3414
|
+
async listMandates(pathParams = {}) {
|
|
3415
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3416
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/mandates", { params: { path: resolvedPathParams } }));
|
|
3417
|
+
}
|
|
3418
|
+
async createMandate(pathParamsOrBody, maybeBody) {
|
|
3419
|
+
const pathParams = maybeBody ? pathParamsOrBody : {};
|
|
3420
|
+
const body = maybeBody ?? pathParamsOrBody;
|
|
3421
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3422
|
+
return this.executeRequest(() => this.client.POST("/customers/{customer_id}/mandates", {
|
|
3423
|
+
params: { path: resolvedPathParams },
|
|
3424
|
+
body
|
|
3425
|
+
}));
|
|
3426
|
+
}
|
|
3427
|
+
async getMandate(pathParams, queryParams) {
|
|
3428
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3429
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/mandates/{mandate_id}", { params: {
|
|
3430
|
+
path: resolvedPathParams,
|
|
3431
|
+
query: queryParams
|
|
3432
|
+
} }));
|
|
3433
|
+
}
|
|
3434
|
+
async updateMandate(pathParams, body) {
|
|
3435
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3436
|
+
return this.executeRequest(() => this.client.PUT("/customers/{customer_id}/mandates/{mandate_id}", {
|
|
3437
|
+
params: { path: resolvedPathParams },
|
|
3438
|
+
body
|
|
3439
|
+
}));
|
|
3440
|
+
}
|
|
3441
|
+
async pauseMandate(pathParams) {
|
|
3442
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3443
|
+
return this.executeRequest(() => this.client.POST("/customers/{customer_id}/mandates/{mandate_id}/pause", { params: { path: resolvedPathParams } }));
|
|
3444
|
+
}
|
|
3445
|
+
async resumeMandate(pathParams) {
|
|
3446
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3447
|
+
return this.executeRequest(() => this.client.POST("/customers/{customer_id}/mandates/{mandate_id}/resume", { params: { path: resolvedPathParams } }));
|
|
3448
|
+
}
|
|
3449
|
+
async revokeMandate(pathParams) {
|
|
3450
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3451
|
+
return this.executeRequest(() => this.client.POST("/customers/{customer_id}/mandates/{mandate_id}/revoke", { params: { path: resolvedPathParams } }));
|
|
3452
|
+
}
|
|
3453
|
+
async listMandateDebitSchedules(pathParamsOrQuery, queryParams) {
|
|
3454
|
+
const hasPathParams = queryParams !== void 0 || !!pathParamsOrQuery && typeof pathParamsOrQuery === "object" && "customer_id" in pathParamsOrQuery;
|
|
3455
|
+
const pathParams = hasPathParams ? pathParamsOrQuery : {};
|
|
3456
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3457
|
+
const resolvedQueryParams = hasPathParams ? queryParams : pathParamsOrQuery;
|
|
3458
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/mandate-debit-schedules", { params: {
|
|
3459
|
+
path: resolvedPathParams,
|
|
3460
|
+
query: resolvedQueryParams
|
|
3461
|
+
} }));
|
|
3462
|
+
}
|
|
3359
3463
|
};
|
|
3360
|
-
|
|
3361
3464
|
//#endregion
|
|
3362
3465
|
//#region src/lib/shared/store-config.ts
|
|
3363
3466
|
/**
|
|
@@ -3411,7 +3514,6 @@ var BaseStoreConfigClient = class extends StorefrontAPIClientBase {
|
|
|
3411
3514
|
return this.executeRequest(() => this.client.GET("/store/config"));
|
|
3412
3515
|
}
|
|
3413
3516
|
};
|
|
3414
|
-
|
|
3415
3517
|
//#endregion
|
|
3416
3518
|
//#region src/lib/public/store-config.ts
|
|
3417
3519
|
/**
|
|
@@ -3423,7 +3525,6 @@ var PublicStoreConfigClient = class extends BaseStoreConfigClient {
|
|
|
3423
3525
|
attachPublicAuth(this);
|
|
3424
3526
|
}
|
|
3425
3527
|
};
|
|
3426
|
-
|
|
3427
3528
|
//#endregion
|
|
3428
3529
|
//#region src/lib/store-config.ts
|
|
3429
3530
|
/**
|
|
@@ -3435,7 +3536,6 @@ var StoreConfigClient = class extends BaseStoreConfigClient {
|
|
|
3435
3536
|
attachSessionAuth(this, config.sessionManager);
|
|
3436
3537
|
}
|
|
3437
3538
|
};
|
|
3438
|
-
|
|
3439
3539
|
//#endregion
|
|
3440
3540
|
//#region src/lib/storage/token-storage.ts
|
|
3441
3541
|
/**
|
|
@@ -3555,7 +3655,6 @@ var CookieTokenStorage = class {
|
|
|
3555
3655
|
document.cookie = cookieString;
|
|
3556
3656
|
}
|
|
3557
3657
|
};
|
|
3558
|
-
|
|
3559
3658
|
//#endregion
|
|
3560
3659
|
//#region src/lib/session/jwt-utils.ts
|
|
3561
3660
|
/**
|
|
@@ -3657,7 +3756,6 @@ function isUserLoggedIn(token) {
|
|
|
3657
3756
|
function isUserAnonymous(token) {
|
|
3658
3757
|
return extractUserInfoFromToken(token)?.isAnonymous ?? true;
|
|
3659
3758
|
}
|
|
3660
|
-
|
|
3661
3759
|
//#endregion
|
|
3662
3760
|
//#region src/types/auth-operation-metadata.ts
|
|
3663
3761
|
const API_KEY_ONLY_OPERATIONS = [
|
|
@@ -3698,7 +3796,6 @@ const API_KEY_ONLY_OPERATIONS = [
|
|
|
3698
3796
|
path: "/store/sellers/{id}/reviews"
|
|
3699
3797
|
}
|
|
3700
3798
|
];
|
|
3701
|
-
|
|
3702
3799
|
//#endregion
|
|
3703
3800
|
//#region src/lib/session/auth-utils.ts
|
|
3704
3801
|
const TOKEN_RETURNING_OPERATIONS = [
|
|
@@ -3776,7 +3873,6 @@ function isApiKeyOnlyOperation(method, pathname) {
|
|
|
3776
3873
|
function isTokenReturningOperation(method, pathname) {
|
|
3777
3874
|
return matchesOperationList(method, pathname, TOKEN_RETURNING_OPERATIONS);
|
|
3778
3875
|
}
|
|
3779
|
-
|
|
3780
3876
|
//#endregion
|
|
3781
3877
|
//#region src/lib/session/manager.ts
|
|
3782
3878
|
/**
|
|
@@ -4153,7 +4249,6 @@ var StorefrontSessionManager = class {
|
|
|
4153
4249
|
if (refreshToken) await this.tokenStorage.setRefreshToken(refreshToken);
|
|
4154
4250
|
}
|
|
4155
4251
|
};
|
|
4156
|
-
|
|
4157
4252
|
//#endregion
|
|
4158
4253
|
//#region src/index.ts
|
|
4159
4254
|
/**
|
|
@@ -4535,7 +4630,7 @@ function createStorefront(options) {
|
|
|
4535
4630
|
session
|
|
4536
4631
|
};
|
|
4537
4632
|
}
|
|
4538
|
-
|
|
4539
4633
|
//#endregion
|
|
4540
4634
|
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, PaymentsClient, PublicCatalogClient, PublicHelpersClient, PublicStoreConfigClient, PublicStorefrontAPIClient, PublicStorefrontSDK, ResponseUtils, SessionStorefrontAPIClient, SessionStorefrontSDK, StoreConfigClient, createStorefront };
|
|
4635
|
+
|
|
4541
4636
|
//# sourceMappingURL=index.mjs.map
|