@dropins/storefront-wishlist 3.2.0 → 3.3.0-beta.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 +10 -0
- package/api.js +164 -5
- package/api.js.map +1 -1
- package/containers/Wishlist.js +1 -15
- package/containers/Wishlist.js.map +1 -1
- package/containers/WishlistAlert.js +1 -1
- package/containers/WishlistItem.js +1 -1
- package/containers/WishlistToggle.js +15 -1
- package/containers/WishlistToggle.js.map +1 -1
- package/package.json +1 -1
- package/render.js +1 -1
- package/render.js.map +1 -1
- package/chunks/Heart.js +0 -4
- package/chunks/Heart.js.map +0 -1
- package/chunks/HeartFilled.js +0 -4
- package/chunks/HeartFilled.js.map +0 -1
- package/chunks/Trash.js +0 -4
- package/chunks/Trash.js.map +0 -1
- package/chunks/WishlistAlert.js +0 -4
- package/chunks/WishlistAlert.js.map +0 -1
- package/chunks/WishlistItem.js +0 -4
- package/chunks/WishlistItem.js.map +0 -1
- package/chunks/fetch-error.js +0 -4
- package/chunks/fetch-error.js.map +0 -1
- package/chunks/mergeWishlists.js +0 -148
- package/chunks/mergeWishlists.js.map +0 -1
- package/chunks/removeProductsFromWishlist.js +0 -19
- package/chunks/removeProductsFromWishlist.js.map +0 -1
package/chunks/mergeWishlists.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/*! Copyright 2026 Adobe
|
|
2
|
-
All Rights Reserved. */
|
|
3
|
-
import{Initializer as y}from"@dropins/tools/lib.js";import{events as r}from"@dropins/tools/event-bus.js";import{e as A,s as e,f as I,h as p,g as h,i as T,j as G}from"./fetch-error.js";const g=new y({init:async t=>{const s={isGuestWishlistEnabled:!1,...t};g.config.setConfig(s),e.storeCode=t.storeCode||void 0,f().catch(console.error)},listeners:()=>[r.on("wishlist/data",t=>{A(t)},{eager:!0}),r.on("authenticated",async t=>{if(e.authenticated&&!t&&r.emit("wishlist/reset",void 0),t&&!e.authenticated){e.authenticated=t;const s=await f().catch(console.error);s&&Z(s)}},{eager:!0}),r.on("wishlist/reset",()=>{B().catch(console.error),r.emit("wishlist/data",null)})]}),V=g.config;function N(t){return t?{wishlistIsEnabled:t.storeConfig.magento_wishlist_general_is_enabled,wishlistMultipleListIsEnabled:t.storeConfig.enable_multiple_wishlists,wishlistMaxNumber:t.storeConfig.maximum_number_of_wishlists}:null}function w(t,s){return t?{id:t.id,updated_at:t.updated_at,sharing_code:t.sharing_code,items_count:t.items_count,items:L(t,s??[])}:null}function L(t,s){var i,a;return(a=(i=t==null?void 0:t.items_v2)==null?void 0:i.items)!=null&&a.length?t.items_v2.items.map(n=>{const l=R(n);return{id:n.id,quantity:n.quantity,description:n.description,added_at:n.added_at,enteredOptions:s,selectedOptions:l,product:{sku:n.product.sku}}}):[]}function R(t){return t.__typename==="ConfigurableWishlistItem"?t.configurable_options?t.configurable_options.map(s=>({uid:s.configurable_product_option_value_uid})):[]:t.__typename==="BundleWishlistItem"?(t.bundle_options??[]).flatMap(i=>i.values??[]).map(i=>({uid:i.uid})):[]}const v=`
|
|
4
|
-
query STORE_CONFIG_QUERY {
|
|
5
|
-
storeConfig {
|
|
6
|
-
magento_wishlist_general_is_enabled
|
|
7
|
-
enable_multiple_wishlists
|
|
8
|
-
maximum_number_of_wishlists
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
`,C=async()=>I(v,{method:"GET",cache:"force-cache"}).then(({errors:t,data:s})=>t?p(t):N(s)),D=`
|
|
12
|
-
fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption {
|
|
13
|
-
type
|
|
14
|
-
customizable_option_uid
|
|
15
|
-
label
|
|
16
|
-
is_required
|
|
17
|
-
values {
|
|
18
|
-
label
|
|
19
|
-
value
|
|
20
|
-
price{
|
|
21
|
-
type
|
|
22
|
-
units
|
|
23
|
-
value
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
`,U=`
|
|
28
|
-
... on ConfigurableWishlistItem {
|
|
29
|
-
configurable_options {
|
|
30
|
-
option_label
|
|
31
|
-
value_label
|
|
32
|
-
configurable_product_option_value_uid
|
|
33
|
-
configurable_product_option_uid
|
|
34
|
-
}
|
|
35
|
-
configured_variant {
|
|
36
|
-
canonical_url
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
`,F=`
|
|
40
|
-
... on DownloadableWishlistItem {
|
|
41
|
-
added_at
|
|
42
|
-
description
|
|
43
|
-
links_v2 {
|
|
44
|
-
sample_url
|
|
45
|
-
sort_order
|
|
46
|
-
title
|
|
47
|
-
uid
|
|
48
|
-
}
|
|
49
|
-
quantity
|
|
50
|
-
}
|
|
51
|
-
`,H=`
|
|
52
|
-
... on GiftCardWishlistItem {
|
|
53
|
-
added_at
|
|
54
|
-
description
|
|
55
|
-
gift_card_options {
|
|
56
|
-
amount {
|
|
57
|
-
value
|
|
58
|
-
currency
|
|
59
|
-
}
|
|
60
|
-
custom_giftcard_amount {
|
|
61
|
-
value
|
|
62
|
-
currency
|
|
63
|
-
}
|
|
64
|
-
message
|
|
65
|
-
recipient_email
|
|
66
|
-
recipient_name
|
|
67
|
-
sender_email
|
|
68
|
-
sender_name
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
`,k=`
|
|
72
|
-
... on BundleWishlistItem {
|
|
73
|
-
bundle_options {
|
|
74
|
-
label
|
|
75
|
-
type
|
|
76
|
-
uid
|
|
77
|
-
values {
|
|
78
|
-
uid
|
|
79
|
-
label
|
|
80
|
-
quantity
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
`,P=`
|
|
85
|
-
fragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {
|
|
86
|
-
__typename
|
|
87
|
-
id
|
|
88
|
-
quantity
|
|
89
|
-
description
|
|
90
|
-
added_at
|
|
91
|
-
product {
|
|
92
|
-
sku
|
|
93
|
-
}
|
|
94
|
-
${U}
|
|
95
|
-
${F}
|
|
96
|
-
${H}
|
|
97
|
-
${k}
|
|
98
|
-
customizable_options {
|
|
99
|
-
...CUSTOMIZABLE_OPTIONS_FRAGMENT
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
${D}
|
|
104
|
-
`,S=`
|
|
105
|
-
fragment WISHLIST_FRAGMENT on Wishlist {
|
|
106
|
-
id
|
|
107
|
-
updated_at
|
|
108
|
-
sharing_code
|
|
109
|
-
items_count
|
|
110
|
-
items_v2 {
|
|
111
|
-
items {
|
|
112
|
-
...WISHLIST_ITEM_FRAGMENT
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
${P}
|
|
118
|
-
`,$=`
|
|
119
|
-
query GET_WISHLISTS_QUERY {
|
|
120
|
-
customer {
|
|
121
|
-
wishlists {
|
|
122
|
-
...WISHLIST_FRAGMENT
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
${S}
|
|
128
|
-
`,q=async()=>e.authenticated?I($).then(({errors:t,data:s})=>{var i;return t?p(t):(i=s==null?void 0:s.customer)!=null&&i.wishlists?s.customer.wishlists.map(a=>w(a)):null}):h(),z=`
|
|
129
|
-
mutation ADD_PRODUCTS_TO_WISHLIST_MUTATION(
|
|
130
|
-
$wishlistId: ID!,
|
|
131
|
-
$wishlistItems: [WishlistItemInput!]!,
|
|
132
|
-
) {
|
|
133
|
-
addProductsToWishlist(
|
|
134
|
-
wishlistId: $wishlistId
|
|
135
|
-
wishlistItems: $wishlistItems
|
|
136
|
-
) {
|
|
137
|
-
wishlist {
|
|
138
|
-
...WISHLIST_FRAGMENT
|
|
139
|
-
}
|
|
140
|
-
user_errors {
|
|
141
|
-
code
|
|
142
|
-
message
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
${S}
|
|
147
|
-
`,x=async t=>{var a,n,l,d,m;if(!t)return null;const s=h();let i={id:(s==null?void 0:s.id)??"",updated_at:"",sharing_code:"",items_count:0,items:(s==null?void 0:s.items)??[]};for(const o of t){if((a=i.items)==null?void 0:a.some(_=>T(_,{sku:o.sku,optionUIDs:o.optionsUIDs})))continue;const c=o.optionsUIDs?(n=o.optionsUIDs)==null?void 0:n.map(_=>({uid:_})):[];i.items=[...i.items,{id:crypto.randomUUID(),quantity:o.quantity,selectedOptions:c,enteredOptions:o.enteredOptions??[],product:{sku:o.sku}}]}if(i.items_count=(l=i.items)==null?void 0:l.length,r.emit("wishlist/data",i),e.authenticated){if(!e.wishlistId)throw r.emit("wishlist/data",s),Error("Wishlist ID is not set");const o={wishlistId:e.wishlistId,wishlistItems:t.map(({sku:W,quantity:b,optionsUIDs:O,enteredOptions:M})=>({sku:W,quantity:b,selected_options:O,entered_options:M}))},{errors:u,data:c}=await I(z,{variables:o}),_=[...((d=c==null?void 0:c.addProductsToWishlist)==null?void 0:d.user_errors)??[],...u??[]];if(_.length>0)return r.emit("wishlist/data",s),p(_);const E=w(c.addProductsToWishlist.wishlist,((m=t[0])==null?void 0:m.enteredOptions)??[]);r.emit("wishlist/data",E)}return null},B=()=>(e.wishlistId=null,e.authenticated=!1,Promise.resolve(null)),f=async()=>{if(e.initializing)return null;e.initializing=!0,e.config||(e.config=await C());const t=e.authenticated?await Q():await Y();return r.emit("wishlist/initialized",t),r.emit("wishlist/data",t),e.initializing=!1,t};async function Q(){const t=await q(),s=t?t[0]:null;return s?(e.wishlistId=s.id,s):null}async function Y(){try{return await h()}catch(t){throw console.error(t),t}}const Z=async t=>{var n;if(!t)return null;const s=h(!0),i=[];if((n=s==null?void 0:s.items)==null||n.forEach(l=>{var o;const d=((o=l.selectedOptions)==null?void 0:o.map(u=>u.uid))||[];if(!t.items.some(u=>T(u,{sku:l.product.sku,optionUIDs:d}))){const u={sku:l.product.sku,quantity:1,optionsUIDs:d,enteredOptions:l.enteredOptions||void 0};i.push(u)}}),i.length===0)return null;const a=await x(i);return G(),a};export{P as W,x as a,S as b,V as c,q as d,f as e,Q as f,C as g,Y as h,g as i,Z as m,B as r,w as t};
|
|
148
|
-
//# sourceMappingURL=mergeWishlists.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mergeWishlists.js","sources":["/@dropins/storefront-wishlist/src/api/initialize/initialize.ts","/@dropins/storefront-wishlist/src/data/transforms/transform-store-config.ts","/@dropins/storefront-wishlist/src/data/transforms/transform-wishlist.ts","/@dropins/storefront-wishlist/src/api/getStoreConfig/graphql/StoreConfigQuery.ts","/@dropins/storefront-wishlist/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-wishlist/src/api/graphql/CustomizableOptionsFragment.graphql.ts","/@dropins/storefront-wishlist/src/api/graphql/WishlistItemFragment.graphql.ts","/@dropins/storefront-wishlist/src/api/graphql/WishlistFragment.graphql.ts","/@dropins/storefront-wishlist/src/api/getWishlists/graphql/getWishlists.graphql.ts","/@dropins/storefront-wishlist/src/api/getWishlists/getWishlists.ts","/@dropins/storefront-wishlist/src/api/addProductsToWishlist/graphql/addProductsToWishlistMutation.ts","/@dropins/storefront-wishlist/src/api/addProductsToWishlist/addProductsToWishlist.ts","/@dropins/storefront-wishlist/src/api/resetWishlist/resetWishlist.ts","/@dropins/storefront-wishlist/src/api/initializeWishlist/initializeWishlist.ts","/@dropins/storefront-wishlist/src/api/mergeWishlists/mergeWishlists.ts"],"sourcesContent":["import { Initializer } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport { state } from '@/wishlist/lib/state';\nimport {\n initializeWishlist,\n resetWishlist,\n mergeWishlists,\n} from '@/wishlist/api';\nimport { setPersistedWishlistData } from '@/wishlist/lib/persisted-data';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n isGuestWishlistEnabled?: boolean;\n storeCode?: string;\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig = { isGuestWishlistEnabled: false, ...config };\n\n initialize.config.setConfig(defaultConfig);\n\n state.storeCode = config.storeCode || undefined;\n\n initializeWishlist().catch(console.error);\n },\n\n listeners: () => [\n events.on(\n 'wishlist/data',\n (payload) => {\n setPersistedWishlistData(payload);\n },\n { eager: true }\n ),\n events.on(\n 'authenticated',\n async (authenticated) => {\n if (state.authenticated && !authenticated) {\n // Reset wishlist if the user is no longer authenticated\n events.emit('wishlist/reset', undefined);\n }\n // Login event occurred\n if (authenticated && !state.authenticated) {\n state.authenticated = authenticated;\n const wishlist = await initializeWishlist().catch(console.error);\n if (wishlist) {\n mergeWishlists(wishlist);\n }\n }\n },\n { eager: true }\n ),\n events.on('wishlist/reset', () => {\n resetWishlist().catch(console.error);\n events.emit('wishlist/data', null);\n }),\n ],\n});\n\nexport const config = initialize.config;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { StoreConfigModel } from '@/wishlist/data/models';\n\nexport function transformStoreConfig(data: any): StoreConfigModel | null {\n if (!data) return null;\n\n return {\n wishlistIsEnabled: data.storeConfig.magento_wishlist_general_is_enabled,\n wishlistMultipleListIsEnabled: data.storeConfig.enable_multiple_wishlists,\n wishlistMaxNumber: data.storeConfig.maximum_number_of_wishlists,\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { Wishlist, Item, Option } from '@/wishlist/data/models/wishlist';\n\nexport function transformWishlist(\n data: any,\n enteredOptions?: { uid: string; value: string }[]\n): Wishlist | null {\n if (!data) return null;\n\n return {\n id: data.id,\n updated_at: data.updated_at,\n sharing_code: data.sharing_code,\n items_count: data.items_count,\n items: transformItems(data, enteredOptions ?? []),\n };\n}\n\nfunction transformItems(\n data: any,\n enteredOptions: { uid: string; value: string }[]\n): Item[] {\n if (!data?.items_v2?.items?.length) return [];\n\n return data.items_v2.items.map((item: any) => {\n const selectedOptions = getSelectedOptions(item);\n return {\n id: item.id,\n quantity: item.quantity,\n description: item.description,\n added_at: item.added_at,\n enteredOptions,\n selectedOptions,\n product: { sku: item.product.sku },\n };\n });\n}\n\nfunction getSelectedOptions(item: Item): Option[] {\n if (item.__typename === 'ConfigurableWishlistItem') {\n return item.configurable_options\n ? item.configurable_options.map((option: any) => ({\n uid: option.configurable_product_option_value_uid,\n }))\n : [];\n }\n if (item.__typename === 'BundleWishlistItem') {\n const values = (item.bundle_options ?? []).flatMap(\n (option: any) => option.values ?? []\n );\n return values.map((value: any) => ({ uid: value.uid }));\n }\n return [];\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const STORE_CONFIG_QUERY = `\nquery STORE_CONFIG_QUERY {\n storeConfig {\n magento_wishlist_general_is_enabled\n enable_multiple_wishlists\n maximum_number_of_wishlists\n }\n}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/wishlist/api';\nimport { StoreConfigModel } from '@/wishlist/data/models';\nimport { transformStoreConfig } from '@/wishlist/data/transforms';\nimport { handleFetchError } from '@/wishlist/lib/fetch-error';\n\nimport { STORE_CONFIG_QUERY } from './graphql/StoreConfigQuery';\n\nexport const getStoreConfig = async (): Promise<StoreConfigModel | null> => {\n return fetchGraphQl(STORE_CONFIG_QUERY, {\n method: 'GET',\n cache: 'force-cache',\n }).then(({ errors, data }) => {\n if (errors) return handleFetchError(errors);\n\n return transformStoreConfig(data);\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const CUSTOMIZABLE_OPTIONS_FRAGMENT = `\n fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption {\n type\n customizable_option_uid\n label\n is_required\n values {\n label\n value\n price{\n type\n units\n value\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CUSTOMIZABLE_OPTIONS_FRAGMENT } from './CustomizableOptionsFragment.graphql';\n\nconst CONFIGURABLE_WISHLIST_ITEM_FRAGMENT = `\n ... on ConfigurableWishlistItem {\n configurable_options {\n option_label\n value_label\n configurable_product_option_value_uid\n configurable_product_option_uid\n }\n configured_variant {\n canonical_url\n }\n }\n`;\n\nconst DOWNLOADABLE_WISHLIST_ITEM_FRAGMENT = `\n ... on DownloadableWishlistItem {\n added_at\n description\n links_v2 {\n sample_url\n sort_order\n title\n uid\n }\n quantity\n }\n`;\n\nconst GIFT_CARD_WISHLIST_ITEM_FRAGMENT = `\n ... on GiftCardWishlistItem {\n added_at\n description\n gift_card_options {\n amount {\n value\n currency\n }\n custom_giftcard_amount {\n value\n currency\n }\n message\n recipient_email\n recipient_name\n sender_email\n sender_name\n }\n }\n`;\n\nconst BUNDLE_WISHLIST_ITEM_FRAGMENT = `\n ... on BundleWishlistItem {\n bundle_options {\n label\n type\n uid\n values {\n uid\n label\n quantity\n }\n }\n }\n`;\n\nexport const WISHLIST_ITEM_FRAGMENT = `\nfragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {\n __typename\n id\n quantity\n description\n added_at\n product {\n sku\n }\n ${CONFIGURABLE_WISHLIST_ITEM_FRAGMENT}\n ${DOWNLOADABLE_WISHLIST_ITEM_FRAGMENT}\n ${GIFT_CARD_WISHLIST_ITEM_FRAGMENT}\n ${BUNDLE_WISHLIST_ITEM_FRAGMENT}\n customizable_options {\n ...CUSTOMIZABLE_OPTIONS_FRAGMENT\n }\n }\n \n ${CUSTOMIZABLE_OPTIONS_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WISHLIST_ITEM_FRAGMENT } from '@/wishlist/api/fragments';\n\nexport const WISHLIST_FRAGMENT = `\nfragment WISHLIST_FRAGMENT on Wishlist {\n id\n updated_at\n sharing_code\n items_count\n items_v2 {\n items {\n ...WISHLIST_ITEM_FRAGMENT\n }\n }\n }\n\n${WISHLIST_ITEM_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WISHLIST_FRAGMENT } from '@/wishlist/api/fragments';\n\nexport const GET_WISHLISTS_QUERY = `\n query GET_WISHLISTS_QUERY {\n customer {\n wishlists {\n ...WISHLIST_FRAGMENT\n }\n }\n }\n\n ${WISHLIST_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { GET_WISHLISTS_QUERY } from '@/wishlist/api/getWishlists/graphql/getWishlists.graphql';\nimport { Wishlist } from '@/wishlist/data/models';\nimport { transformWishlist } from '@/wishlist/data/transforms';\nimport { state } from '@/wishlist/lib/state';\nimport { fetchGraphQl, getPersistedWishlistData } from '@/wishlist/api';\nimport { handleFetchError } from '@/wishlist/lib/fetch-error';\n\nexport const getWishlists = async (): Promise<void | Wishlist[] | null> => {\n // When the user is not authenticated, we just have a single wishlist\n // There is no necessity to check any IDs\n if (!state.authenticated) {\n return getPersistedWishlistData();\n }\n\n return fetchGraphQl(GET_WISHLISTS_QUERY).then(({ errors, data }) => {\n if (errors) return handleFetchError(errors);\n\n if (!data?.customer?.wishlists) {\n return null;\n }\n\n return data.customer.wishlists.map((wishlist: any) =>\n transformWishlist(wishlist)\n );\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WISHLIST_FRAGMENT } from '@/wishlist/api/fragments';\n\nexport const ADD_PRODUCTS_TO_WISHLIST_MUTATION = `\n mutation ADD_PRODUCTS_TO_WISHLIST_MUTATION(\n $wishlistId: ID!, \n $wishlistItems: [WishlistItemInput!]!,\n ) {\n addProductsToWishlist(\n wishlistId: $wishlistId\n wishlistItems: $wishlistItems\n ) {\n wishlist {\n ...WISHLIST_FRAGMENT\n }\n user_errors {\n code\n message\n }\n }\n }\n${WISHLIST_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl, getPersistedWishlistData } from '@/wishlist/api';\nimport { state } from '@/wishlist/lib/state';\nimport { handleFetchError } from '@/wishlist/lib/fetch-error';\nimport { ADD_PRODUCTS_TO_WISHLIST_MUTATION } from './graphql/addProductsToWishlistMutation';\nimport { Wishlist } from '@/wishlist/data/models/wishlist';\nimport { transformWishlist } from '@/wishlist/data/transforms';\nimport { events } from '@adobe-commerce/event-bus';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nexport const addProductsToWishlist = async (\n items: [\n {\n sku: string;\n quantity: number;\n optionsUIDs?: string[]; // should be the options available for the product\n enteredOptions?: { uid: string; value: string }[]; // refer to both selected and entered options\n }\n ]\n): Promise<Wishlist | null> => {\n if (!items) return null;\n\n const wishlist = getPersistedWishlistData();\n let updatedWishlist = {\n id: wishlist?.id ?? '',\n updated_at: '',\n sharing_code: '',\n items_count: 0,\n items: wishlist?.items ?? [],\n };\n\n for (const item of items) {\n const skuExists = updatedWishlist.items?.some((wishlistItem: any) =>\n isMatchingWishlistItem(wishlistItem, {\n sku: item.sku,\n optionUIDs: item.optionsUIDs,\n })\n );\n\n if (skuExists) {\n continue;\n }\n\n const selectedOptions: { uid: string }[] = item.optionsUIDs\n ? item.optionsUIDs?.map((option: any) => ({\n uid: option,\n }))\n : [];\n\n updatedWishlist.items = [\n ...updatedWishlist.items,\n {\n id: crypto.randomUUID(),\n quantity: item.quantity,\n selectedOptions,\n enteredOptions: item.enteredOptions ?? [],\n product: { sku: item.sku },\n },\n ];\n }\n\n updatedWishlist.items_count = updatedWishlist.items?.length;\n events.emit('wishlist/data', updatedWishlist);\n\n if (state.authenticated) {\n if (!state.wishlistId) {\n events.emit('wishlist/data', wishlist);\n throw Error('Wishlist ID is not set');\n }\n\n const variables = {\n wishlistId: state.wishlistId,\n wishlistItems: items.map(\n ({ sku, quantity, optionsUIDs, enteredOptions }) => ({\n sku,\n quantity,\n selected_options: optionsUIDs,\n entered_options: enteredOptions,\n })\n ),\n };\n\n const { errors, data }: { errors: any; data: any } = await fetchGraphQl(\n ADD_PRODUCTS_TO_WISHLIST_MUTATION,\n { variables }\n );\n\n const _errors = [\n ...(data?.addProductsToWishlist?.user_errors ?? []),\n ...(errors ?? []),\n ];\n\n // if saving item to wishlist for logged user failed, we need to restore original wishlist in storage:\n if (_errors.length > 0) {\n events.emit('wishlist/data', wishlist);\n return handleFetchError(_errors);\n }\n\n const updatedWishlist = transformWishlist(\n data.addProductsToWishlist.wishlist,\n items[0]?.enteredOptions ?? []\n );\n events.emit('wishlist/data', updatedWishlist);\n }\n\n return null;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { state } from '@/wishlist/lib/state';\nimport { Wishlist } from '@/wishlist/data/models';\n\nexport const resetWishlist = (): Promise<Wishlist | null> => {\n state.wishlistId = null;\n state.authenticated = false;\n\n return Promise.resolve(null);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { events } from '@adobe-commerce/event-bus';\nimport { state } from '@/wishlist/lib/state';\nimport { getStoreConfig, getWishlists } from '@/wishlist/api';\nimport { getPersistedWishlistData } from '@/wishlist/lib/persisted-data';\nimport { Wishlist } from '@/wishlist/data/models';\n\nexport const initializeWishlist = async (): Promise<Wishlist | null> => {\n if (state.initializing) return null;\n\n state.initializing = true;\n\n // set config\n if (!state.config) {\n state.config = await getStoreConfig();\n }\n\n const payload = state.authenticated\n ? await getDefaultWishlist()\n : await getGuestWishlist();\n\n events.emit('wishlist/initialized', payload);\n events.emit('wishlist/data', payload);\n\n state.initializing = false;\n\n return payload;\n};\n\nexport async function getDefaultWishlist() {\n const wishlists = await getWishlists();\n const wishlist = wishlists ? wishlists[0] : null;\n if (!wishlist) return null;\n\n state.wishlistId = wishlist.id;\n\n return wishlist;\n}\n\nexport async function getGuestWishlist() {\n try {\n return await getPersistedWishlistData();\n } catch (error) {\n console.error(error);\n throw error;\n }\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Wishlist, Item } from '@/wishlist/data/models';\nimport { addProductsToWishlist } from '@/wishlist/api';\nimport {\n getPersistedWishlistData,\n clearPersistedLocalStorage,\n} from '@/wishlist/lib/persisted-data';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nexport const mergeWishlists = async (\n wishlist: Wishlist\n): Promise<Wishlist | null> => {\n if (!wishlist) {\n return null;\n }\n\n const guestWishlist: {\n id?: string;\n items?: Item[];\n } = getPersistedWishlistData(true);\n const itemsToMerge: any[] = [];\n\n guestWishlist?.items?.forEach((item: any) => {\n const optionUIDs =\n item.selectedOptions?.map((option: any) => option.uid) || [];\n\n const exists = wishlist.items.some((wishlistItem: any) =>\n isMatchingWishlistItem(wishlistItem, {\n sku: item.product.sku,\n optionUIDs,\n })\n );\n\n if (!exists) {\n const mergeItem = {\n sku: item.product.sku,\n quantity: 1,\n optionsUIDs: optionUIDs,\n enteredOptions: item.enteredOptions || undefined,\n };\n\n itemsToMerge.push(mergeItem);\n }\n });\n\n if (itemsToMerge.length === 0) {\n return null;\n }\n\n const result = await addProductsToWishlist(itemsToMerge);\n clearPersistedLocalStorage();\n return result;\n};\n"],"names":["initialize","Initializer","config","defaultConfig","state","initializeWishlist","events","payload","setPersistedWishlistData","authenticated","wishlist","mergeWishlists","resetWishlist","transformStoreConfig","data","transformWishlist","enteredOptions","transformItems","_b","_a","item","selectedOptions","getSelectedOptions","option","value","STORE_CONFIG_QUERY","getStoreConfig","fetchGraphQl","errors","handleFetchError","CUSTOMIZABLE_OPTIONS_FRAGMENT","CONFIGURABLE_WISHLIST_ITEM_FRAGMENT","DOWNLOADABLE_WISHLIST_ITEM_FRAGMENT","GIFT_CARD_WISHLIST_ITEM_FRAGMENT","BUNDLE_WISHLIST_ITEM_FRAGMENT","WISHLIST_ITEM_FRAGMENT","WISHLIST_FRAGMENT","GET_WISHLISTS_QUERY","getWishlists","getPersistedWishlistData","ADD_PRODUCTS_TO_WISHLIST_MUTATION","addProductsToWishlist","items","updatedWishlist","wishlistItem","isMatchingWishlistItem","_c","variables","sku","quantity","optionsUIDs","_errors","_d","_e","getDefaultWishlist","getGuestWishlist","wishlists","error","guestWishlist","itemsToMerge","optionUIDs","mergeItem","result","clearPersistedLocalStorage"],"mappings":"wLAiBa,MAAAA,EAAa,IAAIC,EAAyB,CACrD,KAAM,MAAOC,GAAW,CACtB,MAAMC,EAAgB,CAAE,uBAAwB,GAAO,GAAGD,CAAO,EAEtDF,EAAA,OAAO,UAAUG,CAAa,EAEnCC,EAAA,UAAYF,EAAO,WAAa,OAEnBG,IAAE,MAAM,QAAQ,KAAK,CAC1C,EAEA,UAAW,IAAM,CACfC,EAAO,GACL,gBACCC,GAAY,CACXC,EAAyBD,CAAO,CAClC,EACA,CA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3
|
-
import{g as c,i as u,s as h,f as w,h as _}from"./fetch-error.js";import{events as m}from"@dropins/tools/event-bus.js";const p=`
|
|
4
|
-
mutation REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION(
|
|
5
|
-
$wishlistId: ID!,
|
|
6
|
-
$wishlistItemsIds: [ID!]!,
|
|
7
|
-
) {
|
|
8
|
-
removeProductsFromWishlist(
|
|
9
|
-
wishlistId: $wishlistId
|
|
10
|
-
wishlistItemsIds: $wishlistItemsIds
|
|
11
|
-
) {
|
|
12
|
-
user_errors {
|
|
13
|
-
code
|
|
14
|
-
message
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
`,f=async l=>{var a,I,d;const e=c(),r={...e,items:(a=e.items)==null?void 0:a.filter(o=>!l.some(t=>{var s;return u(o,{sku:t.product.sku,optionUIDs:(s=t.selectedOptions)==null?void 0:s.map(i=>i.uid)})}))};if(h.authenticated){if(!h.wishlistId)throw Error("Wishlist ID is not set");const o=l.map(n=>n.id),{errors:t,data:s}=await w(p,{variables:{wishlistId:h.wishlistId,wishlistItemsIds:o}}),i=[...((I=s==null?void 0:s.removeProductsFromWishlist)==null?void 0:I.user_errors)??[],...t??[]];if(i.length>0)return m.emit("wishlist/data",e),_(i)}return r.items_count=(d=r.items)==null?void 0:d.length,m.emit("wishlist/data",r),null};export{f as r};
|
|
19
|
-
//# sourceMappingURL=removeProductsFromWishlist.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"removeProductsFromWishlist.js","sources":["/@dropins/storefront-wishlist/src/api/removeProductsFromWishlist/graphql/removeProductsFromWishlistMutation.ts","/@dropins/storefront-wishlist/src/api/removeProductsFromWishlist/removeProductsFromWishlist.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION = `\n mutation REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION(\n $wishlistId: ID!, \n $wishlistItemsIds: [ID!]!,\n ) {\n removeProductsFromWishlist(\n wishlistId: $wishlistId\n wishlistItemsIds: $wishlistItemsIds\n ) {\n user_errors {\n code\n message\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/wishlist/api';\nimport { state } from '@/wishlist/lib/state';\nimport { handleFetchError } from '@/wishlist/lib/fetch-error';\nimport { REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION } from './graphql/removeProductsFromWishlistMutation';\nimport { Item, Wishlist } from '@/wishlist/data/models/wishlist';\nimport { events } from '@adobe-commerce/event-bus';\nimport { getPersistedWishlistData } from '@/wishlist/lib/persisted-data';\nimport { isMatchingWishlistItem } from '@/wishlist/lib/wishlist-item-comparator';\n\nexport const removeProductsFromWishlist = async (\n items: Array<Item>\n): Promise<Wishlist | null> => {\n const wishlist = getPersistedWishlistData();\n const updatedWishlist = {\n ...wishlist,\n items: wishlist.items?.filter((wishlistItem: any) => {\n return !items.some((item) =>\n isMatchingWishlistItem(wishlistItem, {\n sku: item.product.sku,\n optionUIDs: item.selectedOptions?.map((option: any) => option.uid),\n })\n );\n }),\n };\n\n if (state.authenticated) {\n if (!state.wishlistId) {\n throw Error('Wishlist ID is not set');\n }\n\n const itemIds = items.map((item) => item.id);\n const { errors, data } = await fetchGraphQl(\n REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION,\n {\n variables: { wishlistId: state.wishlistId, wishlistItemsIds: itemIds },\n }\n );\n\n const _errors = [\n ...(data?.removeProductsFromWishlist?.user_errors ?? []),\n ...(errors ?? []),\n ];\n\n // restore wishlist if removing item failed:\n if (_errors.length > 0) {\n events.emit('wishlist/data', wishlist);\n return handleFetchError(_errors);\n }\n }\n\n updatedWishlist.items_count = updatedWishlist.items?.length;\n events.emit('wishlist/data', updatedWishlist);\n\n return null;\n};\n"],"names":["REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION","removeProductsFromWishlist","items","wishlist","getPersistedWishlistData","updatedWishlist","_a","wishlistItem","item","isMatchingWishlistItem","option","state","itemIds","errors","data","fetchGraphQl","_errors","_b","events","handleFetchError","_c"],"mappings":"sHAiBO,MAAMA,EAAyC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECSzCC,EAA6B,MACxCC,GAC6B,WAC7B,MAAMC,EAAWC,EAAyB,EACpCC,EAAkB,CACtB,GAAGF,EACH,OAAOG,EAAAH,EAAS,QAAT,YAAAG,EAAgB,OAAQC,GACtB,CAACL,EAAM,KAAMM,GAClB,OAAA,OAAAC,EAAuBF,EAAc,CACnC,IAAKC,EAAK,QAAQ,IAClB,YAAYF,EAAAE,EAAK,kBAAL,YAAAF,EAAsB,IAAKI,GAAgBA,EAAO,IAC/D,CAAA,EACH,EAEJ,EAEA,GAAIC,EAAM,cAAe,CACnB,GAAA,CAACA,EAAM,WACT,MAAM,MAAM,wBAAwB,EAGtC,MAAMC,EAAUV,EAAM,IAAKM,GAASA,EAAK,EAAE,EACrC,CAAE,OAAAK,EAAQ,KAAAC,CAAK,EAAI,MAAMC,EAC7Bf,EACA,CACE,UAAW,CAAE,WAAYW,EAAM,WAAY,iBAAkBC,CAAQ,CAAA,CAEzE,EAEMI,EAAU,CACd,KAAIC,EAAAH,GAAA,YAAAA,EAAM,6BAAN,YAAAG,EAAkC,cAAe,CAAC,EACtD,GAAIJ,GAAU,CAAA,CAChB,EAGI,GAAAG,EAAQ,OAAS,EACZ,OAAAE,EAAA,KAAK,gBAAiBf,CAAQ,EAC9BgB,EAAiBH,CAAO,CACjC,CAGc,OAAAX,EAAA,aAAce,EAAAf,EAAgB,QAAhB,YAAAe,EAAuB,OAC9CF,EAAA,KAAK,gBAAiBb,CAAe,EAErC,IACT"}
|