@epcc-sdk/sdks-shopper 0.0.28 → 0.0.29

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.
Files changed (55) hide show
  1. package/dist/constants/credentials.cjs +32 -0
  2. package/dist/constants/credentials.cjs.map +1 -0
  3. package/dist/constants/credentials.d.cts +4 -0
  4. package/dist/constants/credentials.d.ts +4 -0
  5. package/dist/constants/credentials.mjs +7 -0
  6. package/dist/constants/credentials.mjs.map +1 -0
  7. package/dist/index.cjs +8 -2
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +3 -0
  10. package/dist/index.d.ts +3 -0
  11. package/dist/index.mjs +5 -2
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/interceptors/auth-local-storage-interceptor.cjs +69 -0
  14. package/dist/interceptors/auth-local-storage-interceptor.cjs.map +1 -0
  15. package/dist/interceptors/auth-local-storage-interceptor.d.cts +10 -0
  16. package/dist/interceptors/auth-local-storage-interceptor.d.ts +10 -0
  17. package/dist/interceptors/auth-local-storage-interceptor.mjs +45 -0
  18. package/dist/interceptors/auth-local-storage-interceptor.mjs.map +1 -0
  19. package/dist/interceptors/index.cjs +23 -0
  20. package/dist/interceptors/index.cjs.map +1 -0
  21. package/dist/interceptors/index.d.cts +2 -0
  22. package/dist/interceptors/index.d.ts +2 -0
  23. package/dist/interceptors/index.mjs +2 -0
  24. package/dist/interceptors/index.mjs.map +1 -0
  25. package/dist/test/setup.cjs +27 -0
  26. package/dist/test/setup.cjs.map +1 -0
  27. package/dist/test/setup.d.cts +2 -0
  28. package/dist/test/setup.d.ts +2 -0
  29. package/dist/test/setup.mjs +26 -0
  30. package/dist/test/setup.mjs.map +1 -0
  31. package/dist/utils/get-cart-id.cjs +32 -0
  32. package/dist/utils/get-cart-id.cjs.map +1 -0
  33. package/dist/utils/get-cart-id.d.cts +3 -0
  34. package/dist/utils/get-cart-id.d.ts +3 -0
  35. package/dist/utils/get-cart-id.mjs +8 -0
  36. package/dist/utils/get-cart-id.mjs.map +1 -0
  37. package/dist/utils/index.cjs +8 -2
  38. package/dist/utils/index.cjs.map +1 -1
  39. package/dist/utils/index.d.cts +2 -0
  40. package/dist/utils/index.d.ts +2 -0
  41. package/dist/utils/index.mjs +5 -1
  42. package/dist/utils/index.mjs.map +1 -1
  43. package/dist/utils/initialize-cart.cjs +53 -0
  44. package/dist/utils/initialize-cart.cjs.map +1 -0
  45. package/dist/utils/initialize-cart.d.cts +10 -0
  46. package/dist/utils/initialize-cart.d.ts +10 -0
  47. package/dist/utils/initialize-cart.mjs +28 -0
  48. package/dist/utils/initialize-cart.mjs.map +1 -0
  49. package/dist/utils/token-expired.cjs +31 -0
  50. package/dist/utils/token-expired.cjs.map +1 -0
  51. package/dist/utils/token-expired.d.cts +3 -0
  52. package/dist/utils/token-expired.d.ts +3 -0
  53. package/dist/utils/token-expired.mjs +7 -0
  54. package/dist/utils/token-expired.mjs.map +1 -0
  55. package/package.json +9 -3
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var credentials_exports = {};
20
+ __export(credentials_exports, {
21
+ CART_STORAGE_KEY: () => CART_STORAGE_KEY,
22
+ CREDENTIALS_STORAGE_KEY: () => CREDENTIALS_STORAGE_KEY
23
+ });
24
+ module.exports = __toCommonJS(credentials_exports);
25
+ const CREDENTIALS_STORAGE_KEY = "_store_ep_credentials";
26
+ const CART_STORAGE_KEY = "_store_ep_cart";
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ CART_STORAGE_KEY,
30
+ CREDENTIALS_STORAGE_KEY
31
+ });
32
+ //# sourceMappingURL=credentials.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/constants/credentials.ts"],"sourcesContent":["// TODO remove _store prefix once work has been done in examples folder\nexport const CREDENTIALS_STORAGE_KEY = \"_store_ep_credentials\"\nexport const CART_STORAGE_KEY = \"_store_ep_cart\"\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,MAAM,0BAA0B;AAChC,MAAM,mBAAmB;","names":[]}
@@ -0,0 +1,4 @@
1
+ declare const CREDENTIALS_STORAGE_KEY = "_store_ep_credentials";
2
+ declare const CART_STORAGE_KEY = "_store_ep_cart";
3
+
4
+ export { CART_STORAGE_KEY, CREDENTIALS_STORAGE_KEY };
@@ -0,0 +1,4 @@
1
+ declare const CREDENTIALS_STORAGE_KEY = "_store_ep_credentials";
2
+ declare const CART_STORAGE_KEY = "_store_ep_cart";
3
+
4
+ export { CART_STORAGE_KEY, CREDENTIALS_STORAGE_KEY };
@@ -0,0 +1,7 @@
1
+ const CREDENTIALS_STORAGE_KEY = "_store_ep_credentials";
2
+ const CART_STORAGE_KEY = "_store_ep_cart";
3
+ export {
4
+ CART_STORAGE_KEY,
5
+ CREDENTIALS_STORAGE_KEY
6
+ };
7
+ //# sourceMappingURL=credentials.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/constants/credentials.ts"],"sourcesContent":["// TODO remove _store prefix once work has been done in examples folder\nexport const CREDENTIALS_STORAGE_KEY = \"_store_ep_credentials\"\nexport const CART_STORAGE_KEY = \"_store_ep_cart\"\n"],"mappings":"AACO,MAAM,0BAA0B;AAChC,MAAM,mBAAmB;","names":[]}
package/dist/index.cjs CHANGED
@@ -21,7 +21,9 @@ var index_exports = {};
21
21
  __export(index_exports, {
22
22
  client: () => import_sdk.client,
23
23
  createClient: () => import_client_fetch.createClient,
24
- extractProductImage: () => import_utils.extractProductImage
24
+ extractProductImage: () => import_utils.extractProductImage,
25
+ getCartId: () => import_utils.getCartId,
26
+ initializeCart: () => import_utils.initializeCart
25
27
  });
26
28
  module.exports = __toCommonJS(index_exports);
27
29
  __reExport(index_exports, require('./client/index.cjs'), module.exports);
