@jetshop/core 6.3.8-alpha.32 → 6.3.8
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/ChannelHandler/ChannelHandler.d.ts +53 -0
- package/ChannelHandler/ChannelHandler.js +114 -0
- package/ChannelHandler/ChannelHandler.js.map +1 -0
- package/ChannelHandler/channelUtils.d.ts +73 -0
- package/ChannelHandler/channelUtils.js +313 -0
- package/ChannelHandler/channelUtils.js.map +1 -0
- package/ChannelHandler/redirectUtils.d.ts +4 -0
- package/ChannelHandler/redirectUtils.js +53 -0
- package/ChannelHandler/redirectUtils.js.map +1 -0
- package/analytics/Analytics.d.ts +18 -0
- package/analytics/Analytics.js +57 -0
- package/analytics/Analytics.js.map +1 -0
- package/analytics/AnalyticsProvider.d.ts +54 -0
- package/analytics/AnalyticsProvider.js +229 -0
- package/analytics/AnalyticsProvider.js.map +1 -0
- package/analytics/deprecatedTracking.d.ts +17 -0
- package/analytics/deprecatedTracking.js +33 -0
- package/analytics/deprecatedTracking.js.map +1 -0
- package/analytics/integrations/ga4.d.ts +28 -0
- package/analytics/integrations/ga4.js +189 -0
- package/analytics/integrations/ga4.js.map +1 -0
- package/analytics/integrations/gtag/gtag.d.ts +8 -0
- package/analytics/integrations/gtag/gtag.js +209 -0
- package/analytics/integrations/gtag/gtag.js.map +1 -0
- package/analytics/integrations/gtag/index.d.ts +1 -0
- package/analytics/integrations/gtag/index.js +2 -0
- package/analytics/integrations/gtag/index.js.map +1 -0
- package/analytics/integrations/gtm/gtm.d.ts +12 -0
- package/analytics/integrations/gtm/gtm.js +227 -0
- package/analytics/integrations/gtm/gtm.js.map +1 -0
- package/analytics/integrations/gtm/index.d.ts +1 -0
- package/analytics/integrations/gtm/index.js +2 -0
- package/analytics/integrations/gtm/index.js.map +1 -0
- package/analytics/integrations/gtm/referrerModifier.d.ts +1 -0
- package/analytics/integrations/gtm/referrerModifier.js +62 -0
- package/analytics/integrations/gtm/referrerModifier.js.map +1 -0
- package/analytics/integrations/releware/index.d.ts +3 -0
- package/analytics/integrations/releware/index.js +39 -0
- package/analytics/integrations/releware/index.js.map +1 -0
- package/analytics/integrations/unslugify.d.ts +1 -0
- package/analytics/integrations/unslugify.js +16 -0
- package/analytics/integrations/unslugify.js.map +1 -0
- package/analytics/trackerRegistry.d.ts +113 -0
- package/analytics/trackerRegistry.js +234 -0
- package/analytics/trackerRegistry.js.map +1 -0
- package/analytics/tracking.d.ts +14 -0
- package/analytics/tracking.js +72 -0
- package/analytics/tracking.js.map +1 -0
- package/analytics/utils/breadcrumbsWithoutProduct.d.ts +1 -0
- package/analytics/utils/breadcrumbsWithoutProduct.js +9 -0
- package/analytics/utils/breadcrumbsWithoutProduct.js.map +1 -0
- package/analytics/utils/script.d.ts +8 -0
- package/analytics/utils/script.js +40 -0
- package/analytics/utils/script.js.map +1 -0
- package/boot/AuthHandler.d.ts +14 -0
- package/boot/AuthHandler.js +39 -0
- package/boot/AuthHandler.js.map +1 -0
- package/boot/NetworkStatusNotifier.d.ts +2 -0
- package/boot/NetworkStatusNotifier.js +4 -0
- package/boot/NetworkStatusNotifier.js.map +1 -0
- package/boot/PreviewHandler.d.ts +7 -0
- package/boot/PreviewHandler.js +14 -0
- package/boot/PreviewHandler.js.map +1 -0
- package/boot/SharedTree.d.ts +23 -0
- package/boot/SharedTree.js +27 -0
- package/boot/SharedTree.js.map +1 -0
- package/boot/addMissingConfig.d.ts +5 -0
- package/boot/addMissingConfig.js +34 -0
- package/boot/addMissingConfig.js.map +1 -0
- package/boot/apollo.d.ts +20 -0
- package/boot/apollo.js +203 -0
- package/boot/apollo.js.map +1 -0
- package/boot/client/entrypoint.d.ts +1 -0
- package/boot/client/entrypoint.js +5 -0
- package/boot/client/entrypoint.js.map +1 -0
- package/boot/client/index.d.ts +1 -0
- package/boot/client/index.js +2 -0
- package/boot/client/index.js.map +1 -0
- package/boot/client/startClient.d.ts +4 -0
- package/boot/client/startClient.js +154 -0
- package/boot/client/startClient.js.map +1 -0
- package/boot/server/IntervalQuery.d.ts +32 -0
- package/boot/server/IntervalQuery.js +95 -0
- package/boot/server/IntervalQuery.js.map +1 -0
- package/boot/server/IntervalQuery.test.js +276 -0
- package/boot/server/PersistedApolloClient.d.ts +20 -0
- package/boot/server/PersistedApolloClient.js +40 -0
- package/boot/server/PersistedApolloClient.js.map +1 -0
- package/boot/server/PersistedApolloClient.test.js +234 -0
- package/boot/server/asyncErrorHandler.d.ts +3 -0
- package/boot/server/asyncErrorHandler.js +5 -0
- package/boot/server/asyncErrorHandler.js.map +1 -0
- package/boot/server/breakpointMiddleware.d.ts +3 -0
- package/boot/server/breakpointMiddleware.js +10 -0
- package/boot/server/breakpointMiddleware.js.map +1 -0
- package/boot/server/createApolloServer.d.ts +29 -0
- package/boot/server/createApolloServer.js +144 -0
- package/boot/server/createApolloServer.js.map +1 -0
- package/boot/server/createApolloServer.test.js +114 -0
- package/boot/server/createDevServer.d.ts +14 -0
- package/boot/server/createDevServer.js +30 -0
- package/boot/server/createDevServer.js.map +1 -0
- package/boot/server/createRenderer.d.ts +28 -0
- package/boot/server/createRenderer.js +246 -0
- package/boot/server/createRenderer.js.map +1 -0
- package/boot/server/createServer.d.ts +14 -0
- package/boot/server/createServer.js +42 -0
- package/boot/server/createServer.js.map +1 -0
- package/boot/server/entrypoint.d.ts +1 -0
- package/boot/server/entrypoint.js +39 -0
- package/boot/server/entrypoint.js.map +1 -0
- package/boot/server/getPrefetchFiles.d.ts +10 -0
- package/boot/server/getPrefetchFiles.js +20 -0
- package/boot/server/getPrefetchFiles.js.map +1 -0
- package/boot/server/getPreloadAssets.d.ts +10 -0
- package/boot/server/getPreloadAssets.js +18 -0
- package/boot/server/getPreloadAssets.js.map +1 -0
- package/boot/server/getPreloadAssets.test.js +133 -0
- package/boot/server/index.d.ts +9 -0
- package/boot/server/index.js +126 -0
- package/boot/server/index.js.map +1 -0
- package/boot/server/listen.d.ts +13 -0
- package/boot/server/listen.js +17 -0
- package/boot/server/listen.js.map +1 -0
- package/boot/server/persistedQueries/PersistedClient.d.ts +22 -0
- package/boot/server/persistedQueries/PersistedClient.js +58 -0
- package/boot/server/persistedQueries/PersistedClient.js.map +1 -0
- package/boot/server/persistedQueries/__tests__/getPersistedQueriesForRequest.test.js +201 -0
- package/boot/server/persistedQueries/__tests__/mockQuery.gql +6 -0
- package/boot/server/persistedQueries/getPersistedQueriesForRequest.d.ts +3 -0
- package/boot/server/persistedQueries/getPersistedQueriesForRequest.js +27 -0
- package/boot/server/persistedQueries/getPersistedQueriesForRequest.js.map +1 -0
- package/boot/server/saleSource.test.js +39 -0
- package/boot/server/salesSource.d.ts +8 -0
- package/boot/server/salesSource.js +16 -0
- package/boot/server/salesSource.js.map +1 -0
- package/boot/utils/createIntOptions.d.ts +6 -0
- package/boot/utils/createIntOptions.js +19 -0
- package/boot/utils/createIntOptions.js.map +1 -0
- package/boot/utils/queryLoggingMiddleware.d.ts +2 -0
- package/boot/utils/queryLoggingMiddleware.js +15 -0
- package/boot/utils/queryLoggingMiddleware.js.map +1 -0
- package/boot/utils/uid.d.ts +3 -0
- package/boot/utils/uid.js +20 -0
- package/boot/utils/uid.js.map +1 -0
- package/cart/AddToCartFormik.d.ts +42 -0
- package/cart/AddToCartFormik.js +79 -0
- package/cart/AddToCartFormik.js.map +1 -0
- package/cart/useAddToCart.d.ts +88 -0
- package/cart/useAddToCart.js +119 -0
- package/cart/useAddToCart.js.map +1 -0
- package/cart/useCart.d.ts +0 -0
- package/cart/useCart.js +1 -0
- package/cart/useCart.js.map +1 -0
- package/components/Auth/CustomerFormContainer.d.ts +0 -0
- package/components/Auth/CustomerFormContainer.js +1 -0
- package/components/Auth/CustomerFormContainer.js.map +1 -0
- package/components/Auth/CustomerUpdateForm.d.ts +32 -0
- package/components/Auth/CustomerUpdateForm.js +122 -0
- package/components/Auth/CustomerUpdateForm.js.map +1 -0
- package/components/Auth/ForgotPasswordProvider.d.ts +69 -0
- package/components/Auth/ForgotPasswordProvider.js +57 -0
- package/components/Auth/ForgotPasswordProvider.js.map +1 -0
- package/components/Auth/ResetPasswordProvider.d.ts +90 -0
- package/components/Auth/ResetPasswordProvider.js +78 -0
- package/components/Auth/ResetPasswordProvider.js.map +1 -0
- package/components/Auth/SSN.d.ts +12 -0
- package/components/Auth/SSN.js +35 -0
- package/components/Auth/SSN.js.map +1 -0
- package/components/Auth/SSNLookupContainer.d.ts +15 -0
- package/components/Auth/SSNLookupContainer.js +20 -0
- package/components/Auth/SSNLookupContainer.js.map +1 -0
- package/components/Auth/SignupFormContainer.d.ts +16 -0
- package/components/Auth/SignupFormContainer.js +82 -0
- package/components/Auth/SignupFormContainer.js.map +1 -0
- package/components/Auth/UpdatePasswordForm.d.ts +44 -0
- package/components/Auth/UpdatePasswordForm.js +98 -0
- package/components/Auth/UpdatePasswordForm.js.map +1 -0
- package/components/Auth/formFieldsFromSettings.d.ts +65 -0
- package/components/Auth/formFieldsFromSettings.js +77 -0
- package/components/Auth/formFieldsFromSettings.js.map +1 -0
- package/components/Auth/formatSignupInput.d.ts +8 -0
- package/components/Auth/formatSignupInput.js +43 -0
- package/components/Auth/formatSignupInput.js.map +1 -0
- package/components/Auth/signup-context.d.ts +36 -0
- package/components/Auth/signup-context.js +71 -0
- package/components/Auth/signup-context.js.map +1 -0
- package/components/Auth/signup-field-translations.d.ts +3 -0
- package/components/Auth/signup-field-translations.js +44 -0
- package/components/Auth/signup-field-translations.js.map +1 -0
- package/components/Auth/signupSubmit.d.ts +6 -0
- package/components/Auth/signupSubmit.js +65 -0
- package/components/Auth/signupSubmit.js.map +1 -0
- package/components/Auth/useAddressFields.d.ts +22 -0
- package/components/Auth/useAddressFields.js +33 -0
- package/components/Auth/useAddressFields.js.map +1 -0
- package/components/Auth/useCustomer.d.ts +116 -0
- package/components/Auth/useCustomer.js +189 -0
- package/components/Auth/useCustomer.js.map +1 -0
- package/components/Auth/useLoginFields.d.ts +20 -0
- package/components/Auth/useLoginFields.js +21 -0
- package/components/Auth/useLoginFields.js.map +1 -0
- package/components/Auth/useSignupForm.d.ts +7 -0
- package/components/Auth/useSignupForm.js +15 -0
- package/components/Auth/useSignupForm.js.map +1 -0
- package/components/AuthContext/AuthContext.d.ts +12 -0
- package/components/AuthContext/AuthContext.js +11 -0
- package/components/AuthContext/AuthContext.js.map +1 -0
- package/components/AuthContext/AuthProvider.d.ts +6 -0
- package/components/AuthContext/AuthProvider.js +100 -0
- package/components/AuthContext/AuthProvider.js.map +1 -0
- package/components/AuthContext/LogOut.d.ts +5 -0
- package/components/AuthContext/LogOut.js +17 -0
- package/components/AuthContext/LogOut.js.map +1 -0
- package/components/AuthContext/useAuth.d.ts +6 -0
- package/components/AuthContext/useAuth.js +20 -0
- package/components/AuthContext/useAuth.js.map +1 -0
- package/components/BreakpointProvider.d.ts +21 -0
- package/components/BreakpointProvider.js +24 -0
- package/components/BreakpointProvider.js.map +1 -0
- package/components/Cart/CartIdContext.d.ts +11 -0
- package/components/Cart/CartIdContext.js +61 -0
- package/components/Cart/CartIdContext.js.map +1 -0
- package/components/ChannelContext/ChannelContext.d.ts +21 -0
- package/components/ChannelContext/ChannelContext.js +4 -0
- package/components/ChannelContext/ChannelContext.js.map +1 -0
- package/components/ChannelContext/ChannelProvider.d.ts +10 -0
- package/components/ChannelContext/ChannelProvider.js +45 -0
- package/components/ChannelContext/ChannelProvider.js.map +1 -0
- package/components/ChannelContext/index.d.ts +2 -0
- package/components/ChannelContext/index.js +3 -0
- package/components/ChannelContext/index.js.map +1 -0
- package/components/ChannelContext/useCountrySettings.d.ts +8 -0
- package/components/ChannelContext/useCountrySettings.js +24 -0
- package/components/ChannelContext/useCountrySettings.js.map +1 -0
- package/components/ConfigProvider.d.ts +116 -0
- package/components/ConfigProvider.js +20 -0
- package/components/ConfigProvider.js.map +1 -0
- package/components/DynamicRoute/CategoryRoute.d.ts +13 -0
- package/components/DynamicRoute/CategoryRoute.js +59 -0
- package/components/DynamicRoute/CategoryRoute.js.map +1 -0
- package/components/DynamicRoute/ContentRoute.d.ts +14 -0
- package/components/DynamicRoute/ContentRoute.js +28 -0
- package/components/DynamicRoute/ContentRoute.js.map +1 -0
- package/components/DynamicRoute/CustomerRoute.d.ts +0 -0
- package/components/DynamicRoute/CustomerRoute.js +1 -0
- package/components/DynamicRoute/CustomerRoute.js.map +1 -0
- package/components/DynamicRoute/GenericError.d.ts +18 -0
- package/components/DynamicRoute/GenericError.js +61 -0
- package/components/DynamicRoute/GenericError.js.map +1 -0
- package/components/DynamicRoute/PreviewRoute.d.ts +17 -0
- package/components/DynamicRoute/PreviewRoute.js +58 -0
- package/components/DynamicRoute/PreviewRoute.js.map +1 -0
- package/components/DynamicRoute/ProductByArticlenumber.d.ts +5 -0
- package/components/DynamicRoute/ProductByArticlenumber.js +22 -0
- package/components/DynamicRoute/ProductByArticlenumber.js.map +1 -0
- package/components/DynamicRoute/ProductRoute.d.ts +15 -0
- package/components/DynamicRoute/ProductRoute.js +73 -0
- package/components/DynamicRoute/ProductRoute.js.map +1 -0
- package/components/DynamicRoute/RouteResolver.d.ts +22 -0
- package/components/DynamicRoute/RouteResolver.js +64 -0
- package/components/DynamicRoute/RouteResolver.js.map +1 -0
- package/components/DynamicRoute/Status.d.ts +15 -0
- package/components/DynamicRoute/Status.js +20 -0
- package/components/DynamicRoute/Status.js.map +1 -0
- package/components/DynamicRoute/index.d.ts +17 -0
- package/components/DynamicRoute/index.js +101 -0
- package/components/DynamicRoute/index.js.map +1 -0
- package/components/Filters/index.d.ts +1 -0
- package/components/Filters/index.js +2 -0
- package/components/Filters/index.js.map +1 -0
- package/components/Filters/utils/replaceInSearch.d.ts +14 -0
- package/components/Filters/utils/replaceInSearch.js +23 -0
- package/components/Filters/utils/replaceInSearch.js.map +1 -0
- package/components/Filters/utils/updateHistory.d.ts +25 -0
- package/components/Filters/utils/updateHistory.js +30 -0
- package/components/Filters/utils/updateHistory.js.map +1 -0
- package/components/Fonts/CustomFont.d.ts +14 -0
- package/components/Fonts/CustomFont.js +17 -0
- package/components/Fonts/CustomFont.js.map +1 -0
- package/components/Fonts/injectFont.d.ts +11 -0
- package/components/Fonts/injectFont.js +30 -0
- package/components/Fonts/injectFont.js.map +1 -0
- package/components/Head.d.ts +11 -0
- package/components/Head.js +86 -0
- package/components/Head.js.map +1 -0
- package/components/Mutation/AddToCart/addToCartUtils.d.ts +18 -0
- package/components/Mutation/AddToCart/addToCartUtils.js +52 -0
- package/components/Mutation/AddToCart/addToCartUtils.js.map +1 -0
- package/components/Mutation/AddToCartFormik.d.ts +53 -0
- package/components/Mutation/AddToCartFormik.js +183 -0
- package/components/Mutation/AddToCartFormik.js.map +1 -0
- package/components/Mutation/DecrementQuantity.d.ts +4 -0
- package/components/Mutation/DecrementQuantity.js +35 -0
- package/components/Mutation/DecrementQuantity.js.map +1 -0
- package/components/Mutation/IncrementQuantity.d.ts +4 -0
- package/components/Mutation/IncrementQuantity.js +35 -0
- package/components/Mutation/IncrementQuantity.js.map +1 -0
- package/components/Mutation/RemoveFromCart.d.ts +5 -0
- package/components/Mutation/RemoveFromCart.js +52 -0
- package/components/Mutation/RemoveFromCart.js.map +1 -0
- package/components/Mutation/SetQuantity.d.ts +4 -0
- package/components/Mutation/SetQuantity.js +37 -0
- package/components/Mutation/SetQuantity.js.map +1 -0
- package/components/Mutation/SubscribeToNewsletter.d.ts +4 -0
- package/components/Mutation/SubscribeToNewsletter.js +30 -0
- package/components/Mutation/SubscribeToNewsletter.js.map +1 -0
- package/components/Mutation/SubscribeToStockNotifications.d.ts +4 -0
- package/components/Mutation/SubscribeToStockNotifications.js +35 -0
- package/components/Mutation/SubscribeToStockNotifications.js.map +1 -0
- package/components/Mutation/cartMutationUtils.d.ts +27 -0
- package/components/Mutation/cartMutationUtils.js +106 -0
- package/components/Mutation/cartMutationUtils.js.map +1 -0
- package/components/Mutation/useDecrementQuantity.d.ts +11 -0
- package/components/Mutation/useDecrementQuantity.js +50 -0
- package/components/Mutation/useDecrementQuantity.js.map +1 -0
- package/components/Mutation/useIncrementQuantity.d.ts +11 -0
- package/components/Mutation/useIncrementQuantity.js +50 -0
- package/components/Mutation/useIncrementQuantity.js.map +1 -0
- package/components/Mutation/useRemoveFromCart.d.ts +13 -0
- package/components/Mutation/useRemoveFromCart.js +45 -0
- package/components/Mutation/useRemoveFromCart.js.map +1 -0
- package/components/Mutation/useSetQuantity.d.ts +12 -0
- package/components/Mutation/useSetQuantity.js +38 -0
- package/components/Mutation/useSetQuantity.js.map +1 -0
- package/components/Notifications/Notifications.d.ts +15 -0
- package/components/Notifications/Notifications.js +26 -0
- package/components/Notifications/Notifications.js.map +1 -0
- package/components/Notifications/index.d.ts +2 -0
- package/components/Notifications/index.js +3 -0
- package/components/Notifications/index.js.map +1 -0
- package/components/Notifications/notificationMachine.d.ts +30 -0
- package/components/Notifications/notificationMachine.js +74 -0
- package/components/Notifications/notificationMachine.js.map +1 -0
- package/components/Notifications/notificationsMachine.d.ts +37 -0
- package/components/Notifications/notificationsMachine.js +66 -0
- package/components/Notifications/notificationsMachine.js.map +1 -0
- package/components/Notifications/useNotification.d.ts +9 -0
- package/components/Notifications/useNotification.js +27 -0
- package/components/Notifications/useNotification.js.map +1 -0
- package/components/OpenGraph/OpenGraphGeneralPageData.d.ts +25 -0
- package/components/OpenGraph/OpenGraphGeneralPageData.js +37 -0
- package/components/OpenGraph/OpenGraphGeneralPageData.js.map +1 -0
- package/components/OpenGraph/OpenGraphProductData.d.ts +25 -0
- package/components/OpenGraph/OpenGraphProductData.js +49 -0
- package/components/OpenGraph/OpenGraphProductData.js.map +1 -0
- package/components/OpenGraph/index.d.ts +2 -0
- package/components/OpenGraph/index.js +3 -0
- package/components/OpenGraph/index.js.map +1 -0
- package/components/Pagination/PaginationContainer.d.ts +2 -0
- package/components/Pagination/PaginationContainer.js +5 -0
- package/components/Pagination/PaginationContainer.js.map +1 -0
- package/components/Pagination/PaginationContext.d.ts +14 -0
- package/components/Pagination/PaginationContext.js +4 -0
- package/components/Pagination/PaginationContext.js.map +1 -0
- package/components/Pagination/PaginationProvider.d.ts +19 -0
- package/components/Pagination/PaginationProvider.js +95 -0
- package/components/Pagination/PaginationProvider.js.map +1 -0
- package/components/PreviewContext.d.ts +10 -0
- package/components/PreviewContext.js +27 -0
- package/components/PreviewContext.js.map +1 -0
- package/components/ProductConfigurationProvider/ProductConfigurationContext.d.ts +13 -0
- package/components/ProductConfigurationProvider/ProductConfigurationContext.js +5 -0
- package/components/ProductConfigurationProvider/ProductConfigurationContext.js.map +1 -0
- package/components/ProductConfigurationProvider/ProductConfigurationProvider.d.ts +6 -0
- package/components/ProductConfigurationProvider/ProductConfigurationProvider.js +50 -0
- package/components/ProductConfigurationProvider/ProductConfigurationProvider.js.map +1 -0
- package/components/Query/CartProvider.d.ts +22 -0
- package/components/Query/CartProvider.js +68 -0
- package/components/Query/CartProvider.js.map +1 -0
- package/components/SortOrder/SortOrderContainer.d.ts +40 -0
- package/components/SortOrder/SortOrderContainer.js +108 -0
- package/components/SortOrder/SortOrderContainer.js.map +1 -0
- package/components/SortOrder/SortOrderContext.d.ts +9 -0
- package/components/SortOrder/SortOrderContext.js +9 -0
- package/components/SortOrder/SortOrderContext.js.map +1 -0
- package/components/StructuredData/SiteLinksSearchStructuredData.d.ts +3 -0
- package/components/StructuredData/SiteLinksSearchStructuredData.js +25 -0
- package/components/StructuredData/SiteLinksSearchStructuredData.js.map +1 -0
- package/components/StructuredData/StructuredBreadcrumbData.d.ts +12 -0
- package/components/StructuredData/StructuredBreadcrumbData.js +55 -0
- package/components/StructuredData/StructuredBreadcrumbData.js.map +1 -0
- package/components/StructuredData/StructuredCategoryData.d.ts +16 -0
- package/components/StructuredData/StructuredCategoryData.js +18 -0
- package/components/StructuredData/StructuredCategoryData.js.map +1 -0
- package/components/StructuredData/StructuredData.d.ts +9 -0
- package/components/StructuredData/StructuredData.js +7 -0
- package/components/StructuredData/StructuredData.js.map +1 -0
- package/components/StructuredData/StructuredPageData.d.ts +16 -0
- package/components/StructuredData/StructuredPageData.js +17 -0
- package/components/StructuredData/StructuredPageData.js.map +1 -0
- package/components/StructuredData/StructuredProductData.d.ts +18 -0
- package/components/StructuredData/StructuredProductData.js +43 -0
- package/components/StructuredData/StructuredProductData.js.map +1 -0
- package/components/StructuredData/index.d.ts +5 -0
- package/components/StructuredData/index.js +6 -0
- package/components/StructuredData/index.js.map +1 -0
- package/data/cache.d.ts +3 -0
- package/data/cache.js +71 -0
- package/data/cache.js.map +1 -0
- package/data/fragmentTypes.d.ts +8 -0
- package/data/fragmentTypes.js +84 -0
- package/data/fragmentTypes.js.map +1 -0
- package/data/fragments/index.d.ts +1 -0
- package/data/fragments/index.js +2 -0
- package/data/fragments/index.js.map +1 -0
- package/errorReporting.browser.d.ts +3 -0
- package/errorReporting.browser.js +17 -0
- package/errorReporting.browser.js.map +1 -0
- package/errorReporting.d.ts +4 -0
- package/errorReporting.js +24 -0
- package/errorReporting.js.map +1 -0
- package/errorReporting.server.d.ts +3 -0
- package/errorReporting.server.js +12 -0
- package/errorReporting.server.js.map +1 -0
- package/errorReporting.shared.d.ts +5 -0
- package/errorReporting.shared.js +17 -0
- package/errorReporting.shared.js.map +1 -0
- package/experiments/ExperimentsProvider.d.ts +4 -0
- package/experiments/ExperimentsProvider.js +29 -0
- package/experiments/ExperimentsProvider.js.map +1 -0
- package/experiments/selectExperimentVariant.d.ts +3 -0
- package/experiments/selectExperimentVariant.js +35 -0
- package/experiments/selectExperimentVariant.js.map +1 -0
- package/experiments/useExperiment.d.ts +2 -0
- package/experiments/useExperiment.js +11 -0
- package/experiments/useExperiment.js.map +1 -0
- package/global.d.ts +1 -0
- package/helpers/decodeUrlQuery.d.ts +9 -0
- package/helpers/decodeUrlQuery.js +27 -0
- package/helpers/decodeUrlQuery.js.map +1 -0
- package/helpers/distance.d.ts +7 -0
- package/helpers/distance.js +13 -0
- package/helpers/distance.js.map +1 -0
- package/helpers/encodeVariant.d.ts +3 -0
- package/helpers/encodeVariant.js +25 -0
- package/helpers/encodeVariant.js.map +1 -0
- package/helpers/getBreakpointsFromValues.d.ts +6 -0
- package/helpers/getBreakpointsFromValues.js +15 -0
- package/helpers/getBreakpointsFromValues.js.map +1 -0
- package/helpers/getCartItemVariant.d.ts +7 -0
- package/helpers/getCartItemVariant.js +9 -0
- package/helpers/getCartItemVariant.js.map +1 -0
- package/helpers/getErrorDetail.d.ts +7 -0
- package/helpers/getErrorDetail.js +12 -0
- package/helpers/getErrorDetail.js.map +1 -0
- package/helpers/getHeaders.d.ts +6 -0
- package/helpers/getHeaders.js +4 -0
- package/helpers/getHeaders.js.map +1 -0
- package/helpers/isRelativeUrl.d.ts +1 -0
- package/helpers/isRelativeUrl.js +4 -0
- package/helpers/isRelativeUrl.js.map +1 -0
- package/helpers/logError.d.ts +1 -0
- package/helpers/logError.js +17 -0
- package/helpers/logError.js.map +1 -0
- package/helpers/logWarningInDev.d.ts +1 -0
- package/helpers/logWarningInDev.js +7 -0
- package/helpers/logWarningInDev.js.map +1 -0
- package/helpers/throwErrorInDev.d.ts +6 -0
- package/helpers/throwErrorInDev.js +20 -0
- package/helpers/throwErrorInDev.js.map +1 -0
- package/helpers/uniqueId.d.ts +5 -0
- package/helpers/uniqueId.js +10 -0
- package/helpers/uniqueId.js.map +1 -0
- package/hooks/Channels/useChannelSettings.d.ts +7 -0
- package/hooks/Channels/useChannelSettings.js +12 -0
- package/hooks/Channels/useChannelSettings.js.map +1 -0
- package/hooks/Filters/useBooleanFilter.d.ts +8 -0
- package/hooks/Filters/useBooleanFilter.js +20 -0
- package/hooks/Filters/useBooleanFilter.js.map +1 -0
- package/hooks/Filters/useFilters.d.ts +3 -0
- package/hooks/Filters/useFilters.js +15 -0
- package/hooks/Filters/useFilters.js.map +1 -0
- package/hooks/Filters/useListFilter.d.ts +10 -0
- package/hooks/Filters/useListFilter.js +37 -0
- package/hooks/Filters/useListFilter.js.map +1 -0
- package/hooks/Filters/useMultiFilter.d.ts +13 -0
- package/hooks/Filters/useMultiFilter.js +49 -0
- package/hooks/Filters/useMultiFilter.js.map +1 -0
- package/hooks/Filters/useRangeFilter.d.ts +10 -0
- package/hooks/Filters/useRangeFilter.js +35 -0
- package/hooks/Filters/useRangeFilter.js.map +1 -0
- package/hooks/Filters/useSortOrder.d.ts +16 -0
- package/hooks/Filters/useSortOrder.js +23 -0
- package/hooks/Filters/useSortOrder.js.map +1 -0
- package/hooks/PackageProducts/index.d.ts +2 -0
- package/hooks/PackageProducts/index.js +3 -0
- package/hooks/PackageProducts/index.js.map +1 -0
- package/hooks/PackageProducts/usePackageProductItem.d.ts +17 -0
- package/hooks/PackageProducts/usePackageProductItem.js +27 -0
- package/hooks/PackageProducts/usePackageProductItem.js.map +1 -0
- package/hooks/PackageProducts/usePackageProducts.d.ts +19 -0
- package/hooks/PackageProducts/usePackageProducts.js +346 -0
- package/hooks/PackageProducts/usePackageProducts.js.map +1 -0
- package/hooks/Product/index.d.ts +1 -0
- package/hooks/Product/index.js +2 -0
- package/hooks/Product/index.js.map +1 -0
- package/hooks/Product/useStockStatus.d.ts +9 -0
- package/hooks/Product/useStockStatus.js +26 -0
- package/hooks/Product/useStockStatus.js.map +1 -0
- package/hooks/Product/useSwitchToVariantImage.d.ts +9 -0
- package/hooks/Product/useSwitchToVariantImage.js +21 -0
- package/hooks/Product/useSwitchToVariantImage.js.map +1 -0
- package/hooks/ProductList/ProductListContext.d.ts +12 -0
- package/hooks/ProductList/ProductListContext.js +129 -0
- package/hooks/ProductList/ProductListContext.js.map +1 -0
- package/hooks/ProductList/action-creators.d.ts +46 -0
- package/hooks/ProductList/action-creators.js +295 -0
- package/hooks/ProductList/action-creators.js.map +1 -0
- package/hooks/ProductList/index.d.ts +119 -0
- package/hooks/ProductList/index.js +22 -0
- package/hooks/ProductList/index.js.map +1 -0
- package/hooks/ProductList/list-transforms.d.ts +75 -0
- package/hooks/ProductList/list-transforms.js +107 -0
- package/hooks/ProductList/list-transforms.js.map +1 -0
- package/hooks/ProductList/product-list-reducer.d.ts +76 -0
- package/hooks/ProductList/product-list-reducer.js +192 -0
- package/hooks/ProductList/product-list-reducer.js.map +1 -0
- package/hooks/ProductList/useProductList.d.ts +13 -0
- package/hooks/ProductList/useProductList.js +94 -0
- package/hooks/ProductList/useProductList.js.map +1 -0
- package/hooks/ProductList/useProductListItems.d.ts +10 -0
- package/hooks/ProductList/useProductListItems.js +50 -0
- package/hooks/ProductList/useProductListItems.js.map +1 -0
- package/hooks/ProductList/validate-product.d.ts +6 -0
- package/hooks/ProductList/validate-product.js +41 -0
- package/hooks/ProductList/validate-product.js.map +1 -0
- package/hooks/Subscriptions/useNewsletterSubscription.d.ts +38 -0
- package/hooks/Subscriptions/useNewsletterSubscription.js +42 -0
- package/hooks/Subscriptions/useNewsletterSubscription.js.map +1 -0
- package/hooks/Subscriptions/useStockNotifications.d.ts +36 -0
- package/hooks/Subscriptions/useStockNotifications.js +38 -0
- package/hooks/Subscriptions/useStockNotifications.js.map +1 -0
- package/hooks/Subscriptions/useStoreSubscriptions.d.ts +48 -0
- package/hooks/Subscriptions/useStoreSubscriptions.js +148 -0
- package/hooks/Subscriptions/useStoreSubscriptions.js.map +1 -0
- package/hooks/useAddMultipleToCart.d.ts +27 -0
- package/hooks/useAddMultipleToCart.js +113 -0
- package/hooks/useAddMultipleToCart.js.map +1 -0
- package/hooks/useChannels.d.ts +1 -0
- package/hooks/useChannels.js +10 -0
- package/hooks/useChannels.js.map +1 -0
- package/hooks/useCustomerOrdersQuery.d.ts +21 -0
- package/hooks/useCustomerOrdersQuery.js +21 -0
- package/hooks/useCustomerOrdersQuery.js.map +1 -0
- package/hooks/useDeleteAccountMutation.d.ts +15 -0
- package/hooks/useDeleteAccountMutation.js +39 -0
- package/hooks/useDeleteAccountMutation.js.map +1 -0
- package/hooks/useDynamicPrice.d.ts +3 -0
- package/hooks/useDynamicPrice.js +25 -0
- package/hooks/useDynamicPrice.js.map +1 -0
- package/hooks/useFreeShippingCheck.d.ts +15 -0
- package/hooks/useFreeShippingCheck.js +31 -0
- package/hooks/useFreeShippingCheck.js.map +1 -0
- package/hooks/useGeolocation.d.ts +11 -0
- package/hooks/useGeolocation.js +34 -0
- package/hooks/useGeolocation.js.map +1 -0
- package/hooks/useInfinitePagination.d.ts +37 -0
- package/hooks/useInfinitePagination.js +142 -0
- package/hooks/useInfinitePagination.js.map +1 -0
- package/hooks/useLogError.d.ts +1 -0
- package/hooks/useLogError.js +8 -0
- package/hooks/useLogError.js.map +1 -0
- package/hooks/useLoginMutation.d.ts +13 -0
- package/hooks/useLoginMutation.js +19 -0
- package/hooks/useLoginMutation.js.map +1 -0
- package/hooks/useLoginRedirect.d.ts +4 -0
- package/hooks/useLoginRedirect.js +37 -0
- package/hooks/useLoginRedirect.js.map +1 -0
- package/hooks/useOrderDetailQuery.d.ts +20 -0
- package/hooks/useOrderDetailQuery.js +29 -0
- package/hooks/useOrderDetailQuery.js.map +1 -0
- package/hooks/usePreconnectLinks.d.ts +10 -0
- package/hooks/usePreconnectLinks.js +30 -0
- package/hooks/usePreconnectLinks.js.map +1 -0
- package/hooks/usePreconnectLinks.test.js +4 -0
- package/hooks/usePrice.d.ts +41 -0
- package/hooks/usePrice.js +73 -0
- package/hooks/usePrice.js.map +1 -0
- package/hooks/useProductVariants/index.d.ts +1 -0
- package/hooks/useProductVariants/index.js +2 -0
- package/hooks/useProductVariants/index.js.map +1 -0
- package/hooks/useProductVariants/useProductVariants.d.ts +19 -0
- package/hooks/useProductVariants/useProductVariants.js +203 -0
- package/hooks/useProductVariants/useProductVariants.js.map +1 -0
- package/hooks/useProductVariants/useVariantFromUrl.d.ts +5 -0
- package/hooks/useProductVariants/useVariantFromUrl.js +16 -0
- package/hooks/useProductVariants/useVariantFromUrl.js.map +1 -0
- package/hooks/useRoutePreload.d.ts +24 -0
- package/hooks/useRoutePreload.js +45 -0
- package/hooks/useRoutePreload.js.map +1 -0
- package/hooks/useShopConfig.d.ts +1 -0
- package/hooks/useShopConfig.js +11 -0
- package/hooks/useShopConfig.js.map +1 -0
- package/hooks/useStockStatus.d.ts +8 -0
- package/hooks/useStockStatus.js +26 -0
- package/hooks/useStockStatus.js.map +1 -0
- package/hooks/useThrowErrorInDev.d.ts +1 -0
- package/hooks/useThrowErrorInDev.js +8 -0
- package/hooks/useThrowErrorInDev.js.map +1 -0
- package/hooks/useThunkReducer.d.ts +7 -0
- package/hooks/useThunkReducer.js +24 -0
- package/hooks/useThunkReducer.js.map +1 -0
- package/hooks/useWarningInDev.d.ts +1 -0
- package/hooks/useWarningInDev.js +10 -0
- package/hooks/useWarningInDev.js.map +1 -0
- package/inServer.d.ts +1 -0
- package/inServer.js +3 -0
- package/inServer.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/index.js.map +1 -0
- package/integrations/sluggishSchemaExtension.d.ts +2 -0
- package/integrations/sluggishSchemaExtension.js +27 -0
- package/integrations/sluggishSchemaExtension.js.map +1 -0
- package/package.json +6 -5
- package/polyfills.d.ts +1 -0
- package/polyfills.js +58 -0
- package/polyfills.js.map +1 -0
- package/resolvers/filters/boolFilter.d.ts +3 -0
- package/resolvers/filters/boolFilter.js +82 -0
- package/resolvers/filters/boolFilter.js.map +1 -0
- package/resolvers/filters/defaultActiveFilters.d.ts +3 -0
- package/resolvers/filters/defaultActiveFilters.js +9 -0
- package/resolvers/filters/defaultActiveFilters.js.map +1 -0
- package/resolvers/filters/filterParams.d.ts +3 -0
- package/resolvers/filters/filterParams.js +85 -0
- package/resolvers/filters/filterParams.js.map +1 -0
- package/resolvers/filters/filters.d.ts +5 -0
- package/resolvers/filters/filters.js +79 -0
- package/resolvers/filters/filters.js.map +1 -0
- package/resolvers/filters/index.d.ts +23 -0
- package/resolvers/filters/index.js +8 -0
- package/resolvers/filters/index.js.map +1 -0
- package/resolvers/filters/listFilter.d.ts +7 -0
- package/resolvers/filters/listFilter.js +69 -0
- package/resolvers/filters/listFilter.js.map +1 -0
- package/resolvers/filters/listFilterItem.d.ts +3 -0
- package/resolvers/filters/listFilterItem.js +118 -0
- package/resolvers/filters/listFilterItem.js.map +1 -0
- package/resolvers/filters/multiListFilter.d.ts +5 -0
- package/resolvers/filters/multiListFilter.js +195 -0
- package/resolvers/filters/multiListFilter.js.map +1 -0
- package/resolvers/filters/multiListFilterList.d.ts +3 -0
- package/resolvers/filters/multiListFilterList.js +56 -0
- package/resolvers/filters/multiListFilterList.js.map +1 -0
- package/resolvers/filters/rangeFilter.d.ts +5 -0
- package/resolvers/filters/rangeFilter.js +122 -0
- package/resolvers/filters/rangeFilter.js.map +1 -0
- package/resolvers/filters/updateQueryString.d.ts +12 -0
- package/resolvers/filters/updateQueryString.js +117 -0
- package/resolvers/filters/updateQueryString.js.map +1 -0
- package/resolvers/index.d.ts +37 -0
- package/resolvers/index.js +38 -0
- package/resolvers/index.js.map +1 -0
- package/sentry/client.d.ts +1 -0
- package/sentry/client.js +30 -0
- package/sentry/client.js.map +1 -0
- package/sentry/common.d.ts +1 -0
- package/sentry/common.js +5 -0
- package/sentry/common.js.map +1 -0
- package/sentry/server.d.ts +1 -0
- package/sentry/server.js +20 -0
- package/sentry/server.js.map +1 -0
- package/sentry/utils.d.ts +1 -0
- package/sentry/utils.js +2 -0
- package/sentry/utils.js.map +1 -0
- package/server/graphql.d.ts +20 -0
- package/server/graphql.js +118 -0
- package/server/graphql.js.map +1 -0
- package/server/index.d.ts +2 -0
- package/server/index.js +3 -0
- package/server/index.js.map +1 -0
- package/server/tracking/facebook.d.ts +5 -0
- package/server/tracking/facebook.js +148 -0
- package/server/tracking/facebook.js.map +1 -0
- package/server/tracking/middleware.d.ts +8 -0
- package/server/tracking/middleware.js +15 -0
- package/server/tracking/middleware.js.map +1 -0
- package/time.d.ts +1 -0
- package/time.js +6 -0
- package/time.js.map +1 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { getPersistedQueriesForRequest } from '../getPersistedQueriesForRequest';
|
|
2
|
+
import aQuery from './mockQuery.gql';
|
|
3
|
+
import nock from 'nock';
|
|
4
|
+
import { ApolloError } from '@apollo/client';
|
|
5
|
+
import { ChannelHandler } from '../../../../ChannelHandler/ChannelHandler';
|
|
6
|
+
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
jest.useFakeTimers();
|
|
9
|
+
nock.disableNetConnect();
|
|
10
|
+
});
|
|
11
|
+
afterAll(() => {
|
|
12
|
+
jest.useRealTimers();
|
|
13
|
+
nock.enableNetConnect();
|
|
14
|
+
});
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
jest.restoreAllMocks();
|
|
17
|
+
jest.clearAllTimers();
|
|
18
|
+
nock.enableNetConnect();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const apolloConfig = {
|
|
22
|
+
shopid: '...',
|
|
23
|
+
graphQLURI: 'http://localhost/graphql',
|
|
24
|
+
token: '...',
|
|
25
|
+
enableGateway: false,
|
|
26
|
+
persistedQueries: [{ query: aQuery }]
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const defaultChannel = {
|
|
30
|
+
id: 1,
|
|
31
|
+
language: { name: 'English' },
|
|
32
|
+
currency: { name: 'Dollarydoos' },
|
|
33
|
+
country: {
|
|
34
|
+
id: 1234,
|
|
35
|
+
code: 'UK'
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function mockResponse(resp, { statusCode = 200, errors } = {}) {
|
|
40
|
+
const data = {
|
|
41
|
+
errors,
|
|
42
|
+
data: resp && {
|
|
43
|
+
[resp.name]: resp.values.map((val) =>
|
|
44
|
+
Object.assign({ __typename: resp.name }, val)
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const res = jest.fn(() => data);
|
|
50
|
+
nock('http://localhost').post('/graphql').reply(statusCode, res);
|
|
51
|
+
return res;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe('getPersistedQueriesForRequest', () => {
|
|
55
|
+
let opts;
|
|
56
|
+
|
|
57
|
+
beforeEach(() => {
|
|
58
|
+
const channelHandler = new ChannelHandler({
|
|
59
|
+
selectedChannel: defaultChannel
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
opts = {
|
|
63
|
+
apolloConfig,
|
|
64
|
+
channelHandler,
|
|
65
|
+
authHandler: {
|
|
66
|
+
getAuthHeaders: () => {},
|
|
67
|
+
loadAuthToken: () => {},
|
|
68
|
+
authToken: ''
|
|
69
|
+
},
|
|
70
|
+
previewHandler: {
|
|
71
|
+
getPreviewHeaders: () => {},
|
|
72
|
+
preview: false
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
opts = {};
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('creates an object keyed by the channel', async () => {
|
|
81
|
+
const clients = {};
|
|
82
|
+
|
|
83
|
+
mockResponse({
|
|
84
|
+
name: 'dogs',
|
|
85
|
+
values: [{ id: 1, name: 'Roger' }]
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const newChannel = {
|
|
89
|
+
id: 2,
|
|
90
|
+
language: { name: 'Deutsch' },
|
|
91
|
+
currency: { name: 'Deutschmarks' },
|
|
92
|
+
country: {
|
|
93
|
+
id: 1923,
|
|
94
|
+
code: 'DE'
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// First request comes in at channel 2…
|
|
99
|
+
opts.channelHandler.setSelectedChannel(newChannel);
|
|
100
|
+
getPersistedQueriesForRequest(clients, {
|
|
101
|
+
...opts
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// It's added to the clients object
|
|
105
|
+
expect(Object.keys(clients).length).toBe(1);
|
|
106
|
+
expect(Object.keys(clients)).toEqual(
|
|
107
|
+
expect.arrayContaining(['2_Deutsch_Deutschmarks'])
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
mockResponse({
|
|
111
|
+
name: 'dogs',
|
|
112
|
+
values: [{ id: 1, name: 'Roger' }]
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// Another request comes in on channel 1…
|
|
116
|
+
opts.channelHandler.setSelectedChannel(defaultChannel);
|
|
117
|
+
getPersistedQueriesForRequest(clients, opts);
|
|
118
|
+
|
|
119
|
+
// Now both are kept in memory
|
|
120
|
+
expect(Object.keys(clients).length).toBe(2);
|
|
121
|
+
expect(Object.keys(clients)).toEqual(
|
|
122
|
+
expect.arrayContaining([
|
|
123
|
+
'2_Deutsch_Deutschmarks',
|
|
124
|
+
'1_English_Dollarydoos'
|
|
125
|
+
])
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
test('requests on the same channel do not create new cache entries', async () => {
|
|
129
|
+
const clients = {};
|
|
130
|
+
|
|
131
|
+
mockResponse({
|
|
132
|
+
name: 'dogs',
|
|
133
|
+
values: [{ id: 1, name: 'Roger' }]
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// A request comes in on channel 1…
|
|
137
|
+
getPersistedQueriesForRequest(clients, opts);
|
|
138
|
+
|
|
139
|
+
// And then another!
|
|
140
|
+
getPersistedQueriesForRequest(clients, opts);
|
|
141
|
+
|
|
142
|
+
// Only one entry in the cache tho
|
|
143
|
+
const keys = Object.keys(clients);
|
|
144
|
+
expect(keys.length).toBe(1);
|
|
145
|
+
expect(keys).toEqual(expect.arrayContaining(['1_English_Dollarydoos']));
|
|
146
|
+
});
|
|
147
|
+
test('propagates errors', async () => {
|
|
148
|
+
const clients = {};
|
|
149
|
+
|
|
150
|
+
mockResponse(null, {
|
|
151
|
+
errors: [
|
|
152
|
+
{
|
|
153
|
+
message: 'Something went wrong',
|
|
154
|
+
extensions: { code: 'an error occurred' }
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// A request comes in on channel 1…
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
await getPersistedQueriesForRequest(clients, opts).extractCache();
|
|
163
|
+
} catch (err) {
|
|
164
|
+
expect(err).toBeInstanceOf(ApolloError);
|
|
165
|
+
expect(err.message).toBe(`GraphQL error: Something went wrong`);
|
|
166
|
+
}
|
|
167
|
+
expect.assertions(2);
|
|
168
|
+
});
|
|
169
|
+
it('response updates cache', async () => {
|
|
170
|
+
const clients = {};
|
|
171
|
+
mockResponse({
|
|
172
|
+
name: 'dogs',
|
|
173
|
+
values: [{ id: 1, name: 'Roger' }]
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// A request comes in on channel 1…
|
|
177
|
+
getPersistedQueriesForRequest(clients, opts);
|
|
178
|
+
|
|
179
|
+
const firstCache = await clients['1_English_Dollarydoos'].extractCache();
|
|
180
|
+
|
|
181
|
+
expect(firstCache['dogs:1']).toEqual(
|
|
182
|
+
expect.objectContaining({ name: 'Roger' })
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
const mock = mockResponse({
|
|
186
|
+
name: 'dogs',
|
|
187
|
+
values: [{ id: 1, name: 'Updated name' }]
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// The timer ticks over, firing off another request which should have the
|
|
191
|
+
// updated return value
|
|
192
|
+
jest.advanceTimersByTime(30000);
|
|
193
|
+
expect(mock).toHaveBeenCalled();
|
|
194
|
+
|
|
195
|
+
const updatedCache = await clients['1_English_Dollarydoos'].extractCache();
|
|
196
|
+
|
|
197
|
+
expect(updatedCache['dogs:1']).toEqual(
|
|
198
|
+
expect.objectContaining({ name: 'Updated name' })
|
|
199
|
+
);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PersistedClient } from './PersistedClient';
|
|
2
|
+
export function getPersistedQueriesForRequest(persistedQueryClients, opts) {
|
|
3
|
+
const { apolloConfig, authHandler, previewHandler, channelHandler } = opts;
|
|
4
|
+
const queriesToPersist = apolloConfig.persistedQueries || [];
|
|
5
|
+
// When auth is enabled or we are in a preview route, we don't want to cache
|
|
6
|
+
if (!!(authHandler === null || authHandler === void 0 ? void 0 : authHandler.authToken) || (previewHandler === null || previewHandler === void 0 ? void 0 : previewHandler.preview))
|
|
7
|
+
return null;
|
|
8
|
+
// If there are no persisted queries in the config, we have nothing to cache
|
|
9
|
+
if (queriesToPersist.length === 0)
|
|
10
|
+
return null;
|
|
11
|
+
let client;
|
|
12
|
+
const channel = channelHandler.getSelectedChannel();
|
|
13
|
+
if (channel.requiresAuth)
|
|
14
|
+
return null;
|
|
15
|
+
// Create a key unique to this selected channel, lang, currency
|
|
16
|
+
const key = `${channel.id}_${channel.language.name}_${channel.currency.name}`;
|
|
17
|
+
const headers = channelHandler.getChannelHeaders();
|
|
18
|
+
if (key in persistedQueryClients) {
|
|
19
|
+
client = persistedQueryClients[key];
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const newClient = new PersistedClient(Object.assign(Object.assign({}, opts), { headers }));
|
|
23
|
+
client = persistedQueryClients[key] = newClient;
|
|
24
|
+
}
|
|
25
|
+
return client;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=getPersistedQueriesForRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPersistedQueriesForRequest.js","sourceRoot":"","sources":["getPersistedQueriesForRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,UAAU,6BAA6B,CAC3C,qBAA0B,EAC1B,IAAsB;IAEtB,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAE3E,MAAM,gBAAgB,GAAG,YAAY,CAAC,gBAAgB,IAAI,EAAE,CAAC;IAE7D,4EAA4E;IAC5E,IAAI,CAAC,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,SAAS,CAAA,KAAI,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,OAAO,CAAA;QAAE,OAAO,IAAI,CAAC;IAErE,4EAA4E;IAC5E,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAE/C,IAAI,MAAuB,CAAC;IAE5B,MAAM,OAAO,GAAG,cAAc,CAAC,kBAAkB,EAAE,CAAC;IAEpD,IAAI,OAAO,CAAC,YAAY;QAAE,OAAO,IAAI,CAAC;IAEtC,+DAA+D;IAC/D,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,EAAE,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAE9E,MAAM,OAAO,GAAG,cAAc,CAAC,iBAAiB,EAAE,CAAC;IAEnD,IAAI,GAAG,IAAI,qBAAqB,EAAE;QAChC,MAAM,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;KACrC;SAAM;QACL,MAAM,SAAS,GAAG,IAAI,eAAe,iCAAM,IAAI,KAAE,OAAO,IAAG,CAAC;QAE5D,MAAM,GAAG,qBAAqB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;KACjD;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { salesSourceMiddleware } from './salesSource';
|
|
2
|
+
import { Cookies } from 'react-cookie';
|
|
3
|
+
|
|
4
|
+
describe('Sales source test', () => {
|
|
5
|
+
it('Will set the sales source cookie', () => {
|
|
6
|
+
const cookies = new Cookies();
|
|
7
|
+
salesSourceMiddleware({
|
|
8
|
+
queryObject: {
|
|
9
|
+
SalesSource: 'test'
|
|
10
|
+
},
|
|
11
|
+
cookies
|
|
12
|
+
});
|
|
13
|
+
expect(cookies.get('SalesSource')).toBe('test');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('Will remove the sales source cookie', () => {
|
|
17
|
+
const cookies = new Cookies();
|
|
18
|
+
cookies.set('SalesSource', 'test');
|
|
19
|
+
expect(cookies.get('SalesSource')).toBe('test');
|
|
20
|
+
salesSourceMiddleware({
|
|
21
|
+
queryObject: {
|
|
22
|
+
SalesSource: 'remove'
|
|
23
|
+
},
|
|
24
|
+
cookies
|
|
25
|
+
});
|
|
26
|
+
expect(cookies.get('SalesSource')).toBeFalsy();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('Will set the cookie regardless of case', () => {
|
|
30
|
+
const cookies = new Cookies();
|
|
31
|
+
salesSourceMiddleware({
|
|
32
|
+
queryObject: {
|
|
33
|
+
salEsSoUrCe: 'test'
|
|
34
|
+
},
|
|
35
|
+
cookies
|
|
36
|
+
});
|
|
37
|
+
expect(cookies.get('SalesSource')).toBe('test');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function salesSourceMiddleware({ queryObject, cookies }) {
|
|
2
|
+
const caseInsensitiveSalesSourceKey = Object.keys(queryObject).find(key => key.toLowerCase() === 'salessource');
|
|
3
|
+
const salesSourceParam = queryObject[caseInsensitiveSalesSourceKey];
|
|
4
|
+
if (salesSourceParam === 'remove') {
|
|
5
|
+
cookies.remove('SalesSource');
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
const expires = new Date();
|
|
9
|
+
expires.setFullYear(new Date().getFullYear() + 10);
|
|
10
|
+
cookies.set('SalesSource', salesSourceParam, {
|
|
11
|
+
expires
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export { salesSourceMiddleware };
|
|
16
|
+
//# sourceMappingURL=salesSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"salesSource.js","sourceRoot":"","sources":["salesSource.ts"],"names":[],"mappings":"AAEA,SAAS,qBAAqB,CAAC,EAC7B,WAAW,EACX,OAAO,EAMR;IACC,MAAM,6BAA6B,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CACjE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,aAAa,CAC3C,CAAC;IACF,MAAM,gBAAgB,GAAG,WAAW,CAAC,6BAA6B,CAAC,CAAC;IACpE,IAAI,gBAAgB,KAAK,QAAQ,EAAE;QACjC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;KAC/B;SAAM;QACL,MAAM,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;QAC3B,OAAO,CAAC,WAAW,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,gBAAgB,EAAE;YAC3C,OAAO;SACR,CAAC,CAAC;KACJ;AACH,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Todo: removing "any" type casting
|
|
2
|
+
const createIntlOptions = ({ selectedChannel, options }) => {
|
|
3
|
+
const numberFormats = {};
|
|
4
|
+
selectedChannel.currencies &&
|
|
5
|
+
selectedChannel.currencies.forEach(currency => {
|
|
6
|
+
if (!currency || !currency.format || !currency.id)
|
|
7
|
+
return null;
|
|
8
|
+
numberFormats[currency.id] = {
|
|
9
|
+
style: 'currency',
|
|
10
|
+
currency: currency.format.code,
|
|
11
|
+
minimumFractionDigits: currency.format.decimals
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
return Object.assign({ formats: {
|
|
15
|
+
number: numberFormats
|
|
16
|
+
} }, options);
|
|
17
|
+
};
|
|
18
|
+
export default createIntlOptions;
|
|
19
|
+
//# sourceMappingURL=createIntOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createIntOptions.js","sourceRoot":"","sources":["createIntOptions.ts"],"names":[],"mappings":"AAEA,oCAAoC;AACpC,MAAM,iBAAiB,GAAG,CAAC,EACzB,eAAe,EACf,OAAO,EAIR,EAAE,EAAE;IACH,MAAM,aAAa,GAA2B,EAAE,CAAC;IACjD,eAAe,CAAC,UAAU;QACxB,eAAe,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC5C,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAAE,OAAO,IAAI,CAAC;YAE/D,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG;gBAC3B,KAAK,EAAE,UAAU;gBACjB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI;gBAC9B,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ;aAChD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,uBACE,OAAO,EAAE;YACP,MAAM,EAAE,aAAa;SACtB,IACE,OAAO,EACV;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApolloLink } from '@apollo/client';
|
|
2
|
+
const timeStartLink = new ApolloLink((operation, forward) => {
|
|
3
|
+
operation.setContext({ start: Date.now() });
|
|
4
|
+
return forward(operation);
|
|
5
|
+
});
|
|
6
|
+
const logTimeLink = new ApolloLink((operation, forward) => {
|
|
7
|
+
return forward(operation).map((data) => {
|
|
8
|
+
// data from a previous link
|
|
9
|
+
const time = Date.now() - operation.getContext().start;
|
|
10
|
+
console.log(new Date(), `operation ${operation.operationName} took ${time} to complete`);
|
|
11
|
+
return data;
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
export const logOperationTime = timeStartLink.concat(logTimeLink);
|
|
15
|
+
//# sourceMappingURL=queryLoggingMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryLoggingMiddleware.js","sourceRoot":"","sources":["queryLoggingMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,aAAa,GAAG,IAAI,UAAU,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE;IAC1D,SAAS,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5C,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,IAAI,UAAU,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE;IACxD,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACrC,4BAA4B;QAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC;QACvD,OAAO,CAAC,GAAG,CACT,IAAI,IAAI,EAAE,EACV,aAAa,SAAS,CAAC,aAAa,SAAS,IAAI,cAAc,CAChE,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Generates a random UID
|
|
2
|
+
export function generateUID() {
|
|
3
|
+
// Math.random should be unique because of its seeding algorithm. Convert it
|
|
4
|
+
// to base 36 (numbers + letters), and grab the first 9 characters after the
|
|
5
|
+
// decimal.
|
|
6
|
+
return Math.random()
|
|
7
|
+
.toString(36)
|
|
8
|
+
.substr(2, 9);
|
|
9
|
+
}
|
|
10
|
+
// Takes Cookies (from react-cookie) as an arg. Checks for an existing UID, and
|
|
11
|
+
// either returns it or creates one & sets it in a cookie if it doesn't exist
|
|
12
|
+
export function setUID(cookies) {
|
|
13
|
+
let uid = cookies.get('RWuid');
|
|
14
|
+
if (!uid) {
|
|
15
|
+
uid = generateUID();
|
|
16
|
+
cookies.set('RWuid', uid);
|
|
17
|
+
}
|
|
18
|
+
return uid;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=uid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uid.js","sourceRoot":"","sources":["uid.ts"],"names":[],"mappings":"AAEA,yBAAyB;AACzB,MAAM,UAAU,WAAW;IACzB,4EAA4E;IAC5E,4EAA4E;IAC5E,WAAW;IACX,OAAO,IAAI,CAAC,MAAM,EAAE;SACjB,QAAQ,CAAC,EAAE,CAAC;SACZ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,+EAA+E;AAC/E,6EAA6E;AAC7E,MAAM,UAAU,MAAM,CAAC,OAAgB;IACrC,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC/B,IAAI,CAAC,GAAG,EAAE;QACR,GAAG,GAAG,WAAW,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;KAC3B;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormikProps } from 'formik';
|
|
3
|
+
import { Price, Product, ProductVariant, ProductVariantOption } from '../types';
|
|
4
|
+
import { DocumentNode } from 'graphql';
|
|
5
|
+
import { ApolloError } from '@apollo/client';
|
|
6
|
+
type Comments = Record<string, string>;
|
|
7
|
+
type Options = Record<string, string>;
|
|
8
|
+
interface AddToCartFormikValues {
|
|
9
|
+
quantity: number;
|
|
10
|
+
comments: Comments;
|
|
11
|
+
options?: Options;
|
|
12
|
+
[otherValues: string]: any;
|
|
13
|
+
}
|
|
14
|
+
interface AddToCartCallbackOptions {
|
|
15
|
+
mutationId: string;
|
|
16
|
+
quantity: number;
|
|
17
|
+
product: Product;
|
|
18
|
+
selectedVariation: ProductVariant;
|
|
19
|
+
price: Price;
|
|
20
|
+
}
|
|
21
|
+
interface AddToCartFormikProps {
|
|
22
|
+
product: Product;
|
|
23
|
+
variant?: ProductVariant;
|
|
24
|
+
commentValidators?: {
|
|
25
|
+
[commentName: string]: ({ name, value }: {
|
|
26
|
+
name?: string;
|
|
27
|
+
value: string;
|
|
28
|
+
}) => string;
|
|
29
|
+
};
|
|
30
|
+
getMissingOptions?(): ProductVariantOption[] | null;
|
|
31
|
+
initialValues?: Record<string, any>;
|
|
32
|
+
cartQuery?: DocumentNode;
|
|
33
|
+
cartMutation?: DocumentNode;
|
|
34
|
+
onAddToCartInit?: (opts: AddToCartCallbackOptions) => void;
|
|
35
|
+
onAddToCartSuccess?: (opts: AddToCartCallbackOptions) => void;
|
|
36
|
+
onAddToCartError?: (opts: AddToCartCallbackOptions & {
|
|
37
|
+
error: Error | ApolloError;
|
|
38
|
+
}) => void;
|
|
39
|
+
children: (props: FormikProps<AddToCartFormikValues>) => React.ReactNode;
|
|
40
|
+
}
|
|
41
|
+
export declare function AddToCartFormik({ product, variant, commentValidators, getMissingOptions, initialValues, onAddToCartInit, onAddToCartError, onAddToCartSuccess, cartMutation, children }: AddToCartFormikProps): React.JSX.Element;
|
|
42
|
+
export default AddToCartFormik;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { useAddToCart } from './useAddToCart';
|
|
12
|
+
import { FormikProvider } from 'formik';
|
|
13
|
+
import { useMutation } from '@apollo/client';
|
|
14
|
+
import { addToCartError, addToCartSuccess, useTrackProductAdd } from '../components/Mutation/AddToCart/addToCartUtils';
|
|
15
|
+
import uniqueId from '@jetshop/core/helpers/uniqueId';
|
|
16
|
+
import { useCartId } from '../components/Cart/CartIdContext';
|
|
17
|
+
export function AddToCartFormik({ product, variant, commentValidators = {}, getMissingOptions, initialValues,
|
|
18
|
+
// Apollo specific props
|
|
19
|
+
onAddToCartInit, onAddToCartError, onAddToCartSuccess, cartMutation,
|
|
20
|
+
// Backwards compatability with render props
|
|
21
|
+
children }) {
|
|
22
|
+
const [addToCartMutation] = useMutation(cartMutation, {
|
|
23
|
+
onCompleted: () => localStorage.setItem('cartChange', '1')
|
|
24
|
+
});
|
|
25
|
+
const { cartId, setCartId } = useCartId();
|
|
26
|
+
const trackAddProductVariant = useTrackProductAdd(variant);
|
|
27
|
+
function submit({ input, optimistic }) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
trackAddProductVariant(product, input.quantity);
|
|
30
|
+
const mutationId = uniqueId();
|
|
31
|
+
const callbackOptions = {
|
|
32
|
+
product: optimistic.product,
|
|
33
|
+
price: optimistic.price,
|
|
34
|
+
quantity: input.quantity,
|
|
35
|
+
selectedVariation: variant,
|
|
36
|
+
mutationId
|
|
37
|
+
};
|
|
38
|
+
if (onAddToCartInit) {
|
|
39
|
+
onAddToCartInit(callbackOptions);
|
|
40
|
+
}
|
|
41
|
+
return addToCartMutation({
|
|
42
|
+
variables: {
|
|
43
|
+
input
|
|
44
|
+
},
|
|
45
|
+
update: (cache, { data }) => {
|
|
46
|
+
cache.modify({
|
|
47
|
+
fields: {
|
|
48
|
+
cart() {
|
|
49
|
+
var _a;
|
|
50
|
+
return (_a = data === null || data === void 0 ? void 0 : data.addToCart) === null || _a === void 0 ? void 0 : _a.cart;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
.then(addToCartSuccess({
|
|
57
|
+
onAddToCartSuccess,
|
|
58
|
+
callbackOptions,
|
|
59
|
+
cartId,
|
|
60
|
+
setCartId
|
|
61
|
+
}))
|
|
62
|
+
.catch(addToCartError({
|
|
63
|
+
onAddToCartError,
|
|
64
|
+
callbackOptions
|
|
65
|
+
}));
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const { form } = useAddToCart({
|
|
69
|
+
product,
|
|
70
|
+
variant,
|
|
71
|
+
commentValidators,
|
|
72
|
+
getMissingOptions,
|
|
73
|
+
initialValues,
|
|
74
|
+
submit
|
|
75
|
+
});
|
|
76
|
+
return React.createElement(FormikProvider, { value: form }, children(form));
|
|
77
|
+
}
|
|
78
|
+
export default AddToCartFormik;
|
|
79
|
+
//# sourceMappingURL=AddToCartFormik.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddToCartFormik.js","sourceRoot":"","sources":["AddToCartFormik.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAmB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAe,MAAM,QAAQ,CAAC;AAWrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,iDAAiD,CAAC;AACzD,OAAO,QAAQ,MAAM,gCAAgC,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AA6C7D,MAAM,UAAU,eAAe,CAAC,EAC9B,OAAO,EACP,OAAO,EACP,iBAAiB,GAAG,EAAE,EACtB,iBAAiB,EACjB,aAAa;AACb,wBAAwB;AACxB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,YAAY;AACZ,4CAA4C;AAC5C,QAAQ,EACa;IACrB,MAAM,CAAC,iBAAiB,CAAC,GAAG,WAAW,CAGrC,YAAY,EAAE;QACd,WAAW,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC;KAC3D,CAAC,CAAC;IAEH,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAAC;IAC1C,MAAM,sBAAsB,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAE3D,SAAe,MAAM,CAAC,EAAE,KAAK,EAAE,UAAU,EAAmB;;YAC1D,sBAAsB,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;YAChD,MAAM,UAAU,GAAG,QAAQ,EAAE,CAAC;YAE9B,MAAM,eAAe,GAAG;gBACtB,OAAO,EAAE,UAAU,CAAC,OAAO;gBAC3B,KAAK,EAAE,UAAU,CAAC,KAAK;gBACvB,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,iBAAiB,EAAE,OAAO;gBAC1B,UAAU;aACX,CAAC;YAEF,IAAI,eAAe,EAAE;gBACnB,eAAe,CAAC,eAAe,CAAC,CAAC;aAClC;YAED,OAAO,iBAAiB,CAAC;gBACvB,SAAS,EAAE;oBACT,KAAK;iBACN;gBACD,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;oBAC1B,KAAK,CAAC,MAAM,CAAC;wBACX,MAAM,EAAE;4BACN,IAAI;;gCACF,OAAO,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,0CAAE,IAAI,CAAC;4BAC/B,CAAC;yBACF;qBACF,CAAC,CAAC;gBACL,CAAC;aACF,CAAC;iBACC,IAAI,CACH,gBAAgB,CAAC;gBACf,kBAAkB;gBAClB,eAAe;gBACf,MAAM;gBACN,SAAS;aACV,CAAC,CACH;iBACA,KAAK,CACJ,cAAc,CAAC;gBACb,gBAAgB;gBAChB,eAAe;aAChB,CAAC,CACH,CAAC;QACN,CAAC;KAAA;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC;QAC5B,OAAO;QACP,OAAO;QACP,iBAAiB;QACjB,iBAAiB;QACjB,aAAa;QACb,MAAM;KACP,CAAC,CAAC;IAEH,OAAO,oBAAC,cAAc,IAAC,KAAK,EAAE,IAAI,IAAG,QAAQ,CAAC,IAAI,CAAC,CAAkB,CAAC;AACxE,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AddToCartInput, Price, Product, ProductVariant, ProductVariantOption } from '../types';
|
|
3
|
+
type Comments = Record<string, string>;
|
|
4
|
+
type Options = Record<string, string>;
|
|
5
|
+
export interface AddToCartSubmit {
|
|
6
|
+
input: AddToCartInput;
|
|
7
|
+
optimistic: {
|
|
8
|
+
price?: Price;
|
|
9
|
+
previousPrice?: Price;
|
|
10
|
+
quantity: number;
|
|
11
|
+
product: Product;
|
|
12
|
+
variant?: ProductVariant;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
interface AddToCartOptions {
|
|
16
|
+
product?: Product;
|
|
17
|
+
variant?: ProductVariant;
|
|
18
|
+
commentValidators?: {
|
|
19
|
+
[commentName: string]: ({ name, value }: {
|
|
20
|
+
name?: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}) => string;
|
|
23
|
+
};
|
|
24
|
+
getMissingOptions?(): ProductVariantOption[] | null;
|
|
25
|
+
submit: (data: AddToCartSubmit) => Promise<any>;
|
|
26
|
+
initialValues?: Record<string, any>;
|
|
27
|
+
}
|
|
28
|
+
export interface AddToCartFormikValues {
|
|
29
|
+
quantity: number;
|
|
30
|
+
comments: Comments;
|
|
31
|
+
options?: Options;
|
|
32
|
+
[otherValues: string]: any;
|
|
33
|
+
}
|
|
34
|
+
export interface AddToCartFormikErrors {
|
|
35
|
+
quantity?: string;
|
|
36
|
+
comments?: Comments;
|
|
37
|
+
options?: Options;
|
|
38
|
+
[otherValues: string]: any;
|
|
39
|
+
}
|
|
40
|
+
export declare function useAddToCart({ product, variant, submit, commentValidators, getMissingOptions, initialValues }: AddToCartOptions): {
|
|
41
|
+
form: {
|
|
42
|
+
initialValues: AddToCartFormikValues;
|
|
43
|
+
initialErrors: import("formik").FormikErrors<unknown>;
|
|
44
|
+
initialTouched: import("formik").FormikTouched<unknown>;
|
|
45
|
+
initialStatus: any;
|
|
46
|
+
handleBlur: {
|
|
47
|
+
(e: import("react").FocusEvent<any, Element>): void;
|
|
48
|
+
<T = any>(fieldOrEvent: T): T extends string ? (e: any) => void : void;
|
|
49
|
+
};
|
|
50
|
+
handleChange: {
|
|
51
|
+
(e: import("react").ChangeEvent<any>): void;
|
|
52
|
+
<T_1 = string | import("react").ChangeEvent<any>>(field: T_1): T_1 extends import("react").ChangeEvent<any> ? void : (e: string | import("react").ChangeEvent<any>) => void;
|
|
53
|
+
};
|
|
54
|
+
handleReset: (e: any) => void;
|
|
55
|
+
handleSubmit: (e?: import("react").FormEvent<HTMLFormElement>) => void;
|
|
56
|
+
resetForm: (nextState?: Partial<import("formik").FormikState<AddToCartFormikValues>>) => void;
|
|
57
|
+
setErrors: (errors: import("formik").FormikErrors<AddToCartFormikValues>) => void;
|
|
58
|
+
setFormikState: (stateOrCb: import("formik").FormikState<AddToCartFormikValues> | ((state: import("formik").FormikState<AddToCartFormikValues>) => import("formik").FormikState<AddToCartFormikValues>)) => void;
|
|
59
|
+
setFieldTouched: (field: string, touched?: boolean, shouldValidate?: boolean) => Promise<void> | Promise<import("formik").FormikErrors<AddToCartFormikValues>>;
|
|
60
|
+
setFieldValue: (field: string, value: any, shouldValidate?: boolean) => Promise<void> | Promise<import("formik").FormikErrors<AddToCartFormikValues>>;
|
|
61
|
+
setFieldError: (field: string, value: string) => void;
|
|
62
|
+
setStatus: (status: any) => void;
|
|
63
|
+
setSubmitting: (isSubmitting: boolean) => void;
|
|
64
|
+
setTouched: (touched: import("formik").FormikTouched<AddToCartFormikValues>, shouldValidate?: boolean) => Promise<void> | Promise<import("formik").FormikErrors<AddToCartFormikValues>>;
|
|
65
|
+
setValues: (values: import("react").SetStateAction<AddToCartFormikValues>, shouldValidate?: boolean) => Promise<void> | Promise<import("formik").FormikErrors<AddToCartFormikValues>>;
|
|
66
|
+
submitForm: () => Promise<any>;
|
|
67
|
+
validateForm: (values?: AddToCartFormikValues) => Promise<import("formik").FormikErrors<AddToCartFormikValues>>;
|
|
68
|
+
validateField: (name: string) => Promise<void> | Promise<string>;
|
|
69
|
+
isValid: boolean;
|
|
70
|
+
dirty: boolean;
|
|
71
|
+
unregisterField: (name: string) => void;
|
|
72
|
+
registerField: (name: string, { validate }: any) => void;
|
|
73
|
+
getFieldProps: (nameOrOptions: string | import("formik").FieldConfig<any>) => import("formik").FieldInputProps<any>;
|
|
74
|
+
getFieldMeta: (name: string) => import("formik").FieldMetaProps<any>;
|
|
75
|
+
getFieldHelpers: (name: string) => import("formik").FieldHelperProps<any>;
|
|
76
|
+
validateOnBlur: boolean;
|
|
77
|
+
validateOnChange: boolean;
|
|
78
|
+
validateOnMount: boolean;
|
|
79
|
+
values: AddToCartFormikValues;
|
|
80
|
+
errors: import("formik").FormikErrors<AddToCartFormikValues>;
|
|
81
|
+
touched: import("formik").FormikTouched<AddToCartFormikValues>;
|
|
82
|
+
isSubmitting: boolean;
|
|
83
|
+
isValidating: boolean;
|
|
84
|
+
status?: any;
|
|
85
|
+
submitCount: number;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export {};
|