@magento/peregrine 12.1.0-alpha.1 → 12.2.0-alpha.2
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/lib/Apollo/clearCartDataFromCache.js +11 -12
- package/lib/Apollo/clearCustomerDataFromCache.js +15 -8
- package/lib/Apollo/policies/index.js +35 -3
- package/lib/Toasts/useToasts.js +5 -0
- package/lib/hooks/useCustomerWishlistSkus/customerWishlist.gql.ce.js +3 -3
- package/lib/store/actions/cart/asyncActions.js +1 -2
- package/lib/store/actions/user/asyncActions.js +2 -4
- package/lib/store/reducers/catalog.js +7 -7
- package/lib/store/reducers/user.js +1 -3
- package/lib/talons/Adapter/useAdapter.js +80 -11
- package/lib/talons/AddToCartDialog/addToCartDialog.gql.js +2 -2
- package/lib/talons/AddressBookPage/addressBookPage.gql.js +3 -9
- package/lib/talons/Breadcrumbs/breadcrumbs.gql.js +16 -12
- package/lib/talons/Breadcrumbs/useBreadcrumbs.js +6 -4
- package/lib/talons/CartPage/GiftCards/giftCardQueries.gql.ee.js +2 -2
- package/lib/talons/CartPage/PriceAdjustments/CouponCode/couponCode.gql.js +2 -3
- package/lib/talons/CartPage/PriceAdjustments/ShippingMethods/shippingMethods.gql.js +1 -1
- package/lib/talons/CartPage/PriceSummary/priceSummaryFragments.gql.js +2 -1
- package/lib/talons/CartPage/ProductListing/EditModal/productForm.gql.js +3 -3
- package/lib/talons/CartPage/ProductListing/EditModal/productFormFragment.gql.js +6 -3
- package/lib/talons/CartPage/ProductListing/EditModal/useProductForm.js +1 -0
- package/lib/talons/CartPage/ProductListing/product.gql.js +2 -1
- package/lib/talons/CartPage/ProductListing/productListing.gql.ce.js +2 -1
- package/lib/talons/CartPage/ProductListing/productListing.gql.ee.js +2 -1
- package/lib/talons/CartPage/ProductListing/productListingFragments.gql.js +14 -5
- package/lib/talons/CartPage/ProductListing/useProduct.js +8 -1
- package/lib/talons/CartPage/ProductListing/useProductListing.js +4 -2
- package/lib/talons/CartPage/useCartPage.js +4 -3
- package/lib/talons/CategoryList/categoryList.gql.js +25 -17
- package/lib/talons/CategoryList/useCategoryList.js +6 -1
- package/lib/talons/CategoryList/useCategoryTile.js +2 -0
- package/lib/talons/CategoryTree/categoryTree.gql.js +18 -12
- package/lib/talons/CategoryTree/useCategoryBranch.js +1 -1
- package/lib/talons/CategoryTree/useCategoryTree.js +5 -5
- package/lib/talons/CheckoutPage/AddressBook/addressBook.gql.js +1 -1
- package/lib/talons/CheckoutPage/BillingAddress/billingAddress.gql.js +1 -1
- package/lib/talons/CheckoutPage/ItemsReview/__fixtures__/cartItems.js +12 -12
- package/lib/talons/CheckoutPage/ItemsReview/itemsReview.gql.js +2 -1
- package/lib/talons/CheckoutPage/ItemsReview/itemsReviewFragments.gql.js +11 -5
- package/lib/talons/CheckoutPage/OrderConfirmationPage/createAccount.gql.js +12 -6
- package/lib/talons/CheckoutPage/PaymentInformation/creditCard.gql.js +2 -2
- package/lib/talons/CheckoutPage/PaymentInformation/paymentInformation.gql.js +2 -2
- package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/customerForm.gql.js +3 -5
- package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js +12 -4
- package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/useGuestForm.js +45 -5
- package/lib/talons/CheckoutPage/ShippingInformation/shippingInformation.gql.js +2 -2
- package/lib/talons/CheckoutPage/ShippingMethod/shippingMethod.gql.js +1 -1
- package/lib/talons/CheckoutPage/checkoutPage.gql.js +2 -2
- package/lib/talons/CheckoutPage/checkoutPageFragments.gql.js +4 -2
- package/lib/talons/CheckoutPage/useCheckoutPage.js +5 -2
- package/lib/talons/Cms/cmsPage.gql.js +0 -4
- package/lib/talons/Cms/useCmsPage.js +6 -23
- package/lib/talons/CommunicationsPage/communicationsPage.gql.js +2 -2
- package/lib/talons/ContactPage/contactUs.gql.js +48 -0
- package/lib/talons/ContactPage/index.js +2 -0
- package/lib/talons/ContactPage/useContactLink.js +27 -0
- package/lib/talons/ContactPage/useContactPage.js +85 -0
- package/lib/talons/CreateAccount/createAccount.gql.js +15 -8
- package/lib/talons/CreateAccount/useCreateAccount.js +2 -4
- package/lib/talons/Footer/footer.gql.js +2 -1
- package/lib/talons/FormError/useFormError.js +9 -7
- package/lib/talons/Gallery/__fixtures__/apolloMocks.js +2 -2
- package/lib/talons/Gallery/gallery.gql.ce.js +2 -1
- package/lib/talons/Gallery/gallery.gql.ee.js +2 -1
- package/lib/talons/Gallery/useAddToCartButton.js +13 -12
- package/lib/talons/Header/storeSwitcher.gql.js +21 -9
- package/lib/talons/Header/useCartTrigger.js +3 -3
- package/lib/talons/Header/useStoreSwitcher.js +10 -8
- package/lib/talons/MagentoRoute/magentoRoute.gql.js +4 -2
- package/lib/talons/MagentoRoute/useMagentoRoute.js +39 -33
- package/lib/talons/MegaMenu/megaMenu.gql.js +10 -5
- package/lib/talons/MegaMenu/useMegaMenu.js +3 -5
- package/lib/talons/MegaMenu/useMegaMenuItem.js +5 -0
- package/lib/talons/MiniCart/ProductList/productListFragments.gql.js +10 -5
- package/lib/talons/MiniCart/miniCart.gql.js +2 -1
- package/lib/talons/MiniCart/useMiniCart.js +8 -7
- package/lib/talons/Navigation/navigation.gql.js +4 -3
- package/lib/talons/Navigation/useNavigation.js +1 -1
- package/lib/talons/Newsletter/newsletter.gql.js +14 -1
- package/lib/talons/Newsletter/useNewsletter.js +31 -12
- package/lib/talons/OrderHistoryPage/orderHistoryContext.gql.js +2 -1
- package/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js +1 -1
- package/lib/talons/OrderHistoryPage/orderRow.gql.js +7 -3
- package/lib/talons/ProductFullDetail/CustomAttributes/AttributeType/useAttributeType.js +26 -0
- package/lib/talons/ProductFullDetail/productFullDetail.gql.ce.js +4 -3
- package/lib/talons/ProductFullDetail/productFullDetail.gql.ee.js +2 -1
- package/lib/talons/ProductFullDetail/useProductFullDetail.js +28 -2
- package/lib/talons/RootComponents/Category/category.gql.js +7 -4
- package/lib/talons/RootComponents/Category/categoryContent.gql.js +26 -7
- package/lib/talons/RootComponents/Category/categoryFragments.gql.js +4 -2
- package/lib/talons/RootComponents/Category/useCategory.js +8 -6
- package/lib/talons/RootComponents/Category/useCategoryContent.js +30 -3
- package/lib/talons/RootComponents/Category/useNoProductsFound.js +0 -1
- package/lib/talons/RootComponents/Product/product.gql.js +2 -1
- package/lib/talons/RootComponents/Product/productDetailFragment.gql.js +66 -10
- package/lib/talons/SearchPage/searchPage.gql.js +18 -2
- package/lib/talons/SearchPage/useSearchPage.js +25 -0
- package/lib/talons/SignIn/signIn.gql.js +4 -3
- package/lib/talons/SignIn/useSignIn.js +2 -4
- package/lib/talons/Wishlist/WishlistDialog/wishlistDialog.gql.js +3 -2
- package/lib/talons/WishlistPage/createWishlist.gql.js +2 -1
- package/lib/talons/WishlistPage/useWishlistItem.js +2 -2
- package/lib/talons/WishlistPage/wishlist.gql.js +2 -2
- package/lib/talons/WishlistPage/wishlistConfig.gql.ce.js +2 -1
- package/lib/talons/WishlistPage/wishlistConfig.gql.ee.js +2 -1
- package/lib/talons/WishlistPage/wishlistItemFragments.gql.js +5 -2
- package/lib/talons/WishlistPage/wishlistPage.gql.js +1 -1
- package/package.json +6 -6
- package/lib/Apollo/clearStore.js +0 -26
- package/lib/Apollo/deleteCacheEntry.js +0 -87
|
@@ -23,13 +23,14 @@ export const ADD_TO_WISHLIST = gql`
|
|
|
23
23
|
|
|
24
24
|
export const GET_WISHLISTS = gql`
|
|
25
25
|
query getWishlistsDialogData {
|
|
26
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
26
27
|
storeConfig {
|
|
27
|
-
|
|
28
|
+
store_code
|
|
28
29
|
enable_multiple_wishlists
|
|
29
30
|
maximum_number_of_wishlists
|
|
30
31
|
}
|
|
32
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
31
33
|
customer {
|
|
32
|
-
id
|
|
33
34
|
wishlists {
|
|
34
35
|
id
|
|
35
36
|
name
|
|
@@ -12,8 +12,9 @@ export const CREATE_WISHLIST = gql`
|
|
|
12
12
|
|
|
13
13
|
export const GET_MULTIPLE_WISHLISTS_ENABLED = gql`
|
|
14
14
|
query getMultipleWishlistsEnabled {
|
|
15
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
15
16
|
storeConfig {
|
|
16
|
-
|
|
17
|
+
store_code
|
|
17
18
|
enable_multiple_wishlists
|
|
18
19
|
}
|
|
19
20
|
}
|
|
@@ -81,8 +81,8 @@ export const useWishlistItem = props => {
|
|
|
81
81
|
const selectedOptionsArray = selectedConfigurableOptions.map(
|
|
82
82
|
selectedOption => {
|
|
83
83
|
const {
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
configurable_product_option_uid: attributeId,
|
|
85
|
+
configurable_product_option_value_uid: selectedValueId
|
|
86
86
|
} = selectedOption;
|
|
87
87
|
const configurableOption = configurableOptions.find(
|
|
88
88
|
option => option.attribute_id_v2 === attributeId
|
|
@@ -5,8 +5,8 @@ import { WishlistItemFragment } from './wishlistItemFragments.gql';
|
|
|
5
5
|
|
|
6
6
|
export const GET_CUSTOMER_WISHLIST = gql`
|
|
7
7
|
query GetCustomerWishlist {
|
|
8
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
8
9
|
customer {
|
|
9
|
-
id
|
|
10
10
|
wishlists {
|
|
11
11
|
id
|
|
12
12
|
...WishlistPageFragment
|
|
@@ -18,8 +18,8 @@ export const GET_CUSTOMER_WISHLIST = gql`
|
|
|
18
18
|
|
|
19
19
|
export const GET_CUSTOMER_WISHLIST_ITEMS = gql`
|
|
20
20
|
query getCustomerWishlist($id: ID!, $currentPage: Int) {
|
|
21
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
21
22
|
customer {
|
|
22
|
-
id
|
|
23
23
|
wishlist_v2(id: $id) {
|
|
24
24
|
id
|
|
25
25
|
items_v2(currentPage: $currentPage) {
|
|
@@ -2,8 +2,9 @@ import { gql } from '@apollo/client';
|
|
|
2
2
|
|
|
3
3
|
export const GET_WISHLIST_CONFIG = gql`
|
|
4
4
|
query GetWishlistConfigForWishlistPageCE {
|
|
5
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
5
6
|
storeConfig {
|
|
6
|
-
|
|
7
|
+
store_code
|
|
7
8
|
magento_wishlist_general_is_enabled
|
|
8
9
|
}
|
|
9
10
|
}
|
|
@@ -2,8 +2,9 @@ import { gql } from '@apollo/client';
|
|
|
2
2
|
|
|
3
3
|
export const GET_WISHLIST_CONFIG = gql`
|
|
4
4
|
query GetWishlistConfigForWishlistPageEE {
|
|
5
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
5
6
|
storeConfig {
|
|
6
|
-
|
|
7
|
+
store_code
|
|
7
8
|
magento_wishlist_general_is_enabled
|
|
8
9
|
enable_multiple_wishlists
|
|
9
10
|
}
|
|
@@ -3,8 +3,9 @@ import { gql } from '@apollo/client';
|
|
|
3
3
|
export const WishlistItemFragment = gql`
|
|
4
4
|
fragment WishlistItemFragment on WishlistItemInterface {
|
|
5
5
|
id
|
|
6
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
6
7
|
product {
|
|
7
|
-
|
|
8
|
+
uid
|
|
8
9
|
image {
|
|
9
10
|
label
|
|
10
11
|
url
|
|
@@ -20,9 +21,11 @@ export const WishlistItemFragment = gql`
|
|
|
20
21
|
}
|
|
21
22
|
sku
|
|
22
23
|
stock_status
|
|
24
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
23
25
|
... on ConfigurableProduct {
|
|
26
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
24
27
|
configurable_options {
|
|
25
|
-
|
|
28
|
+
uid
|
|
26
29
|
attribute_code
|
|
27
30
|
attribute_id
|
|
28
31
|
attribute_id_v2
|
|
@@ -4,8 +4,8 @@ import { WishlistPageFragment } from './wishlistFragment.gql';
|
|
|
4
4
|
|
|
5
5
|
export const GET_CUSTOMER_WISHLIST = gql`
|
|
6
6
|
query GetCustomerWishlist {
|
|
7
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
7
8
|
customer {
|
|
8
|
-
id
|
|
9
9
|
wishlists {
|
|
10
10
|
id
|
|
11
11
|
...WishlistPageFragment
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magento/peregrine",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.2.0-alpha.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/magento/pwa-studio/issues"
|
|
17
17
|
},
|
|
18
|
-
"homepage": "https://github.com/magento/pwa-studio/tree/
|
|
18
|
+
"homepage": "https://github.com/magento/pwa-studio/tree/main/packages/peregrine#readme",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"fast-glob": "~3.2.4"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@apollo/client": "~3.
|
|
23
|
+
"@apollo/client": "~3.4.0",
|
|
24
24
|
"@magento/eslint-config": "~1.5.0",
|
|
25
25
|
"@testing-library/react-hooks": "~5.0.3",
|
|
26
26
|
"intl": "~1.2.5",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"wait-for-expect": "~1.2.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@apollo/client": "~3.
|
|
40
|
-
"@babel/runtime": "~7.
|
|
39
|
+
"@apollo/client": "~3.4.0",
|
|
40
|
+
"@babel/runtime": "~7.15.3",
|
|
41
41
|
"informed": "~3.29.0",
|
|
42
42
|
"react": "~17.0.1",
|
|
43
43
|
"react-dom": "~17.0.1",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"redux-actions": "~2.6.5"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
51
|
+
"node": ">=14.x",
|
|
52
52
|
"yarn": ">=1.12.0"
|
|
53
53
|
},
|
|
54
54
|
"pwa-studio": {
|
package/lib/Apollo/clearStore.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wipes the apollo cache in memory and persistence.
|
|
3
|
-
*
|
|
4
|
-
* According to Apollo's docs you should only have to call client.clearStore
|
|
5
|
-
* but if you use a persistence layer such as apollo-cache-persist you MUST
|
|
6
|
-
* pause and purge the persistor's buffer _before_ calling clear store otherwise
|
|
7
|
-
* the data is immediately replayed into the client store from the persistor.
|
|
8
|
-
*
|
|
9
|
-
* See: https://github.com/apollographql/apollo-cache-persist/issues/34#issuecomment-371177206
|
|
10
|
-
*
|
|
11
|
-
* @param {ApolloClient} client apollo client instance
|
|
12
|
-
* @param {PersistorInstance} persistor persistor instance
|
|
13
|
-
*/
|
|
14
|
-
export const clearStore = async (client, persistor) => {
|
|
15
|
-
// Pause automatic persistence.
|
|
16
|
-
persistor.pause();
|
|
17
|
-
|
|
18
|
-
// Delete everything in the storage provider.
|
|
19
|
-
await persistor.purge();
|
|
20
|
-
|
|
21
|
-
// Wipe the apollo store. Do not replay queries.
|
|
22
|
-
await client.clearStore();
|
|
23
|
-
|
|
24
|
-
// Resume automatic persistence.
|
|
25
|
-
persistor.resume();
|
|
26
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { CACHE_PERSIST_PREFIX } from '@magento/peregrine/lib/Apollo/constants';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Deletes specific entry/entries from the apollo cache and then tries to
|
|
5
|
-
* persist the deletions.
|
|
6
|
-
*
|
|
7
|
-
* @param {ApolloClient} client apollo client instance
|
|
8
|
-
* @param {Function} predicate a matching function
|
|
9
|
-
*/
|
|
10
|
-
export const deleteCacheEntry = async (client, predicate) => {
|
|
11
|
-
await deleteActiveCacheEntry(client, predicate);
|
|
12
|
-
await deleteInactiveCachesEntry(client, predicate);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const deleteActiveCacheEntry = async (client, predicate) => {
|
|
16
|
-
// If there is no client or cache then just back out since it doesn't matter :D
|
|
17
|
-
if (
|
|
18
|
-
!client ||
|
|
19
|
-
!client.cache ||
|
|
20
|
-
!client.cache.data ||
|
|
21
|
-
!client.cache.data.data
|
|
22
|
-
) {
|
|
23
|
-
if (process.env.NODE_ENV === 'development') {
|
|
24
|
-
console.warn(
|
|
25
|
-
'Apollo Cache entry deletion attempted without client or cache.'
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Remove from the active cache.
|
|
32
|
-
Object.keys(client.cache.data.data).forEach(key => {
|
|
33
|
-
if (predicate(key)) {
|
|
34
|
-
client.cache.data.delete(key);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Remove from ROOT_QUERY cache.
|
|
39
|
-
if (client.cache.data.data.ROOT_QUERY) {
|
|
40
|
-
Object.keys(client.cache.data.data.ROOT_QUERY).forEach(key => {
|
|
41
|
-
if (predicate(key)) {
|
|
42
|
-
client.cache.data.delete('ROOT_QUERY', key);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Immediately persist the cache changes to the active cache storage.
|
|
48
|
-
if (client.persistor) {
|
|
49
|
-
await client.persistor.persist();
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const deleteInactiveCachesEntry = async (client, predicate) => {
|
|
54
|
-
if (!client || !client.persistor || !globalThis.localStorage) return;
|
|
55
|
-
|
|
56
|
-
const activeApolloCacheLocalStorageKey =
|
|
57
|
-
client.persistor.persistor.storage.key;
|
|
58
|
-
|
|
59
|
-
const isAnInactiveApolloCache = ([key]) => {
|
|
60
|
-
return (
|
|
61
|
-
key.startsWith(CACHE_PERSIST_PREFIX) &&
|
|
62
|
-
key !== activeApolloCacheLocalStorageKey
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const { localStorage } = globalThis;
|
|
67
|
-
|
|
68
|
-
Object.entries(localStorage)
|
|
69
|
-
.filter(isAnInactiveApolloCache)
|
|
70
|
-
.forEach(([inactiveCacheKey, inactiveCacheValue]) => {
|
|
71
|
-
const inactiveApolloCache = JSON.parse(inactiveCacheValue);
|
|
72
|
-
|
|
73
|
-
Object.keys(inactiveApolloCache).forEach(key => {
|
|
74
|
-
if (predicate(key)) {
|
|
75
|
-
delete inactiveApolloCache[key];
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// We're done deleting keys that match the predicate,
|
|
80
|
-
// but we've only mutated the object in memory.
|
|
81
|
-
// Write the updated inactive cache back out to localStorage.
|
|
82
|
-
localStorage.setItem(
|
|
83
|
-
inactiveCacheKey,
|
|
84
|
-
JSON.stringify(inactiveApolloCache)
|
|
85
|
-
);
|
|
86
|
-
});
|
|
87
|
-
};
|