@@ -29,12 +31,16 @@ __reExport(index_exports, require('./client/@tanstack/react-query.gen.cjs'), mod
29
31
  var import_client_fetch = require("@hey-api/client-fetch");
30
32
  var import_sdk = require('./client/sdk.gen.cjs');
31
33
  var import_utils = require('./utils/index.cjs');
34
+ __reExport(index_exports, require('./interceptors/index.cjs'), module.exports);
32
35
  // Annotate the CommonJS export names for ESM import in node:
33
36
  0 && (module.exports = {
34
37
  client,
35
38
  createClient,
36
39
  extractProductImage,
40
+ getCartId,
41
+ initializeCart,
37
42
  ...require('./client/index.cjs'),
38
- ...require('./client/@tanstack/react-query.gen.cjs')
43
+ ...require('./client/@tanstack/react-query.gen.cjs'),
44
+ ...require('./interceptors/index.cjs')
39
45
  });
40
46
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./client\"\nexport * from \"./client/@tanstack/react-query.gen\"\nimport { type Client, createClient } from \"@hey-api/client-fetch\"\nexport { createClient, type Client }\nexport { client } from \"./client/sdk.gen\"\nexport { extractProductImage } from \"./utils\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAc,qBAAd;AACA,0BAAc,+CADd;AAEA,0BAA0C;AAE1C,iBAAuB;AACvB,mBAAoC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./client\"\nexport * from \"./client/@tanstack/react-query.gen\"\nimport { type Client, createClient } from \"@hey-api/client-fetch\"\nexport { createClient, type Client }\nexport { client } from \"./client/sdk.gen\"\nexport { extractProductImage, initializeCart, getCartId } from \"./utils\"\nexport * from \"./interceptors\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAc,qBAAd;AACA,0BAAc,+CADd;AAEA,0BAA0C;AAE1C,iBAAuB;AACvB,mBAA+D;AAC/D,0BAAc,2BANd;","names":[]}
package/dist/index.d.cts CHANGED
@@ -3,4 +3,7 @@ export { addCustomDiscountToCartItem, addTaxItemToCart, anonymizeOrders, bulkAdd
3
3
  export { addCustomDiscountToCartItemMutation, addCustomDiscountToCartItemOptions, addCustomDiscountToCartItemQueryKey, addTaxItemToCartMutation, addTaxItemToCartOptions, addTaxItemToCartQueryKey, anonymizeOrdersMutation, anonymizeOrdersOptions, anonymizeOrdersQueryKey, bulkAddCustomDiscountsToCartMutation, bulkAddCustomDiscountsToCartOptions, bulkAddCustomDiscountsToCartQueryKey, bulkAddTaxItemsToCartMutation, bulkAddTaxItemsToCartOptions, bulkAddTaxItemsToCartQueryKey, bulkDeleteCustomDiscountsFromCartMutation, bulkDeleteTaxItemsFromCartMutation, bulkUpdateItemsInCartMutation, cancelATransactionMutation, cancelATransactionOptions, cancelATransactionQueryKey, captureATransactionMutation, captureATransactionOptions, captureATransactionQueryKey, checkoutApiMutation, checkoutApiOptions, checkoutApiQueryKey, configureByContextProductMutation, configureByContextProductOptions, configureByContextProductQueryKey, confirmPaymentMutation, confirmPaymentOptions, confirmPaymentQueryKey, createACartMutation, createACartOptions, createACartQueryKey, createAccountCartAssociationMutation, createAccountCartAssociationOptions, createAccountCartAssociationQueryKey, createAnAccessTokenMutation, createAnAccessTokenOptions, createAnAccessTokenQueryKey, createCartPaymentIntentMutation, createCartPaymentIntentOptions, createCartPaymentIntentQueryKey, createCatalogMutation, createCatalogOptions, createCatalogQueryKey, createCustomerCartAssociationMutation, createCustomerCartAssociationOptions, createCustomerCartAssociationQueryKey, createOneTimePasswordTokenRequestMutation, createOneTimePasswordTokenRequestOptions, createOneTimePasswordTokenRequestQueryKey, createRuleMutation, createRuleOptions, createRuleQueryKey, deleteACartItemMutation, deleteACartMutation, deleteAPromotionViaPromotionCodeMutation, deleteATaxItemMutation, deleteAccountCartAssociationMutation, deleteAllCartItemsMutation, deleteCatalogByIdMutation, deleteCustomDiscountFromCartItemMutation, deleteCustomDiscountFromCartMutation, deleteCustomerCartAssociationMutation, deleteReleaseByIdMutation, deleteReleasesMutation, deleteRuleByIdMutation, deleteV2AccountAddressMutation, getACurrencyOptions, getACurrencyQueryKey, getAFileOptions, getAFileQueryKey, getATransactionOptions, getATransactionQueryKey, getAllCurrenciesOptions, getAllCurrenciesQueryKey, getAllFilesOptions, getAllFilesQueryKey, getAllHierarchiesOptions, getAllHierarchiesQueryKey, getAllNodesOptions, getAllNodesQueryKey, getAllProductsOptions, getAllProductsQueryKey, getAnOrderOptions, getAnOrderQueryKey, getByContextAllHierarchiesOptions, getByContextAllHierarchiesQueryKey, getByContextAllNodesOptions, getByContextAllNodesQueryKey, getByContextAllProductsOptions, getByContextAllProductsQueryKey, getByContextChildNodesOptions, getByContextChildNodesQueryKey, getByContextChildProductsOptions, getByContextChildProductsQueryKey, getByContextComponentProductIdsOptions, getByContextComponentProductIdsQueryKey, getByContextHierarchyChildNodesOptions, getByContextHierarchyChildNodesQueryKey, getByContextHierarchyNodesOptions, getByContextHierarchyNodesQueryKey, getByContextHierarchyOptions, getByContextHierarchyQueryKey, getByContextNodeOptions, getByContextNodeQueryKey, getByContextProductOptions, getByContextProductQueryKey, getByContextProductsForHierarchyOptions, getByContextProductsForHierarchyQueryKey, getByContextProductsForNodeOptions, getByContextProductsForNodeQueryKey, getByContextReleaseOptions, getByContextReleaseQueryKey, getCartItemsOptions, getCartItemsQueryKey, getCartOptions, getCartQueryKey, getCartsOptions, getCartsQueryKey, getCatalogByIdOptions, getCatalogByIdQueryKey, getCatalogsOptions, getCatalogsQueryKey, getChildNodesOptions, getChildNodesQueryKey, getChildProductsOptions, getChildProductsQueryKey, getComponentProductIdsOptions, getComponentProductIdsQueryKey, getCustomerOrdersOptions, getCustomerOrdersQueryKey, getFeatureOptions, getFeatureQueryKey, getHierarchyChildNodesOptions, getHierarchyChildNodesQueryKey, getHierarchyNodesOptions, getHierarchyNodesQueryKey, getHierarchyOptions, getHierarchyQueryKey, getInvoiceOptions, getInvoiceQueryKey, getNodeOptions, getNodeQueryKey, getOfferingOptions, getOfferingQueryKey, getOrderItemsOptions, getOrderItemsQueryKey, getOrderTransactionsOptions, getOrderTransactionsQueryKey, getPlanOptions, getPlanQueryKey, getProductOptions, getProductQueryKey, getProductsForHierarchyOptions, getProductsForHierarchyQueryKey, getProductsForNodeOptions, getProductsForNodeQueryKey, getReleaseByIdOptions, getReleaseByIdQueryKey, getReleasesOptions, getReleasesQueryKey, getRuleByIdOptions, getRuleByIdQueryKey, getRulesOptions, getRulesQueryKey, getStockOptions, getStockQueryKey, getSubscriptionInvoiceOptions, getSubscriptionInvoicePaymentOptions, getSubscriptionInvoicePaymentQueryKey, getSubscriptionInvoiceQueryKey, getSubscriptionOptions, getSubscriptionProductOptions, getSubscriptionProductQueryKey, getSubscriptionQueryKey, getSubscriptionStateOptions, getSubscriptionStateQueryKey, getV2AccountAddressOptions, getV2AccountAddressQueryKey, getV2AccountAddressesOptions, getV2AccountAddressesQueryKey, getV2AccountMembersAccountMemberIdOptions, getV2AccountMembersAccountMemberIdQueryKey, getV2AccountMembersOptions, getV2AccountMembersQueryKey, getV2AccountsAccountIdAccountMembershipsOptions, getV2AccountsAccountIdAccountMembershipsQueryKey, getV2AccountsAccountIdOptions, getV2AccountsAccountIdQueryKey, getV2AccountsOptions, getV2AccountsQueryKey, listInvoicesOptions, listInvoicesQueryKey, listLocationsOptions, listLocationsQueryKey, listOfferingFeaturesOptions, listOfferingFeaturesQueryKey, listOfferingPlansOptions, listOfferingPlansQueryKey, listOfferingProductsOptions, listOfferingProductsQueryKey, listOfferingsOptions, listOfferingsQueryKey, listSubscriptionInvoicePaymentsOptions, listSubscriptionInvoicePaymentsQueryKey, listSubscriptionInvoicesOptions, listSubscriptionInvoicesQueryKey, listSubscriptionPlansOptions, listSubscriptionPlansQueryKey, listSubscriptionProductsOptions, listSubscriptionProductsQueryKey, listSubscriptionStatesOptions, listSubscriptionStatesQueryKey, listSubscriptionsOptions, listSubscriptionsQueryKey, manageCartsMutation, manageCartsOptions, manageCartsQueryKey, paymentSetupMutation, paymentSetupOptions, paymentSetupQueryKey, postV2AccountAddressMutation, postV2AccountAddressOptions, postV2AccountAddressQueryKey, postV2AccountMembersTokensMutation, postV2AccountMembersTokensOptions, postV2AccountMembersTokensQueryKey, postV2AccountsMutation, postV2AccountsOptions, postV2AccountsQueryKey, publishReleaseMutation, publishReleaseOptions, publishReleaseQueryKey, putV2AccountAddressMutation, putV2AccountsAccountIdMutation, refundATransactionMutation, refundATransactionOptions, refundATransactionQueryKey, updateACartItemMutation, updateACartMutation, updateATaxItemMutation, updateAnOrderMutation, updateCatalogMutation, updateCustomDiscountForCartItemMutation, updateCustomDiscountForCartMutation, updatePasswordProfileInfoMutation, updateRuleMutation } from './client/@tanstack/react-query.gen.cjs';
4
4
  export { Client, createClient } from '@hey-api/client-fetch';
5
5
  export { extractProductImage } from './utils/extract-product-image.cjs';
6
+ export { initializeCart } from './utils/initialize-cart.cjs';
7
+ export { getCartId } from './utils/get-cart-id.cjs';
8
+ export { createAuthLocalStorageInterceptor } from './interceptors/auth-local-storage-interceptor.cjs';
6
9
  import '@tanstack/react-query';
package/dist/index.d.ts CHANGED
@@ -3,4 +3,7 @@ export { addCustomDiscountToCartItem, addTaxItemToCart, anonymizeOrders, bulkAdd
3
3
  export { addCustomDiscountToCartItemMutation, addCustomDiscountToCartItemOptions, addCustomDiscountToCartItemQueryKey, addTaxItemToCartMutation, addTaxItemToCartOptions, addTaxItemToCartQueryKey, anonymizeOrdersMutation, anonymizeOrdersOptions, anonymizeOrdersQueryKey, bulkAddCustomDiscountsToCartMutation, bulkAddCustomDiscountsToCartOptions, bulkAddCustomDiscountsToCartQueryKey, bulkAddTaxItemsToCartMutation, bulkAddTaxItemsToCartOptions, bulkAddTaxItemsToCartQueryKey, bulkDeleteCustomDiscountsFromCartMutation, bulkDeleteTaxItemsFromCartMutation, bulkUpdateItemsInCartMutation, cancelATransactionMutation, cancelATransactionOptions, cancelATransactionQueryKey, captureATransactionMutation, captureATransactionOptions, captureATransactionQueryKey, checkoutApiMutation, checkoutApiOptions, checkoutApiQueryKey, configureByContextProductMutation, configureByContextProductOptions, configureByContextProductQueryKey, confirmPaymentMutation, confirmPaymentOptions, confirmPaymentQueryKey, createACartMutation, createACartOptions, createACartQueryKey, createAccountCartAssociationMutation, createAccountCartAssociationOptions, createAccountCartAssociationQueryKey, createAnAccessTokenMutation, createAnAccessTokenOptions, createAnAccessTokenQueryKey, createCartPaymentIntentMutation, createCartPaymentIntentOptions, createCartPaymentIntentQueryKey, createCatalogMutation, createCatalogOptions, createCatalogQueryKey, createCustomerCartAssociationMutation, createCustomerCartAssociationOptions, createCustomerCartAssociationQueryKey, createOneTimePasswordTokenRequestMutation, createOneTimePasswordTokenRequestOptions, createOneTimePasswordTokenRequestQueryKey, createRuleMutation, createRuleOptions, createRuleQueryKey, deleteACartItemMutation, deleteACartMutation, deleteAPromotionViaPromotionCodeMutation, deleteATaxItemMutation, deleteAccountCartAssociationMutation, deleteAllCartItemsMutation, deleteCatalogByIdMutation, deleteCustomDiscountFromCartItemMutation, deleteCustomDiscountFromCartMutation, deleteCustomerCartAssociationMutation, deleteReleaseByIdMutation, deleteReleasesMutation, deleteRuleByIdMutation, deleteV2AccountAddressMutation, getACurrencyOptions, getACurrencyQueryKey, getAFileOptions, getAFileQueryKey, getATransactionOptions, getATransactionQueryKey, getAllCurrenciesOptions, getAllCurrenciesQueryKey, getAllFilesOptions, getAllFilesQueryKey, getAllHierarchiesOptions, getAllHierarchiesQueryKey, getAllNodesOptions, getAllNodesQueryKey, getAllProductsOptions, getAllProductsQueryKey, getAnOrderOptions, getAnOrderQueryKey, getByContextAllHierarchiesOptions, getByContextAllHierarchiesQueryKey, getByContextAllNodesOptions, getByContextAllNodesQueryKey, getByContextAllProductsOptions, getByContextAllProductsQueryKey, getByContextChildNodesOptions, getByContextChildNodesQueryKey, getByContextChildProductsOptions, getByContextChildProductsQueryKey, getByContextComponentProductIdsOptions, getByContextComponentProductIdsQueryKey, getByContextHierarchyChildNodesOptions, getByContextHierarchyChildNodesQueryKey, getByContextHierarchyNodesOptions, getByContextHierarchyNodesQueryKey, getByContextHierarchyOptions, getByContextHierarchyQueryKey, getByContextNodeOptions, getByContextNodeQueryKey, getByContextProductOptions, getByContextProductQueryKey, getByContextProductsForHierarchyOptions, getByContextProductsForHierarchyQueryKey, getByContextProductsForNodeOptions, getByContextProductsForNodeQueryKey, getByContextReleaseOptions, getByContextReleaseQueryKey, getCartItemsOptions, getCartItemsQueryKey, getCartOptions, getCartQueryKey, getCartsOptions, getCartsQueryKey, getCatalogByIdOptions, getCatalogByIdQueryKey, getCatalogsOptions, getCatalogsQueryKey, getChildNodesOptions, getChildNodesQueryKey, getChildProductsOptions, getChildProductsQueryKey, getComponentProductIdsOptions, getComponentProductIdsQueryKey, getCustomerOrdersOptions, getCustomerOrdersQueryKey, getFeatureOptions, getFeatureQueryKey, getHierarchyChildNodesOptions, getHierarchyChildNodesQueryKey, getHierarchyNodesOptions, getHierarchyNodesQueryKey, getHierarchyOptions, getHierarchyQueryKey, getInvoiceOptions, getInvoiceQueryKey, getNodeOptions, getNodeQueryKey, getOfferingOptions, getOfferingQueryKey, getOrderItemsOptions, getOrderItemsQueryKey, getOrderTransactionsOptions, getOrderTransactionsQueryKey, getPlanOptions, getPlanQueryKey, getProductOptions, getProductQueryKey, getProductsForHierarchyOptions, getProductsForHierarchyQueryKey, getProductsForNodeOptions, getProductsForNodeQueryKey, getReleaseByIdOptions, getReleaseByIdQueryKey, getReleasesOptions, getReleasesQueryKey, getRuleByIdOptions, getRuleByIdQueryKey, getRulesOptions, getRulesQueryKey, getStockOptions, getStockQueryKey, getSubscriptionInvoiceOptions, getSubscriptionInvoicePaymentOptions, getSubscriptionInvoicePaymentQueryKey, getSubscriptionInvoiceQueryKey, getSubscriptionOptions, getSubscriptionProductOptions, getSubscriptionProductQueryKey, getSubscriptionQueryKey, getSubscriptionStateOptions, getSubscriptionStateQueryKey, getV2AccountAddressOptions, getV2AccountAddressQueryKey, getV2AccountAddressesOptions, getV2AccountAddressesQueryKey, getV2AccountMembersAccountMemberIdOptions, getV2AccountMembersAccountMemberIdQueryKey, getV2AccountMembersOptions, getV2AccountMembersQueryKey, getV2AccountsAccountIdAccountMembershipsOptions, getV2AccountsAccountIdAccountMembershipsQueryKey, getV2AccountsAccountIdOptions, getV2AccountsAccountIdQueryKey, getV2AccountsOptions, getV2AccountsQueryKey, listInvoicesOptions, listInvoicesQueryKey, listLocationsOptions, listLocationsQueryKey, listOfferingFeaturesOptions, listOfferingFeaturesQueryKey, listOfferingPlansOptions, listOfferingPlansQueryKey, listOfferingProductsOptions, listOfferingProductsQueryKey, listOfferingsOptions, listOfferingsQueryKey, listSubscriptionInvoicePaymentsOptions, listSubscriptionInvoicePaymentsQueryKey, listSubscriptionInvoicesOptions, listSubscriptionInvoicesQueryKey, listSubscriptionPlansOptions, listSubscriptionPlansQueryKey, listSubscriptionProductsOptions, listSubscriptionProductsQueryKey, listSubscriptionStatesOptions, listSubscriptionStatesQueryKey, listSubscriptionsOptions, listSubscriptionsQueryKey, manageCartsMutation, manageCartsOptions, manageCartsQueryKey, paymentSetupMutation, paymentSetupOptions, paymentSetupQueryKey, postV2AccountAddressMutation, postV2AccountAddressOptions, postV2AccountAddressQueryKey, postV2AccountMembersTokensMutation, postV2AccountMembersTokensOptions, postV2AccountMembersTokensQueryKey, postV2AccountsMutation, postV2AccountsOptions, postV2AccountsQueryKey, publishReleaseMutation, publishReleaseOptions, publishReleaseQueryKey, putV2AccountAddressMutation, putV2AccountsAccountIdMutation, refundATransactionMutation, refundATransactionOptions, refundATransactionQueryKey, updateACartItemMutation, updateACartMutation, updateATaxItemMutation, updateAnOrderMutation, updateCatalogMutation, updateCustomDiscountForCartItemMutation, updateCustomDiscountForCartMutation, updatePasswordProfileInfoMutation, updateRuleMutation } from './client/@tanstack/react-query.gen.js';
4
4
  export { Client, createClient } from '@hey-api/client-fetch';
5
5
  export { extractProductImage } from './utils/extract-product-image.js';
6
+ export { initializeCart } from './utils/initialize-cart.js';
7
+ export { getCartId } from './utils/get-cart-id.js';
8
+ export { createAuthLocalStorageInterceptor } from './interceptors/auth-local-storage-interceptor.js';
6
9
  import '@tanstack/react-query';
package/dist/index.mjs CHANGED
@@ -2,10 +2,13 @@ export * from "./client/index.mjs";
2
2
  export * from "./client/@tanstack/react-query.gen.mjs";
3
3
  import { createClient } from "@hey-api/client-fetch";
4
4
  import { client } from "./client/sdk.gen.mjs";
5
- import { extractProductImage } from "./utils/index.mjs";
5
+ import { extractProductImage, initializeCart, getCartId } from "./utils/index.mjs";
6
+ export * from "./interceptors/index.mjs";
6
7
  export {
7
8
  client,
8
9
  createClient,
9
- extractProductImage
10
+ extractProductImage,
11
+ getCartId,
12
+ initializeCart
10
13
  };
11
14
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./client\"\nexport * from \"./client/@tanstack/react-query.gen\"\nimport { type Client, createClient } from \"@hey-api/client-fetch\"\nexport { createClient, type Client }\nexport { client } from \"./client/sdk.gen\"\nexport { extractProductImage } from \"./utils\"\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,SAAsB,oBAAoB;AAE1C,SAAS,cAAc;AACvB,SAAS,2BAA2B;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./client\"\nexport * from \"./client/@tanstack/react-query.gen\"\nimport { type Client, createClient } from \"@hey-api/client-fetch\"\nexport { createClient, type Client }\nexport { client } from \"./client/sdk.gen\"\nexport { extractProductImage, initializeCart, getCartId } from \"./utils\"\nexport * from \"./interceptors\"\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,SAAsB,oBAAoB;AAE1C,SAAS,cAAc;AACvB,SAAS,qBAAqB,gBAAgB,iBAAiB;AAC/D,cAAc;","names":[]}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var auth_local_storage_interceptor_exports = {};
20
+ __export(auth_local_storage_interceptor_exports, {
21
+ createAuthLocalStorageInterceptor: () => createAuthLocalStorageInterceptor
22
+ });
23
+ module.exports = __toCommonJS(auth_local_storage_interceptor_exports);
24
+ var import_credentials = require('../constants/credentials.cjs');
25
+ var import_client = require('../client/index.cjs');
26
+ var import_token_expired = require('../utils/token-expired.cjs');
27
+ function createAuthLocalStorageInterceptor(createOptions) {
28
+ return async function authCookieInterceptor(request, _options) {
29
+ const {
30
+ storageKey = import_credentials.CREDENTIALS_STORAGE_KEY,
31
+ clientId,
32
+ autoRefresh = true,
33
+ autoStoreCredentials = true
34
+ } = createOptions;
35
+ if (request.url?.includes("/oauth/access_token")) {
36
+ return request;
37
+ }
38
+ let credentials = JSON.parse(localStorage.getItem(storageKey) ?? "{}");
39
+ if (
40
+ // We don't have a token and auto-storing is enabled
41
+ !credentials?.access_token && autoStoreCredentials || // OR token exists but is expired and auto-refresh is enabled
42
+ credentials?.access_token && credentials.expires && (0, import_token_expired.tokenExpired)(credentials.expires) && autoRefresh
43
+ ) {
44
+ if (!clientId) {
45
+ throw new Error("Missing storefront client id");
46
+ }
47
+ const authResponse = await (0, import_client.createAnAccessToken)({
48
+ body: {
49
+ grant_type: "implicit",
50
+ client_id: clientId
51
+ }
52
+ });
53
+ if (!authResponse.data) {
54
+ throw new Error("Failed to get access token");
55
+ }
56
+ credentials = authResponse.data;
57
+ localStorage.setItem(storageKey, JSON.stringify(credentials));
58
+ }
59
+ if (credentials?.access_token) {
60
+ request.headers.set("Authorization", `Bearer ${credentials.access_token}`);
61
+ }
62
+ return request;
63
+ };
64
+ }
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ createAuthLocalStorageInterceptor
68
+ });
69
+ //# sourceMappingURL=auth-local-storage-interceptor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/interceptors/auth-local-storage-interceptor.ts"],"sourcesContent":["import { Client } from \"@hey-api/client-fetch\"\nimport { CREDENTIALS_STORAGE_KEY } from \"../constants/credentials\"\nimport { AccessTokenResponse, createAnAccessToken } from \"../client\"\nimport { tokenExpired } from \"../utils/token-expired\"\n\nexport function createAuthLocalStorageInterceptor(createOptions: {\n storageKey?: string\n clientId: string\n autoRefresh?: boolean\n autoStoreCredentials?: boolean\n}): Parameters<Client[\"interceptors\"][\"request\"][\"use\"]>[0] {\n return async function authCookieInterceptor(request, _options) {\n const {\n storageKey = CREDENTIALS_STORAGE_KEY,\n clientId,\n autoRefresh = true,\n autoStoreCredentials = true,\n } = createOptions\n\n // Bypass interceptor logic for token requests to prevent infinite loop\n if (request.url?.includes(\"/oauth/access_token\")) {\n return request\n }\n\n let credentials = JSON.parse(localStorage.getItem(storageKey) ?? \"{}\") as\n | AccessTokenResponse\n | undefined\n\n // Create a new token if...\n if (\n // We don't have a token and auto-storing is enabled\n (!credentials?.access_token && autoStoreCredentials) ||\n // OR token exists but is expired and auto-refresh is enabled\n (credentials?.access_token &&\n credentials.expires &&\n tokenExpired(credentials.expires) &&\n autoRefresh)\n ) {\n if (!clientId) {\n throw new Error(\"Missing storefront client id\")\n }\n const authResponse = await createAnAccessToken({\n body: {\n grant_type: \"implicit\",\n client_id: clientId,\n },\n })\n\n if (!authResponse.data) {\n throw new Error(\"Failed to get access token\")\n }\n\n credentials = authResponse.data\n // Store the credentials in localStorage\n localStorage.setItem(storageKey, JSON.stringify(credentials))\n }\n\n if (credentials?.access_token) {\n request.headers.set(\"Authorization\", `Bearer ${credentials.access_token}`)\n }\n return request\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAAwC;AACxC,oBAAyD;AACzD,2BAA6B;AAEtB,SAAS,kCAAkC,eAKU;AAC1D,SAAO,eAAe,sBAAsB,SAAS,UAAU;AAC7D,UAAM;AAAA,MACJ,aAAa;AAAA,MACb;AAAA,MACA,cAAc;AAAA,MACd,uBAAuB;AAAA,IACzB,IAAI;AAGJ,QAAI,QAAQ,KAAK,SAAS,qBAAqB,GAAG;AAChD,aAAO;AAAA,IACT;AAEA,QAAI,cAAc,KAAK,MAAM,aAAa,QAAQ,UAAU,KAAK,IAAI;AAKrE;AAAA;AAAA,MAEG,CAAC,aAAa,gBAAgB;AAAA,MAE9B,aAAa,gBACZ,YAAY,eACZ,mCAAa,YAAY,OAAO,KAChC;AAAA,MACF;AACA,UAAI,CAAC,UAAU;AACb,cAAM,IAAI,MAAM,8BAA8B;AAAA,MAChD;AACA,YAAM,eAAe,UAAM,mCAAoB;AAAA,QAC7C,MAAM;AAAA,UACJ,YAAY;AAAA,UACZ,WAAW;AAAA,QACb;AAAA,MACF,CAAC;AAED,UAAI,CAAC,aAAa,MAAM;AACtB,cAAM,IAAI,MAAM,4BAA4B;AAAA,MAC9C;AAEA,oBAAc,aAAa;AAE3B,mBAAa,QAAQ,YAAY,KAAK,UAAU,WAAW,CAAC;AAAA,IAC9D;AAEA,QAAI,aAAa,cAAc;AAC7B,cAAQ,QAAQ,IAAI,iBAAiB,UAAU,YAAY,YAAY,EAAE;AAAA,IAC3E;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,10 @@
1
+ import { Client } from '@hey-api/client-fetch';
2
+
3
+ declare function createAuthLocalStorageInterceptor(createOptions: {
4
+ storageKey?: string;
5
+ clientId: string;
6
+ autoRefresh?: boolean;
7
+ autoStoreCredentials?: boolean;
8
+ }): Parameters<Client["interceptors"]["request"]["use"]>[0];
9
+
10
+ export { createAuthLocalStorageInterceptor };
@@ -0,0 +1,10 @@
1
+ import { Client } from '@hey-api/client-fetch';
2
+
3
+ declare function createAuthLocalStorageInterceptor(createOptions: {
4
+ storageKey?: string;
5
+ clientId: string;
6
+ autoRefresh?: boolean;
7
+ autoStoreCredentials?: boolean;
8
+ }): Parameters<Client["interceptors"]["request"]["use"]>[0];
9
+
10
+ export { createAuthLocalStorageInterceptor };
@@ -0,0 +1,45 @@
1
+ import { CREDENTIALS_STORAGE_KEY } from "../constants/credentials.mjs";
2
+ import { createAnAccessToken } from "../client/index.mjs";
3
+ import { tokenExpired } from "../utils/token-expired.mjs";
4
+ function createAuthLocalStorageInterceptor(createOptions) {
5
+ return async function authCookieInterceptor(request, _options) {
6
+ const {
7
+ storageKey = CREDENTIALS_STORAGE_KEY,
8
+ clientId,
9
+ autoRefresh = true,
10
+ autoStoreCredentials = true
11
+ } = createOptions;
12
+ if (request.url?.includes("/oauth/access_token")) {
13
+ return request;
14
+ }
15
+ let credentials = JSON.parse(localStorage.getItem(storageKey) ?? "{}");
16
+ if (
17
+ // We don't have a token and auto-storing is enabled
18
+ !credentials?.access_token && autoStoreCredentials || // OR token exists but is expired and auto-refresh is enabled
19
+ credentials?.access_token && credentials.expires && tokenExpired(credentials.expires) && autoRefresh
20
+ ) {
21
+ if (!clientId) {
22
+ throw new Error("Missing storefront client id");
23
+ }
24
+ const authResponse = await createAnAccessToken({
25
+ body: {
26
+ grant_type: "implicit",
27
+ client_id: clientId
28
+ }
29
+ });
30
+ if (!authResponse.data) {
31
+ throw new Error("Failed to get access token");
32
+ }
33
+ credentials = authResponse.data;
34
+ localStorage.setItem(storageKey, JSON.stringify(credentials));
35
+ }
36
+ if (credentials?.access_token) {
37
+ request.headers.set("Authorization", `Bearer ${credentials.access_token}`);
38
+ }
39
+ return request;
40
+ };
41
+ }
42
+ export {
43
+ createAuthLocalStorageInterceptor
44
+ };
45
+ //# sourceMappingURL=auth-local-storage-interceptor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/interceptors/auth-local-storage-interceptor.ts"],"sourcesContent":["import { Client } from \"@hey-api/client-fetch\"\nimport { CREDENTIALS_STORAGE_KEY } from \"../constants/credentials\"\nimport { AccessTokenResponse, createAnAccessToken } from \"../client\"\nimport { tokenExpired } from \"../utils/token-expired\"\n\nexport function createAuthLocalStorageInterceptor(createOptions: {\n storageKey?: string\n clientId: string\n autoRefresh?: boolean\n autoStoreCredentials?: boolean\n}): Parameters<Client[\"interceptors\"][\"request\"][\"use\"]>[0] {\n return async function authCookieInterceptor(request, _options) {\n const {\n storageKey = CREDENTIALS_STORAGE_KEY,\n clientId,\n autoRefresh = true,\n autoStoreCredentials = true,\n } = createOptions\n\n // Bypass interceptor logic for token requests to prevent infinite loop\n if (request.url?.includes(\"/oauth/access_token\")) {\n return request\n }\n\n let credentials = JSON.parse(localStorage.getItem(storageKey) ?? \"{}\") as\n | AccessTokenResponse\n | undefined\n\n // Create a new token if...\n if (\n // We don't have a token and auto-storing is enabled\n (!credentials?.access_token && autoStoreCredentials) ||\n // OR token exists but is expired and auto-refresh is enabled\n (credentials?.access_token &&\n credentials.expires &&\n tokenExpired(credentials.expires) &&\n autoRefresh)\n ) {\n if (!clientId) {\n throw new Error(\"Missing storefront client id\")\n }\n const authResponse = await createAnAccessToken({\n body: {\n grant_type: \"implicit\",\n client_id: clientId,\n },\n })\n\n if (!authResponse.data) {\n throw new Error(\"Failed to get access token\")\n }\n\n credentials = authResponse.data\n // Store the credentials in localStorage\n localStorage.setItem(storageKey, JSON.stringify(credentials))\n }\n\n if (credentials?.access_token) {\n request.headers.set(\"Authorization\", `Bearer ${credentials.access_token}`)\n }\n return request\n }\n}\n"],"mappings":"AACA,SAAS,+BAA+B;AACxC,SAA8B,2BAA2B;AACzD,SAAS,oBAAoB;AAEtB,SAAS,kCAAkC,eAKU;AAC1D,SAAO,eAAe,sBAAsB,SAAS,UAAU;AAC7D,UAAM;AAAA,MACJ,aAAa;AAAA,MACb;AAAA,MACA,cAAc;AAAA,MACd,uBAAuB;AAAA,IACzB,IAAI;AAGJ,QAAI,QAAQ,KAAK,SAAS,qBAAqB,GAAG;AAChD,aAAO;AAAA,IACT;AAEA,QAAI,cAAc,KAAK,MAAM,aAAa,QAAQ,UAAU,KAAK,IAAI;AAKrE;AAAA;AAAA,MAEG,CAAC,aAAa,gBAAgB;AAAA,MAE9B,aAAa,gBACZ,YAAY,WACZ,aAAa,YAAY,OAAO,KAChC;AAAA,MACF;AACA,UAAI,CAAC,UAAU;AACb,cAAM,IAAI,MAAM,8BAA8B;AAAA,MAChD;AACA,YAAM,eAAe,MAAM,oBAAoB;AAAA,QAC7C,MAAM;AAAA,UACJ,YAAY;AAAA,UACZ,WAAW;AAAA,QACb;AAAA,MACF,CAAC;AAED,UAAI,CAAC,aAAa,MAAM;AACtB,cAAM,IAAI,MAAM,4BAA4B;AAAA,MAC9C;AAEA,oBAAc,aAAa;AAE3B,mBAAa,QAAQ,YAAY,KAAK,UAAU,WAAW,CAAC;AAAA,IAC9D;AAEA,QAAI,aAAa,cAAc;AAC7B,cAAQ,QAAQ,IAAI,iBAAiB,UAAU,YAAY,YAAY,EAAE;AAAA,IAC3E;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var interceptors_exports = {};
17
+ module.exports = __toCommonJS(interceptors_exports);
18
+ __reExport(interceptors_exports, require('./auth-local-storage-interceptor.cjs'), module.exports);
19
+ // Annotate the CommonJS export names for ESM import in node:
20
+ 0 && (module.exports = {
21
+ ...require('./auth-local-storage-interceptor.cjs')
22
+ });
23
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/interceptors/index.ts"],"sourcesContent":["export * from \"./auth-local-storage-interceptor\"\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iCAAc,6CAAd;","names":[]}
@@ -0,0 +1,2 @@
1
+ export { createAuthLocalStorageInterceptor } from './auth-local-storage-interceptor.cjs';
2
+ import '@hey-api/client-fetch';
@@ -0,0 +1,2 @@
1
+ export { createAuthLocalStorageInterceptor } from './auth-local-storage-interceptor.js';
2
+ import '@hey-api/client-fetch';
@@ -0,0 +1,2 @@
1
+ export * from "./auth-local-storage-interceptor.mjs";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/interceptors/index.ts"],"sourcesContent":["export * from \"./auth-local-storage-interceptor\"\n"],"mappings":"AAAA,cAAc;","names":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var import_jest_dom = require("@testing-library/jest-dom");
3
+ var import_vitest = require("vitest");
4
+ const localStorageMock = (() => {
5
+ let store = {};
6
+ return {
7
+ getItem: import_vitest.vi.fn((key) => store[key] || null),
8
+ setItem: import_vitest.vi.fn((key, value) => {
9
+ store[key] = value;
10
+ }),
11
+ clear: import_vitest.vi.fn(() => {
12
+ store = {};
13
+ }),
14
+ removeItem: import_vitest.vi.fn((key) => {
15
+ delete store[key];
16
+ }),
17
+ key: import_vitest.vi.fn((idx) => Object.keys(store)[idx] || null),
18
+ length: 0
19
+ };
20
+ })();
21
+ beforeEach(() => {
22
+ import_vitest.vi.resetAllMocks();
23
+ Object.defineProperty(window, "localStorage", { value: localStorageMock });
24
+ localStorageMock.clear();
25
+ });
26
+ import_vitest.vi.stubGlobal("localStorage", localStorageMock);
27
+ //# sourceMappingURL=setup.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test/setup.ts"],"sourcesContent":["import \"@testing-library/jest-dom\"\nimport { vi } from \"vitest\"\n\n// Setup global localStorage mock\nconst localStorageMock = (() => {\n let store: Record<string, string> = {}\n return {\n getItem: vi.fn((key: string) => store[key] || null),\n setItem: vi.fn((key: string, value: string) => {\n store[key] = value\n }),\n clear: vi.fn(() => {\n store = {}\n }),\n removeItem: vi.fn((key: string) => {\n delete store[key]\n }),\n key: vi.fn((idx: number) => Object.keys(store)[idx] || null),\n length: 0,\n }\n})()\n\nbeforeEach(() => {\n vi.resetAllMocks()\n // Setup localStorage mock\n Object.defineProperty(window, \"localStorage\", { value: localStorageMock })\n localStorageMock.clear()\n})\n\n// Make localStorage mock available globally for tests\nvi.stubGlobal(\"localStorage\", localStorageMock)\n"],"mappings":";AAAA,sBAAO;AACP,oBAAmB;AAGnB,MAAM,oBAAoB,MAAM;AAC9B,MAAI,QAAgC,CAAC;AACrC,SAAO;AAAA,IACL,SAAS,iBAAG,GAAG,CAAC,QAAgB,MAAM,GAAG,KAAK,IAAI;AAAA,IAClD,SAAS,iBAAG,GAAG,CAAC,KAAa,UAAkB;AAC7C,YAAM,GAAG,IAAI;AAAA,IACf,CAAC;AAAA,IACD,OAAO,iBAAG,GAAG,MAAM;AACjB,cAAQ,CAAC;AAAA,IACX,CAAC;AAAA,IACD,YAAY,iBAAG,GAAG,CAAC,QAAgB;AACjC,aAAO,MAAM,GAAG;AAAA,IAClB,CAAC;AAAA,IACD,KAAK,iBAAG,GAAG,CAAC,QAAgB,OAAO,KAAK,KAAK,EAAE,GAAG,KAAK,IAAI;AAAA,IAC3D,QAAQ;AAAA,EACV;AACF,GAAG;AAEH,WAAW,MAAM;AACf,mBAAG,cAAc;AAEjB,SAAO,eAAe,QAAQ,gBAAgB,EAAE,OAAO,iBAAiB,CAAC;AACzE,mBAAiB,MAAM;AACzB,CAAC;AAGD,iBAAG,WAAW,gBAAgB,gBAAgB;","names":[]}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,26 @@
1
+ import "@testing-library/jest-dom";
2
+ import { vi } from "vitest";
3
+ const localStorageMock = (() => {
4
+ let store = {};
5
+ return {
6
+ getItem: vi.fn((key) => store[key] || null),
7
+ setItem: vi.fn((key, value) => {
8
+ store[key] = value;
9
+ }),
10
+ clear: vi.fn(() => {
11
+ store = {};
12
+ }),
13
+ removeItem: vi.fn((key) => {
14
+ delete store[key];
15
+ }),
16
+ key: vi.fn((idx) => Object.keys(store)[idx] || null),
17
+ length: 0
18
+ };
19
+ })();
20
+ beforeEach(() => {
21
+ vi.resetAllMocks();
22
+ Object.defineProperty(window, "localStorage", { value: localStorageMock });
23
+ localStorageMock.clear();
24
+ });
25
+ vi.stubGlobal("localStorage", localStorageMock);
26
+ //# sourceMappingURL=setup.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test/setup.ts"],"sourcesContent":["import \"@testing-library/jest-dom\"\nimport { vi } from \"vitest\"\n\n// Setup global localStorage mock\nconst localStorageMock = (() => {\n let store: Record<string, string> = {}\n return {\n getItem: vi.fn((key: string) => store[key] || null),\n setItem: vi.fn((key: string, value: string) => {\n store[key] = value\n }),\n clear: vi.fn(() => {\n store = {}\n }),\n removeItem: vi.fn((key: string) => {\n delete store[key]\n }),\n key: vi.fn((idx: number) => Object.keys(store)[idx] || null),\n length: 0,\n }\n})()\n\nbeforeEach(() => {\n vi.resetAllMocks()\n // Setup localStorage mock\n Object.defineProperty(window, \"localStorage\", { value: localStorageMock })\n localStorageMock.clear()\n})\n\n// Make localStorage mock available globally for tests\nvi.stubGlobal(\"localStorage\", localStorageMock)\n"],"mappings":"AAAA,OAAO;AACP,SAAS,UAAU;AAGnB,MAAM,oBAAoB,MAAM;AAC9B,MAAI,QAAgC,CAAC;AACrC,SAAO;AAAA,IACL,SAAS,GAAG,GAAG,CAAC,QAAgB,MAAM,GAAG,KAAK,IAAI;AAAA,IAClD,SAAS,GAAG,GAAG,CAAC,KAAa,UAAkB;AAC7C,YAAM,GAAG,IAAI;AAAA,IACf,CAAC;AAAA,IACD,OAAO,GAAG,GAAG,MAAM;AACjB,cAAQ,CAAC;AAAA,IACX,CAAC;AAAA,IACD,YAAY,GAAG,GAAG,CAAC,QAAgB;AACjC,aAAO,MAAM,GAAG;AAAA,IAClB,CAAC;AAAA,IACD,KAAK,GAAG,GAAG,CAAC,QAAgB,OAAO,KAAK,KAAK,EAAE,GAAG,KAAK,IAAI;AAAA,IAC3D,QAAQ;AAAA,EACV;AACF,GAAG;AAEH,WAAW,MAAM;AACf,KAAG,cAAc;AAEjB,SAAO,eAAe,QAAQ,gBAAgB,EAAE,OAAO,iBAAiB,CAAC;AACzE,mBAAiB,MAAM;AACzB,CAAC;AAGD,GAAG,WAAW,gBAAgB,gBAAgB;","names":[]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var get_cart_id_exports = {};
20
+ __export(get_cart_id_exports, {
21
+ getCartId: () => getCartId
22
+ });
23
+ module.exports = __toCommonJS(get_cart_id_exports);
24
+ var import_initialize_cart = require('./initialize-cart.cjs');
25
+ function getCartId() {
26
+ return localStorage.getItem(import_initialize_cart.PERSISTED_CART_STORAGE_KEY);
27
+ }
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ getCartId
31
+ });
32
+ //# sourceMappingURL=get-cart-id.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/get-cart-id.ts"],"sourcesContent":["import { PERSISTED_CART_STORAGE_KEY } from \"./initialize-cart\"\n\nexport function getCartId() {\n return localStorage.getItem(PERSISTED_CART_STORAGE_KEY)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAA2C;AAEpC,SAAS,YAAY;AAC1B,SAAO,aAAa,QAAQ,iDAA0B;AACxD;","names":[]}
@@ -0,0 +1,3 @@
1
+ declare function getCartId(): string | null;
2
+
3
+ export { getCartId };
@@ -0,0 +1,3 @@
1
+ declare function getCartId(): string | null;
2
+
3
+ export { getCartId };
@@ -0,0 +1,8 @@
1
+ import { PERSISTED_CART_STORAGE_KEY } from "./initialize-cart.mjs";
2
+ function getCartId() {
3
+ return localStorage.getItem(PERSISTED_CART_STORAGE_KEY);
4
+ }
5
+ export {
6
+ getCartId
7
+ };
8
+ //# sourceMappingURL=get-cart-id.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/get-cart-id.ts"],"sourcesContent":["import { PERSISTED_CART_STORAGE_KEY } from \"./initialize-cart\"\n\nexport function getCartId() {\n return localStorage.getItem(PERSISTED_CART_STORAGE_KEY)\n}\n"],"mappings":"AAAA,SAAS,kCAAkC;AAEpC,SAAS,YAAY;AAC1B,SAAO,aAAa,QAAQ,0BAA0B;AACxD;","names":[]}
@@ -19,14 +19,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var utils_exports = {};
20
20
  __export(utils_exports, {
21
21
  extractProductImage: () => import_extract_product_image.extractProductImage,
22
- extractProductMedia: () => import_extract_media.extractProductMedia
22
+ extractProductMedia: () => import_extract_media.extractProductMedia,
23
+ getCartId: () => import_get_cart_id.getCartId,
24
+ initializeCart: () => import_initialize_cart.initializeCart
23
25
  });
