@personizely/shopify-hydrogen 1.0.0 → 1.0.1
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/dist/index.cjs +386 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +342 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +342 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +264 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +13 -4
- package/dist/classes/Adapter.d.ts +0 -33
- package/dist/classes/Adapter.d.ts.map +0 -1
- package/dist/classes/Adapter.js +0 -126
- package/dist/classes/Adapter.js.map +0 -1
- package/dist/classes/Cart.d.ts +0 -29
- package/dist/classes/Cart.d.ts.map +0 -1
- package/dist/classes/Cart.js +0 -272
- package/dist/classes/Cart.js.map +0 -1
- package/dist/components/PersonizelyProvider.d.ts +0 -36
- package/dist/components/PersonizelyProvider.d.ts.map +0 -1
- package/dist/components/PersonizelyProvider.js +0 -118
- package/dist/components/PersonizelyProvider.js.map +0 -1
- package/dist/graphql/queries/cart.d.ts +0 -7
- package/dist/graphql/queries/cart.d.ts.map +0 -1
- package/dist/graphql/queries/cart.js +0 -142
- package/dist/graphql/queries/cart.js.map +0 -1
- package/dist/graphql/queries/customer.d.ts +0 -5
- package/dist/graphql/queries/customer.d.ts.map +0 -1
- package/dist/graphql/queries/customer.js +0 -72
- package/dist/graphql/queries/customer.js.map +0 -1
- package/dist/graphql/queries/product.d.ts +0 -5
- package/dist/graphql/queries/product.d.ts.map +0 -1
- package/dist/graphql/queries/product.js +0 -114
- package/dist/graphql/queries/product.js.map +0 -1
- package/dist/hooks/useCartAdd.d.ts +0 -3
- package/dist/hooks/useCartAdd.d.ts.map +0 -1
- package/dist/hooks/useCartAdd.js +0 -18
- package/dist/hooks/useCartAdd.js.map +0 -1
- package/dist/hooks/useCheckout.d.ts +0 -2
- package/dist/hooks/useCheckout.d.ts.map +0 -1
- package/dist/hooks/useCheckout.js +0 -12
- package/dist/hooks/useCheckout.js.map +0 -1
- package/dist/hooks/usePageContext.d.ts +0 -3
- package/dist/hooks/usePageContext.d.ts.map +0 -1
- package/dist/hooks/usePageContext.js +0 -6
- package/dist/hooks/usePageContext.js.map +0 -1
- package/dist/hooks/usePersonizely.d.ts +0 -3
- package/dist/hooks/usePersonizely.d.ts.map +0 -1
- package/dist/hooks/usePersonizely.js +0 -11
- package/dist/hooks/usePersonizely.js.map +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -170
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +0 -1
- package/dist/types/interfaces.d.ts +0 -35
- package/dist/types/interfaces.d.ts.map +0 -1
- package/dist/types/interfaces.js +0 -2
- package/dist/types/interfaces.js.map +0 -1
- package/dist/utils/cookies.d.ts +0 -4
- package/dist/utils/cookies.d.ts.map +0 -1
- package/dist/utils/cookies.js +0 -33
- package/dist/utils/cookies.js.map +0 -1
- package/dist/utils/id.d.ts +0 -3
- package/dist/utils/id.d.ts.map +0 -1
- package/dist/utils/id.js +0 -7
- package/dist/utils/id.js.map +0 -1
- package/dist/utils/storefront-client.d.ts +0 -15
- package/dist/utils/storefront-client.d.ts.map +0 -1
- package/dist/utils/storefront-client.js +0 -39
- package/dist/utils/storefront-client.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/interfaces.ts","../src/types/index.ts","../src/utils/storefront-client.ts","../src/classes/Cart.ts","../src/classes/Adapter.ts","../src/components/PersonizelyProvider.tsx","../src/hooks/usePersonizely.ts","../src/hooks/useCartAdd.ts","../src/hooks/useCheckout.ts","../src/hooks/usePageContext.ts"],"sourcesContent":[],"mappings":";;;;UAWiB,KAAA;;4BAUW;EAVX,KAAA,CAAA,KAAK,CAAA,EAA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AAA,IAAA;CAIA;AAAa,iBIJR,mBAAA,CJIQ;EAAA,aAAA;EAAA,qBAAA;EAAA,UAAA;EAAA,MAAA;EAAA,QAAA;EAAA,MAAA;EAAA,UAAA;EAAA,aAAA;EAAA,OAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EIQrB,wBJRqB,CAAA,EIQG,KAAA,CAAA,GAAA,CAAA,OJRH;;;iBK/BR,cAAA,CAAA,GAAmB;;;iBCmBnB,UAAA,CAAA,aAGqB,mBAAiB;;;iBCdtC,WAAA,CAAA,SAGe;;;iBC9Bf,cAAA,UAAyB,QAAQ"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import e,{createContext as t,useCallback as n,useContext as r,useEffect as i,useMemo as a,useRef as o}from"react";import{useMatches as s,useRevalidator as c}from"react-router";function l(e){if(typeof document>`u`)return null;let t=e+`=`,n=document.cookie.split(`;`);for(let e=0;e<n.length;e++){let r=n[e];for(;r.charAt(0)===` `;)r=r.substring(1,r.length);if(r.indexOf(t)===0)return r.substring(t.length,r.length)}return null}function u(e,t,n,r=`/`){if(typeof document>`u`)return;let i=``;if(n){let e=new Date;e.setTime(e.getTime()+n*24*60*60*1e3),i=`; expires=`+e.toUTCString()}document.cookie=e+`=`+t+i+`; path=`+r}const d=`
|
|
2
|
+
fragment CartFragment on Cart {
|
|
3
|
+
id
|
|
4
|
+
checkoutUrl
|
|
5
|
+
totalQuantity
|
|
6
|
+
cost {
|
|
7
|
+
subtotalAmount {
|
|
8
|
+
amount
|
|
9
|
+
currencyCode
|
|
10
|
+
}
|
|
11
|
+
totalAmount {
|
|
12
|
+
amount
|
|
13
|
+
currencyCode
|
|
14
|
+
}
|
|
15
|
+
totalTaxAmount {
|
|
16
|
+
amount
|
|
17
|
+
currencyCode
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
lines(first: 100) {
|
|
21
|
+
nodes {
|
|
22
|
+
id
|
|
23
|
+
quantity
|
|
24
|
+
cost {
|
|
25
|
+
totalAmount {
|
|
26
|
+
amount
|
|
27
|
+
currencyCode
|
|
28
|
+
}
|
|
29
|
+
amountPerQuantity {
|
|
30
|
+
amount
|
|
31
|
+
currencyCode
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
merchandise {
|
|
35
|
+
... on ProductVariant {
|
|
36
|
+
id
|
|
37
|
+
title
|
|
38
|
+
price {
|
|
39
|
+
amount
|
|
40
|
+
currencyCode
|
|
41
|
+
}
|
|
42
|
+
image {
|
|
43
|
+
url
|
|
44
|
+
altText
|
|
45
|
+
}
|
|
46
|
+
selectedOptions {
|
|
47
|
+
name
|
|
48
|
+
value
|
|
49
|
+
}
|
|
50
|
+
product {
|
|
51
|
+
id
|
|
52
|
+
handle
|
|
53
|
+
title
|
|
54
|
+
featuredImage {
|
|
55
|
+
url
|
|
56
|
+
altText
|
|
57
|
+
}
|
|
58
|
+
tags
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
attributes {
|
|
63
|
+
key
|
|
64
|
+
value
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
discountCodes {
|
|
69
|
+
code
|
|
70
|
+
applicable
|
|
71
|
+
}
|
|
72
|
+
attributes {
|
|
73
|
+
key
|
|
74
|
+
value
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`;`${d}`;const f=`
|
|
78
|
+
mutation cartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {
|
|
79
|
+
cartLinesAdd(cartId: $cartId, lines: $lines) {
|
|
80
|
+
cart {
|
|
81
|
+
...CartFragment
|
|
82
|
+
}
|
|
83
|
+
userErrors {
|
|
84
|
+
field
|
|
85
|
+
message
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
${d}
|
|
90
|
+
`,p=`
|
|
91
|
+
mutation cartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {
|
|
92
|
+
cartLinesUpdate(cartId: $cartId, lines: $lines) {
|
|
93
|
+
cart {
|
|
94
|
+
...CartFragment
|
|
95
|
+
}
|
|
96
|
+
userErrors {
|
|
97
|
+
field
|
|
98
|
+
message
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
${d}
|
|
103
|
+
`,m=`
|
|
104
|
+
mutation cartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {
|
|
105
|
+
cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {
|
|
106
|
+
cart {
|
|
107
|
+
...CartFragment
|
|
108
|
+
}
|
|
109
|
+
userErrors {
|
|
110
|
+
field
|
|
111
|
+
message
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
${d}
|
|
116
|
+
`,h=`
|
|
117
|
+
mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {
|
|
118
|
+
cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
|
|
119
|
+
cart {
|
|
120
|
+
...CartFragment
|
|
121
|
+
}
|
|
122
|
+
userErrors {
|
|
123
|
+
field
|
|
124
|
+
message
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
${d}
|
|
129
|
+
`;function g(e,t){return`gid://shopify/${t}/${e}`}function _(e){return Number(e.split(`/`).pop())}const v=`_ply_coupon`;var y=class{constructor(e,t,n){this.listeners=[],this.cart=null,this.storefrontClient=t,this.cartPromise=e,this.revalidate=n}updateCartData(e){this.cart=e,this.cartPromise=null}notifyListeners(){this.cart&&this.listeners.forEach(e=>{try{this.cart&&e(this.toCartData(this.cart))}catch(e){console.error(`Cart listener error:`,e)}})}isSynced(){return!!this.cart}onChange(e){return this.listeners.push(e),()=>{let t=this.listeners.indexOf(e);t>-1&&this.listeners.splice(t,1)}}async fetch(e=!0){return this.cart&&!e?this.toCartData(this.cart):this.cartPromise?(this.cart=await this.cartPromise,this.toCartData(this.cart)):this.cart?this.toCartData(this.cart):null}async update(e,t){if(!this.cart)throw Error(`Cart not initialized`);let n=this.cart.lines.nodes.map(e=>e.id);try{let r;switch(e){case`add`:r=await this.storefrontClient.mutate(f,{cartId:this.cart.id,lines:[{merchandiseId:g(t.id,`ProductVariant`),quantity:t.quantity||1,attributes:t.properties?Object.entries(t.properties).map(([e,t])=>({key:e,value:String(t)})):void 0}]}),r?.cartLinesAdd?.cart&&(this.cart=r.cartLinesAdd.cart,this.notifyListeners());break;case`update`:case`change`:if(t.updates){let e=[],n=[];Object.entries(t.updates).forEach(([t,r])=>{let i=this.cart.lines.nodes.find(e=>_(e.merchandise.id)===Number(t));i?e.push({id:i.id,quantity:Number(r)}):Number(r)>0&&n.push({merchandiseId:g(Number(t),`ProductVariant`),quantity:Number(r)})});let r=[];if(e.length>0&&r.push(this.storefrontClient.mutate(p,{cartId:this.cart.id,lines:e})),n.length>0&&r.push(this.storefrontClient.mutate(f,{cartId:this.cart.id,lines:n})),r.length>0){let e=await Promise.all(r),t=e[e.length-1];(t?.cartLinesUpdate?.cart||t?.cartLinesAdd?.cart)&&(this.cart=t.cartLinesUpdate?.cart||t.cartLinesAdd?.cart,this.notifyListeners())}}else r=await this.storefrontClient.mutate(p,{cartId:this.cart.id,lines:[{id:`gid://shopify/CartLine/${t.id}`,quantity:t.quantity}]}),r?.cartLinesUpdate?.cart&&(this.cart=r.cartLinesUpdate.cart,this.notifyListeners());t.discount&&this.cart&&(r=await this.storefrontClient.mutate(h,{cartId:this.cart.id,discountCodes:[t.discount]}),r?.cartDiscountCodesUpdate?.cart&&(this.cart=r.cartDiscountCodesUpdate.cart,this.notifyListeners()));break;case`clear`:r=await this.storefrontClient.mutate(m,{cartId:this.cart.id,lineIds:n}),r?.cartLinesRemove?.cart&&(this.cart=r.cartLinesRemove.cart,this.notifyListeners());break;default:console.warn(`Unknown cart action: ${e}`)}this.revalidate&&this.revalidate()}catch(e){throw console.error(`Cart update error:`,e),e}}async buy(e,t=1){if(!this.cart)return;let n=this.getCoupon(),r=this.cart.checkoutUrl||`/checkout`,i=n?`${r}?discount=${n}`:r;typeof window<`u`&&(window.location.href=i)}get(e){return this.cart?e?this.toCartData(this.cart)[e]:this.toCartData(this.cart):e?void 0:null}getToken(){return this.cart&&this.cart.id||null}getItemsIds(){return this.cart?this.cart.lines.nodes.map(e=>e.merchandise.product.id):[]}getCurrency(){return this.cart?this.cart.cost.totalAmount.currencyCode:`USD`}getValue(e){return this.cart?parseFloat(this.cart.cost.totalAmount.amount)*100:0}getSize(e=!1){return this.cart?e?new Set(this.cart.lines.nodes.map(e=>e.merchandise.product.id)).size:this.cart.totalQuantity:0}async fetchCollections(e=!1){return console.warn(`fetchCollections: Not implemented for Hydrogen. Use custom metafield query.`),{}}async applyCoupon(e,t){if(!this.cart)throw Error(`Cart not initialized`);u(v,e,t);try{let t=await this.storefrontClient.mutate(h,{cartId:this.cart.id,discountCodes:[e]});t?.cartDiscountCodesUpdate?.cart&&(this.cart=t.cartDiscountCodesUpdate.cart,this.notifyListeners()),this.revalidate&&this.revalidate()}catch(e){throw console.error(`Error applying coupon:`,e),e}}getCoupon(){return this.cart?this.cart.discountCodes&&this.cart.discountCodes.length>0?this.cart.discountCodes[0].code:l(v):null}toCartData(e){return{token:e.id,item_count:e.totalQuantity||0,items:(e.lines?.nodes||[]).map(e=>({id:_(e.id),product_id:_(e.merchandise.product.id),variant_id:_(e.merchandise.id),price:Number(e.merchandise.price.amount)*100,quantity:e.quantity})),total_price:Number(e.cost.totalAmount.amount)*100,discount_codes:e.discountCodes,attributes:e.attributes,note:e.note}}};const b=`
|
|
130
|
+
fragment ProductFragment on Product {
|
|
131
|
+
id
|
|
132
|
+
handle
|
|
133
|
+
title
|
|
134
|
+
description
|
|
135
|
+
descriptionHtml
|
|
136
|
+
productType
|
|
137
|
+
vendor
|
|
138
|
+
tags
|
|
139
|
+
availableForSale
|
|
140
|
+
requiresSellingPlan
|
|
141
|
+
priceRange {
|
|
142
|
+
minVariantPrice {
|
|
143
|
+
amount
|
|
144
|
+
currencyCode
|
|
145
|
+
}
|
|
146
|
+
maxVariantPrice {
|
|
147
|
+
amount
|
|
148
|
+
currencyCode
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
featuredImage {
|
|
152
|
+
id
|
|
153
|
+
url
|
|
154
|
+
altText
|
|
155
|
+
width
|
|
156
|
+
height
|
|
157
|
+
}
|
|
158
|
+
images(first: 10) {
|
|
159
|
+
nodes {
|
|
160
|
+
id
|
|
161
|
+
url
|
|
162
|
+
altText
|
|
163
|
+
width
|
|
164
|
+
height
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
variants(first: 100) {
|
|
168
|
+
nodes {
|
|
169
|
+
id
|
|
170
|
+
title
|
|
171
|
+
availableForSale
|
|
172
|
+
quantityAvailable
|
|
173
|
+
sellingPlanAllocations(first: 10) {
|
|
174
|
+
edges {
|
|
175
|
+
node {
|
|
176
|
+
sellingPlan {
|
|
177
|
+
id
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
sku
|
|
183
|
+
price {
|
|
184
|
+
amount
|
|
185
|
+
currencyCode
|
|
186
|
+
}
|
|
187
|
+
compareAtPrice {
|
|
188
|
+
amount
|
|
189
|
+
currencyCode
|
|
190
|
+
}
|
|
191
|
+
selectedOptions {
|
|
192
|
+
name
|
|
193
|
+
value
|
|
194
|
+
}
|
|
195
|
+
image {
|
|
196
|
+
id
|
|
197
|
+
url
|
|
198
|
+
altText
|
|
199
|
+
width
|
|
200
|
+
height
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
options {
|
|
205
|
+
id
|
|
206
|
+
name
|
|
207
|
+
values
|
|
208
|
+
}
|
|
209
|
+
collections(first: 10) {
|
|
210
|
+
nodes {
|
|
211
|
+
id
|
|
212
|
+
handle
|
|
213
|
+
title
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
`,x=`
|
|
218
|
+
query getProductByHandle($handle: String!) {
|
|
219
|
+
product(handle: $handle) {
|
|
220
|
+
...ProductFragment
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
${b}
|
|
224
|
+
`,S=`
|
|
225
|
+
query getProductById($id: ID!) {
|
|
226
|
+
product(id: $id) {
|
|
227
|
+
...ProductFragment
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
${b}
|
|
231
|
+
`,C=`
|
|
232
|
+
query getProductRecommendations($productId: ID!) {
|
|
233
|
+
productRecommendations(productId: $productId) {
|
|
234
|
+
...ProductFragment
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
${b}
|
|
238
|
+
`;var w=class{constructor(e,t){this.customerAccessToken=null,this.client=t,this.methods=e.methods,this.currency={active:`USD`,base:`USD`,rate:1,...e.currency},this.locale=e.locale||`en-US`,this.market=e.market||null,this.pageContext={pageType:void 0,product:null,collection:null}}setCustomerAccessToken(e){this.customerAccessToken=e}async fetchProduct(e){let t=await this.client.query(x,{handle:e});if(!t.product)throw Error(`Product not found: ${e}`);return this.toProductData(t.product)}async fetchProductCollections(e,t){let n;if(t?n=await this.client.query(S,{id:`gid://shopify/Product/${t}`}):e&&(n=await this.client.query(x,{handle:e})),!n||!n.product)throw Error(`Product not found: ${t}`);return n.product.collections.nodes.map(e=>_(e.id))}async fetchRecommendations(e,t){return{intent:t,products:(await this.client.query(C,{productId:`gid://shopify/Product/${e}`,intent:t})).productRecommendations.map(e=>this.toProductData(e))||[]}}buildProductPath(e){return typeof this.methods?.builtProductPath==`function`?this.methods.builtProductPath(e):`/products/${e.handle}`}convertToBaseCurrency(e){return this.currency.rate/e}convertFromBaseCurrency(e){return this.currency.rate*e}formatMoney(e,t=!0){return typeof this.methods?.formatMoney==`function`?this.methods.formatMoney(e,t):new Intl.NumberFormat(this.locale,{style:`currency`,currency:this.currency.active,maximumFractionDigits:t?void 0:0}).format(e/100)}async getCustomer(){if(!this.customerAccessToken)return null;try{return(await this.client.query(`
|
|
239
|
+
query getCustomer($customerAccessToken: String!) {
|
|
240
|
+
customer(customerAccessToken: $customerAccessToken) {
|
|
241
|
+
...CustomerFragment
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
fragment CustomerFragment on Customer {
|
|
246
|
+
id
|
|
247
|
+
email
|
|
248
|
+
phone
|
|
249
|
+
firstName
|
|
250
|
+
lastName
|
|
251
|
+
displayName
|
|
252
|
+
defaultAddress {
|
|
253
|
+
id
|
|
254
|
+
address1
|
|
255
|
+
address2
|
|
256
|
+
city
|
|
257
|
+
province
|
|
258
|
+
country
|
|
259
|
+
zip
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
`,{customerAccessToken:this.customerAccessToken})).customer||null}catch(e){return console.error(`Error fetching customer:`,e),null}}getPageContext(){return this.pageContext}setPageContext(e){e.product&&(e.product.id=_(String(e.product.id))),e.collection&&(e.collection.id=_(String(e.collection.id))),this.pageContext=e}getVisitorId(){return null}getMarket(){return this.market}getCurrencyRate(){return this.currency.rate}toProductData(e){return{id:_(e.id),handle:e.handle,title:e.title,available:e.availableForSale,requires_selling_plan:e.requiresSellingPlan,images:e.images.nodes.map(e=>e.url),variants:e.variants.nodes.map(e=>({id:_(e.id),title:e.title,available:e.availableForSale,price:Math.round(parseFloat(e.price.amount)*100),compare_at_price:e.compareAtPrice?Math.round(parseFloat(e.compareAtPrice.amount)*100):null,featured_image:e.image?{src:e.image.url}:null,selling_plan_allocations:e.sellingPlanAllocations?.edges?.map(e=>({selling_plan_id:e.node.sellingPlan.id}))||[]}))}}},T=class{constructor(e){this.storefrontAccessToken=e.storefrontAccessToken,this.shopDomain=e.shopDomain,this.apiVersion=e.apiVersion||`2024-01`,this.endpoint=`https://${this.shopDomain}/api/${this.apiVersion}/graphql.json`}async query(e,t){try{let n=await fetch(this.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:t})});if(!n.ok)throw Error(`Storefront API request failed: ${n.statusText}`);let r=await n.json();if(r.errors)throw Error(`GraphQL errors: ${JSON.stringify(r.errors)}`);return r.data}catch(e){throw console.error(`Storefront API error:`,e),e}}async mutate(e,t){return this.query(e,t)}};const E=t(null);function D({websiteApiKey:t,storefrontAccessToken:n,shopDomain:r,locale:l,currency:u,market:d,apiVersion:f,scriptBaseUrl:p,methods:m,children:h,customerAccessToken:g}){let _=s().find(e=>e.id===`root`)?.loaderData?.cart,v=c(),b=a(()=>new T({storefrontAccessToken:n,shopDomain:r,apiVersion:f}),[n,r,f]),x=a(()=>{let e=new w({locale:l,currency:u,market:d,methods:m},b);return g&&e.setCustomerAccessToken(g),e},[]),S=a(()=>new y(_,b,v.revalidate),[]),C=o(null);i(()=>{_.then(e=>{e&&e!==C.current&&(S.updateCartData(e),S.notifyListeners(),C.current=e)})},[_,S]);let D=o([]),O=o([]);i(()=>{if(typeof window>`u`)return;window.__PLY_HYDROGEN_CONFIG__={cart:S,adapter:x,onCartAdd:e=>(D.current.push(e),()=>{let t=D.current.indexOf(e);t>-1&&D.current.splice(t,1)}),onCheckout:e=>(O.current.push(e),()=>{let t=O.current.indexOf(e);t>-1&&O.current.splice(t,1)})};let e=document.createElement(`script`);return e.src=`${p||`https://static.personizely.net`}/${t}.js`,document.head.appendChild(e),()=>{delete window.__PLY_HYDROGEN_CONFIG__,e&&e.remove()}},[]);let k=a(()=>({cart:S,adapter:x,websiteApiKey:t,triggerCartAdd:async e=>{let t=!1;for(let n of D.current)try{await n(e)&&(t=!0)}catch(e){console.error(`Cart add callback error:`,e)}return t},triggerCheckout:async()=>{let e=!1;for(let t of O.current)try{await t()&&(e=!0)}catch(e){console.error(`Checkout callback error:`,e)}return e}}),[S,x,t]);return e.createElement(E.Provider,{value:k},h)}function O(){let e=r(E);if(!e)throw Error(`usePersonizely must be used within a PersonizelyProvider. Make sure your component is wrapped with <PersonizelyProvider>.`);return e}function k(){let e=O();return n(async t=>typeof window>`u`?!1:await e.triggerCartAdd({...t,id:_(String(t.id)),variantId:_(String(t.variantId)),price:Number(t.price)*100}),[e])}function A(){let e=O();return n(async()=>typeof window>`u`?!1:await e.triggerCheckout(),[e])}function j(e){O().adapter.setPageContext(e)}export{w as Adapter,y as Cart,D as PersonizelyProvider,k as useCartAdd,A as useCheckout,j as usePageContext,O as usePersonizely};
|
|
264
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["result: any","linesToUpdate: any[]","linesToAdd: any[]","line","mutations: Promise<any>[]"],"sources":["../src/utils/cookies.ts","../src/graphql/queries/cart.ts","../src/utils/id.ts","../src/classes/Cart.ts","../src/graphql/queries/product.ts","../src/graphql/queries/customer.ts","../src/classes/Adapter.ts","../src/utils/storefront-client.ts","../src/components/PersonizelyProvider.tsx","../src/hooks/usePersonizely.ts","../src/hooks/useCartAdd.ts","../src/hooks/useCheckout.ts","../src/hooks/usePageContext.ts"],"sourcesContent":["/**\n * Cookie utilities for browser storage\n * Mirrors cookie helpers from snippet-manager\n */\n\n/**\n * Read a cookie value by name\n * @param name - Cookie name\n * @returns Cookie value or null if not found\n */\nexport function readCookie (name: string): string | null {\n if (typeof document === 'undefined') {\n return null\n }\n\n const nameEQ = name + '='\n const cookies = document.cookie.split(';')\n\n for (let i = 0; i < cookies.length; i++) {\n let cookie = cookies[i]\n while (cookie.charAt(0) === ' ') {\n cookie = cookie.substring(1, cookie.length)\n }\n if (cookie.indexOf(nameEQ) === 0) {\n return cookie.substring(nameEQ.length, cookie.length)\n }\n }\n\n return null\n}\n\n/**\n * Create/update a cookie\n * @param name - Cookie name\n * @param value - Cookie value\n * @param days - Expiration in days (optional, default: session cookie)\n * @param path - Cookie path (default: '/')\n */\nexport function createCookie (name: string,\n value: string,\n days?: number,\n path: string = '/'): void {\n if (typeof document === 'undefined') {\n return\n }\n\n let expires = ''\n if (days) {\n const date = new Date()\n date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000))\n expires = '; expires=' + date.toUTCString()\n }\n\n document.cookie = name + '=' + value + expires + '; path=' + path\n}\n\n/**\n * Delete a cookie by name\n * @param name - Cookie name\n * @param path - Cookie path (default: '/')\n */\nexport function deleteCookie (name: string, path: string = '/'): void {\n createCookie(name, '', -1, path)\n}\n","/**\n * GraphQL queries and mutations for cart operations\n */\n\nexport const CART_FRAGMENT = `\n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n nodes {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n amountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n selectedOptions {\n name\n value\n }\n product {\n id\n handle\n title\n featuredImage {\n url\n altText\n }\n tags\n }\n }\n }\n attributes {\n key\n value\n }\n }\n }\n discountCodes {\n code\n applicable\n }\n attributes {\n key\n value\n }\n }\n`\n\nexport const GET_CART = `\n query getCart($cartId: ID!) {\n cart(id: $cartId) {\n ...CartFragment\n }\n }\n ${CART_FRAGMENT}\n`\n\n/**\n * Cart mutations\n */\n\nexport const CART_LINES_ADD = `\n mutation cartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_LINES_UPDATE = `\n mutation cartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_LINES_REMOVE = `\n mutation cartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_DISCOUNT_CODES_UPDATE = `\n mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n","export function toGId (id: number, type: string): string {\n return `gid://shopify/${type}/${id}`\n}\n\nexport function toId (id: string): number {\n return Number(id.split('/').pop())\n}","import type { CartData, ICart } from '../types'\nimport { createCookie, readCookie } from '../utils/cookies'\nimport type { CartReturn } from '@shopify/hydrogen'\nimport { StorefrontClient } from '../utils/storefront-client'\nimport {\n CART_LINES_ADD,\n CART_LINES_UPDATE,\n CART_LINES_REMOVE,\n CART_DISCOUNT_CODES_UPDATE\n} from '../graphql/queries/cart'\nimport { toGId, toId } from '../utils/id'\n\nconst COUPON_COOKIE_NAME = '_ply_coupon'\n\nexport class Cart implements ICart {\n private storefrontClient: StorefrontClient\n\n private listeners: Array<(cart: CartData) => void> = []\n\n private cart: CartReturn | null = null\n\n private cartPromise: Promise<CartReturn> | null\n\n private revalidate?: () => void\n\n constructor (cartPromise: Promise<CartReturn>, storefrontClient: StorefrontClient, revalidate?: () => void) {\n this.storefrontClient = storefrontClient\n this.cartPromise = cartPromise\n this.revalidate = revalidate\n }\n\n /**\n * Update internal cart data\n * Called by Provider when cart data changes from loader\n */\n updateCartData (cart: CartReturn): void {\n this.cart = cart\n this.cartPromise = null\n }\n\n /**\n * Notify all listeners of cart change\n * Called by Provider when cart updates\n */\n notifyListeners (): void {\n if (!this.cart) return\n\n this.listeners.forEach((listener) => {\n try {\n if (this.cart) {\n listener(this.toCartData(this.cart))\n }\n } catch (error) {\n console.error('Cart listener error:', error)\n }\n })\n }\n\n /**\n * Check if cart data is loaded and synced\n */\n isSynced (): boolean {\n return !!this.cart\n }\n\n /**\n * Register a callback to be called when cart changes\n * Returns a function to unregister the callback\n */\n onChange (callback: (cart: CartData) => void): () => void {\n this.listeners.push(callback)\n\n // Return unsubscribe function\n return () => {\n const index = this.listeners.indexOf(callback)\n if (index > -1) {\n this.listeners.splice(index, 1)\n }\n }\n }\n\n /**\n * Fetch current cart data\n * Returns cached cart data from loader (always fresh from React Router)\n */\n async fetch (force: boolean = true): Promise<CartData | null> {\n if (this.cart && !force) {\n return this.toCartData(this.cart)\n }\n\n if (this.cartPromise) {\n this.cart = await this.cartPromise\n return this.toCartData(this.cart)\n }\n\n if (!this.cart) return null\n\n return this.toCartData(this.cart)\n }\n\n /**\n * Update cart via Storefront API mutations\n * Actions: 'add', 'update', 'change', 'clear'\n */\n async update (action: string, data: any): Promise<void> {\n if (!this.cart) {\n throw new Error('Cart not initialized')\n }\n\n const lineIds = this.cart.lines.nodes.map((line: any) => line.id)\n\n try {\n let result: any\n\n switch (action) {\n case 'add':\n result = await this.storefrontClient.mutate(CART_LINES_ADD, {\n cartId: this.cart.id,\n lines: [{\n merchandiseId: toGId(data.id, 'ProductVariant'),\n quantity: data.quantity || 1,\n attributes: data.properties\n ? Object.entries(data.properties).map(([key, value]) => ({\n key,\n value: String(value)\n }))\n : undefined\n }]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesAdd?.cart) {\n this.cart = result.cartLinesAdd.cart\n this.notifyListeners()\n }\n break\n\n case 'update':\n case 'change':\n // Handle Cart AJAX API format: { updates: { [variantId]: quantity } }\n if (data.updates) {\n // Separate into lines to update vs lines to add\n const linesToUpdate: any[] = []\n const linesToAdd: any[] = []\n\n Object.entries(data.updates).forEach(([variantId, quantity]) => {\n const line = this.cart!.lines.nodes.find((line: any) =>\n toId(line.merchandise.id) === Number(variantId))\n\n if (line) {\n linesToUpdate.push({\n id: line.id,\n quantity: Number(quantity)\n })\n } else if (Number(quantity) > 0) {\n // Line doesn't exist and quantity > 0 - add it\n linesToAdd.push({\n merchandiseId: toGId(Number(variantId), 'ProductVariant'),\n quantity: Number(quantity)\n })\n }\n })\n\n // Execute mutations in parallel\n const mutations: Promise<any>[] = []\n\n if (linesToUpdate.length > 0) {\n mutations.push(this.storefrontClient.mutate(CART_LINES_UPDATE, {\n cartId: this.cart.id,\n lines: linesToUpdate\n }))\n }\n\n if (linesToAdd.length > 0) {\n mutations.push(this.storefrontClient.mutate(CART_LINES_ADD, {\n cartId: this.cart.id,\n lines: linesToAdd\n }))\n }\n\n if (mutations.length > 0) {\n const results = await Promise.all(mutations)\n // Use the last result's cart (both mutations return the updated cart)\n const lastResult = results[results.length - 1]\n if (lastResult?.cartLinesUpdate?.cart || lastResult?.cartLinesAdd?.cart) {\n this.cart = lastResult.cartLinesUpdate?.cart || lastResult.cartLinesAdd?.cart\n this.notifyListeners()\n }\n }\n } else {\n // Handle single item update (old format)\n result = await this.storefrontClient.mutate(CART_LINES_UPDATE, {\n cartId: this.cart.id,\n lines: [{\n id: `gid://shopify/CartLine/${data.id}`,\n quantity: data.quantity\n }]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesUpdate?.cart) {\n this.cart = result.cartLinesUpdate.cart\n this.notifyListeners()\n }\n }\n\n // Handle discount update\n if (data.discount && this.cart) {\n result = await this.storefrontClient.mutate(CART_DISCOUNT_CODES_UPDATE, {\n cartId: this.cart.id,\n discountCodes: [data.discount]\n })\n\n // Update local cart immediately\n if (result?.cartDiscountCodesUpdate?.cart) {\n this.cart = result.cartDiscountCodesUpdate.cart\n this.notifyListeners()\n }\n }\n break\n\n case 'clear':\n result = await this.storefrontClient.mutate(CART_LINES_REMOVE, {\n cartId: this.cart.id,\n lineIds\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesRemove?.cart) {\n this.cart = result.cartLinesRemove.cart\n this.notifyListeners()\n }\n break\n\n default:\n console.warn(`Unknown cart action: ${action}`)\n }\n\n // Trigger revalidation to fetch fresh cart data from loader\n if (this.revalidate) {\n this.revalidate()\n }\n } catch (error) {\n console.error('Cart update error:', error)\n throw error\n }\n }\n\n /**\n * Quick buy - redirect to checkout with variant\n */\n async buy (_variantId: string, _quantity: number = 1): Promise<void> {\n if (!this.cart) return\n\n const coupon = this.getCoupon()\n const baseUrl = this.cart.checkoutUrl || '/checkout'\n const url = coupon ? `${baseUrl}?discount=${coupon}` : baseUrl\n\n if (typeof window !== 'undefined') {\n window.location.href = url\n }\n }\n\n /**\n * Get cart data or specific property\n */\n get (property?: string): any {\n if (!this.cart) {\n return property ? undefined : null\n }\n\n if (!property) {\n return this.toCartData(this.cart)\n }\n\n return (this.toCartData(this.cart) as any)[property]\n }\n\n /**\n * Get cart token/ID\n */\n getToken (): string | null {\n if (!this.cart) return null\n\n return this.cart.id || null\n }\n\n /**\n * Get array of product IDs in cart\n */\n getItemsIds (): string[] {\n if (!this.cart) {\n return []\n }\n\n return this.cart.lines.nodes.map(line => line.merchandise.product.id)\n }\n\n /**\n * Get cart currency code\n */\n getCurrency (): string {\n if (!this.cart) return 'USD'\n\n return this.cart.cost.totalAmount.currencyCode\n }\n\n /**\n * Get cart total value\n * For Hydrogen, currency conversion would need to be handled separately\n */\n getValue (_currency?: string): number {\n if (!this.cart) return 0\n\n return parseFloat(this.cart.cost.totalAmount.amount) * 100\n }\n\n /**\n * Get cart item count\n * @param distinct - Count distinct products instead of total quantity\n */\n getSize (distinct: boolean = false): number {\n if (!this.cart) return 0\n\n if (distinct) {\n const uniqueProductIds = new Set(this.cart.lines.nodes.map(line => line.merchandise.product.id))\n return uniqueProductIds.size\n }\n\n return this.cart.totalQuantity\n }\n\n /**\n * Fetch cart collections data\n * Requires custom implementation or metafield query\n */\n async fetchCollections (_force: boolean = false): Promise<any> {\n console.warn('fetchCollections: Not implemented for Hydrogen. Use custom metafield query.')\n return {}\n }\n\n /**\n * Apply discount code to cart\n */\n async applyCoupon (code: string, expiresIn?: number): Promise<void> {\n if (!this.cart) {\n throw new Error('Cart not initialized')\n }\n\n // Store in cookie\n createCookie(COUPON_COOKIE_NAME, code, expiresIn)\n\n try {\n const result = await this.storefrontClient.mutate(CART_DISCOUNT_CODES_UPDATE, {\n cartId: this.cart.id,\n discountCodes: [code]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartDiscountCodesUpdate?.cart) {\n this.cart = result.cartDiscountCodesUpdate.cart\n this.notifyListeners()\n }\n\n // Trigger revalidation to fetch fresh cart data from loader (backup)\n if (this.revalidate) {\n this.revalidate()\n }\n } catch (error) {\n console.error('Error applying coupon:', error)\n throw error\n }\n }\n\n /**\n * Get currently applied coupon code\n */\n getCoupon (): string | null {\n if (!this.cart) return null\n\n // First check cart discount codes\n if (this.cart.discountCodes && this.cart.discountCodes.length > 0) {\n return this.cart.discountCodes[0].code\n }\n\n // Fall back to cookie\n return readCookie(COUPON_COOKIE_NAME)\n }\n\n /**\n * Convert Hydrogen cart to CartData format\n * For compatibility with snippet-manager\n */\n private toCartData (cart: CartReturn): CartData {\n return {\n token: cart.id,\n item_count: cart.totalQuantity || 0,\n items: (cart.lines?.nodes || []).map(line => ({\n id: toId(line.id),\n product_id: toId(line.merchandise.product.id),\n variant_id: toId(line.merchandise.id),\n price: Number(line.merchandise.price.amount) * 100,\n quantity: line.quantity\n })),\n total_price: Number(cart.cost.totalAmount.amount) * 100,\n discount_codes: cart.discountCodes,\n attributes: cart.attributes,\n note: cart.note\n }\n }\n}\n","/**\n * GraphQL queries for product operations\n */\n\nexport const PRODUCT_FRAGMENT = `\n fragment ProductFragment on Product {\n id\n handle\n title\n description\n descriptionHtml\n productType\n vendor\n tags\n availableForSale\n requiresSellingPlan\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n id\n url\n altText\n width\n height\n }\n images(first: 10) {\n nodes {\n id\n url\n altText\n width\n height\n }\n }\n variants(first: 100) {\n nodes {\n id\n title\n availableForSale\n quantityAvailable\n sellingPlanAllocations(first: 10) {\n edges {\n node {\n sellingPlan {\n id\n }\n }\n }\n }\n sku\n price {\n amount\n currencyCode\n }\n compareAtPrice {\n amount\n currencyCode\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url\n altText\n width\n height\n }\n }\n }\n options {\n id\n name\n values\n }\n collections(first: 10) {\n nodes {\n id\n handle\n title\n }\n }\n }\n`\n\nexport const GET_PRODUCT_BY_HANDLE = `\n query getProductByHandle($handle: String!) {\n product(handle: $handle) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n\nexport const GET_PRODUCT_BY_ID = `\n query getProductById($id: ID!) {\n product(id: $id) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n\nexport const GET_PRODUCT_RECOMMENDATIONS = `\n query getProductRecommendations($productId: ID!) {\n productRecommendations(productId: $productId) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n","/**\n * GraphQL queries for customer operations\n */\n\nexport const CUSTOMER_FRAGMENT = `\n fragment CustomerFragment on Customer {\n id\n email\n phone\n firstName\n lastName\n displayName\n defaultAddress {\n id\n address1\n address2\n city\n province\n country\n zip\n }\n }\n`\n\nexport const ORDER_FRAGMENT = `\n fragment OrderFragment on Order {\n id\n orderNumber\n processedAt\n financialStatus\n fulfillmentStatus\n totalPrice {\n amount\n currencyCode\n }\n lineItems(first: 100) {\n nodes {\n title\n quantity\n variant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n }\n }\n }\n }\n`\n\nexport const GET_CUSTOMER = `\n query getCustomer($customerAccessToken: String!) {\n customer(customerAccessToken: $customerAccessToken) {\n ...CustomerFragment\n }\n }\n ${CUSTOMER_FRAGMENT}\n`\n\nexport const GET_CUSTOMER_ORDERS = `\n query getCustomerOrders($customerAccessToken: String!, $first: Int = 20) {\n customer(customerAccessToken: $customerAccessToken) {\n id\n orders(first: $first, sortKey: PROCESSED_AT, reverse: true) {\n nodes {\n ...OrderFragment\n }\n }\n }\n }\n ${ORDER_FRAGMENT}\n`\n","import type {\n IShopifyAdapter,\n Product,\n Customer,\n PageContext,\n PersonizelyConfig,\n PersonizelyConfigMethods,\n ProductData\n} from '../types'\nimport { StorefrontClient } from '../utils/storefront-client'\nimport {\n GET_PRODUCT_BY_HANDLE, GET_PRODUCT_BY_ID,\n GET_PRODUCT_RECOMMENDATIONS\n} from '../graphql/queries/product'\nimport { GET_CUSTOMER } from '../graphql/queries/customer'\nimport { toId } from '../utils/id'\n\nexport class Adapter implements IShopifyAdapter {\n private client: StorefrontClient\n\n private currency: {\n active: string\n base: string\n rate: number\n }\n\n private market: string | null\n\n private locale: string\n\n private pageContext: PageContext\n\n private methods?: PersonizelyConfigMethods\n\n private customerAccessToken: string | null = null\n\n constructor (config: PersonizelyConfig, storefrontClient: StorefrontClient) {\n this.client = storefrontClient\n\n this.methods = config.methods\n this.currency = { active: 'USD', base: 'USD', rate: 1, ...config.currency }\n this.locale = config.locale || 'en-US'\n this.market = config.market || null\n\n this.pageContext = {\n pageType: undefined,\n product: null,\n collection: null\n }\n }\n\n /**\n * Set customer access token for authenticated requests\n */\n setCustomerAccessToken (token: string | null): void {\n this.customerAccessToken = token\n }\n\n /**\n * Fetch product by handle from Storefront API\n */\n async fetchProduct (handle: string): Promise<ProductData> {\n const data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_HANDLE, { handle })\n\n if (!data.product) {\n throw new Error(`Product not found: ${handle}`)\n }\n\n return this.toProductData(data.product)\n }\n\n /**\n * Fetch product collections metadata\n */\n async fetchProductCollections (handle: string, productId: number): Promise<number[]> {\n let data\n if (productId) {\n data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_ID, { id: `gid://shopify/Product/${productId}` })\n } else if (handle) {\n data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_HANDLE, { handle })\n }\n\n if (!data || !data.product) {\n throw new Error(`Product not found: ${productId}`)\n }\n\n return data.product.collections.nodes.map(c => toId(c.id))\n }\n\n /**\n * Fetch product recommendations\n */\n async fetchRecommendations (productId: number, intent: string): Promise<{ products: ProductData[], intent: string }> {\n const data = await this.client.query<{ productRecommendations: Product[] }>(GET_PRODUCT_RECOMMENDATIONS, { productId: `gid://shopify/Product/${productId}`, intent })\n\n return {\n intent,\n products: data.productRecommendations.map(p => this.toProductData(p)) || []\n }\n }\n\n /**\n * Build product URL path\n */\n buildProductPath (product: { handle: string }): string {\n if (typeof this.methods?.builtProductPath !== 'function') return `/products/${product.handle}`\n\n return this.methods.builtProductPath(product)\n }\n\n /**\n * Convert currency amount\n */\n convertToBaseCurrency (amount: number): number {\n return this.currency.rate / amount\n }\n\n /**\n * Convert currency amount\n */\n convertFromBaseCurrency (amount: number): number {\n return this.currency.rate * amount\n }\n\n /**\n * Format money according to shop's format\n */\n formatMoney (amount: number, includeDecimals: boolean = true): string {\n if (typeof this.methods?.formatMoney !== 'function') return new Intl.NumberFormat(this.locale, {\n style: 'currency',\n currency: this.currency.active,\n maximumFractionDigits: includeDecimals ? undefined : 0\n }).format(amount / 100)\n\n return this.methods.formatMoney(amount, includeDecimals)\n }\n\n /**\n * Fetch customer data from Storefront API\n * Requires customer access token to be set\n */\n async getCustomer (): Promise<Customer | null> {\n if (!this.customerAccessToken) {\n return null\n }\n\n try {\n const data = await this.client.query<{ customer: Customer }>(GET_CUSTOMER, { customerAccessToken: this.customerAccessToken })\n\n return data.customer || null\n } catch (error) {\n console.error('Error fetching customer:', error)\n return null\n }\n }\n\n /**\n * Get current page context\n * Auto-detected from Remix router in Provider\n */\n getPageContext (): PageContext {\n return this.pageContext\n }\n\n setPageContext (context: Partial<PageContext>) {\n if (context.product) {\n context.product.id = toId(String(context.product.id))\n }\n if (context.collection) {\n context.collection.id = toId(String(context.collection.id))\n }\n this.pageContext = context\n }\n\n getVisitorId (): string | null {\n return null\n }\n\n /**\n * Get current market information\n */\n getMarket (): string | null {\n return this.market\n }\n\n /**\n * Get currency conversion rate\n * Note: Stub implementation\n */\n getCurrencyRate (): number {\n return this.currency.rate\n }\n\n /**\n * Transform Hydrogen Product to snippet-manager ProductData format\n */\n toProductData (product: Product): ProductData {\n return {\n id: toId(product.id),\n handle: product.handle,\n title: product.title,\n available: product.availableForSale,\n requires_selling_plan: product.requiresSellingPlan,\n images: product.images.nodes.map(img => img.url),\n variants: product.variants.nodes.map(variant => ({\n id: toId(variant.id),\n title: variant.title,\n available: variant.availableForSale,\n price: Math.round(parseFloat(variant.price.amount) * 100), // Convert to cents\n compare_at_price: variant.compareAtPrice\n ? Math.round(parseFloat(variant.compareAtPrice.amount) * 100)\n : null,\n featured_image: variant.image ? { src: variant.image.url } : null,\n selling_plan_allocations: variant.sellingPlanAllocations?.edges?.map(edge => ({\n selling_plan_id: edge.node.sellingPlan.id\n })) || []\n }))\n }\n }\n}\n","/**\n * Shopify Storefront API GraphQL client\n */\n\nexport type StorefrontClientConfig = {\n storefrontAccessToken: string\n shopDomain: string\n apiVersion?: string\n}\n\nexport class StorefrontClient {\n private storefrontAccessToken: string\n\n private shopDomain: string\n\n private apiVersion: string\n\n private endpoint: string\n\n constructor (config: StorefrontClientConfig) {\n this.storefrontAccessToken = config.storefrontAccessToken\n this.shopDomain = config.shopDomain\n this.apiVersion = config.apiVersion || '2024-01'\n this.endpoint = `https://${this.shopDomain}/api/${this.apiVersion}/graphql.json`\n }\n\n /**\n * Execute a GraphQL query against the Storefront API\n */\n async query<T = any>(query: string, variables?: Record<string, any>): Promise<T> {\n try {\n const response = await fetch(this.endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Shopify-Storefront-Access-Token': this.storefrontAccessToken\n },\n body: JSON.stringify({\n query,\n variables\n })\n })\n\n if (!response.ok) {\n throw new Error(`Storefront API request failed: ${response.statusText}`)\n }\n\n const result = await response.json()\n\n if (result.errors) {\n throw new Error(`GraphQL errors: ${JSON.stringify(result.errors)}`)\n }\n\n return result.data as T\n } catch (error) {\n console.error('Storefront API error:', error)\n throw error\n }\n }\n\n /**\n * Execute a GraphQL mutation against the Storefront API\n */\n async mutate<T = any>(mutation: string, variables?: Record<string, any>): Promise<T> {\n return this.query<T>(mutation, variables)\n }\n}\n","import React, { createContext, useEffect, useMemo, useRef, ReactNode } from 'react'\nimport { useMatches, useRevalidator } from 'react-router'\nimport {\n PersonizelyConfigMethods,\n HydrogenConfig,\n CartAddProduct\n} from '../types'\nimport type { CartReturn } from '@shopify/hydrogen'\nimport { Cart } from '../classes/Cart'\nimport { Adapter } from '../classes/Adapter'\nimport { StorefrontClient } from '../utils/storefront-client'\n\ndeclare global {\n interface Window {\n __PLY_HYDROGEN_CONFIG__?: HydrogenConfig\n }\n}\n\nexport type PersonizelyContextType = {\n cart: Cart\n adapter: Adapter\n websiteApiKey: string\n triggerCartAdd: (product: CartAddProduct) => Promise<boolean>\n triggerCheckout: () => Promise<boolean>\n}\n\nexport const PersonizelyContext = createContext<PersonizelyContextType | null>(null)\n\nexport type PersonizelyProviderProps = {\n websiteApiKey: string\n storefrontAccessToken: string\n shopDomain: string\n apiVersion?: string\n scriptBaseUrl?: string\n locale?: string\n currency?: {\n rate: number\n active: string\n base: string\n }\n market?: string\n methods?: PersonizelyConfigMethods\n children: ReactNode\n /**\n * Optional: Customer access token for authenticated requests\n */\n customerAccessToken?: string | null\n}\n\nexport function PersonizelyProvider ({\n websiteApiKey,\n storefrontAccessToken,\n shopDomain,\n locale,\n currency,\n market,\n apiVersion,\n scriptBaseUrl,\n methods,\n children,\n customerAccessToken\n}: PersonizelyProviderProps) {\n const matches = useMatches()\n const rootMatch = matches.find(m => m.id === 'root')\n const localCart = (rootMatch?.loaderData as any)?.cart as Promise<CartReturn>\n const revalidator = useRevalidator()\n\n const storefrontClient = useMemo(() => {\n return new StorefrontClient({\n storefrontAccessToken,\n shopDomain,\n apiVersion\n })\n }, [storefrontAccessToken, shopDomain, apiVersion])\n\n const adapter = useMemo(() => {\n const adapterInstance = new Adapter({\n locale,\n currency,\n market,\n methods\n }, storefrontClient)\n\n if (customerAccessToken) {\n adapterInstance.setCustomerAccessToken(customerAccessToken)\n }\n\n return adapterInstance\n }, [])\n\n const cart = useMemo(() => new Cart(localCart, storefrontClient, revalidator.revalidate), [])\n\n // Update cart data when it changes from the loader\n const prevCartDataRef = useRef<CartReturn | null>(null)\n useEffect(() => {\n localCart.then((data) => {\n if (data && data !== prevCartDataRef.current) {\n cart.updateCartData(data)\n cart.notifyListeners()\n prevCartDataRef.current = data\n }\n })\n }, [localCart, cart])\n\n const cartAddCallbacksRef = useRef<Array<(product: CartAddProduct) => Promise<boolean>>>([])\n const checkoutCallbacksRef = useRef<Array<() => Promise<boolean>>>([])\n\n // Set up window.__PLY_HYDROGEN_CONFIG__ and load Personizely script\n useEffect(() => {\n if (typeof window === 'undefined') {\n return\n }\n\n window.__PLY_HYDROGEN_CONFIG__ = {\n cart,\n adapter,\n onCartAdd: (callback) => {\n cartAddCallbacksRef.current.push(callback)\n\n return () => {\n const index = cartAddCallbacksRef.current.indexOf(callback)\n if (index > -1) {\n cartAddCallbacksRef.current.splice(index, 1)\n }\n }\n },\n onCheckout: (callback) => {\n checkoutCallbacksRef.current.push(callback)\n\n return () => {\n const index = checkoutCallbacksRef.current.indexOf(callback)\n if (index > -1) {\n checkoutCallbacksRef.current.splice(index, 1)\n }\n }\n }\n }\n\n const script = document.createElement('script')\n const baseUrl = scriptBaseUrl || 'https://static.personizely.net'\n script.src = `${baseUrl}/${websiteApiKey}.js`\n document.head.appendChild(script)\n\n return () => {\n delete window.__PLY_HYDROGEN_CONFIG__\n if (script) {\n script.remove()\n }\n }\n }, [])\n\n const contextValue = useMemo(() => ({\n cart,\n adapter,\n websiteApiKey,\n triggerCartAdd: async (product: CartAddProduct): Promise<boolean> => {\n let shown = false\n for (const callback of cartAddCallbacksRef.current) {\n try {\n const result = await callback(product)\n if (result) {\n shown = true\n }\n } catch (error) {\n console.error('Cart add callback error:', error)\n }\n }\n return shown\n },\n triggerCheckout: async (): Promise<boolean> => {\n let shown = false\n for (const callback of checkoutCallbacksRef.current) {\n try {\n const result = await callback()\n if (result) {\n shown = true\n }\n } catch (error) {\n console.error('Checkout callback error:', error)\n }\n }\n return shown\n }\n }), [cart, adapter, websiteApiKey])\n\n return (\n <PersonizelyContext.Provider value={contextValue}>\n {children}\n </PersonizelyContext.Provider>\n )\n}\n","/**\n * usePersonizely - Access Personizely context\n */\n\nimport { useContext } from 'react'\nimport { PersonizelyContext, PersonizelyContextType } from '../components/PersonizelyProvider'\n\n/**\n * Hook to access Personizely context\n * Provides access to cart, adapter, and configuration\n *\n * @returns PersonizelyContextType\n * @throws Error if used outside PersonizelyProvider\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { cart, adapter } = usePersonizely()\n * // Use cart and adapter...\n * }\n * ```\n */\nexport function usePersonizely (): PersonizelyContextType {\n const context = useContext(PersonizelyContext)\n\n if (!context) {\n throw new Error('usePersonizely must be used within a PersonizelyProvider. ' +\n 'Make sure your component is wrapped with <PersonizelyProvider>.')\n }\n\n return context\n}\n","/**\n * useCartAdd - Hook to trigger Personizely cart add widgets\n */\n\nimport { useCallback } from 'react'\nimport type { CartAddProduct } from '../types'\nimport { usePersonizely } from './usePersonizely'\nimport { toId } from '../utils/id'\n\n/**\n * Hook to trigger Personizely cart add event\n * Call this when a product is being added to cart to show relevant widgets\n *\n * @returns Function to trigger cart add event\n *\n * @example\n * ```tsx\n * function ProductForm({ product, selectedVariant }) {\n * const triggerCartAdd = useCartAdd()\n *\n * const handleAddToCart = async () => {\n * const widgetShown = await triggerCartAdd({\n * id: product.id,\n * variantId: selectedVariant.id,\n * price: parseFloat(selectedVariant.price.amount),\n * quantity: 1,\n * handle: product.handle\n * })\n *\n * if (!widgetShown) {\n * await cart.linesAdd([{\n * merchandiseId: selectedVariant.id,\n * quantity: 1\n * }])\n * }\n * }\n *\n * return <button onClick={handleAddToCart}>Add to Cart</button>\n * }\n * ```\n */\nexport function useCartAdd () {\n const personizely = usePersonizely()\n\n return useCallback(async (product: CartAddProduct): Promise<boolean> => {\n if (typeof window === 'undefined') {\n return false\n }\n\n return await personizely.triggerCartAdd({\n ...product,\n id: toId(String(product.id)),\n variantId: toId(String(product.variantId)),\n price: Number(product.price) * 100\n })\n }, [personizely])\n}\n","/**\n * useCheckout - Hook to trigger Personizely checkout widgets\n */\n\nimport { useCallback } from 'react'\nimport { usePersonizely } from './usePersonizely'\n\n/**\n * Hook to trigger Personizely checkout event\n * Call this when proceeding to checkout to show relevant widgets\n *\n * @returns Function to trigger checkout event\n *\n * @example\n * ```tsx\n * function CheckoutButton() {\n * const triggerCheckout = useCheckout()\n *\n * const handleCheckout = async () => {\n * const widgetShown = await triggerCheckout()\n *\n * if (!widgetShown) {\n * window.location.href = cart.checkoutUrl\n * }\n * }\n *\n * return <button onClick={handleCheckout}>Checkout</button>\n * }\n * ```\n */\nexport function useCheckout () {\n const personizely = usePersonizely()\n\n return useCallback(async (): Promise<boolean> => {\n if (typeof window === 'undefined') {\n return false\n }\n\n return await personizely.triggerCheckout()\n }, [personizely])\n}\n","import { usePersonizely } from './usePersonizely'\nimport { PageContext } from '../types'\n\nexport function usePageContext (context: Partial<PageContext>) {\n const personizely = usePersonizely()\n\n personizely.adapter.setPageContext(context)\n}\n"],"mappings":"gLAUA,SAAgB,EAAY,EAA6B,CACvD,GAAI,OAAO,SAAa,IACtB,OAAO,KAGT,IAAM,EAAS,EAAO,IAChB,EAAU,SAAS,OAAO,MAAM,IAAI,CAE1C,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAAK,CACvC,IAAI,EAAS,EAAQ,GACrB,KAAO,EAAO,OAAO,EAAE,GAAK,KAC1B,EAAS,EAAO,UAAU,EAAG,EAAO,OAAO,CAE7C,GAAI,EAAO,QAAQ,EAAO,GAAK,EAC7B,OAAO,EAAO,UAAU,EAAO,OAAQ,EAAO,OAAO,CAIzD,OAAO,KAUT,SAAgB,EAAc,EAC5B,EACA,EACA,EAAe,IAAW,CAC1B,GAAI,OAAO,SAAa,IACtB,OAGF,IAAI,EAAU,GACd,GAAI,EAAM,CACR,IAAM,EAAO,IAAI,KACjB,EAAK,QAAQ,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O,CACd,QAAQ,MAAM,2BAA4B,EAAM,CAGpD,OAAO,GAEV,EAAG,CAAC,EAAM,EAAS,EAAc,CAAC,CAEnC,OACE,EAAA,cAAC,EAAmB,SAAA,CAAS,MAAO,EAAA,CACjC,EAC2B,CCtKlC,SAAgB,GAA0C,CACxD,IAAM,EAAU,EAAW,EAAmB,CAE9C,GAAI,CAAC,EACH,MAAU,MAAM,4HACoD,CAGtE,OAAO,ECWT,SAAgB,GAAc,CAC5B,IAAM,EAAc,GAAgB,CAEpC,OAAO,EAAY,KAAO,IACpB,OAAO,OAAW,IACb,GAGF,MAAM,EAAY,eAAe,CACtC,GAAG,EACH,GAAI,EAAK,OAAO,EAAQ,GAAG,CAAC,CAC5B,UAAW,EAAK,OAAO,EAAQ,UAAU,CAAC,CAC1C,MAAO,OAAO,EAAQ,MAAM,CAAG,IAChC,CAAC,CACD,CAAC,EAAY,CAAC,CCzBnB,SAAgB,GAAe,CAC7B,IAAM,EAAc,GAAgB,CAEpC,OAAO,EAAY,SACb,OAAO,OAAW,IACb,GAGF,MAAM,EAAY,iBAAiB,CACzC,CAAC,EAAY,CAAC,CCpCnB,SAAgB,EAAgB,EAA+B,CACzC,GAAgB,CAExB,QAAQ,eAAe,EAAQ"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@personizely/shopify-hydrogen",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Personizely adapter for Shopify Hydrogen headless storefronts - Simple React Provider integration",
|
|
5
|
-
"main": "dist/index.
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
7
15
|
"publishConfig": { "access": "public" },
|
|
8
16
|
"type": "module",
|
|
9
17
|
"files": [
|
|
@@ -27,11 +35,11 @@
|
|
|
27
35
|
"url": "https://github.com/personizely/shopify-hydrogen.git"
|
|
28
36
|
},
|
|
29
37
|
"scripts": {
|
|
30
|
-
"build": "
|
|
38
|
+
"build": "tsdown",
|
|
31
39
|
"clean": "rm -rf dist",
|
|
32
40
|
"lint": "eslint src --ext .ts,.tsx",
|
|
33
41
|
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
34
|
-
"prepublishOnly": "npm run
|
|
42
|
+
"prepublishOnly": "npm run build",
|
|
35
43
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
36
44
|
},
|
|
37
45
|
"dependencies": {
|
|
@@ -51,6 +59,7 @@
|
|
|
51
59
|
"@typescript-eslint/eslint-plugin": "^8.20.0",
|
|
52
60
|
"@typescript-eslint/parser": "^8.20.0",
|
|
53
61
|
"eslint": "^9.18.0",
|
|
62
|
+
"tsdown": "^0.18.2",
|
|
54
63
|
"typescript": "^5.3.0"
|
|
55
64
|
}
|
|
56
65
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { IShopifyAdapter, Product, Customer, PageContext, PersonizelyConfig, ProductData } from '../types';
|
|
2
|
-
import { StorefrontClient } from '../utils/storefront-client';
|
|
3
|
-
export declare class Adapter implements IShopifyAdapter {
|
|
4
|
-
private client;
|
|
5
|
-
private currency;
|
|
6
|
-
private market;
|
|
7
|
-
private locale;
|
|
8
|
-
private pageContext;
|
|
9
|
-
private methods?;
|
|
10
|
-
private customerAccessToken;
|
|
11
|
-
constructor(config: PersonizelyConfig, storefrontClient: StorefrontClient);
|
|
12
|
-
setCustomerAccessToken(token: string | null): void;
|
|
13
|
-
fetchProduct(handle: string): Promise<ProductData>;
|
|
14
|
-
fetchProductCollections(handle: string, productId: number): Promise<number[]>;
|
|
15
|
-
fetchRecommendations(productId: number, intent: string): Promise<{
|
|
16
|
-
products: ProductData[];
|
|
17
|
-
intent: string;
|
|
18
|
-
}>;
|
|
19
|
-
buildProductPath(product: {
|
|
20
|
-
handle: string;
|
|
21
|
-
}): string;
|
|
22
|
-
convertToBaseCurrency(amount: number): number;
|
|
23
|
-
convertFromBaseCurrency(amount: number): number;
|
|
24
|
-
formatMoney(amount: number, includeDecimals?: boolean): string;
|
|
25
|
-
getCustomer(): Promise<Customer | null>;
|
|
26
|
-
getPageContext(): PageContext;
|
|
27
|
-
setPageContext(context: Partial<PageContext>): void;
|
|
28
|
-
getVisitorId(): string | null;
|
|
29
|
-
getMarket(): string | null;
|
|
30
|
-
getCurrencyRate(): number;
|
|
31
|
-
toProductData(product: Product): ProductData;
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=Adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Adapter.d.ts","sourceRoot":"","sources":["../../src/classes/Adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,OAAO,EACP,QAAQ,EACR,WAAW,EACX,iBAAiB,EAEjB,WAAW,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAQ7D,qBAAa,OAAQ,YAAW,eAAe;IAC7C,OAAO,CAAC,MAAM,CAAkB;IAEhC,OAAO,CAAC,QAAQ,CAIf;IAED,OAAO,CAAC,MAAM,CAAe;IAE7B,OAAO,CAAC,MAAM,CAAQ;IAEtB,OAAO,CAAC,WAAW,CAAa;IAEhC,OAAO,CAAC,OAAO,CAAC,CAA0B;IAE1C,OAAO,CAAC,mBAAmB,CAAsB;gBAEpC,MAAM,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB;IAkB1E,sBAAsB,CAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAO7C,YAAY,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAanD,uBAAuB,CAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAkB9E,oBAAoB,CAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAYpH,gBAAgB,CAAE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IAStD,qBAAqB,CAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAO9C,uBAAuB,CAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAOhD,WAAW,CAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAE,OAAc,GAAG,MAAM;IAc/D,WAAW,IAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAmB9C,cAAc,IAAK,WAAW;IAI9B,cAAc,CAAE,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC;IAU7C,YAAY,IAAK,MAAM,GAAG,IAAI;IAO9B,SAAS,IAAK,MAAM,GAAG,IAAI;IAQ3B,eAAe,IAAK,MAAM;IAO1B,aAAa,CAAE,OAAO,EAAE,OAAO,GAAG,WAAW;CAuB9C"}
|
package/dist/classes/Adapter.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { GET_PRODUCT_BY_HANDLE, GET_PRODUCT_BY_ID, GET_PRODUCT_RECOMMENDATIONS } from '../graphql/queries/product';
|
|
2
|
-
import { GET_CUSTOMER } from '../graphql/queries/customer';
|
|
3
|
-
import { toId } from '../utils/id';
|
|
4
|
-
export class Adapter {
|
|
5
|
-
constructor(config, storefrontClient) {
|
|
6
|
-
this.customerAccessToken = null;
|
|
7
|
-
this.client = storefrontClient;
|
|
8
|
-
this.methods = config.methods;
|
|
9
|
-
this.currency = { active: 'USD', base: 'USD', rate: 1, ...config.currency };
|
|
10
|
-
this.locale = config.locale || 'en-US';
|
|
11
|
-
this.market = config.market || null;
|
|
12
|
-
this.pageContext = {
|
|
13
|
-
pageType: undefined,
|
|
14
|
-
product: null,
|
|
15
|
-
collection: null
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
setCustomerAccessToken(token) {
|
|
19
|
-
this.customerAccessToken = token;
|
|
20
|
-
}
|
|
21
|
-
async fetchProduct(handle) {
|
|
22
|
-
const data = await this.client.query(GET_PRODUCT_BY_HANDLE, { handle });
|
|
23
|
-
if (!data.product) {
|
|
24
|
-
throw new Error(`Product not found: ${handle}`);
|
|
25
|
-
}
|
|
26
|
-
return this.toProductData(data.product);
|
|
27
|
-
}
|
|
28
|
-
async fetchProductCollections(handle, productId) {
|
|
29
|
-
let data;
|
|
30
|
-
if (productId) {
|
|
31
|
-
data = await this.client.query(GET_PRODUCT_BY_ID, { id: `gid://shopify/Product/${productId}` });
|
|
32
|
-
}
|
|
33
|
-
else if (handle) {
|
|
34
|
-
data = await this.client.query(GET_PRODUCT_BY_HANDLE, { handle });
|
|
35
|
-
}
|
|
36
|
-
if (!data || !data.product) {
|
|
37
|
-
throw new Error(`Product not found: ${productId}`);
|
|
38
|
-
}
|
|
39
|
-
return data.product.collections.nodes.map(c => toId(c.id));
|
|
40
|
-
}
|
|
41
|
-
async fetchRecommendations(productId, intent) {
|
|
42
|
-
const data = await this.client.query(GET_PRODUCT_RECOMMENDATIONS, { productId: `gid://shopify/Product/${productId}`, intent });
|
|
43
|
-
return {
|
|
44
|
-
intent,
|
|
45
|
-
products: data.productRecommendations.map(p => this.toProductData(p)) || []
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
buildProductPath(product) {
|
|
49
|
-
if (typeof this.methods?.builtProductPath !== 'function')
|
|
50
|
-
return `/products/${product.handle}`;
|
|
51
|
-
return this.methods.builtProductPath(product);
|
|
52
|
-
}
|
|
53
|
-
convertToBaseCurrency(amount) {
|
|
54
|
-
return this.currency.rate / amount;
|
|
55
|
-
}
|
|
56
|
-
convertFromBaseCurrency(amount) {
|
|
57
|
-
return this.currency.rate * amount;
|
|
58
|
-
}
|
|
59
|
-
formatMoney(amount, includeDecimals = true) {
|
|
60
|
-
if (typeof this.methods?.formatMoney !== 'function')
|
|
61
|
-
return new Intl.NumberFormat(this.locale, {
|
|
62
|
-
style: 'currency',
|
|
63
|
-
currency: this.currency.active,
|
|
64
|
-
maximumFractionDigits: includeDecimals ? undefined : 0
|
|
65
|
-
}).format(amount / 100);
|
|
66
|
-
return this.methods.formatMoney(amount, includeDecimals);
|
|
67
|
-
}
|
|
68
|
-
async getCustomer() {
|
|
69
|
-
if (!this.customerAccessToken) {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
try {
|
|
73
|
-
const data = await this.client.query(GET_CUSTOMER, { customerAccessToken: this.customerAccessToken });
|
|
74
|
-
return data.customer || null;
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
console.error('Error fetching customer:', error);
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
getPageContext() {
|
|
82
|
-
return this.pageContext;
|
|
83
|
-
}
|
|
84
|
-
setPageContext(context) {
|
|
85
|
-
if (context.product) {
|
|
86
|
-
context.product.id = toId(String(context.product.id));
|
|
87
|
-
}
|
|
88
|
-
if (context.collection) {
|
|
89
|
-
context.collection.id = toId(String(context.collection.id));
|
|
90
|
-
}
|
|
91
|
-
this.pageContext = context;
|
|
92
|
-
}
|
|
93
|
-
getVisitorId() {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
getMarket() {
|
|
97
|
-
return this.market;
|
|
98
|
-
}
|
|
99
|
-
getCurrencyRate() {
|
|
100
|
-
return this.currency.rate;
|
|
101
|
-
}
|
|
102
|
-
toProductData(product) {
|
|
103
|
-
return {
|
|
104
|
-
id: toId(product.id),
|
|
105
|
-
handle: product.handle,
|
|
106
|
-
title: product.title,
|
|
107
|
-
available: product.availableForSale,
|
|
108
|
-
requires_selling_plan: product.requiresSellingPlan,
|
|
109
|
-
images: product.images.nodes.map(img => img.url),
|
|
110
|
-
variants: product.variants.nodes.map(variant => ({
|
|
111
|
-
id: toId(variant.id),
|
|
112
|
-
title: variant.title,
|
|
113
|
-
available: variant.availableForSale,
|
|
114
|
-
price: Math.round(parseFloat(variant.price.amount) * 100),
|
|
115
|
-
compare_at_price: variant.compareAtPrice
|
|
116
|
-
? Math.round(parseFloat(variant.compareAtPrice.amount) * 100)
|
|
117
|
-
: null,
|
|
118
|
-
featured_image: variant.image ? { src: variant.image.url } : null,
|
|
119
|
-
selling_plan_allocations: variant.sellingPlanAllocations?.edges?.map(edge => ({
|
|
120
|
-
selling_plan_id: edge.node.sellingPlan.id
|
|
121
|
-
})) || []
|
|
122
|
-
}))
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
//# sourceMappingURL=Adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Adapter.js","sourceRoot":"","sources":["../../src/classes/Adapter.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,qBAAqB,EAAE,iBAAiB,EACxC,2BAA2B,EAC5B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC,MAAM,OAAO,OAAO;IAmBlB,YAAa,MAAyB,EAAE,gBAAkC;QAFlE,wBAAmB,GAAkB,IAAI,CAAA;QAG/C,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAA;QAE9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,QAAQ,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;QAC3E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM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