@lana-commerce/core 11.0.0
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/CHANGELOG.md +531 -0
- package/cjs/actionLock.js +31 -0
- package/cjs/addEmptyListItem.js +7 -0
- package/cjs/aggregateOptions.js +178 -0
- package/cjs/analytics.js +90 -0
- package/cjs/analyticsProductData.js +33 -0
- package/cjs/arrayToDict.js +12 -0
- package/cjs/asyncModuleWrapper.js +52 -0
- package/cjs/averageReviewScore.js +45 -0
- package/cjs/buildconfig.js +16 -0
- package/cjs/cachedLoader.js +36 -0
- package/cjs/canonicalVariantURL.js +2 -0
- package/cjs/cartOperation.js +132 -0
- package/cjs/categorySEO.js +20 -0
- package/cjs/commonTypes.js +2 -0
- package/cjs/compact.js +8 -0
- package/cjs/configLoader.js +69 -0
- package/cjs/controlledQueue.js +46 -0
- package/cjs/convertImageURL.js +19 -0
- package/cjs/dataLoader.js +185 -0
- package/cjs/defaultVariant.js +30 -0
- package/cjs/effector/clearOnChangeAfterDelay.js +17 -0
- package/cjs/effector/combineEvery.js +8 -0
- package/cjs/effector/combineSome.js +8 -0
- package/cjs/effector/debounced.js +18 -0
- package/cjs/effector/form.js +168 -0
- package/cjs/effector/hideOnChangeAfterDelay.js +17 -0
- package/cjs/effector/requestResponse.js +30 -0
- package/cjs/effector/requestResponseMulti.js +51 -0
- package/cjs/effector/restoreNamed.js +8 -0
- package/cjs/effector/split.js +29 -0
- package/cjs/effector/validator.js +33 -0
- package/cjs/effector/wrapSignInRequired.js +13 -0
- package/cjs/exceptions.js +6 -0
- package/cjs/fetchAllItems.js +56 -0
- package/cjs/file.js +83 -0
- package/cjs/fileWebsocket.js +83 -0
- package/cjs/filterFunc.js +48 -0
- package/cjs/filterFuncBrand.js +12 -0
- package/cjs/filterFuncCategory.js +12 -0
- package/cjs/filterFuncContentBlock.js +19 -0
- package/cjs/filterFuncCustomer.js +161 -0
- package/cjs/filterFuncDataFeed.js +54 -0
- package/cjs/filterFuncOrder.js +334 -0
- package/cjs/filterFuncPreprocess.js +14 -0
- package/cjs/filterFuncProduct.js +70 -0
- package/cjs/filterFuncPurchaseOrder.js +126 -0
- package/cjs/filterFuncSupplier.js +36 -0
- package/cjs/filterFuncTransfer.js +135 -0
- package/cjs/formatAbbrevNumber.js +21 -0
- package/cjs/formatCurrency.js +47 -0
- package/cjs/formatToJSX.js +123 -0
- package/cjs/fulfillmentNumber.js +7 -0
- package/cjs/generateRandomToken.js +12 -0
- package/cjs/generateUUID.js +10 -0
- package/cjs/generated/codes.js +47 -0
- package/cjs/genericFile.js +73 -0
- package/cjs/getSalesChannelID.js +13 -0
- package/cjs/getSessionID.js +13 -0
- package/cjs/getTimezone.js +12 -0
- package/cjs/graphql/fragments/Branding.js +3 -0
- package/cjs/graphql/fragments/BrandingField.js +3 -0
- package/cjs/graphql/fragments/CartCustomItem.js +3 -0
- package/cjs/graphql/fragments/CartOrder.js +3 -0
- package/cjs/graphql/fragments/CartVariant.js +3 -0
- package/cjs/graphql/fragments/CartVariantFull.js +3 -0
- package/cjs/graphql/fragments/Category.js +3 -0
- package/cjs/graphql/fragments/CommonCartVariant.js +3 -0
- package/cjs/graphql/fragments/Currency.js +3 -0
- package/cjs/graphql/fragments/CurrencyPrice.js +3 -0
- package/cjs/graphql/fragments/CustomField.js +3 -0
- package/cjs/graphql/fragments/CustomFieldObjects.js +3 -0
- package/cjs/graphql/fragments/Customer.js +3 -0
- package/cjs/graphql/fragments/CustomerBalance.js +3 -0
- package/cjs/graphql/fragments/CustomerBalanceHistory.js +3 -0
- package/cjs/graphql/fragments/CustomerFavorite.js +3 -0
- package/cjs/graphql/fragments/CustomerFavoriteShort.js +3 -0
- package/cjs/graphql/fragments/CustomerOAuthProvider.js +3 -0
- package/cjs/graphql/fragments/CustomerOrderBrief.js +3 -0
- package/cjs/graphql/fragments/CustomerOrderFulfillment.js +3 -0
- package/cjs/graphql/fragments/CustomerOrderFull.js +3 -0
- package/cjs/graphql/fragments/CustomerPaymentSource.js +3 -0
- package/cjs/graphql/fragments/CustomerReturnBrief.js +3 -0
- package/cjs/graphql/fragments/CustomerReturnFull.js +3 -0
- package/cjs/graphql/fragments/CustomerReturnPolicy.js +3 -0
- package/cjs/graphql/fragments/CustomerSubscriptionBrief.js +3 -0
- package/cjs/graphql/fragments/CustomerSubscriptionFull.js +3 -0
- package/cjs/graphql/fragments/File.js +3 -0
- package/cjs/graphql/fragments/FileForUpload.js +3 -0
- package/cjs/graphql/fragments/FileNoFallback.js +3 -0
- package/cjs/graphql/fragments/FullAddress.js +3 -0
- package/cjs/graphql/fragments/Gateway.js +3 -0
- package/cjs/graphql/fragments/GatewayManual.js +3 -0
- package/cjs/graphql/fragments/GatewayPaypal.js +3 -0
- package/cjs/graphql/fragments/GatewayStripe.js +3 -0
- package/cjs/graphql/fragments/GatewayTest.js +3 -0
- package/cjs/graphql/fragments/IPAndUAInfo.js +3 -0
- package/cjs/graphql/fragments/InfoCountry.js +3 -0
- package/cjs/graphql/fragments/InfoCountryDedupField.js +3 -0
- package/cjs/graphql/fragments/InfoCurrency.js +3 -0
- package/cjs/graphql/fragments/InfoProvince.js +3 -0
- package/cjs/graphql/fragments/KeyValue.js +3 -0
- package/cjs/graphql/fragments/LineItemField.js +3 -0
- package/cjs/graphql/fragments/MediaFile.js +3 -0
- package/cjs/graphql/fragments/MinCurrencyPrice.js +3 -0
- package/cjs/graphql/fragments/ProductField.js +3 -0
- package/cjs/graphql/fragments/ProductFieldSet.js +3 -0
- package/cjs/graphql/fragments/ProductFlat.js +3 -0
- package/cjs/graphql/fragments/ProductQuestion.js +3 -0
- package/cjs/graphql/fragments/ProductQuestionAnswer.js +3 -0
- package/cjs/graphql/fragments/ProductQuestionPage.js +3 -0
- package/cjs/graphql/fragments/ProductReview.js +3 -0
- package/cjs/graphql/fragments/ProductReviewAnswer.js +3 -0
- package/cjs/graphql/fragments/ProductReviewAverageScore.js +3 -0
- package/cjs/graphql/fragments/ProductReviewPage.js +3 -0
- package/cjs/graphql/fragments/ProductReviewScore.js +3 -0
- package/cjs/graphql/fragments/ProductReviewSurveyAnswer.js +3 -0
- package/cjs/graphql/fragments/ProductSearchOptionAgg.js +3 -0
- package/cjs/graphql/fragments/ProductSearchResult.js +3 -0
- package/cjs/graphql/fragments/ReturnReason.js +3 -0
- package/cjs/graphql/fragments/ReviewDimension.js +3 -0
- package/cjs/graphql/fragments/ReviewDimensionSet.js +3 -0
- package/cjs/graphql/fragments/ReviewImagePage.js +3 -0
- package/cjs/graphql/fragments/ReviewQuestionProduct.js +3 -0
- package/cjs/graphql/fragments/ReviewSettings.js +3 -0
- package/cjs/graphql/fragments/SearchProduct.js +3 -0
- package/cjs/graphql/fragments/Shop.js +3 -0
- package/cjs/graphql/fragments/SubscriptionPlan.js +3 -0
- package/cjs/graphql/fragments/SurveyQuestion.js +3 -0
- package/cjs/graphql/fragments/TieredPricing.js +3 -0
- package/cjs/graphql/fragments/TieredPricingTier.js +3 -0
- package/cjs/graphql/fragments/VariantOption.js +3 -0
- package/cjs/graphql/operations/ApplyGiftCardMutation.js +3 -0
- package/cjs/graphql/operations/AuthRequestMutation.js +3 -0
- package/cjs/graphql/operations/CancelOrderMutation.js +3 -0
- package/cjs/graphql/operations/CancelSubscriptionMutation.js +3 -0
- package/cjs/graphql/operations/ConnectOAuth2Mutation.js +3 -0
- package/cjs/graphql/operations/CreateCartMutation.js +26 -0
- package/cjs/graphql/operations/CreateFavoriteMutation.js +22 -0
- package/cjs/graphql/operations/CreateFileMutation.js +6 -0
- package/cjs/graphql/operations/CreatePaymentSourceMutation.js +6 -0
- package/cjs/graphql/operations/CreateProductQuestionAnswerMutation.js +3 -0
- package/cjs/graphql/operations/CreateProductQuestionMutation.js +8 -0
- package/cjs/graphql/operations/CreateProductReviewMutation.js +18 -0
- package/cjs/graphql/operations/CreateReturnMutation.js +22 -0
- package/cjs/graphql/operations/DeleteFavoriteMutation.js +3 -0
- package/cjs/graphql/operations/DeletePaymentSourceMutation.js +3 -0
- package/cjs/graphql/operations/DeleteProductQuestionAnswerMutation.js +3 -0
- package/cjs/graphql/operations/DeleteProductQuestionMutation.js +3 -0
- package/cjs/graphql/operations/DeleteProductReviewMutation.js +3 -0
- package/cjs/graphql/operations/DisconnectOAuth2Mutation.js +3 -0
- package/cjs/graphql/operations/EditSubscriptionMutation.js +3 -0
- package/cjs/graphql/operations/FileUploadedMutation.js +6 -0
- package/cjs/graphql/operations/FlagQuestionAnswerMutation.js +3 -0
- package/cjs/graphql/operations/FlagQuestionMutation.js +3 -0
- package/cjs/graphql/operations/FlagReviewAnswerMutation.js +3 -0
- package/cjs/graphql/operations/FlagReviewMutation.js +3 -0
- package/cjs/graphql/operations/GetBrandingQuery.js +10 -0
- package/cjs/graphql/operations/GetCartQuery.js +26 -0
- package/cjs/graphql/operations/GetCustomerAddressesPageDataQuery.js +16 -0
- package/cjs/graphql/operations/GetCustomerBalanceHistoryPageQuery.js +6 -0
- package/cjs/graphql/operations/GetCustomerBalanceQuery.js +8 -0
- package/cjs/graphql/operations/GetCustomerInfoQuery.js +10 -0
- package/cjs/graphql/operations/GetCustomerQuery.js +8 -0
- package/cjs/graphql/operations/GetFavoritesQuery.js +22 -0
- package/cjs/graphql/operations/GetFileStatusQuery.js +6 -0
- package/cjs/graphql/operations/GetGatewaysQuery.js +14 -0
- package/cjs/graphql/operations/GetInfoCurrenciesQuery.js +6 -0
- package/cjs/graphql/operations/GetLastCartQuery.js +26 -0
- package/cjs/graphql/operations/GetOrderQuery.js +30 -0
- package/cjs/graphql/operations/GetOrdersPageQuery.js +24 -0
- package/cjs/graphql/operations/GetPaymentMethodsPageDataQuery.js +18 -0
- package/cjs/graphql/operations/GetProductQuestionsPageQuery.js +10 -0
- package/cjs/graphql/operations/GetProductReviewImagesPageQuery.js +8 -0
- package/cjs/graphql/operations/GetProductReviewsPageQuery.js +20 -0
- package/cjs/graphql/operations/GetProvincesQuery.js +6 -0
- package/cjs/graphql/operations/GetQuestionQuery.js +8 -0
- package/cjs/graphql/operations/GetReturnCreationInfoQuery.js +36 -0
- package/cjs/graphql/operations/GetReturnQuery.js +28 -0
- package/cjs/graphql/operations/GetReturnsPageQuery.js +22 -0
- package/cjs/graphql/operations/GetReviewDimensionsQuery.js +6 -0
- package/cjs/graphql/operations/GetReviewQuery.js +18 -0
- package/cjs/graphql/operations/GetReviewSettingsQuery.js +12 -0
- package/cjs/graphql/operations/GetShopCurrenciesQuery.js +6 -0
- package/cjs/graphql/operations/GetShopQuery.js +8 -0
- package/cjs/graphql/operations/GetSubscriptionQuery.js +36 -0
- package/cjs/graphql/operations/GetSubscriptionsPageQuery.js +22 -0
- package/cjs/graphql/operations/GetVariantPageQuery.js +20 -0
- package/cjs/graphql/operations/LoadProductNoCustomerQuery.js +62 -0
- package/cjs/graphql/operations/LoadProductQuery.js +66 -0
- package/cjs/graphql/operations/ModifyCartMutation.js +26 -0
- package/cjs/graphql/operations/ModifyCustomerMutation.js +8 -0
- package/cjs/graphql/operations/ModifyFavoriteMutation.js +22 -0
- package/cjs/graphql/operations/ModifyProductQuestionAnswerMutation.js +3 -0
- package/cjs/graphql/operations/ModifyProductQuestionMutation.js +8 -0
- package/cjs/graphql/operations/ModifyProductReviewMutation.js +18 -0
- package/cjs/graphql/operations/NewPasswordMutation.js +3 -0
- package/cjs/graphql/operations/PauseSubscriptionMutation.js +3 -0
- package/cjs/graphql/operations/ResetPasswordMutation.js +3 -0
- package/cjs/graphql/operations/ResumeSubscriptionMutation.js +3 -0
- package/cjs/graphql/operations/SearchProductsAdvancedQuery.js +24 -0
- package/cjs/graphql/operations/SearchProductsQuery.js +20 -0
- package/cjs/graphql/operations/SearchQuestionsQuery.js +8 -0
- package/cjs/graphql/operations/SearchReviewsQuery.js +18 -0
- package/cjs/graphql/operations/SignInMutation.js +3 -0
- package/cjs/graphql/operations/SignInViaEmailCompleteMutation.js +3 -0
- package/cjs/graphql/operations/SignInViaEmailInitMutation.js +3 -0
- package/cjs/graphql/operations/SignUpMutation.js +3 -0
- package/cjs/graphql/operations/SkipNextSubscriptionMutation.js +3 -0
- package/cjs/graphql/operations/UploadFileMutation.js +3 -0
- package/cjs/graphql/operations/VerifyCodeMutation.js +3 -0
- package/cjs/graphql/operations/VoteQuestionAnswerMutation.js +3 -0
- package/cjs/graphql/operations/VoteQuestionMutation.js +3 -0
- package/cjs/graphql/operations/VoteReviewAnswerMutation.js +3 -0
- package/cjs/graphql/operations/VoteReviewMutation.js +3 -0
- package/cjs/graphql/types.js +2 -0
- package/cjs/hierarchicalSearchOption.js +42 -0
- package/cjs/idgen.js +8 -0
- package/cjs/ignoreQueue.js +50 -0
- package/cjs/imageAltProps.js +13 -0
- package/cjs/invoiceFormat.js +59 -0
- package/cjs/isShippingRequired.js +20 -0
- package/cjs/isoStripTrailingZeros.js +7 -0
- package/cjs/json/commerce.js +10 -0
- package/cjs/json/commerceFileUpload.js +57 -0
- package/cjs/json/commerceTypes.js +2 -0
- package/cjs/json/common.js +320 -0
- package/cjs/json/fetchAllItems.js +61 -0
- package/cjs/json/mutator.js +957 -0
- package/cjs/json/storefront.js +10 -0
- package/cjs/json/storefrontTypes.js +2 -0
- package/cjs/lastValue.js +17 -0
- package/cjs/lineItemPrice.js +111 -0
- package/cjs/loadJWT.js +25 -0
- package/cjs/mapInvalidInput.js +33 -0
- package/cjs/mapResponseData.js +16 -0
- package/cjs/mapResponseMultiData.js +14 -0
- package/cjs/meanBy.js +15 -0
- package/cjs/media.js +16 -0
- package/cjs/modules/advancedSearch.js +127 -0
- package/cjs/modules/cart.js +708 -0
- package/cjs/modules/config/defaultAdvancedSearchGraphQLConfig.js +8 -0
- package/cjs/modules/config/defaultCartGraphQLConfig.js +14 -0
- package/cjs/modules/config/defaultProductGraphQLConfig.js +48 -0
- package/cjs/modules/config/defaultSearchGraphQLConfig.js +8 -0
- package/cjs/modules/customer.js +2174 -0
- package/cjs/modules/helpers/cartInitOption.js +22 -0
- package/cjs/modules/helpers/cookieConsent.js +33 -0
- package/cjs/modules/helpers/customerOauth2.js +64 -0
- package/cjs/modules/helpers/getOAuth2Hook.js +52 -0
- package/cjs/modules/helpers/hookUpAnalytics.js +49 -0
- package/cjs/modules/helpers/loadJWT.js +23 -0
- package/cjs/modules/helpers/misc.js +58 -0
- package/cjs/modules/imageDialog.js +78 -0
- package/cjs/modules/persist.js +55 -0
- package/cjs/modules/popupMessage.js +21 -0
- package/cjs/modules/product.js +1261 -0
- package/cjs/modules/recentlyVisitedProducts.js +72 -0
- package/cjs/modules/search.js +102 -0
- package/cjs/multiResponseToResponse.js +22 -0
- package/cjs/nonNull.js +10 -0
- package/cjs/oauthState.js +40 -0
- package/cjs/orderShippingAddress.js +7 -0
- package/cjs/package.json +3 -0
- package/cjs/pender.js +16 -0
- package/cjs/percentageOff.js +7 -0
- package/cjs/popupConnectQueue.js +62 -0
- package/cjs/preact/components/SixDigitInput.js +167 -0
- package/cjs/preact/effector.js +74 -0
- package/cjs/preact/transition/CSSTransition.js +55 -0
- package/cjs/preact/transition/Transition.js +104 -0
- package/cjs/preact/translateLocalStatic.js +31 -0
- package/cjs/productFiltering.js +173 -0
- package/cjs/productSEO.js +51 -0
- package/cjs/productSorting.js +93 -0
- package/cjs/promiseAll.js +18 -0
- package/cjs/promiseLimit.js +38 -0
- package/cjs/rdsToInitialScores.js +32 -0
- package/cjs/react/components/Portal.js +7 -0
- package/cjs/react/components/RootCloseWrapper.js +41 -0
- package/cjs/react/components/SixDigitInput.js +167 -0
- package/cjs/react/contains.js +14 -0
- package/cjs/react/popperBinder.js +70 -0
- package/cjs/react/rootClose.js +112 -0
- package/cjs/react/translateLocalStatic.js +32 -0
- package/cjs/react/useAsyncCachedValue.js +14 -0
- package/cjs/refreshTimeout.js +25 -0
- package/cjs/remoteAuth.js +59 -0
- package/cjs/request.js +348 -0
- package/cjs/requestDetails.js +76 -0
- package/cjs/rfc3339Normalize.js +10 -0
- package/cjs/script.js +172 -0
- package/cjs/seo.js +2 -0
- package/cjs/shopDomain.js +8 -0
- package/cjs/shopLinks.js +63 -0
- package/cjs/slate.js +376 -0
- package/cjs/sleep.js +10 -0
- package/cjs/splitBy.js +21 -0
- package/cjs/splitName.js +28 -0
- package/cjs/stripZeros.js +13 -0
- package/cjs/stripeError.js +65 -0
- package/cjs/tailSplit.js +12 -0
- package/cjs/tieredPrice.js +32 -0
- package/cjs/timeIt.js +15 -0
- package/cjs/toMajor.js +8 -0
- package/cjs/toMinor.js +8 -0
- package/cjs/trace.js +37 -0
- package/cjs/translateLocale.js +12 -0
- package/cjs/traverse.js +14 -0
- package/cjs/truncate.js +21 -0
- package/cjs/typedLocalStorage.js +30 -0
- package/cjs/variantImage.js +26 -0
- package/cjs/variantImageURL.js +13 -0
- package/cjs/variantImages.js +19 -0
- package/cjs/variantInventory.js +43 -0
- package/cjs/variantOptions.js +21 -0
- package/cjs/variantPrice.js +96 -0
- package/cjs/variantPriceCommerce.js +29 -0
- package/cjs/variantTitle.js +9 -0
- package/cjs/variantTitleFull.js +11 -0
- package/cjs/variantURL.js +9 -0
- package/cjs/vendor/popper/index.d.ts +160 -0
- package/cjs/vendor/popper/index.js +2657 -0
- package/cjs/vendor/popper/index.js.map +1 -0
- package/cjs/vendor/popper/package.json +3 -0
- package/cjs/websocket.js +179 -0
- package/esm/actionLock.js +24 -0
- package/esm/addEmptyListItem.js +3 -0
- package/esm/aggregateOptions.js +169 -0
- package/esm/analytics.js +91 -0
- package/esm/analyticsProductData.js +28 -0
- package/esm/arrayToDict.js +8 -0
- package/esm/asyncModuleWrapper.js +47 -0
- package/esm/averageReviewScore.js +40 -0
- package/esm/buildconfig.js +13 -0
- package/esm/cachedLoader.js +32 -0
- package/esm/canonicalVariantURL.js +1 -0
- package/esm/cartOperation.js +126 -0
- package/esm/categorySEO.js +16 -0
- package/esm/commonTypes.js +1 -0
- package/esm/compact.js +4 -0
- package/esm/configLoader.js +61 -0
- package/esm/controlledQueue.js +38 -0
- package/esm/convertImageURL.js +15 -0
- package/esm/dataLoader.js +192 -0
- package/esm/defaultVariant.js +25 -0
- package/esm/effector/clearOnChangeAfterDelay.js +13 -0
- package/esm/effector/combineEvery.js +4 -0
- package/esm/effector/combineSome.js +4 -0
- package/esm/effector/debounced.js +14 -0
- package/esm/effector/form.js +166 -0
- package/esm/effector/hideOnChangeAfterDelay.js +13 -0
- package/esm/effector/requestResponse.js +24 -0
- package/esm/effector/requestResponseMulti.js +47 -0
- package/esm/effector/restoreNamed.js +4 -0
- package/esm/effector/split.js +25 -0
- package/esm/effector/validator.js +28 -0
- package/esm/effector/wrapSignInRequired.js +9 -0
- package/esm/exceptions.js +2 -0
- package/esm/fetchAllItems.js +44 -0
- package/esm/file.js +67 -0
- package/esm/fileWebsocket.js +75 -0
- package/esm/filterFunc.js +43 -0
- package/esm/filterFuncBrand.js +9 -0
- package/esm/filterFuncCategory.js +9 -0
- package/esm/filterFuncContentBlock.js +16 -0
- package/esm/filterFuncCustomer.js +153 -0
- package/esm/filterFuncDataFeed.js +50 -0
- package/esm/filterFuncOrder.js +325 -0
- package/esm/filterFuncPreprocess.js +9 -0
- package/esm/filterFuncProduct.js +66 -0
- package/esm/filterFuncPurchaseOrder.js +122 -0
- package/esm/filterFuncSupplier.js +31 -0
- package/esm/filterFuncTransfer.js +130 -0
- package/esm/formatAbbrevNumber.js +16 -0
- package/esm/formatCurrency.js +42 -0
- package/esm/formatToJSX.js +118 -0
- package/esm/fulfillmentNumber.js +3 -0
- package/esm/generateRandomToken.js +8 -0
- package/esm/generateUUID.js +6 -0
- package/esm/generated/codes.js +44 -0
- package/esm/genericFile.js +65 -0
- package/esm/getSalesChannelID.js +9 -0
- package/esm/getSessionID.js +9 -0
- package/esm/getTimezone.js +8 -0
- package/esm/graphql/fragments/Branding.js +1 -0
- package/esm/graphql/fragments/BrandingField.js +1 -0
- package/esm/graphql/fragments/CartCustomItem.js +1 -0
- package/esm/graphql/fragments/CartOrder.js +1 -0
- package/esm/graphql/fragments/CartVariant.js +1 -0
- package/esm/graphql/fragments/CartVariantFull.js +1 -0
- package/esm/graphql/fragments/Category.js +1 -0
- package/esm/graphql/fragments/CommonCartVariant.js +1 -0
- package/esm/graphql/fragments/Currency.js +1 -0
- package/esm/graphql/fragments/CurrencyPrice.js +1 -0
- package/esm/graphql/fragments/CustomField.js +1 -0
- package/esm/graphql/fragments/CustomFieldObjects.js +1 -0
- package/esm/graphql/fragments/Customer.js +1 -0
- package/esm/graphql/fragments/CustomerBalance.js +1 -0
- package/esm/graphql/fragments/CustomerBalanceHistory.js +1 -0
- package/esm/graphql/fragments/CustomerFavorite.js +1 -0
- package/esm/graphql/fragments/CustomerFavoriteShort.js +1 -0
- package/esm/graphql/fragments/CustomerOAuthProvider.js +1 -0
- package/esm/graphql/fragments/CustomerOrderBrief.js +1 -0
- package/esm/graphql/fragments/CustomerOrderFulfillment.js +1 -0
- package/esm/graphql/fragments/CustomerOrderFull.js +1 -0
- package/esm/graphql/fragments/CustomerPaymentSource.js +1 -0
- package/esm/graphql/fragments/CustomerReturnBrief.js +1 -0
- package/esm/graphql/fragments/CustomerReturnFull.js +1 -0
- package/esm/graphql/fragments/CustomerReturnPolicy.js +1 -0
- package/esm/graphql/fragments/CustomerSubscriptionBrief.js +1 -0
- package/esm/graphql/fragments/CustomerSubscriptionFull.js +1 -0
- package/esm/graphql/fragments/File.js +1 -0
- package/esm/graphql/fragments/FileForUpload.js +1 -0
- package/esm/graphql/fragments/FileNoFallback.js +1 -0
- package/esm/graphql/fragments/FullAddress.js +1 -0
- package/esm/graphql/fragments/Gateway.js +1 -0
- package/esm/graphql/fragments/GatewayManual.js +1 -0
- package/esm/graphql/fragments/GatewayPaypal.js +1 -0
- package/esm/graphql/fragments/GatewayStripe.js +1 -0
- package/esm/graphql/fragments/GatewayTest.js +1 -0
- package/esm/graphql/fragments/IPAndUAInfo.js +1 -0
- package/esm/graphql/fragments/InfoCountry.js +1 -0
- package/esm/graphql/fragments/InfoCountryDedupField.js +1 -0
- package/esm/graphql/fragments/InfoCurrency.js +1 -0
- package/esm/graphql/fragments/InfoProvince.js +1 -0
- package/esm/graphql/fragments/KeyValue.js +1 -0
- package/esm/graphql/fragments/LineItemField.js +1 -0
- package/esm/graphql/fragments/MediaFile.js +1 -0
- package/esm/graphql/fragments/MinCurrencyPrice.js +1 -0
- package/esm/graphql/fragments/ProductField.js +1 -0
- package/esm/graphql/fragments/ProductFieldSet.js +1 -0
- package/esm/graphql/fragments/ProductFlat.js +1 -0
- package/esm/graphql/fragments/ProductQuestion.js +1 -0
- package/esm/graphql/fragments/ProductQuestionAnswer.js +1 -0
- package/esm/graphql/fragments/ProductQuestionPage.js +1 -0
- package/esm/graphql/fragments/ProductReview.js +1 -0
- package/esm/graphql/fragments/ProductReviewAnswer.js +1 -0
- package/esm/graphql/fragments/ProductReviewAverageScore.js +1 -0
- package/esm/graphql/fragments/ProductReviewPage.js +1 -0
- package/esm/graphql/fragments/ProductReviewScore.js +1 -0
- package/esm/graphql/fragments/ProductReviewSurveyAnswer.js +1 -0
- package/esm/graphql/fragments/ProductSearchOptionAgg.js +1 -0
- package/esm/graphql/fragments/ProductSearchResult.js +1 -0
- package/esm/graphql/fragments/ReturnReason.js +1 -0
- package/esm/graphql/fragments/ReviewDimension.js +1 -0
- package/esm/graphql/fragments/ReviewDimensionSet.js +1 -0
- package/esm/graphql/fragments/ReviewImagePage.js +1 -0
- package/esm/graphql/fragments/ReviewQuestionProduct.js +1 -0
- package/esm/graphql/fragments/ReviewSettings.js +1 -0
- package/esm/graphql/fragments/SearchProduct.js +1 -0
- package/esm/graphql/fragments/Shop.js +1 -0
- package/esm/graphql/fragments/SubscriptionPlan.js +1 -0
- package/esm/graphql/fragments/SurveyQuestion.js +1 -0
- package/esm/graphql/fragments/TieredPricing.js +1 -0
- package/esm/graphql/fragments/TieredPricingTier.js +1 -0
- package/esm/graphql/fragments/VariantOption.js +1 -0
- package/esm/graphql/operations/ApplyGiftCardMutation.js +1 -0
- package/esm/graphql/operations/AuthRequestMutation.js +1 -0
- package/esm/graphql/operations/CancelOrderMutation.js +1 -0
- package/esm/graphql/operations/CancelSubscriptionMutation.js +1 -0
- package/esm/graphql/operations/ConnectOAuth2Mutation.js +1 -0
- package/esm/graphql/operations/CreateCartMutation.js +23 -0
- package/esm/graphql/operations/CreateFavoriteMutation.js +19 -0
- package/esm/graphql/operations/CreateFileMutation.js +3 -0
- package/esm/graphql/operations/CreatePaymentSourceMutation.js +3 -0
- package/esm/graphql/operations/CreateProductQuestionAnswerMutation.js +1 -0
- package/esm/graphql/operations/CreateProductQuestionMutation.js +5 -0
- package/esm/graphql/operations/CreateProductReviewMutation.js +15 -0
- package/esm/graphql/operations/CreateReturnMutation.js +19 -0
- package/esm/graphql/operations/DeleteFavoriteMutation.js +1 -0
- package/esm/graphql/operations/DeletePaymentSourceMutation.js +1 -0
- package/esm/graphql/operations/DeleteProductQuestionAnswerMutation.js +1 -0
- package/esm/graphql/operations/DeleteProductQuestionMutation.js +1 -0
- package/esm/graphql/operations/DeleteProductReviewMutation.js +1 -0
- package/esm/graphql/operations/DisconnectOAuth2Mutation.js +1 -0
- package/esm/graphql/operations/EditSubscriptionMutation.js +1 -0
- package/esm/graphql/operations/FileUploadedMutation.js +3 -0
- package/esm/graphql/operations/FlagQuestionAnswerMutation.js +1 -0
- package/esm/graphql/operations/FlagQuestionMutation.js +1 -0
- package/esm/graphql/operations/FlagReviewAnswerMutation.js +1 -0
- package/esm/graphql/operations/FlagReviewMutation.js +1 -0
- package/esm/graphql/operations/GetBrandingQuery.js +7 -0
- package/esm/graphql/operations/GetCartQuery.js +23 -0
- package/esm/graphql/operations/GetCustomerAddressesPageDataQuery.js +13 -0
- package/esm/graphql/operations/GetCustomerBalanceHistoryPageQuery.js +3 -0
- package/esm/graphql/operations/GetCustomerBalanceQuery.js +5 -0
- package/esm/graphql/operations/GetCustomerInfoQuery.js +7 -0
- package/esm/graphql/operations/GetCustomerQuery.js +5 -0
- package/esm/graphql/operations/GetFavoritesQuery.js +19 -0
- package/esm/graphql/operations/GetFileStatusQuery.js +3 -0
- package/esm/graphql/operations/GetGatewaysQuery.js +11 -0
- package/esm/graphql/operations/GetInfoCurrenciesQuery.js +3 -0
- package/esm/graphql/operations/GetLastCartQuery.js +23 -0
- package/esm/graphql/operations/GetOrderQuery.js +27 -0
- package/esm/graphql/operations/GetOrdersPageQuery.js +21 -0
- package/esm/graphql/operations/GetPaymentMethodsPageDataQuery.js +15 -0
- package/esm/graphql/operations/GetProductQuestionsPageQuery.js +7 -0
- package/esm/graphql/operations/GetProductReviewImagesPageQuery.js +5 -0
- package/esm/graphql/operations/GetProductReviewsPageQuery.js +17 -0
- package/esm/graphql/operations/GetProvincesQuery.js +3 -0
- package/esm/graphql/operations/GetQuestionQuery.js +5 -0
- package/esm/graphql/operations/GetReturnCreationInfoQuery.js +33 -0
- package/esm/graphql/operations/GetReturnQuery.js +25 -0
- package/esm/graphql/operations/GetReturnsPageQuery.js +19 -0
- package/esm/graphql/operations/GetReviewDimensionsQuery.js +3 -0
- package/esm/graphql/operations/GetReviewQuery.js +15 -0
- package/esm/graphql/operations/GetReviewSettingsQuery.js +9 -0
- package/esm/graphql/operations/GetShopCurrenciesQuery.js +3 -0
- package/esm/graphql/operations/GetShopQuery.js +5 -0
- package/esm/graphql/operations/GetSubscriptionQuery.js +33 -0
- package/esm/graphql/operations/GetSubscriptionsPageQuery.js +19 -0
- package/esm/graphql/operations/GetVariantPageQuery.js +17 -0
- package/esm/graphql/operations/LoadProductNoCustomerQuery.js +59 -0
- package/esm/graphql/operations/LoadProductQuery.js +63 -0
- package/esm/graphql/operations/ModifyCartMutation.js +23 -0
- package/esm/graphql/operations/ModifyCustomerMutation.js +5 -0
- package/esm/graphql/operations/ModifyFavoriteMutation.js +19 -0
- package/esm/graphql/operations/ModifyProductQuestionAnswerMutation.js +1 -0
- package/esm/graphql/operations/ModifyProductQuestionMutation.js +5 -0
- package/esm/graphql/operations/ModifyProductReviewMutation.js +15 -0
- package/esm/graphql/operations/NewPasswordMutation.js +1 -0
- package/esm/graphql/operations/PauseSubscriptionMutation.js +1 -0
- package/esm/graphql/operations/ResetPasswordMutation.js +1 -0
- package/esm/graphql/operations/ResumeSubscriptionMutation.js +1 -0
- package/esm/graphql/operations/SearchProductsAdvancedQuery.js +21 -0
- package/esm/graphql/operations/SearchProductsQuery.js +17 -0
- package/esm/graphql/operations/SearchQuestionsQuery.js +5 -0
- package/esm/graphql/operations/SearchReviewsQuery.js +15 -0
- package/esm/graphql/operations/SignInMutation.js +1 -0
- package/esm/graphql/operations/SignInViaEmailCompleteMutation.js +1 -0
- package/esm/graphql/operations/SignInViaEmailInitMutation.js +1 -0
- package/esm/graphql/operations/SignUpMutation.js +1 -0
- package/esm/graphql/operations/SkipNextSubscriptionMutation.js +1 -0
- package/esm/graphql/operations/UploadFileMutation.js +1 -0
- package/esm/graphql/operations/VerifyCodeMutation.js +1 -0
- package/esm/graphql/operations/VoteQuestionAnswerMutation.js +1 -0
- package/esm/graphql/operations/VoteQuestionMutation.js +1 -0
- package/esm/graphql/operations/VoteReviewAnswerMutation.js +1 -0
- package/esm/graphql/operations/VoteReviewMutation.js +1 -0
- package/esm/graphql/types.js +1 -0
- package/esm/hierarchicalSearchOption.js +43 -0
- package/esm/idgen.js +4 -0
- package/esm/ignoreQueue.js +45 -0
- package/esm/imageAltProps.js +9 -0
- package/esm/invoiceFormat.js +54 -0
- package/esm/isShippingRequired.js +16 -0
- package/esm/isoStripTrailingZeros.js +3 -0
- package/esm/json/commerce.js +3 -0
- package/esm/json/commerceFileUpload.js +43 -0
- package/esm/json/commerceTypes.js +1 -0
- package/esm/json/common.js +309 -0
- package/esm/json/fetchAllItems.js +51 -0
- package/esm/json/mutator.js +952 -0
- package/esm/json/storefront.js +3 -0
- package/esm/json/storefrontTypes.js +1 -0
- package/esm/lastValue.js +12 -0
- package/esm/lineItemPrice.js +106 -0
- package/esm/loadJWT.js +20 -0
- package/esm/mapInvalidInput.js +27 -0
- package/esm/mapResponseData.js +11 -0
- package/esm/mapResponseMultiData.js +10 -0
- package/esm/meanBy.js +11 -0
- package/esm/media.js +12 -0
- package/esm/modules/advancedSearch.js +132 -0
- package/esm/modules/cart.js +699 -0
- package/esm/modules/config/defaultAdvancedSearchGraphQLConfig.js +4 -0
- package/esm/modules/config/defaultCartGraphQLConfig.js +10 -0
- package/esm/modules/config/defaultProductGraphQLConfig.js +44 -0
- package/esm/modules/config/defaultSearchGraphQLConfig.js +4 -0
- package/esm/modules/customer.js +2198 -0
- package/esm/modules/helpers/cartInitOption.js +18 -0
- package/esm/modules/helpers/cookieConsent.js +29 -0
- package/esm/modules/helpers/customerOauth2.js +53 -0
- package/esm/modules/helpers/getOAuth2Hook.js +48 -0
- package/esm/modules/helpers/hookUpAnalytics.js +44 -0
- package/esm/modules/helpers/loadJWT.js +18 -0
- package/esm/modules/helpers/misc.js +49 -0
- package/esm/modules/imageDialog.js +71 -0
- package/esm/modules/persist.js +49 -0
- package/esm/modules/popupMessage.js +17 -0
- package/esm/modules/product.js +1278 -0
- package/esm/modules/recentlyVisitedProducts.js +70 -0
- package/esm/modules/search.js +103 -0
- package/esm/multiResponseToResponse.js +18 -0
- package/esm/nonNull.js +6 -0
- package/esm/oauthState.js +35 -0
- package/esm/orderShippingAddress.js +3 -0
- package/esm/package.json +3 -0
- package/esm/pender.js +11 -0
- package/esm/percentageOff.js +3 -0
- package/esm/popupConnectQueue.js +55 -0
- package/esm/preact/components/SixDigitInput.js +159 -0
- package/esm/preact/effector.js +69 -0
- package/esm/preact/transition/CSSTransition.js +47 -0
- package/esm/preact/transition/Transition.js +100 -0
- package/esm/preact/translateLocalStatic.js +26 -0
- package/esm/productFiltering.js +164 -0
- package/esm/productSEO.js +46 -0
- package/esm/productSorting.js +89 -0
- package/esm/promiseAll.js +11 -0
- package/esm/promiseLimit.js +32 -0
- package/esm/rdsToInitialScores.js +27 -0
- package/esm/react/components/Portal.js +2 -0
- package/esm/react/components/RootCloseWrapper.js +33 -0
- package/esm/react/components/SixDigitInput.js +158 -0
- package/esm/react/contains.js +10 -0
- package/esm/react/popperBinder.js +71 -0
- package/esm/react/rootClose.js +106 -0
- package/esm/react/translateLocalStatic.js +26 -0
- package/esm/react/useAsyncCachedValue.js +10 -0
- package/esm/refreshTimeout.js +21 -0
- package/esm/remoteAuth.js +52 -0
- package/esm/request.js +323 -0
- package/esm/requestDetails.js +69 -0
- package/esm/rfc3339Normalize.js +6 -0
- package/esm/script.js +157 -0
- package/esm/seo.js +1 -0
- package/esm/shopDomain.js +4 -0
- package/esm/shopLinks.js +47 -0
- package/esm/slate.js +364 -0
- package/esm/sleep.js +3 -0
- package/esm/splitBy.js +17 -0
- package/esm/splitName.js +22 -0
- package/esm/stripZeros.js +9 -0
- package/esm/stripeError.js +53 -0
- package/esm/tailSplit.js +8 -0
- package/esm/tieredPrice.js +28 -0
- package/esm/timeIt.js +8 -0
- package/esm/toMajor.js +4 -0
- package/esm/toMinor.js +4 -0
- package/esm/trace.js +37 -0
- package/esm/translateLocale.js +7 -0
- package/esm/traverse.js +10 -0
- package/esm/truncate.js +17 -0
- package/esm/typedLocalStorage.js +24 -0
- package/esm/variantImage.js +22 -0
- package/esm/variantImageURL.js +9 -0
- package/esm/variantImages.js +15 -0
- package/esm/variantInventory.js +38 -0
- package/esm/variantOptions.js +15 -0
- package/esm/variantPrice.js +92 -0
- package/esm/variantPriceCommerce.js +25 -0
- package/esm/variantTitle.js +5 -0
- package/esm/variantTitleFull.js +7 -0
- package/esm/variantURL.js +5 -0
- package/esm/vendor/popper/index.d.ts +160 -0
- package/esm/vendor/popper/index.js +2657 -0
- package/esm/vendor/popper/index.js.map +1 -0
- package/esm/vendor/popper/package.json +3 -0
- package/esm/websocket.js +169 -0
- package/package.json +92 -0
- package/types/actionLock.d.ts +7 -0
- package/types/addEmptyListItem.d.ts +2 -0
- package/types/aggregateOptions.d.ts +33 -0
- package/types/analytics.d.ts +23 -0
- package/types/analyticsProductData.d.ts +38 -0
- package/types/arrayToDict.d.ts +2 -0
- package/types/asyncModuleWrapper.d.ts +13 -0
- package/types/averageReviewScore.d.ts +28 -0
- package/types/buildconfig.d.ts +13 -0
- package/types/cachedLoader.d.ts +10 -0
- package/types/canonicalVariantURL.d.ts +12 -0
- package/types/cartOperation.d.ts +28 -0
- package/types/categorySEO.d.ts +17 -0
- package/types/commonTypes.d.ts +10 -0
- package/types/compact.d.ts +1 -0
- package/types/configLoader.d.ts +53 -0
- package/types/controlledQueue.d.ts +17 -0
- package/types/convertImageURL.d.ts +9 -0
- package/types/dataLoader.d.ts +301 -0
- package/types/defaultVariant.d.ts +9 -0
- package/types/effector/clearOnChangeAfterDelay.d.ts +2 -0
- package/types/effector/combineEvery.d.ts +2 -0
- package/types/effector/combineSome.d.ts +2 -0
- package/types/effector/debounced.d.ts +2 -0
- package/types/effector/form.d.ts +74 -0
- package/types/effector/hideOnChangeAfterDelay.d.ts +6 -0
- package/types/effector/requestResponse.d.ts +9 -0
- package/types/effector/requestResponseMulti.d.ts +7 -0
- package/types/effector/restoreNamed.d.ts +2 -0
- package/types/effector/split.d.ts +7 -0
- package/types/effector/validator.d.ts +14 -0
- package/types/effector/wrapSignInRequired.d.ts +2 -0
- package/types/exceptions.d.ts +2 -0
- package/types/fetchAllItems.d.ts +25 -0
- package/types/file.d.ts +4 -0
- package/types/fileWebsocket.d.ts +6 -0
- package/types/filterFunc.d.ts +8 -0
- package/types/filterFuncBrand.d.ts +3 -0
- package/types/filterFuncCategory.d.ts +3 -0
- package/types/filterFuncContentBlock.d.ts +3 -0
- package/types/filterFuncCustomer.d.ts +3 -0
- package/types/filterFuncDataFeed.d.ts +8 -0
- package/types/filterFuncOrder.d.ts +3 -0
- package/types/filterFuncPreprocess.d.ts +2 -0
- package/types/filterFuncProduct.d.ts +3 -0
- package/types/filterFuncPurchaseOrder.d.ts +3 -0
- package/types/filterFuncSupplier.d.ts +3 -0
- package/types/filterFuncTransfer.d.ts +3 -0
- package/types/formatAbbrevNumber.d.ts +6 -0
- package/types/formatCurrency.d.ts +44 -0
- package/types/formatToJSX.d.ts +24 -0
- package/types/fulfillmentNumber.d.ts +1 -0
- package/types/generateRandomToken.d.ts +1 -0
- package/types/generateUUID.d.ts +1 -0
- package/types/generated/codes.d.ts +234 -0
- package/types/genericFile.d.ts +57 -0
- package/types/getSalesChannelID.d.ts +1 -0
- package/types/getSessionID.d.ts +1 -0
- package/types/getTimezone.d.ts +1 -0
- package/types/graphql/fragments/Branding.d.ts +2 -0
- package/types/graphql/fragments/BrandingField.d.ts +2 -0
- package/types/graphql/fragments/CartCustomItem.d.ts +2 -0
- package/types/graphql/fragments/CartOrder.d.ts +2 -0
- package/types/graphql/fragments/CartVariant.d.ts +2 -0
- package/types/graphql/fragments/CartVariantFull.d.ts +2 -0
- package/types/graphql/fragments/Category.d.ts +2 -0
- package/types/graphql/fragments/CommonCartVariant.d.ts +2 -0
- package/types/graphql/fragments/Currency.d.ts +2 -0
- package/types/graphql/fragments/CurrencyPrice.d.ts +2 -0
- package/types/graphql/fragments/CustomField.d.ts +2 -0
- package/types/graphql/fragments/CustomFieldObjects.d.ts +2 -0
- package/types/graphql/fragments/Customer.d.ts +2 -0
- package/types/graphql/fragments/CustomerBalance.d.ts +2 -0
- package/types/graphql/fragments/CustomerBalanceHistory.d.ts +2 -0
- package/types/graphql/fragments/CustomerFavorite.d.ts +2 -0
- package/types/graphql/fragments/CustomerFavoriteShort.d.ts +2 -0
- package/types/graphql/fragments/CustomerOAuthProvider.d.ts +2 -0
- package/types/graphql/fragments/CustomerOrderBrief.d.ts +2 -0
- package/types/graphql/fragments/CustomerOrderFulfillment.d.ts +2 -0
- package/types/graphql/fragments/CustomerOrderFull.d.ts +2 -0
- package/types/graphql/fragments/CustomerPaymentSource.d.ts +2 -0
- package/types/graphql/fragments/CustomerReturnBrief.d.ts +2 -0
- package/types/graphql/fragments/CustomerReturnFull.d.ts +2 -0
- package/types/graphql/fragments/CustomerReturnPolicy.d.ts +2 -0
- package/types/graphql/fragments/CustomerSubscriptionBrief.d.ts +2 -0
- package/types/graphql/fragments/CustomerSubscriptionFull.d.ts +2 -0
- package/types/graphql/fragments/File.d.ts +2 -0
- package/types/graphql/fragments/FileForUpload.d.ts +2 -0
- package/types/graphql/fragments/FileNoFallback.d.ts +2 -0
- package/types/graphql/fragments/FullAddress.d.ts +2 -0
- package/types/graphql/fragments/Gateway.d.ts +2 -0
- package/types/graphql/fragments/GatewayManual.d.ts +2 -0
- package/types/graphql/fragments/GatewayPaypal.d.ts +2 -0
- package/types/graphql/fragments/GatewayStripe.d.ts +2 -0
- package/types/graphql/fragments/GatewayTest.d.ts +2 -0
- package/types/graphql/fragments/IPAndUAInfo.d.ts +2 -0
- package/types/graphql/fragments/InfoCountry.d.ts +2 -0
- package/types/graphql/fragments/InfoCountryDedupField.d.ts +2 -0
- package/types/graphql/fragments/InfoCurrency.d.ts +2 -0
- package/types/graphql/fragments/InfoProvince.d.ts +2 -0
- package/types/graphql/fragments/KeyValue.d.ts +2 -0
- package/types/graphql/fragments/LineItemField.d.ts +2 -0
- package/types/graphql/fragments/MediaFile.d.ts +2 -0
- package/types/graphql/fragments/MinCurrencyPrice.d.ts +2 -0
- package/types/graphql/fragments/ProductField.d.ts +2 -0
- package/types/graphql/fragments/ProductFieldSet.d.ts +2 -0
- package/types/graphql/fragments/ProductFlat.d.ts +2 -0
- package/types/graphql/fragments/ProductQuestion.d.ts +2 -0
- package/types/graphql/fragments/ProductQuestionAnswer.d.ts +2 -0
- package/types/graphql/fragments/ProductQuestionPage.d.ts +2 -0
- package/types/graphql/fragments/ProductReview.d.ts +2 -0
- package/types/graphql/fragments/ProductReviewAnswer.d.ts +2 -0
- package/types/graphql/fragments/ProductReviewAverageScore.d.ts +2 -0
- package/types/graphql/fragments/ProductReviewPage.d.ts +2 -0
- package/types/graphql/fragments/ProductReviewScore.d.ts +2 -0
- package/types/graphql/fragments/ProductReviewSurveyAnswer.d.ts +2 -0
- package/types/graphql/fragments/ProductSearchOptionAgg.d.ts +2 -0
- package/types/graphql/fragments/ProductSearchResult.d.ts +2 -0
- package/types/graphql/fragments/ReturnReason.d.ts +2 -0
- package/types/graphql/fragments/ReviewDimension.d.ts +2 -0
- package/types/graphql/fragments/ReviewDimensionSet.d.ts +2 -0
- package/types/graphql/fragments/ReviewImagePage.d.ts +2 -0
- package/types/graphql/fragments/ReviewQuestionProduct.d.ts +2 -0
- package/types/graphql/fragments/ReviewSettings.d.ts +2 -0
- package/types/graphql/fragments/SearchProduct.d.ts +2 -0
- package/types/graphql/fragments/Shop.d.ts +2 -0
- package/types/graphql/fragments/SubscriptionPlan.d.ts +2 -0
- package/types/graphql/fragments/SurveyQuestion.d.ts +2 -0
- package/types/graphql/fragments/TieredPricing.d.ts +2 -0
- package/types/graphql/fragments/TieredPricingTier.d.ts +2 -0
- package/types/graphql/fragments/VariantOption.d.ts +2 -0
- package/types/graphql/operations/ApplyGiftCardMutation.d.ts +3 -0
- package/types/graphql/operations/AuthRequestMutation.d.ts +3 -0
- package/types/graphql/operations/CancelOrderMutation.d.ts +3 -0
- package/types/graphql/operations/CancelSubscriptionMutation.d.ts +3 -0
- package/types/graphql/operations/ConnectOAuth2Mutation.d.ts +3 -0
- package/types/graphql/operations/CreateCartMutation.d.ts +3 -0
- package/types/graphql/operations/CreateFavoriteMutation.d.ts +3 -0
- package/types/graphql/operations/CreateFileMutation.d.ts +3 -0
- package/types/graphql/operations/CreatePaymentSourceMutation.d.ts +3 -0
- package/types/graphql/operations/CreateProductQuestionAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/CreateProductQuestionMutation.d.ts +3 -0
- package/types/graphql/operations/CreateProductReviewMutation.d.ts +3 -0
- package/types/graphql/operations/CreateReturnMutation.d.ts +3 -0
- package/types/graphql/operations/DeleteFavoriteMutation.d.ts +3 -0
- package/types/graphql/operations/DeletePaymentSourceMutation.d.ts +3 -0
- package/types/graphql/operations/DeleteProductQuestionAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/DeleteProductQuestionMutation.d.ts +3 -0
- package/types/graphql/operations/DeleteProductReviewMutation.d.ts +3 -0
- package/types/graphql/operations/DisconnectOAuth2Mutation.d.ts +3 -0
- package/types/graphql/operations/EditSubscriptionMutation.d.ts +3 -0
- package/types/graphql/operations/FileUploadedMutation.d.ts +3 -0
- package/types/graphql/operations/FlagQuestionAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/FlagQuestionMutation.d.ts +3 -0
- package/types/graphql/operations/FlagReviewAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/FlagReviewMutation.d.ts +3 -0
- package/types/graphql/operations/GetBrandingQuery.d.ts +3 -0
- package/types/graphql/operations/GetCartQuery.d.ts +3 -0
- package/types/graphql/operations/GetCustomerAddressesPageDataQuery.d.ts +3 -0
- package/types/graphql/operations/GetCustomerBalanceHistoryPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetCustomerBalanceQuery.d.ts +3 -0
- package/types/graphql/operations/GetCustomerInfoQuery.d.ts +3 -0
- package/types/graphql/operations/GetCustomerQuery.d.ts +3 -0
- package/types/graphql/operations/GetFavoritesQuery.d.ts +3 -0
- package/types/graphql/operations/GetFileStatusQuery.d.ts +3 -0
- package/types/graphql/operations/GetGatewaysQuery.d.ts +3 -0
- package/types/graphql/operations/GetInfoCurrenciesQuery.d.ts +3 -0
- package/types/graphql/operations/GetLastCartQuery.d.ts +3 -0
- package/types/graphql/operations/GetOrderQuery.d.ts +3 -0
- package/types/graphql/operations/GetOrdersPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetPaymentMethodsPageDataQuery.d.ts +3 -0
- package/types/graphql/operations/GetProductQuestionsPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetProductReviewImagesPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetProductReviewsPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetProvincesQuery.d.ts +3 -0
- package/types/graphql/operations/GetQuestionQuery.d.ts +3 -0
- package/types/graphql/operations/GetReturnCreationInfoQuery.d.ts +3 -0
- package/types/graphql/operations/GetReturnQuery.d.ts +3 -0
- package/types/graphql/operations/GetReturnsPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetReviewDimensionsQuery.d.ts +3 -0
- package/types/graphql/operations/GetReviewQuery.d.ts +3 -0
- package/types/graphql/operations/GetReviewSettingsQuery.d.ts +3 -0
- package/types/graphql/operations/GetShopCurrenciesQuery.d.ts +3 -0
- package/types/graphql/operations/GetShopQuery.d.ts +3 -0
- package/types/graphql/operations/GetSubscriptionQuery.d.ts +3 -0
- package/types/graphql/operations/GetSubscriptionsPageQuery.d.ts +3 -0
- package/types/graphql/operations/GetVariantPageQuery.d.ts +3 -0
- package/types/graphql/operations/LoadProductNoCustomerQuery.d.ts +3 -0
- package/types/graphql/operations/LoadProductQuery.d.ts +3 -0
- package/types/graphql/operations/ModifyCartMutation.d.ts +3 -0
- package/types/graphql/operations/ModifyCustomerMutation.d.ts +3 -0
- package/types/graphql/operations/ModifyFavoriteMutation.d.ts +3 -0
- package/types/graphql/operations/ModifyProductQuestionAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/ModifyProductQuestionMutation.d.ts +3 -0
- package/types/graphql/operations/ModifyProductReviewMutation.d.ts +3 -0
- package/types/graphql/operations/NewPasswordMutation.d.ts +3 -0
- package/types/graphql/operations/PauseSubscriptionMutation.d.ts +3 -0
- package/types/graphql/operations/ResetPasswordMutation.d.ts +3 -0
- package/types/graphql/operations/ResumeSubscriptionMutation.d.ts +3 -0
- package/types/graphql/operations/SearchProductsAdvancedQuery.d.ts +3 -0
- package/types/graphql/operations/SearchProductsQuery.d.ts +3 -0
- package/types/graphql/operations/SearchQuestionsQuery.d.ts +3 -0
- package/types/graphql/operations/SearchReviewsQuery.d.ts +3 -0
- package/types/graphql/operations/SignInMutation.d.ts +3 -0
- package/types/graphql/operations/SignInViaEmailCompleteMutation.d.ts +3 -0
- package/types/graphql/operations/SignInViaEmailInitMutation.d.ts +3 -0
- package/types/graphql/operations/SignUpMutation.d.ts +3 -0
- package/types/graphql/operations/SkipNextSubscriptionMutation.d.ts +3 -0
- package/types/graphql/operations/UploadFileMutation.d.ts +3 -0
- package/types/graphql/operations/VerifyCodeMutation.d.ts +3 -0
- package/types/graphql/operations/VoteQuestionAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/VoteQuestionMutation.d.ts +3 -0
- package/types/graphql/operations/VoteReviewAnswerMutation.d.ts +3 -0
- package/types/graphql/operations/VoteReviewMutation.d.ts +3 -0
- package/types/graphql/types.d.ts +2471 -0
- package/types/hierarchicalSearchOption.d.ts +14 -0
- package/types/idgen.d.ts +1 -0
- package/types/ignoreQueue.d.ts +10 -0
- package/types/imageAltProps.d.ts +11 -0
- package/types/invoiceFormat.d.ts +32 -0
- package/types/isShippingRequired.d.ts +14 -0
- package/types/isoStripTrailingZeros.d.ts +1 -0
- package/types/json/commerce.d.ts +3 -0
- package/types/json/commerceFileUpload.d.ts +20 -0
- package/types/json/commerceTypes.d.ts +15422 -0
- package/types/json/common.d.ts +81 -0
- package/types/json/fetchAllItems.d.ts +15 -0
- package/types/json/mutator.d.ts +238 -0
- package/types/json/storefront.d.ts +3 -0
- package/types/json/storefrontTypes.d.ts +5059 -0
- package/types/lastValue.d.ts +10 -0
- package/types/lineItemPrice.d.ts +18 -0
- package/types/loadJWT.d.ts +1 -0
- package/types/mapInvalidInput.d.ts +15 -0
- package/types/mapResponseData.d.ts +3 -0
- package/types/mapResponseMultiData.d.ts +2 -0
- package/types/meanBy.d.ts +1 -0
- package/types/media.d.ts +3 -0
- package/types/modules/advancedSearch.d.ts +78 -0
- package/types/modules/cart.d.ts +263 -0
- package/types/modules/config/defaultAdvancedSearchGraphQLConfig.d.ts +3 -0
- package/types/modules/config/defaultCartGraphQLConfig.d.ts +6 -0
- package/types/modules/config/defaultProductGraphQLConfig.d.ts +23 -0
- package/types/modules/config/defaultSearchGraphQLConfig.d.ts +3 -0
- package/types/modules/customer.d.ts +624 -0
- package/types/modules/helpers/cartInitOption.d.ts +2 -0
- package/types/modules/helpers/cookieConsent.d.ts +4 -0
- package/types/modules/helpers/customerOauth2.d.ts +19 -0
- package/types/modules/helpers/getOAuth2Hook.d.ts +22 -0
- package/types/modules/helpers/hookUpAnalytics.d.ts +21 -0
- package/types/modules/helpers/loadJWT.d.ts +1 -0
- package/types/modules/helpers/misc.d.ts +14 -0
- package/types/modules/imageDialog.d.ts +31 -0
- package/types/modules/persist.d.ts +13 -0
- package/types/modules/popupMessage.d.ts +9 -0
- package/types/modules/product.d.ts +320 -0
- package/types/modules/recentlyVisitedProducts.d.ts +25 -0
- package/types/modules/search.d.ts +54 -0
- package/types/multiResponseToResponse.d.ts +2 -0
- package/types/nonNull.d.ts +1 -0
- package/types/oauthState.d.ts +3 -0
- package/types/orderShippingAddress.d.ts +6 -0
- package/types/pender.d.ts +5 -0
- package/types/percentageOff.d.ts +1 -0
- package/types/popupConnectQueue.d.ts +41 -0
- package/types/preact/components/SixDigitInput.d.ts +28 -0
- package/types/preact/effector.d.ts +8 -0
- package/types/preact/transition/CSSTransition.d.ts +8 -0
- package/types/preact/transition/Transition.d.ts +30 -0
- package/types/preact/translateLocalStatic.d.ts +4 -0
- package/types/productFiltering.d.ts +58 -0
- package/types/productSEO.d.ts +59 -0
- package/types/productSorting.d.ts +35 -0
- package/types/promiseAll.d.ts +5 -0
- package/types/promiseLimit.d.ts +13 -0
- package/types/rdsToInitialScores.d.ts +26 -0
- package/types/react/components/Portal.d.ts +2 -0
- package/types/react/components/RootCloseWrapper.d.ts +18 -0
- package/types/react/components/SixDigitInput.d.ts +27 -0
- package/types/react/contains.d.ts +1 -0
- package/types/react/popperBinder.d.ts +23 -0
- package/types/react/rootClose.d.ts +18 -0
- package/types/react/translateLocalStatic.d.ts +4 -0
- package/types/react/useAsyncCachedValue.d.ts +2 -0
- package/types/refreshTimeout.d.ts +5 -0
- package/types/remoteAuth.d.ts +14 -0
- package/types/request.d.ts +104 -0
- package/types/requestDetails.d.ts +16 -0
- package/types/rfc3339Normalize.d.ts +1 -0
- package/types/script.d.ts +36 -0
- package/types/seo.d.ts +5 -0
- package/types/shopDomain.d.ts +7 -0
- package/types/shopLinks.d.ts +14 -0
- package/types/slate.d.ts +47 -0
- package/types/sleep.d.ts +1 -0
- package/types/splitBy.d.ts +1 -0
- package/types/splitName.d.ts +2 -0
- package/types/stripZeros.d.ts +1 -0
- package/types/stripeError.d.ts +14 -0
- package/types/tailSplit.d.ts +1 -0
- package/types/tieredPrice.d.ts +2 -0
- package/types/timeIt.d.ts +1 -0
- package/types/toMajor.d.ts +8 -0
- package/types/toMinor.d.ts +8 -0
- package/types/trace.d.ts +17 -0
- package/types/translateLocale.d.ts +2 -0
- package/types/traverse.d.ts +1 -0
- package/types/truncate.d.ts +7 -0
- package/types/typedLocalStorage.d.ts +3 -0
- package/types/variantImage.d.ts +16 -0
- package/types/variantImageURL.d.ts +25 -0
- package/types/variantImages.d.ts +11 -0
- package/types/variantInventory.d.ts +14 -0
- package/types/variantOptions.d.ts +18 -0
- package/types/variantPrice.d.ts +37 -0
- package/types/variantPriceCommerce.d.ts +26 -0
- package/types/variantTitle.d.ts +7 -0
- package/types/variantTitleFull.d.ts +11 -0
- package/types/variantURL.d.ts +7 -0
- package/types/websocket.d.ts +33 -0
|
@@ -0,0 +1,699 @@
|
|
|
1
|
+
import { combine, createEvent, createStore, forward, guard, restore } from "effector";
|
|
2
|
+
import { dequal } from "dequal/lite";
|
|
3
|
+
import { klona } from "klona/json";
|
|
4
|
+
import { prettyPrintRequestResponseError, request, } from "../request.js";
|
|
5
|
+
import { compactCartOperations, filterOutNonCreateOpertions } from "../cartOperation.js";
|
|
6
|
+
import { ControlledQueue } from "../controlledQueue.js";
|
|
7
|
+
import { ErrorCode } from "../generated/codes.js";
|
|
8
|
+
import { deserialize, serialize } from "./persist.js";
|
|
9
|
+
import { firstResponseData } from "../mapResponseData.js";
|
|
10
|
+
import { nonNull } from "../nonNull.js";
|
|
11
|
+
class RelaxedCartActivityReporter {
|
|
12
|
+
delay;
|
|
13
|
+
onActivity;
|
|
14
|
+
lastReported = "idle";
|
|
15
|
+
timer;
|
|
16
|
+
constructor(delay, onActivity) {
|
|
17
|
+
this.delay = delay;
|
|
18
|
+
this.onActivity = onActivity;
|
|
19
|
+
}
|
|
20
|
+
reportDelayed(activity) {
|
|
21
|
+
const { onActivity } = this;
|
|
22
|
+
if (!onActivity)
|
|
23
|
+
return;
|
|
24
|
+
this.timer = setTimeout(() => {
|
|
25
|
+
this.lastReported = activity;
|
|
26
|
+
onActivity(activity);
|
|
27
|
+
}, this.delay);
|
|
28
|
+
}
|
|
29
|
+
report(activity) {
|
|
30
|
+
if (this.timer)
|
|
31
|
+
clearTimeout(this.timer);
|
|
32
|
+
if (this.lastReported !== "idle" && activity === "idle") {
|
|
33
|
+
this.reportDelayed("idle");
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.lastReported = activity;
|
|
37
|
+
this.onActivity?.(activity);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function apiStateToLineItems(state, predictedLineItems) {
|
|
42
|
+
const out = [];
|
|
43
|
+
for (let i = 0; i < state.line_items.length; i++) {
|
|
44
|
+
const li = state.line_items[i];
|
|
45
|
+
const ci = li.custom_item_index >= 0 ? state.custom_items?.[li.custom_item_index] : undefined;
|
|
46
|
+
// we will use fake custom item id as variant id, variant id is used for addressing in the API
|
|
47
|
+
const variantID = ci ? ci.id : nonNull(li.variant_id, "line item variant_id");
|
|
48
|
+
const variant = li.variant || predictedLineItems?.find((pli) => pli.variantID === variantID)?.variant;
|
|
49
|
+
out.push({
|
|
50
|
+
quantity: li.quantity,
|
|
51
|
+
variant,
|
|
52
|
+
variantID,
|
|
53
|
+
discountPreview: li.discount_preview,
|
|
54
|
+
fieldSetID: li.field_set?.id || "",
|
|
55
|
+
fields: li.fields,
|
|
56
|
+
subscriptionPlanIndex: li.subscription_plan_index,
|
|
57
|
+
customItemIndex: li.custom_item_index,
|
|
58
|
+
customItem: ci ? { id: ci.id, title: ci.title, price: ci.price } : undefined,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
function doApplyOperationsToLineItems(lineItems, operations) {
|
|
64
|
+
let newLineItems = klona(lineItems);
|
|
65
|
+
for (const op of operations) {
|
|
66
|
+
if (op.kind === "change") {
|
|
67
|
+
const li = newLineItems.find((li) => li.variantID === op.variantID);
|
|
68
|
+
if (li) {
|
|
69
|
+
const hasDiscountPreview = li.discountPreview > 0;
|
|
70
|
+
if (hasDiscountPreview) {
|
|
71
|
+
li.discountPreview /= li.quantity;
|
|
72
|
+
}
|
|
73
|
+
li.quantity += op.quantityDelta;
|
|
74
|
+
if (hasDiscountPreview) {
|
|
75
|
+
li.discountPreview *= li.quantity;
|
|
76
|
+
li.discountPreview = Math.round(li.discountPreview);
|
|
77
|
+
}
|
|
78
|
+
if (op.fieldSetID !== undefined && op.fields !== undefined) {
|
|
79
|
+
li.fields = op.fields;
|
|
80
|
+
li.fieldSetID = op.fieldSetID;
|
|
81
|
+
}
|
|
82
|
+
if (op.subscriptionPlanIndex !== undefined) {
|
|
83
|
+
li.subscriptionPlanIndex = op.subscriptionPlanIndex;
|
|
84
|
+
}
|
|
85
|
+
if (op.customItemIndex !== undefined) {
|
|
86
|
+
li.customItemIndex = op.customItemIndex;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (op.quantityDelta > 0) {
|
|
90
|
+
newLineItems.push({
|
|
91
|
+
quantity: op.quantityDelta,
|
|
92
|
+
variant: op.variant,
|
|
93
|
+
variantID: op.variantID,
|
|
94
|
+
discountPreview: 0,
|
|
95
|
+
fieldSetID: op.fieldSetID || "",
|
|
96
|
+
fields: op.fields,
|
|
97
|
+
subscriptionPlanIndex: op.subscriptionPlanIndex,
|
|
98
|
+
customItemIndex: op.customItemIndex,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
// this should never happen
|
|
103
|
+
console.error(`line item not found (${op.variantID}) and quantity delta is ${op.quantityDelta}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (op.kind === "remove") {
|
|
107
|
+
newLineItems = newLineItems.filter((li) => li.variantID !== op.variantID);
|
|
108
|
+
}
|
|
109
|
+
else if (op.kind === "set") {
|
|
110
|
+
const li = newLineItems.find((li) => li.variantID === op.variantID);
|
|
111
|
+
if (op.quantity <= 0) {
|
|
112
|
+
// this should never happen
|
|
113
|
+
console.error(`negative quantity on set operation ${op.variantID}: ${op.quantity}`);
|
|
114
|
+
}
|
|
115
|
+
else if (li) {
|
|
116
|
+
if (li.discountPreview > 0) {
|
|
117
|
+
li.discountPreview /= li.quantity;
|
|
118
|
+
li.discountPreview *= op.quantity;
|
|
119
|
+
li.discountPreview = Math.round(li.discountPreview);
|
|
120
|
+
}
|
|
121
|
+
li.quantity = op.quantity;
|
|
122
|
+
if (op.fieldSetID !== undefined && op.fields !== undefined) {
|
|
123
|
+
li.fields = op.fields;
|
|
124
|
+
li.fieldSetID = op.fieldSetID;
|
|
125
|
+
}
|
|
126
|
+
if (op.subscriptionPlanIndex !== undefined) {
|
|
127
|
+
li.subscriptionPlanIndex = op.subscriptionPlanIndex;
|
|
128
|
+
}
|
|
129
|
+
if (op.customItemIndex !== undefined) {
|
|
130
|
+
li.customItemIndex = op.customItemIndex;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
newLineItems.push({
|
|
135
|
+
quantity: op.quantity,
|
|
136
|
+
variant: op.variant,
|
|
137
|
+
variantID: op.variantID,
|
|
138
|
+
discountPreview: 0,
|
|
139
|
+
fieldSetID: op.fieldSetID || "",
|
|
140
|
+
fields: op.fields,
|
|
141
|
+
subscriptionPlanIndex: op.subscriptionPlanIndex,
|
|
142
|
+
customItemIndex: op.customItemIndex,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (newLineItems.some((li) => li.quantity <= 0)) {
|
|
148
|
+
newLineItems = newLineItems.filter((li) => li.quantity > 0);
|
|
149
|
+
}
|
|
150
|
+
return newLineItems;
|
|
151
|
+
}
|
|
152
|
+
function lineItemsToAPIMutation(lineItems) {
|
|
153
|
+
return lineItems.map((li) => ({
|
|
154
|
+
variant_id: li.variantID.startsWith("ci_") ? "" : li.variantID,
|
|
155
|
+
quantity: li.quantity,
|
|
156
|
+
field_set_id: li.fieldSetID,
|
|
157
|
+
fields: li.fields,
|
|
158
|
+
subscription_plan_index: li.subscriptionPlanIndex !== undefined ? { value: li.subscriptionPlanIndex } : undefined,
|
|
159
|
+
custom_item_index: li.customItemIndex !== undefined ? { value: li.customItemIndex } : undefined,
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Create the Cart instance with a given config and init option. Note that if init option is not "new", cart
|
|
164
|
+
* will start fetching its state from the server right away.
|
|
165
|
+
*/
|
|
166
|
+
export function createCart(config, init) {
|
|
167
|
+
let initialized = false;
|
|
168
|
+
let configWithJWT = { ...config };
|
|
169
|
+
let savedCurrency = "";
|
|
170
|
+
const queue = new ControlledQueue();
|
|
171
|
+
const setActivity = createEvent();
|
|
172
|
+
const setLocked = createEvent();
|
|
173
|
+
const setCartData = createEvent();
|
|
174
|
+
const setLineItems = createEvent();
|
|
175
|
+
const setLineItemsIfChanged = createEvent();
|
|
176
|
+
const setCurrencyValue = createEvent();
|
|
177
|
+
const applyOperationsToLineItems = createEvent();
|
|
178
|
+
const setDiscountCodeResult = createEvent();
|
|
179
|
+
const setDiscountCodePending = createEvent();
|
|
180
|
+
const setDiscountCodeResultAndPending = createEvent();
|
|
181
|
+
const setDiscountCodeInput = createEvent();
|
|
182
|
+
const setAllState = createEvent();
|
|
183
|
+
const discountCodeInput = restore(setDiscountCodeInput, "")
|
|
184
|
+
.reset(guard({ source: setDiscountCodeResult, filter: (v) => v.kind === "ok" }))
|
|
185
|
+
.on(setAllState, (_, v) => v.discountCodeInput);
|
|
186
|
+
const activity = restore(setActivity, "idle").on(setAllState, (_, v) => v.activity);
|
|
187
|
+
const locked = restore(setLocked, false).on(setAllState, (_, v) => v.locked);
|
|
188
|
+
const lineItems = restore(setLineItems, [])
|
|
189
|
+
.on(applyOperationsToLineItems, doApplyOperationsToLineItems)
|
|
190
|
+
.on(setLineItemsIfChanged, (lineItems, newLineItems) => !dequal(lineItems, newLineItems) ? newLineItems : undefined)
|
|
191
|
+
.on(setAllState, (_, v) => v.lineItems);
|
|
192
|
+
const cartData = restore(setCartData, null).on(setAllState, (_, v) => v.cartData);
|
|
193
|
+
const discountCode = createStore("")
|
|
194
|
+
.on(setCartData, (_, v) => v?.cart.discount_code || "")
|
|
195
|
+
.on(setAllState, (_, v) => v.discountCode);
|
|
196
|
+
const discountCodePending = restore(setDiscountCodePending, false).on(setAllState, (_, v) => v.discountCodePending);
|
|
197
|
+
const discountCodeResult = restore(setDiscountCodeResult, { kind: "ok" }).on(setAllState, (_, v) => v.discountCodeResult);
|
|
198
|
+
const currency = restore(setCurrencyValue, "")
|
|
199
|
+
.on(setCartData, (_, v) => v?.cart.currency || "")
|
|
200
|
+
.on(setAllState, (_, v) => v.currency);
|
|
201
|
+
let persistLoaded = false;
|
|
202
|
+
if (config.persist) {
|
|
203
|
+
const VERSION = 1;
|
|
204
|
+
const { load, save, onChange, maxAgeMs } = config.persist;
|
|
205
|
+
const realMaxAgeMs = Math.max(maxAgeMs ?? 0, 0) || 1800000;
|
|
206
|
+
const allState = combine({
|
|
207
|
+
discountCodeInput,
|
|
208
|
+
activity,
|
|
209
|
+
locked,
|
|
210
|
+
lineItems,
|
|
211
|
+
cartData,
|
|
212
|
+
discountCode,
|
|
213
|
+
discountCodePending,
|
|
214
|
+
discountCodeResult,
|
|
215
|
+
currency,
|
|
216
|
+
});
|
|
217
|
+
if (init.kind === "load_or") {
|
|
218
|
+
const allState = deserialize(load(), VERSION, realMaxAgeMs);
|
|
219
|
+
if (allState) {
|
|
220
|
+
setAllState(allState);
|
|
221
|
+
persistLoaded = true;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
allState.updates.watch((data) => {
|
|
225
|
+
if (data.activity === "idle") {
|
|
226
|
+
// We only save cart when it's idle.
|
|
227
|
+
save(serialize(data, VERSION));
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
onChange((data) => {
|
|
231
|
+
const newAllState = deserialize(data, VERSION, realMaxAgeMs);
|
|
232
|
+
if (newAllState) {
|
|
233
|
+
queue.exec(async () => {
|
|
234
|
+
if (allState.getState().activity === "idle") {
|
|
235
|
+
// Only set new state if the cart is idle. It's better to ignore state updates from other browser tabs
|
|
236
|
+
// than to disrupt the current cart flow, whatever it is. Cart has recovery mechanisms for dealing with
|
|
237
|
+
// out-of-date state.
|
|
238
|
+
setAllState(newAllState);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
// api sync queue is drained as soon as possible and is used to update "lastAPIState"
|
|
245
|
+
const apiSyncQueue = [];
|
|
246
|
+
// prediction queue is drained as soon as possible and is used to produce "lineItems"
|
|
247
|
+
const predictionQueue = [];
|
|
248
|
+
const relaxedActivityReporter = new RelaxedCartActivityReporter(400, setActivity);
|
|
249
|
+
forward({
|
|
250
|
+
from: setDiscountCodeResultAndPending.map(([r, _code, _p]) => r),
|
|
251
|
+
to: setDiscountCodeResult,
|
|
252
|
+
});
|
|
253
|
+
forward({
|
|
254
|
+
from: setDiscountCodeResultAndPending.map(([_r, _code, p]) => p),
|
|
255
|
+
to: setDiscountCodePending,
|
|
256
|
+
});
|
|
257
|
+
// init never fails
|
|
258
|
+
queue.exec(async () => {
|
|
259
|
+
if (init.kind === "load_or") {
|
|
260
|
+
if (persistLoaded) {
|
|
261
|
+
initialized = true;
|
|
262
|
+
applyPredictionsIfInitialized();
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
await initCart(init.init);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
await initCart(init);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
function reportActivity(activity) {
|
|
273
|
+
relaxedActivityReporter.report(activity);
|
|
274
|
+
}
|
|
275
|
+
function applyLastAPIState(cart, predictedLineItems) {
|
|
276
|
+
const cartData = {
|
|
277
|
+
cart,
|
|
278
|
+
lineItems: apiStateToLineItems(cart, predictedLineItems),
|
|
279
|
+
};
|
|
280
|
+
setCartData(cartData);
|
|
281
|
+
return cartData;
|
|
282
|
+
}
|
|
283
|
+
async function initCart(init) {
|
|
284
|
+
const { graphql: { getCartQuery, getLastCartQuery }, shopID, opts, } = configWithJWT;
|
|
285
|
+
let resp;
|
|
286
|
+
if (init.kind === "fetch_by_id") {
|
|
287
|
+
reportActivity("init");
|
|
288
|
+
resp = firstResponseData(await request(getCartQuery)({ shopID, id: init.id, uuid: init.uuid }, opts));
|
|
289
|
+
reportActivity("idle");
|
|
290
|
+
}
|
|
291
|
+
else if (init.kind === "fetch_last") {
|
|
292
|
+
reportActivity("init");
|
|
293
|
+
resp = await request(getLastCartQuery)({ shopID }, opts);
|
|
294
|
+
reportActivity("idle");
|
|
295
|
+
}
|
|
296
|
+
else if (init.kind === "fetch_last_or_by_id") {
|
|
297
|
+
reportActivity("init");
|
|
298
|
+
resp = await request(getLastCartQuery)({ shopID }, opts);
|
|
299
|
+
if (resp.kind === "error" && resp.error.apiError?.code === ErrorCode.NotFound) {
|
|
300
|
+
resp = firstResponseData(await request(getCartQuery)({ shopID, id: init.id, uuid: init.uuid }, opts));
|
|
301
|
+
}
|
|
302
|
+
reportActivity("idle");
|
|
303
|
+
}
|
|
304
|
+
else if (init.kind === "new") {
|
|
305
|
+
// do nothing, new cart will be initialized lazily
|
|
306
|
+
}
|
|
307
|
+
if (resp) {
|
|
308
|
+
if (resp.kind === "data") {
|
|
309
|
+
if (resp.data.state === "cart") {
|
|
310
|
+
setLineItems(applyLastAPIState(resp.data).lineItems);
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
// for non-cart state we also do nothing
|
|
314
|
+
// TODO: unreserve reserved orders
|
|
315
|
+
console.error("order is not in cart state");
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
// print error and do nothing, we'll start a new cart
|
|
320
|
+
console.error(prettyPrintRequestResponseError(resp));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
initialized = true;
|
|
324
|
+
applyPredictionsIfInitialized();
|
|
325
|
+
}
|
|
326
|
+
function drainPredictionQueue() {
|
|
327
|
+
const operations = compactCartOperations(predictionQueue);
|
|
328
|
+
predictionQueue.length = 0;
|
|
329
|
+
return operations;
|
|
330
|
+
}
|
|
331
|
+
function drainAPISyncQueue() {
|
|
332
|
+
const operations = compactCartOperations(apiSyncQueue);
|
|
333
|
+
apiSyncQueue.length = 0;
|
|
334
|
+
return operations;
|
|
335
|
+
}
|
|
336
|
+
function applyPredictionsIfInitialized() {
|
|
337
|
+
if (!initialized)
|
|
338
|
+
return;
|
|
339
|
+
const operations = drainPredictionQueue();
|
|
340
|
+
if (operations.length === 0)
|
|
341
|
+
return;
|
|
342
|
+
applyOperationsToLineItems(operations);
|
|
343
|
+
}
|
|
344
|
+
function launchLineItemsSyncTaskIfInitialized() {
|
|
345
|
+
if (!initialized)
|
|
346
|
+
return;
|
|
347
|
+
queue.exec(async (controller) => {
|
|
348
|
+
const respError = await lineItemsSync();
|
|
349
|
+
if (respError) {
|
|
350
|
+
controller.discard();
|
|
351
|
+
}
|
|
352
|
+
return respError;
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
async function submitOperationsToAPIOnce(operations) {
|
|
356
|
+
const { graphql: { createCartMutation, modifyCartMutation }, shopID, opts, } = configWithJWT;
|
|
357
|
+
let predictedLineItems;
|
|
358
|
+
let resp;
|
|
359
|
+
const cd = cartData.getState();
|
|
360
|
+
if (!cd) {
|
|
361
|
+
predictedLineItems = doApplyOperationsToLineItems([], filterOutNonCreateOpertions(operations));
|
|
362
|
+
resp = await request(createCartMutation)({
|
|
363
|
+
shopID,
|
|
364
|
+
data: { line_items: lineItemsToAPIMutation(predictedLineItems), currency: savedCurrency || undefined },
|
|
365
|
+
}, opts);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
predictedLineItems = doApplyOperationsToLineItems(cd.lineItems, operations);
|
|
369
|
+
resp = await request(modifyCartMutation)({
|
|
370
|
+
shopID,
|
|
371
|
+
id: cd.cart.id,
|
|
372
|
+
uuid: cd.cart.uuid,
|
|
373
|
+
updatedAt: cd.cart.updated_at,
|
|
374
|
+
data: { line_items: lineItemsToAPIMutation(predictedLineItems) },
|
|
375
|
+
}, opts);
|
|
376
|
+
}
|
|
377
|
+
if (resp.kind === "data") {
|
|
378
|
+
applyLastAPIState(resp.data[0], predictedLineItems);
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
return resp;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
async function submitOperationsToAPI(operations) {
|
|
385
|
+
while (true) {
|
|
386
|
+
const respError = await submitOperationsToAPIOnce(operations);
|
|
387
|
+
if (!respError) {
|
|
388
|
+
// if there was no error, return
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
const cd = cartData.getState();
|
|
392
|
+
if (respError.kind === "error" && respError.error.apiError?.code === ErrorCode.VersionMismatch && cd) {
|
|
393
|
+
// if it was version mismatch, fetch the cart again and retry
|
|
394
|
+
const { id, uuid } = cd.cart;
|
|
395
|
+
const respError = await refetchCart(id, uuid);
|
|
396
|
+
if (respError) {
|
|
397
|
+
return respError;
|
|
398
|
+
}
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
// otherwise, some unknown error? return it
|
|
403
|
+
return respError;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
async function refetchCart(id, uuid) {
|
|
408
|
+
const { graphql: { getCartQuery }, shopID, opts, } = configWithJWT;
|
|
409
|
+
const resp = await request(getCartQuery)({ shopID, id, uuid }, opts);
|
|
410
|
+
if (resp.kind === "data") {
|
|
411
|
+
// TODO: what if it's not in cart state?
|
|
412
|
+
applyLastAPIState(resp.data[0]);
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
return resp;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
async function lineItemsSync() {
|
|
419
|
+
// exit early if there is nothing to do
|
|
420
|
+
if (apiSyncQueue.length === 0)
|
|
421
|
+
return undefined;
|
|
422
|
+
let error;
|
|
423
|
+
reportActivity("sync");
|
|
424
|
+
while (true) {
|
|
425
|
+
const operations = drainAPISyncQueue();
|
|
426
|
+
if (operations.length === 0)
|
|
427
|
+
break;
|
|
428
|
+
error = await submitOperationsToAPI(operations);
|
|
429
|
+
if (error) {
|
|
430
|
+
// if there was an error, operations were not applied, return them to queue and break out of the loop
|
|
431
|
+
apiSyncQueue.splice(0, 0, ...operations);
|
|
432
|
+
}
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
reportActivity("idle");
|
|
436
|
+
if (error) {
|
|
437
|
+
initialized = false;
|
|
438
|
+
setLocked(true);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
// correct prediction if it's required
|
|
442
|
+
const cd = cartData.getState();
|
|
443
|
+
if (cd) {
|
|
444
|
+
setLineItemsIfChanged(cd.lineItems);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return error;
|
|
448
|
+
}
|
|
449
|
+
function applyOp(op) {
|
|
450
|
+
predictionQueue.push(op);
|
|
451
|
+
apiSyncQueue.push(op);
|
|
452
|
+
applyPredictionsIfInitialized();
|
|
453
|
+
launchLineItemsSyncTaskIfInitialized();
|
|
454
|
+
}
|
|
455
|
+
function makeSureNotLocked() {
|
|
456
|
+
if (locked.getState()) {
|
|
457
|
+
throw new Error("Cart is locked due to synchronization error. Please reload() it before continuing its usage.");
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function postInit() {
|
|
461
|
+
initialized = true;
|
|
462
|
+
applyPredictionsIfInitialized();
|
|
463
|
+
if (apiSyncQueue.length > 0) {
|
|
464
|
+
// successful init, we might have some items in the queue, let's drain them
|
|
465
|
+
launchLineItemsSyncTaskIfInitialized();
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
// successful init, but no operations to apply, make sure there is no stale state
|
|
469
|
+
setLineItemsIfChanged(cartData.getState()?.lineItems || []);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
async function applyDiscountCodeImpl(discount_code) {
|
|
473
|
+
if (discountCodePending.getState())
|
|
474
|
+
return;
|
|
475
|
+
setDiscountCodePending(true);
|
|
476
|
+
const result = await queue.exec(async () => {
|
|
477
|
+
const { shopID, opts, graphql: { createCartMutation, modifyCartMutation }, } = configWithJWT;
|
|
478
|
+
while (true) {
|
|
479
|
+
let resp;
|
|
480
|
+
reportActivity("discount");
|
|
481
|
+
const cd = cartData.getState();
|
|
482
|
+
if (!cd) {
|
|
483
|
+
resp = await request(createCartMutation)({ shopID, data: { currency: savedCurrency || undefined, discount_code } }, opts);
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
const { id, uuid, updated_at: updatedAt } = cd.cart;
|
|
487
|
+
resp = await request(modifyCartMutation)({ shopID, id, uuid, updatedAt, data: { discount_code } }, opts);
|
|
488
|
+
}
|
|
489
|
+
reportActivity("idle");
|
|
490
|
+
if (resp.kind === "data") {
|
|
491
|
+
const lis = applyLastAPIState(resp.data[0], lineItems.getState()).lineItems;
|
|
492
|
+
if (apiSyncQueue.length === 0) {
|
|
493
|
+
// only sync items if there is nothing in the sync queue, otherwise let api sync loop to
|
|
494
|
+
// do the job, this also plays better with prediction model
|
|
495
|
+
setLineItemsIfChanged(lis);
|
|
496
|
+
}
|
|
497
|
+
return { kind: "ok" };
|
|
498
|
+
}
|
|
499
|
+
else if (resp.kind === "system_error" || resp.kind === "custom_error") {
|
|
500
|
+
return { kind: "unexpected_error", error: resp };
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
const apiError = resp.error.apiError;
|
|
504
|
+
if (apiError?.code === ErrorCode.VersionMismatch && cd) {
|
|
505
|
+
const { id, uuid } = cd.cart;
|
|
506
|
+
const respError = await refetchCart(id, uuid);
|
|
507
|
+
if (respError) {
|
|
508
|
+
return { kind: "unexpected_error", error: respError };
|
|
509
|
+
}
|
|
510
|
+
continue; // retry
|
|
511
|
+
}
|
|
512
|
+
else if (apiError?.code === ErrorCode.NotFound && apiError.field === "[0].discount_code") {
|
|
513
|
+
return { kind: "not_found" };
|
|
514
|
+
}
|
|
515
|
+
else if (apiError?.code === ErrorCode.InvalidInput) {
|
|
516
|
+
const fields = apiError.meta?.fields;
|
|
517
|
+
if (fields &&
|
|
518
|
+
fields.length === 1 &&
|
|
519
|
+
fields[0].field === "[0].customer_id" &&
|
|
520
|
+
fields[0].problem === "mandatory") {
|
|
521
|
+
return { kind: "customer_id_required" };
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
return { kind: "unexpected_error", error: resp };
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
setDiscountCodeResultAndPending([
|
|
529
|
+
result.kind === "discarded" ? { kind: "discarded" } : result.value,
|
|
530
|
+
discount_code,
|
|
531
|
+
false,
|
|
532
|
+
]);
|
|
533
|
+
}
|
|
534
|
+
function reload() {
|
|
535
|
+
if (!locked.getState()) {
|
|
536
|
+
throw new Error("You can reload() the cart only if it was locked due to synchronization errors previously.");
|
|
537
|
+
}
|
|
538
|
+
const cd = cartData.getState();
|
|
539
|
+
if (!cd) {
|
|
540
|
+
// if cart failed during "create cart" operation, there is nothing to restore, just unlock
|
|
541
|
+
setLocked(false);
|
|
542
|
+
postInit();
|
|
543
|
+
}
|
|
544
|
+
else {
|
|
545
|
+
// if cart failed during "modify cart" operation, we should attempt to refetch it
|
|
546
|
+
const { id, uuid } = cd.cart;
|
|
547
|
+
setLocked(false);
|
|
548
|
+
queue.exec(async (controller) => {
|
|
549
|
+
reportActivity("init");
|
|
550
|
+
const respError = await refetchCart(id, uuid);
|
|
551
|
+
reportActivity("idle");
|
|
552
|
+
if (respError) {
|
|
553
|
+
controller.discard();
|
|
554
|
+
setLocked(true);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
postInit();
|
|
558
|
+
}
|
|
559
|
+
return respError;
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function setItem(variantID, variant, quantity, fieldSetID, fields, subscriptionPlanIndex) {
|
|
564
|
+
makeSureNotLocked();
|
|
565
|
+
applyOp({ kind: "set", quantity, variant, variantID, fieldSetID, fields, subscriptionPlanIndex });
|
|
566
|
+
}
|
|
567
|
+
function changeItem(variantID, variant, quantityDelta, fieldSetID, fields, subscriptionPlanIndex) {
|
|
568
|
+
makeSureNotLocked();
|
|
569
|
+
applyOp({ kind: "change", quantityDelta, variant, variantID, fieldSetID, fields, subscriptionPlanIndex });
|
|
570
|
+
}
|
|
571
|
+
function removeItem(variantID) {
|
|
572
|
+
makeSureNotLocked();
|
|
573
|
+
applyOp({ kind: "remove", variantID });
|
|
574
|
+
}
|
|
575
|
+
function removeDiscountCode() {
|
|
576
|
+
makeSureNotLocked();
|
|
577
|
+
applyDiscountCodeImpl("");
|
|
578
|
+
}
|
|
579
|
+
function applyDiscountCode() {
|
|
580
|
+
makeSureNotLocked();
|
|
581
|
+
applyDiscountCodeImpl(discountCodeInput.getState());
|
|
582
|
+
}
|
|
583
|
+
function checkout(callback) {
|
|
584
|
+
makeSureNotLocked();
|
|
585
|
+
queue.exec(async () => {
|
|
586
|
+
await callback();
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
function setCurrency(currency, mode) {
|
|
590
|
+
makeSureNotLocked();
|
|
591
|
+
queue.exec(async (controller) => {
|
|
592
|
+
const cd = cartData.getState();
|
|
593
|
+
if (cd && cd.cart.currency !== currency) {
|
|
594
|
+
// Soft mode means we only set currency if there is no cart yet.
|
|
595
|
+
if (mode === "soft")
|
|
596
|
+
return;
|
|
597
|
+
const { shopID, opts, graphql: { modifyCartMutation }, } = configWithJWT;
|
|
598
|
+
const { id, uuid, updated_at: updatedAt } = cd.cart;
|
|
599
|
+
reportActivity("currency");
|
|
600
|
+
const resp = await request(modifyCartMutation)({ shopID, id, uuid, updatedAt, data: { currency } }, opts);
|
|
601
|
+
reportActivity("idle");
|
|
602
|
+
if (resp.kind === "data") {
|
|
603
|
+
const lis = applyLastAPIState(resp.data[0], lineItems.getState()).lineItems;
|
|
604
|
+
if (apiSyncQueue.length === 0) {
|
|
605
|
+
// only sync items if there is nothing in the sync queue, otherwise let api sync loop to
|
|
606
|
+
// do the job, this also plays better with prediction model
|
|
607
|
+
setLineItemsIfChanged(lis);
|
|
608
|
+
}
|
|
609
|
+
savedCurrency = currency;
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
controller.discard();
|
|
613
|
+
setLocked(true);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
else {
|
|
617
|
+
savedCurrency = currency;
|
|
618
|
+
setCurrencyValue(currency);
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
config.locale.updates.watch((locale) => {
|
|
623
|
+
makeSureNotLocked();
|
|
624
|
+
queue.exec(async (controller) => {
|
|
625
|
+
configWithJWT = {
|
|
626
|
+
...configWithJWT,
|
|
627
|
+
opts: {
|
|
628
|
+
...configWithJWT.opts,
|
|
629
|
+
locale,
|
|
630
|
+
},
|
|
631
|
+
};
|
|
632
|
+
const cd = cartData.getState();
|
|
633
|
+
if (cd) {
|
|
634
|
+
const { id, uuid } = cd.cart;
|
|
635
|
+
reportActivity("init");
|
|
636
|
+
const respError = await refetchCart(id, uuid);
|
|
637
|
+
reportActivity("idle");
|
|
638
|
+
if (respError) {
|
|
639
|
+
controller.discard();
|
|
640
|
+
setLocked(true);
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
postInit();
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
config.jwt.updates.watch((jwt) => {
|
|
649
|
+
makeSureNotLocked();
|
|
650
|
+
queue.exec(async (controller) => {
|
|
651
|
+
configWithJWT = {
|
|
652
|
+
...configWithJWT,
|
|
653
|
+
opts: {
|
|
654
|
+
...configWithJWT.opts,
|
|
655
|
+
authToken: jwt,
|
|
656
|
+
},
|
|
657
|
+
};
|
|
658
|
+
// when there is no jwt, just apply it and we'll continue using id/uuid from now on
|
|
659
|
+
if (!jwt)
|
|
660
|
+
return;
|
|
661
|
+
const { graphql: { getLastCartQuery }, shopID, opts, } = configWithJWT;
|
|
662
|
+
reportActivity("init");
|
|
663
|
+
const resp = await request(getLastCartQuery)({ shopID }, opts);
|
|
664
|
+
reportActivity("idle");
|
|
665
|
+
if (resp.kind === "error" && resp.error.apiError?.code === ErrorCode.NotFound) {
|
|
666
|
+
// if there is no last cart, do nothing
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
if (resp.kind === "data") {
|
|
670
|
+
applyLastAPIState(resp.data);
|
|
671
|
+
postInit();
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
controller.discard();
|
|
675
|
+
setLocked(true);
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
return {
|
|
680
|
+
setDiscountCodeInput,
|
|
681
|
+
discountCodeInput,
|
|
682
|
+
activity,
|
|
683
|
+
locked,
|
|
684
|
+
lineItems,
|
|
685
|
+
cartData,
|
|
686
|
+
discountCode,
|
|
687
|
+
discountCodePending,
|
|
688
|
+
discountCodeResult,
|
|
689
|
+
reload,
|
|
690
|
+
setItem,
|
|
691
|
+
changeItem,
|
|
692
|
+
removeItem,
|
|
693
|
+
applyDiscountCode,
|
|
694
|
+
removeDiscountCode,
|
|
695
|
+
checkout,
|
|
696
|
+
currency,
|
|
697
|
+
setCurrency,
|
|
698
|
+
};
|
|
699
|
+
}
|