24
26
  module.exports = __toCommonJS(utils_exports);
25
27
  var import_extract_product_image = require('./extract-product-image.cjs');
26
28
  var import_extract_media = require('./extract-media.cjs');
29
+ var import_initialize_cart = require('./initialize-cart.cjs');
30
+ var import_get_cart_id = require('./get-cart-id.cjs');
27
31
  // Annotate the CommonJS export names for ESM import in node:
28
32
  0 && (module.exports = {
29
33
  extractProductImage,
30
- extractProductMedia
34
+ extractProductMedia,
35
+ getCartId,
36
+ initializeCart
31
37
  });
32
38
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export { extractProductImage } from \"./extract-product-image\"\nexport { extractProductMedia } from \"./extract-media\"\nexport type { ExtractedMedia } from \"./extract-media\"\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mCAAoC;AACpC,2BAAoC;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export { extractProductImage } from \"./extract-product-image\"\nexport { extractProductMedia } from \"./extract-media\"\nexport type { ExtractedMedia } from \"./extract-media\"\nexport { initializeCart } from \"./initialize-cart\"\nexport { getCartId } from \"./get-cart-id\"\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mCAAoC;AACpC,2BAAoC;AAEpC,6BAA+B;AAC/B,yBAA0B;","names":[]}
@@ -1,3 +1,5 @@
1
1
  export { extractProductImage } from './extract-product-image.cjs';
2
2
  export { ExtractedMedia, extractProductMedia } from './extract-media.cjs';
3
+ export { initializeCart } from './initialize-cart.cjs';
4
+ export { getCartId } from './get-cart-id.cjs';
3
5
  import '../client/types.gen.cjs';
@@ -1,3 +1,5 @@
1
1
  export { extractProductImage } from './extract-product-image.js';
2
2
  export { ExtractedMedia, extractProductMedia } from './extract-media.js';
3
+ export { initializeCart } from './initialize-cart.js';
4
+ export { getCartId } from './get-cart-id.js';
3
5
  import '../client/types.gen.js';
@@ -1,7 +1,11 @@
1
1
  import { extractProductImage } from "./extract-product-image.mjs";
2
2
  import { extractProductMedia } from "./extract-media.mjs";
3
+ import { initializeCart } from "./initialize-cart.mjs";
4
+ import { getCartId } from "./get-cart-id.mjs";
3
5
  export {
4
6
  extractProductImage,
5
- extractProductMedia
7
+ extractProductMedia,
8
+ getCartId,
9
+ initializeCart
6
10
  };
7
11
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export { extractProductImage } from \"./extract-product-image\"\nexport { extractProductMedia } from \"./extract-media\"\nexport type { ExtractedMedia } from \"./extract-media\"\n"],"mappings":"AAAA,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export { extractProductImage } from \"./extract-product-image\"\nexport { extractProductMedia } from \"./extract-media\"\nexport type { ExtractedMedia } from \"./extract-media\"\nexport { initializeCart } from \"./initialize-cart\"\nexport { getCartId } from \"./get-cart-id\"\n"],"mappings":"AAAA,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AAEpC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;","names":[]}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var initialize_cart_exports = {};
20
+ __export(initialize_cart_exports, {
21
+ PERSISTED_CART_STORAGE_KEY: () => PERSISTED_CART_STORAGE_KEY,
22
+ initializeCart: () => initializeCart
23
+ });
24
+ module.exports = __toCommonJS(initialize_cart_exports);
25
+ var import_client = require('../client/index.cjs');
26
+ var import_credentials = require('../constants/credentials.cjs');
27
+ let PERSISTED_CART_STORAGE_KEY = import_credentials.CART_STORAGE_KEY;
28
+ async function initializeCart(options) {
29
+ PERSISTED_CART_STORAGE_KEY = options?.storageKey ?? PERSISTED_CART_STORAGE_KEY;
30
+ let cartId = localStorage.getItem(PERSISTED_CART_STORAGE_KEY);
31
+ if (!cartId) {
32
+ const cartResponse = await (0, import_client.createACart)({
33
+ body: {
34
+ data: {
35
+ name: "Storefront cart",
36
+ description: "Standard cart created by the Storefront SDK"
37
+ }
38
+ }
39
+ });
40
+ if (!cartResponse.data?.data?.id) {
41
+ throw new Error("Failed to create cart");
42
+ }
43
+ cartId = cartResponse.data.data.id;
44
+ localStorage.setItem(PERSISTED_CART_STORAGE_KEY, cartId);
45
+ }
46
+ return cartId;
47
+ }
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ PERSISTED_CART_STORAGE_KEY,
51
+ initializeCart
52
+ });
53
+ //# sourceMappingURL=initialize-cart.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/initialize-cart.ts"],"sourcesContent":["import { createACart } from \"../client\"\nimport { CART_STORAGE_KEY } from \"../constants/credentials\"\n\nexport let PERSISTED_CART_STORAGE_KEY = CART_STORAGE_KEY\n\n/**\n * Initialize a cart and return the cartId\n * @returns {Promise<string>} The cartId\n */\nexport async function initializeCart(options?: {\n storageKey?: string\n}): Promise<string> {\n PERSISTED_CART_STORAGE_KEY = options?.storageKey ?? PERSISTED_CART_STORAGE_KEY\n let cartId = localStorage.getItem(PERSISTED_CART_STORAGE_KEY)\n\n // check if cartId is missing\n if (!cartId) {\n // Create a new cart\n const cartResponse = await createACart({\n body: {\n data: {\n name: \"Storefront cart\",\n description: \"Standard cart created by the Storefront SDK\",\n },\n },\n })\n\n if (!cartResponse.data?.data?.id) {\n throw new Error(\"Failed to create cart\")\n }\n\n cartId = cartResponse.data.data.id\n // Store the cartId in localStorage\n localStorage.setItem(PERSISTED_CART_STORAGE_KEY, cartId)\n }\n\n return cartId\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA4B;AAC5B,yBAAiC;AAE1B,IAAI,6BAA6B;AAMxC,eAAsB,eAAe,SAEjB;AAClB,+BAA6B,SAAS,cAAc;AACpD,MAAI,SAAS,aAAa,QAAQ,0BAA0B;AAG5D,MAAI,CAAC,QAAQ;AAEX,UAAM,eAAe,UAAM,2BAAY;AAAA,MACrC,MAAM;AAAA,QACJ,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,MACF;AAAA,IACF,CAAC;AAED,QAAI,CAAC,aAAa,MAAM,MAAM,IAAI;AAChC,YAAM,IAAI,MAAM,uBAAuB;AAAA,IACzC;AAEA,aAAS,aAAa,KAAK,KAAK;AAEhC,iBAAa,QAAQ,4BAA4B,MAAM;AAAA,EACzD;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,10 @@
1
+ declare let PERSISTED_CART_STORAGE_KEY: string;
2
+ /**
3
+ * Initialize a cart and return the cartId
4
+ * @returns {Promise<string>} The cartId
5
+ */
6
+ declare function initializeCart(options?: {
7
+ storageKey?: string;
8
+ }): Promise<string>;
9
+
10
+ export { PERSISTED_CART_STORAGE_KEY, initializeCart };
@@ -0,0 +1,10 @@
1
+ declare let PERSISTED_CART_STORAGE_KEY: string;
2
+ /**
3
+ * Initialize a cart and return the cartId
4
+ * @returns {Promise<string>} The cartId
5
+ */
6
+ declare function initializeCart(options?: {
7
+ storageKey?: string;
8
+ }): Promise<string>;
9
+
10
+ export { PERSISTED_CART_STORAGE_KEY, initializeCart };
@@ -0,0 +1,28 @@
1
+ import { createACart } from "../client/index.mjs";
2
+ import { CART_STORAGE_KEY } from "../constants/credentials.mjs";
3
+ let PERSISTED_CART_STORAGE_KEY = CART_STORAGE_KEY;
4
+ async function initializeCart(options) {
5
+ PERSISTED_CART_STORAGE_KEY = options?.storageKey ?? PERSISTED_CART_STORAGE_KEY;
6
+ let cartId = localStorage.getItem(PERSISTED_CART_STORAGE_KEY);
7
+ if (!cartId) {
8
+ const cartResponse = await createACart({
9
+ body: {
10
+ data: {
11
+ name: "Storefront cart",
12
+ description: "Standard cart created by the Storefront SDK"
13
+ }
14
+ }
15
+ });
16
+ if (!cartResponse.data?.data?.id) {
17
+ throw new Error("Failed to create cart");
18
+ }
19
+ cartId = cartResponse.data.data.id;
20
+ localStorage.setItem(PERSISTED_CART_STORAGE_KEY, cartId);
21
+ }
22
+ return cartId;
23
+ }
24
+ export {
25
+ PERSISTED_CART_STORAGE_KEY,
26
+ initializeCart
27
+ };
28
+ //# sourceMappingURL=initialize-cart.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/initialize-cart.ts"],"sourcesContent":["import { createACart } from \"../client\"\nimport { CART_STORAGE_KEY } from \"../constants/credentials\"\n\nexport let PERSISTED_CART_STORAGE_KEY = CART_STORAGE_KEY\n\n/**\n * Initialize a cart and return the cartId\n * @returns {Promise<string>} The cartId\n */\nexport async function initializeCart(options?: {\n storageKey?: string\n}): Promise<string> {\n PERSISTED_CART_STORAGE_KEY = options?.storageKey ?? PERSISTED_CART_STORAGE_KEY\n let cartId = localStorage.getItem(PERSISTED_CART_STORAGE_KEY)\n\n // check if cartId is missing\n if (!cartId) {\n // Create a new cart\n const cartResponse = await createACart({\n body: {\n data: {\n name: \"Storefront cart\",\n description: \"Standard cart created by the Storefront SDK\",\n },\n },\n })\n\n if (!cartResponse.data?.data?.id) {\n throw new Error(\"Failed to create cart\")\n }\n\n cartId = cartResponse.data.data.id\n // Store the cartId in localStorage\n localStorage.setItem(PERSISTED_CART_STORAGE_KEY, cartId)\n }\n\n return cartId\n}\n"],"mappings":"AAAA,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AAE1B,IAAI,6BAA6B;AAMxC,eAAsB,eAAe,SAEjB;AAClB,+BAA6B,SAAS,cAAc;AACpD,MAAI,SAAS,aAAa,QAAQ,0BAA0B;AAG5D,MAAI,CAAC,QAAQ;AAEX,UAAM,eAAe,MAAM,YAAY;AAAA,MACrC,MAAM;AAAA,QACJ,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,MACF;AAAA,IACF,CAAC;AAED,QAAI,CAAC,aAAa,MAAM,MAAM,IAAI;AAChC,YAAM,IAAI,MAAM,uBAAuB;AAAA,IACzC;AAEA,aAAS,aAAa,KAAK,KAAK;AAEhC,iBAAa,QAAQ,4BAA4B,MAAM;AAAA,EACzD;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var token_expired_exports = {};
20
+ __export(token_expired_exports, {
21
+ tokenExpired: () => tokenExpired
22
+ });
23
+ module.exports = __toCommonJS(token_expired_exports);
24
+ function tokenExpired(expires) {
25
+ return Math.floor(Date.now() / 1e3) >= expires;
26
+ }
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ tokenExpired
30
+ });
31
+ //# sourceMappingURL=token-expired.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/token-expired.ts"],"sourcesContent":["export function tokenExpired(expires: number): boolean {\n return Math.floor(Date.now() / 1000) >= expires\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,aAAa,SAA0B;AACrD,SAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,KAAK;AAC1C;","names":[]}
@@ -0,0 +1,3 @@
1
+ declare function tokenExpired(expires: number): boolean;
2
+
3
+ export { tokenExpired };
@@ -0,0 +1,3 @@
1
+ declare function tokenExpired(expires: number): boolean;
2
+
3
+ export { tokenExpired };
@@ -0,0 +1,7 @@
1
+ function tokenExpired(expires) {
2
+ return Math.floor(Date.now() / 1e3) >= expires;
3
+ }
4
+ export {
5
+ tokenExpired
6
+ };
7
+ //# sourceMappingURL=token-expired.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/token-expired.ts"],"sourcesContent":["export function tokenExpired(expires: number): boolean {\n return Math.floor(Date.now() / 1000) >= expires\n}\n"],"mappings":"AAAO,SAAS,aAAa,SAA0B;AACrD,SAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,KAAK;AAC1C;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epcc-sdk/sdks-shopper",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -28,13 +28,16 @@
28
28
  "@redocly/cli": "^1.21.0",
29
29
  "@redocly/openapi-core": "^1.21.0",
30
30
  "@tanstack/react-query": "^5.69.0",
31
+ "@testing-library/jest-dom": "6.6.3",
31
32
  "@types/ejs": "^3.1.5",
32
33
  "ejs": "^3.1.10",
33
34
  "esbuild-fix-imports-plugin": "^1.0.19",
34
35
  "esbuild-plugin-file-path-extensions": "^1.0.0",
36
+ "jsdom": "26.1.0",
35
37
  "lodash": "^4.17.21",
36
38
  "tsup": "^8.4.0",
37
- "typescript": "^5.5.3"
39
+ "typescript": "^5.5.3",
40
+ "vitest": "3.1.4"
38
41
  },
39
42
  "dependencies": {
40
43
  "@hey-api/client-fetch": "0.6.0"
@@ -59,6 +62,9 @@
59
62
  "oas:redocly:lint": "redocly lint --config ../specs/config/redocly.yaml",
60
63
  "oas:redocly:join:shopper": "redocly join --config ../specs/config/redocly.yaml --output ../specs/shopper.yaml ../specs/bundled/catalog_view_3.1.yaml ../specs/bundled/cart_checkout.yaml ../specs/bundled/subscriptions_3.1.yaml ../specs/bundled/inventories_3.1.yaml ../specs/bundled/authentication.yaml ../specs/bundled/account-addresses.yaml ../specs/bundled/account_management.yaml ../specs/bundled/authentication-realms.yaml ../specs/bundled/currencies.yaml ../specs/bundled/files.yaml",
61
64
  "oas:redocly:bundle": "redocly bundle --config ../specs/config/redocly.yaml",
62
- "oas:openapi-format:convert": "pnpm dlx openapi-format ../specs/bundled/catalog_view.yaml -o ../specs/bundled/catalog_view_3.1.yaml --convertTo \"3.1\" && pnpm dlx openapi-format ../specs/bundled/subscriptions.yaml -o ../specs/bundled/subscriptions_3.1.yaml --convertTo \"3.1\" && pnpm dlx openapi-format ../specs/bundled/inventories.yaml -o ../specs/bundled/inventories_3.1.yaml --convertTo \"3.1\""
65
+ "oas:openapi-format:convert": "pnpm dlx openapi-format ../specs/bundled/catalog_view.yaml -o ../specs/bundled/catalog_view_3.1.yaml --convertTo \"3.1\" && pnpm dlx openapi-format ../specs/bundled/subscriptions.yaml -o ../specs/bundled/subscriptions_3.1.yaml --convertTo \"3.1\" && pnpm dlx openapi-format ../specs/bundled/inventories.yaml -o ../specs/bundled/inventories_3.1.yaml --convertTo \"3.1\"",
66
+ "test": "vitest run",
67
+ "test:watch": "vitest",
68
+ "test:coverage": "vitest run --coverage"
63
69
  }
64
70
  }