@shopify/shop-minis-react 0.5.0 → 0.6.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/dist/hooks/product/useProductReviews.js +18 -0
- package/dist/hooks/product/useProductReviews.js.map +1 -0
- package/dist/index.js +34 -34
- package/dist/mocks.js +74 -58
- package/dist/mocks.js.map +1 -1
- package/generated-hook-maps/hook-actions-map.json +3 -3
- package/package.json +2 -2
- package/src/hooks/index.ts +1 -1
- package/src/hooks/product/useProductReviews.ts +40 -0
- package/src/mocks.ts +30 -7
- package/src/test-utils.tsx +0 -1
- package/dist/hooks/product/useCuratedProducts.js +0 -18
- package/dist/hooks/product/useCuratedProducts.js.map +0 -1
- package/src/hooks/product/useCuratedProducts.ts +0 -39
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useShopActions as n } from "../../internal/useShopActions.js";
|
|
2
|
+
import { useShopActionInfiniteQuery as u } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
|
|
3
|
+
const d = (s) => {
|
|
4
|
+
const { getProductReviews: o } = n(), { id: e, skip: r = !1, ...t } = s, { data: i, ...c } = u(
|
|
5
|
+
["productReviews", e, t],
|
|
6
|
+
o,
|
|
7
|
+
{ id: e, ...t },
|
|
8
|
+
{ skip: r }
|
|
9
|
+
);
|
|
10
|
+
return {
|
|
11
|
+
...c,
|
|
12
|
+
reviews: i
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
d as useProductReviews
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useProductReviews.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProductReviews.js","sources":["../../../src/hooks/product/useProductReviews.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n ProductReview,\n} from '../../types'\n\nexport interface UseProductReviewsParams extends PaginatedDataHookOptionsBase {\n /**\n * The product ID to fetch reviews for.\n */\n id: string\n}\n\ninterface UseProductReviewsReturns extends PaginatedDataHookReturnsBase {\n /**\n * The product reviews returned from the query.\n */\n reviews: ProductReview[] | null\n}\n\nexport const useProductReviews = (\n params: UseProductReviewsParams\n): UseProductReviewsReturns => {\n const {getProductReviews} = useShopActions()\n const {id, skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['productReviews', id, restParams],\n getProductReviews,\n {id, ...restParams},\n {skip}\n )\n\n return {\n ...rest,\n reviews: data,\n }\n}\n"],"names":["useProductReviews","params","getProductReviews","useShopActions","id","skip","restParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAsBa,MAAAA,IAAoB,CAC/BC,MAC6B;AACvB,QAAA,EAAC,mBAAAC,EAAiB,IAAIC,EAAe,GACrC,EAAC,IAAAC,GAAI,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAL,GAEpC,EAAC,MAAAM,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,kBAAkBL,GAAIE,CAAU;AAAA,IACjCJ;AAAA,IACA,EAAC,IAAAE,GAAI,GAAGE,EAAU;AAAA,IAClB,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,SAASD;AAAA,EACX;AACF;"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { AddToCartButton as n } from "./components/commerce/add-to-cart.js";
|
|
|
4
4
|
import { BuyNowButton as s } from "./components/commerce/buy-now.js";
|
|
5
5
|
import { ProductCard as u, ProductCardBadge as f, ProductCardContainer as x, ProductCardFavoriteButton as c, ProductCardImage as d, ProductCardImageContainer as C, ProductCardInfo as g, ProductCardPrice as S, ProductCardReviewStars as A, ProductCardTitle as D } from "./components/commerce/product-card.js";
|
|
6
6
|
import { ProductLink as T } from "./components/commerce/product-link.js";
|
|
7
|
-
import { MerchantCard as I, MerchantCardContainer as R, MerchantCardHeader as
|
|
7
|
+
import { MerchantCard as I, MerchantCardContainer as R, MerchantCardHeader as v, MerchantCardInfo as w, MerchantCardName as B, MerchantCardRating as E } from "./components/commerce/merchant-card.js";
|
|
8
8
|
import { ProductCardSkeleton as F } from "./components/commerce/product-card-skeleton.js";
|
|
9
9
|
import { MerchantCardSkeleton as L } from "./components/commerce/merchant-card-skeleton.js";
|
|
10
10
|
import { QuantitySelector as N } from "./components/commerce/quantity-selector.js";
|
|
@@ -26,15 +26,15 @@ import { ContentWrapper as cr } from "./components/atoms/content-wrapper.js";
|
|
|
26
26
|
import { ProductVariantPrice as Cr } from "./components/atoms/product-variant-price.js";
|
|
27
27
|
import { Accordion as Sr, AccordionContent as Ar, AccordionItem as Dr, AccordionTrigger as Pr } from "./components/ui/accordion.js";
|
|
28
28
|
import { Alert as hr, AlertDescription as Ir, AlertTitle as Rr } from "./components/ui/alert.js";
|
|
29
|
-
import { AlertDialog as
|
|
29
|
+
import { AlertDialog as wr, AlertDialogAction as Br, AlertDialogCancel as Er, AlertDialogContent as Mr, AlertDialogDescription as Fr, AlertDialogFooter as Ur, AlertDialogHeader as Lr, AlertDialogOverlay as br, AlertDialogPortal as Nr, AlertDialogTitle as kr, AlertDialogTrigger as Or } from "./components/ui/alert-dialog.js";
|
|
30
30
|
import { Avatar as yr, AvatarFallback as Gr, AvatarImage as Hr } from "./components/ui/avatar.js";
|
|
31
31
|
import { Badge as zr, badgeVariants as Wr } from "./components/ui/badge.js";
|
|
32
32
|
import { Card as qr, CardAction as Kr, CardContent as Qr, CardDescription as Zr, CardFooter as jr, CardHeader as Jr, CardTitle as Xr } from "./components/ui/card.js";
|
|
33
33
|
import { Carousel as re, CarouselContent as ee, CarouselItem as oe, CarouselNext as te, CarouselPrevious as ae } from "./components/ui/carousel.js";
|
|
34
34
|
import { Checkbox as pe } from "./components/ui/checkbox.js";
|
|
35
35
|
import { Dialog as me, DialogClose as se, DialogContent as le, DialogDescription as ue, DialogFooter as fe, DialogHeader as xe, DialogOverlay as ce, DialogPortal as de, DialogTitle as Ce, DialogTrigger as ge } from "./components/ui/dialog.js";
|
|
36
|
-
import { Drawer as Ae, DrawerClose as De, DrawerContent as Pe, DrawerDescription as Te, DrawerFooter as he, DrawerHeader as Ie, DrawerOverlay as Re, DrawerPortal as
|
|
37
|
-
import { Input as
|
|
36
|
+
import { Drawer as Ae, DrawerClose as De, DrawerContent as Pe, DrawerDescription as Te, DrawerFooter as he, DrawerHeader as Ie, DrawerOverlay as Re, DrawerPortal as ve, DrawerTitle as we, DrawerTrigger as Be } from "./components/ui/drawer.js";
|
|
37
|
+
import { Input as Me } from "./components/ui/input.js";
|
|
38
38
|
import { Label as Ue } from "./components/ui/label.js";
|
|
39
39
|
import { Progress as be } from "./components/ui/progress.js";
|
|
40
40
|
import { RadioGroup as ke, RadioGroupItem as Oe } from "./components/ui/radio-group.js";
|
|
@@ -49,8 +49,8 @@ import { Skeleton as Ao } from "./components/ui/skeleton.js";
|
|
|
49
49
|
import { useRecentProducts as Po } from "./hooks/user/useRecentProducts.js";
|
|
50
50
|
import { useRecentShops as ho } from "./hooks/user/useRecentShops.js";
|
|
51
51
|
import { useSavedProducts as Ro } from "./hooks/user/useSavedProducts.js";
|
|
52
|
-
import { useSavedProductsActions as
|
|
53
|
-
import { useFollowedShops as
|
|
52
|
+
import { useSavedProductsActions as wo } from "./hooks/user/useSavedProductsActions.js";
|
|
53
|
+
import { useFollowedShops as Eo } from "./hooks/user/useFollowedShops.js";
|
|
54
54
|
import { useFollowedShopsActions as Fo } from "./hooks/user/useFollowedShopsActions.js";
|
|
55
55
|
import { useCurrentUser as Lo } from "./hooks/user/useCurrentUser.js";
|
|
56
56
|
import { useOrders as No } from "./hooks/user/useOrders.js";
|
|
@@ -63,10 +63,10 @@ import { useProduct as Ko } from "./hooks/product/useProduct.js";
|
|
|
63
63
|
import { useProducts as Zo } from "./hooks/product/useProducts.js";
|
|
64
64
|
import { useProductVariants as Jo } from "./hooks/product/useProductVariants.js";
|
|
65
65
|
import { useProductMedia as $o } from "./hooks/product/useProductMedia.js";
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
66
|
+
import { useProductReviews as et } from "./hooks/product/useProductReviews.js";
|
|
67
|
+
import { useProductSearch as tt } from "./hooks/product/useProductSearch.js";
|
|
68
|
+
import { useRecommendedProducts as it } from "./hooks/product/useRecommendedProducts.js";
|
|
69
|
+
import { usePopularProducts as nt } from "./hooks/product/usePopularProducts.js";
|
|
70
70
|
import { useAsyncStorage as st } from "./hooks/storage/useAsyncStorage.js";
|
|
71
71
|
import { useSecureStorage as ut } from "./hooks/storage/useSecureStorage.js";
|
|
72
72
|
import { useImageUpload as xt } from "./hooks/storage/useImageUpload.js";
|
|
@@ -76,8 +76,8 @@ import { useDeeplink as At } from "./hooks/navigation/useDeeplink.js";
|
|
|
76
76
|
import { useNavigateWithTransition as Pt } from "./hooks/navigation/useNavigateWithTransition.js";
|
|
77
77
|
import { useShop as ht } from "./hooks/shop/useShop.js";
|
|
78
78
|
import { useRecommendedShops as Rt } from "./hooks/shop/useRecommendedShops.js";
|
|
79
|
-
import { useCreateImageContent as
|
|
80
|
-
import { useErrorToast as
|
|
79
|
+
import { useCreateImageContent as wt } from "./hooks/content/useCreateImageContent.js";
|
|
80
|
+
import { useErrorToast as Et } from "./hooks/util/useErrorToast.js";
|
|
81
81
|
import { useErrorScreen as Ft } from "./hooks/util/useErrorScreen.js";
|
|
82
82
|
import { useShare as Lt } from "./hooks/util/useShare.js";
|
|
83
83
|
import { useImagePicker as Nt } from "./hooks/util/useImagePicker.js";
|
|
@@ -96,7 +96,7 @@ import { formatMoney as da } from "./utils/formatMoney.js";
|
|
|
96
96
|
import { UserState as ga, UserTokenGenerateUserErrorCode as Sa } from "./shop-minis-platform/src/types/user.js";
|
|
97
97
|
import { ContentCreateUserErrorCode as Da, MinisContentStatus as Pa } from "./shop-minis-platform/src/types/content.js";
|
|
98
98
|
import { Social as ha } from "./shop-minis-platform/src/types/share.js";
|
|
99
|
-
import { DATA_FETCHING_DEFAULT_FETCH_POLICY as Ra, DATA_FETCHING_DEFAULT_PAGE_SIZE as
|
|
99
|
+
import { DATA_FETCHING_DEFAULT_FETCH_POLICY as Ra, DATA_FETCHING_DEFAULT_PAGE_SIZE as va } from "./shop-minis-platform/src/constants.js";
|
|
100
100
|
export {
|
|
101
101
|
Sr as Accordion,
|
|
102
102
|
Ar as AccordionContent,
|
|
@@ -105,11 +105,11 @@ export {
|
|
|
105
105
|
n as AddToCartButton,
|
|
106
106
|
hr as Alert,
|
|
107
107
|
Ir as AlertDescription,
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
wr as AlertDialog,
|
|
109
|
+
Br as AlertDialogAction,
|
|
110
110
|
pr as AlertDialogAtom,
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
Er as AlertDialogCancel,
|
|
112
|
+
Mr as AlertDialogContent,
|
|
113
113
|
Fr as AlertDialogDescription,
|
|
114
114
|
Ur as AlertDialogFooter,
|
|
115
115
|
Lr as AlertDialogHeader,
|
|
@@ -140,7 +140,7 @@ export {
|
|
|
140
140
|
Da as ContentCreateUserErrorCode,
|
|
141
141
|
cr as ContentWrapper,
|
|
142
142
|
Ra as DATA_FETCHING_DEFAULT_FETCH_POLICY,
|
|
143
|
-
|
|
143
|
+
va as DATA_FETCHING_DEFAULT_PAGE_SIZE,
|
|
144
144
|
o as DATA_NAVIGATION_TYPE_ATTRIBUTE,
|
|
145
145
|
me as Dialog,
|
|
146
146
|
se as DialogClose,
|
|
@@ -159,23 +159,23 @@ export {
|
|
|
159
159
|
he as DrawerFooter,
|
|
160
160
|
Ie as DrawerHeader,
|
|
161
161
|
Re as DrawerOverlay,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
ve as DrawerPortal,
|
|
163
|
+
we as DrawerTitle,
|
|
164
|
+
Be as DrawerTrigger,
|
|
165
165
|
V as FavoriteButton,
|
|
166
166
|
X as IconButton,
|
|
167
167
|
rr as Image,
|
|
168
168
|
W as ImageContentWrapper,
|
|
169
|
-
|
|
169
|
+
Me as Input,
|
|
170
170
|
Ue as Label,
|
|
171
171
|
mr as List,
|
|
172
172
|
ar as LongPressDetector,
|
|
173
173
|
I as MerchantCard,
|
|
174
174
|
R as MerchantCardContainer,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
v as MerchantCardHeader,
|
|
176
|
+
w as MerchantCardInfo,
|
|
177
|
+
B as MerchantCardName,
|
|
178
|
+
E as MerchantCardRating,
|
|
179
179
|
L as MerchantCardSkeleton,
|
|
180
180
|
Jt as MiniEntityNotFoundError,
|
|
181
181
|
Xt as MiniError,
|
|
@@ -255,13 +255,12 @@ export {
|
|
|
255
255
|
st as useAsyncStorage,
|
|
256
256
|
Oo as useBuyerAttributes,
|
|
257
257
|
gt as useCloseMini,
|
|
258
|
-
|
|
259
|
-
nt as useCuratedProducts,
|
|
258
|
+
wt as useCreateImageContent,
|
|
260
259
|
Lo as useCurrentUser,
|
|
261
260
|
At as useDeeplink,
|
|
262
261
|
Ft as useErrorScreen,
|
|
263
|
-
|
|
264
|
-
|
|
262
|
+
Et as useErrorToast,
|
|
263
|
+
Eo as useFollowedShops,
|
|
265
264
|
Fo as useFollowedShopsActions,
|
|
266
265
|
yo as useGenerateUserToken,
|
|
267
266
|
Nt as useImagePicker,
|
|
@@ -274,22 +273,23 @@ export {
|
|
|
274
273
|
Ht as useOnMiniFocus,
|
|
275
274
|
Zt as useOnNavigateBack,
|
|
276
275
|
No as useOrders,
|
|
277
|
-
|
|
276
|
+
nt as usePopularProducts,
|
|
278
277
|
Ko as useProduct,
|
|
279
278
|
Yo as useProductList,
|
|
280
279
|
Ho as useProductListActions,
|
|
281
280
|
zo as useProductLists,
|
|
282
281
|
$o as useProductMedia,
|
|
283
|
-
et as
|
|
282
|
+
et as useProductReviews,
|
|
283
|
+
tt as useProductSearch,
|
|
284
284
|
Jo as useProductVariants,
|
|
285
285
|
Zo as useProducts,
|
|
286
286
|
Po as useRecentProducts,
|
|
287
287
|
ho as useRecentShops,
|
|
288
|
-
|
|
288
|
+
it as useRecommendedProducts,
|
|
289
289
|
Rt as useRecommendedShops,
|
|
290
290
|
yt as useRequestPermissions,
|
|
291
291
|
Ro as useSavedProducts,
|
|
292
|
-
|
|
292
|
+
wo as useSavedProductsActions,
|
|
293
293
|
ut as useSecureStorage,
|
|
294
294
|
Lt as useShare,
|
|
295
295
|
ht as useShop,
|
package/dist/mocks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UserState as
|
|
2
|
-
import { MinisContentStatus as
|
|
3
|
-
const
|
|
1
|
+
import { UserState as v } from "./shop-minis-platform/src/types/user.js";
|
|
2
|
+
import { MinisContentStatus as S } from "./shop-minis-platform/src/types/content.js";
|
|
3
|
+
const u = [
|
|
4
4
|
"garnished.jpeg",
|
|
5
5
|
"bath.jpeg",
|
|
6
6
|
"teapot.jpg",
|
|
@@ -10,17 +10,17 @@ const m = [
|
|
|
10
10
|
for (let t = 0; t < o.length; t++)
|
|
11
11
|
r = (r << 5) - r + o.charCodeAt(t), r |= 0;
|
|
12
12
|
return Math.abs(r);
|
|
13
|
-
}, e = (o, r, t = "99.99",
|
|
14
|
-
const
|
|
13
|
+
}, e = (o, r, t = "99.99", d) => {
|
|
14
|
+
const s = P(o) % u.length, c = u[s];
|
|
15
15
|
return {
|
|
16
16
|
id: o,
|
|
17
17
|
title: r,
|
|
18
18
|
price: { amount: t, currencyCode: "USD" },
|
|
19
|
-
...
|
|
20
|
-
compareAtPrice: { amount:
|
|
19
|
+
...d && {
|
|
20
|
+
compareAtPrice: { amount: d, currencyCode: "USD" }
|
|
21
21
|
},
|
|
22
22
|
reviewAnalytics: { averageRating: 4.5, reviewCount: 10 },
|
|
23
|
-
shop:
|
|
23
|
+
shop: n("shop1", "Mock Shop"),
|
|
24
24
|
defaultVariantId: `variant-${o}`,
|
|
25
25
|
isFavorited: !1,
|
|
26
26
|
featuredImage: {
|
|
@@ -28,13 +28,22 @@ const m = [
|
|
|
28
28
|
altText: r
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
}, l = (o, r = {}) => ({
|
|
32
|
+
id: o,
|
|
33
|
+
rating: 5,
|
|
34
|
+
title: "Great product",
|
|
35
|
+
body: "Loved it. Would buy again.",
|
|
36
|
+
submittedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
37
|
+
merchantReply: null,
|
|
38
|
+
merchantRepliedAt: null,
|
|
39
|
+
...r
|
|
40
|
+
}), n = (o, r, t) => {
|
|
41
|
+
const d = t?.themeType || "none", s = t?.withBrandSettings || d !== "none", c = t?.featuredImagesLimit || 3, p = Array.from({ length: c }, (C, m) => ({
|
|
42
|
+
url: `https://picsum.photos/400/400?random=${o}-${m}`,
|
|
34
43
|
sensitive: !1,
|
|
35
|
-
altText: `${r} featured image ${
|
|
36
|
-
})),
|
|
37
|
-
switch (
|
|
44
|
+
altText: `${r} featured image ${m + 1}`
|
|
45
|
+
})), g = () => {
|
|
46
|
+
switch (d) {
|
|
38
47
|
case "coverImage":
|
|
39
48
|
return {
|
|
40
49
|
primary: t?.primaryColor,
|
|
@@ -64,8 +73,8 @@ const m = [
|
|
|
64
73
|
coverDominant: t?.coverDominantColor
|
|
65
74
|
};
|
|
66
75
|
}
|
|
67
|
-
},
|
|
68
|
-
if (
|
|
76
|
+
}, h = () => {
|
|
77
|
+
if (d === "coverImage" || t?.coverImageUrl)
|
|
69
78
|
return {
|
|
70
79
|
id: `header-theme-${o}`,
|
|
71
80
|
coverImage: {
|
|
@@ -74,7 +83,7 @@ const m = [
|
|
|
74
83
|
sensitive: !1,
|
|
75
84
|
thumbhash: "k9oGHQRnh493V4dIeHeXh4h3iIeI"
|
|
76
85
|
},
|
|
77
|
-
wordmark: t?.wordmarkUrl ||
|
|
86
|
+
wordmark: t?.wordmarkUrl || d === "coverImage" ? {
|
|
78
87
|
url: t?.wordmarkUrl || "https://merrypeople.com/cdn/shop/files/Transparent_Background_1.png?v=1696465429&width=1024",
|
|
79
88
|
altText: `${r} wordmark`,
|
|
80
89
|
sensitive: !1
|
|
@@ -99,41 +108,41 @@ const m = [
|
|
|
99
108
|
reviewAnalytics: { averageRating: 4.3, reviewCount: 50 },
|
|
100
109
|
visualTheme: {
|
|
101
110
|
id: `visual-theme-${o}`,
|
|
102
|
-
featuredImages:
|
|
111
|
+
featuredImages: p,
|
|
103
112
|
logoImage: {
|
|
104
113
|
url: `https://picsum.photos/100/100?random=${o}`,
|
|
105
114
|
sensitive: !1
|
|
106
115
|
},
|
|
107
|
-
brandSettings:
|
|
116
|
+
brandSettings: s ? {
|
|
108
117
|
id: `brand-settings-${o}`,
|
|
109
118
|
colors: {
|
|
110
119
|
id: `colors-${o}`,
|
|
111
|
-
...
|
|
120
|
+
...g()
|
|
112
121
|
},
|
|
113
|
-
headerTheme:
|
|
122
|
+
headerTheme: h()
|
|
114
123
|
} : void 0
|
|
115
124
|
}
|
|
116
125
|
};
|
|
117
126
|
}, a = (o = !1) => ({
|
|
118
127
|
hasNextPage: o,
|
|
119
128
|
endCursor: o ? "cursor123" : null
|
|
120
|
-
}),
|
|
129
|
+
}), i = (o, r, t = []) => ({
|
|
121
130
|
id: o,
|
|
122
131
|
publicId: `public-${o}`,
|
|
123
132
|
name: r,
|
|
124
133
|
products: t
|
|
125
134
|
});
|
|
126
|
-
function
|
|
135
|
+
function f(o, r) {
|
|
127
136
|
window._mockLogs = window._mockLogs || [], window._mockLogs.push({ action: o, params: r });
|
|
128
137
|
}
|
|
129
|
-
function
|
|
130
|
-
return (t) => (
|
|
138
|
+
function I(o, r) {
|
|
139
|
+
return (t) => (f(String(o), t), Promise.resolve({
|
|
131
140
|
ok: !0,
|
|
132
141
|
data: r,
|
|
133
142
|
mocked: !0
|
|
134
143
|
}));
|
|
135
144
|
}
|
|
136
|
-
function
|
|
145
|
+
function w() {
|
|
137
146
|
const o = {
|
|
138
147
|
translateContentUp: void 0,
|
|
139
148
|
translateContentDown: void 0,
|
|
@@ -212,20 +221,20 @@ function I() {
|
|
|
212
221
|
reportContentImpression: void 0,
|
|
213
222
|
getProductLists: {
|
|
214
223
|
data: [
|
|
215
|
-
|
|
216
|
-
|
|
224
|
+
i("list-1", "Wishlist"),
|
|
225
|
+
i("list-2", "Favorites")
|
|
217
226
|
],
|
|
218
227
|
pageInfo: a()
|
|
219
228
|
},
|
|
220
229
|
getProductList: {
|
|
221
|
-
data:
|
|
230
|
+
data: i("list-1", "Wishlist", [
|
|
222
231
|
e("prod-1", "Sample Product")
|
|
223
232
|
]),
|
|
224
233
|
pageInfo: a()
|
|
225
234
|
},
|
|
226
|
-
addProductList:
|
|
235
|
+
addProductList: i("list-3", "New List"),
|
|
227
236
|
removeProductList: void 0,
|
|
228
|
-
renameProductList:
|
|
237
|
+
renameProductList: i("list-1", "Updated Wishlist"),
|
|
229
238
|
addProductListItem: void 0,
|
|
230
239
|
removeProductListItem: void 0,
|
|
231
240
|
getRecommendedProducts: {
|
|
@@ -244,11 +253,11 @@ function I() {
|
|
|
244
253
|
},
|
|
245
254
|
getRecommendedShops: {
|
|
246
255
|
data: [
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
256
|
+
n("shop-1", "Amazing Store"),
|
|
257
|
+
n("shop-2", "Best Deals Shop"),
|
|
258
|
+
n("shop-3", "Great Products"),
|
|
259
|
+
n("shop-4", "Top Brands"),
|
|
260
|
+
n("shop-5", "Exclusive Offers")
|
|
252
261
|
],
|
|
253
262
|
pageInfo: a()
|
|
254
263
|
},
|
|
@@ -275,7 +284,7 @@ function I() {
|
|
|
275
284
|
product: null
|
|
276
285
|
}
|
|
277
286
|
],
|
|
278
|
-
shop:
|
|
287
|
+
shop: n("shop-1", "Sample Shop")
|
|
279
288
|
}
|
|
280
289
|
],
|
|
281
290
|
pageInfo: a()
|
|
@@ -313,13 +322,6 @@ function I() {
|
|
|
313
322
|
message: "Shared!",
|
|
314
323
|
success: !0
|
|
315
324
|
},
|
|
316
|
-
getCuratedProducts: {
|
|
317
|
-
data: [
|
|
318
|
-
e("cur-1", "Curated Product 1", "79.99"),
|
|
319
|
-
e("cur-2", "Curated Product 2", "129.99")
|
|
320
|
-
],
|
|
321
|
-
pageInfo: a()
|
|
322
|
-
},
|
|
323
325
|
getSavedProducts: {
|
|
324
326
|
data: [
|
|
325
327
|
e("saved-1", "Saved Product 1", "49.99"),
|
|
@@ -384,22 +386,35 @@ function I() {
|
|
|
384
386
|
],
|
|
385
387
|
pageInfo: a()
|
|
386
388
|
},
|
|
389
|
+
getProductReviews: {
|
|
390
|
+
data: [
|
|
391
|
+
l("review-1"),
|
|
392
|
+
l("review-2", { rating: 4, title: "Pretty good" }),
|
|
393
|
+
l("review-3", {
|
|
394
|
+
rating: 3,
|
|
395
|
+
title: "Okay",
|
|
396
|
+
merchantReply: "Thanks for the feedback!",
|
|
397
|
+
merchantRepliedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
398
|
+
})
|
|
399
|
+
],
|
|
400
|
+
pageInfo: a()
|
|
401
|
+
},
|
|
387
402
|
getShop: {
|
|
388
|
-
data:
|
|
403
|
+
data: n("shop-1", "Sample Shop", { featuredImagesLimit: 4 })
|
|
389
404
|
},
|
|
390
405
|
getRecentShops: {
|
|
391
406
|
data: [
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
407
|
+
n("recent-shop-1", "Recent Shop 1"),
|
|
408
|
+
n("recent-shop-2", "Recent Shop 2"),
|
|
409
|
+
n("recent-shop-3", "Recent Shop 3")
|
|
395
410
|
],
|
|
396
411
|
pageInfo: a()
|
|
397
412
|
},
|
|
398
413
|
getFollowedShops: {
|
|
399
414
|
data: [
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
415
|
+
n("followed-shop-1", "Followed Shop 1"),
|
|
416
|
+
n("followed-shop-2", "Followed Shop 2"),
|
|
417
|
+
n("followed-shop-3", "Followed Shop 3")
|
|
403
418
|
],
|
|
404
419
|
pageInfo: a()
|
|
405
420
|
},
|
|
@@ -433,7 +448,7 @@ function I() {
|
|
|
433
448
|
},
|
|
434
449
|
title: "Mock Content",
|
|
435
450
|
visibility: ["DISCOVERABLE"],
|
|
436
|
-
status:
|
|
451
|
+
status: S.READY
|
|
437
452
|
}
|
|
438
453
|
]
|
|
439
454
|
},
|
|
@@ -441,7 +456,7 @@ function I() {
|
|
|
441
456
|
data: {
|
|
442
457
|
token: "user-token-123",
|
|
443
458
|
expiresAt: "2025-01-01",
|
|
444
|
-
userState:
|
|
459
|
+
userState: v.VERIFIED
|
|
445
460
|
}
|
|
446
461
|
},
|
|
447
462
|
navigateToCart: void 0,
|
|
@@ -452,17 +467,17 @@ function I() {
|
|
|
452
467
|
reportFetch: void 0
|
|
453
468
|
}, r = {};
|
|
454
469
|
for (const t in o)
|
|
455
|
-
Object.prototype.hasOwnProperty.call(o, t) && (r[t] =
|
|
470
|
+
Object.prototype.hasOwnProperty.call(o, t) && (r[t] = I(
|
|
456
471
|
t,
|
|
457
472
|
o[t]
|
|
458
473
|
));
|
|
459
474
|
return r;
|
|
460
475
|
}
|
|
461
|
-
const
|
|
476
|
+
const y = () => {
|
|
462
477
|
const o = navigator.userAgent.toLowerCase(), r = /iphone|ipad|ipod/.test(o), t = /android/.test(o);
|
|
463
478
|
return r || t;
|
|
464
479
|
}, A = ({ force: o } = {}) => {
|
|
465
|
-
|
|
480
|
+
y() && !o || window.minisSDK || (window.minisSDK = w(), window.minisParams = {
|
|
466
481
|
handle: "mock-handle",
|
|
467
482
|
initialUrl: "/",
|
|
468
483
|
platform: "web"
|
|
@@ -470,8 +485,9 @@ const w = () => {
|
|
|
470
485
|
};
|
|
471
486
|
export {
|
|
472
487
|
e as createProduct,
|
|
473
|
-
|
|
488
|
+
l as createProductReview,
|
|
489
|
+
n as createShop,
|
|
474
490
|
A as injectMocks,
|
|
475
|
-
|
|
491
|
+
w as makeMockActions
|
|
476
492
|
};
|
|
477
493
|
//# sourceMappingURL=mocks.js.map
|
package/dist/mocks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.js","sources":["../src/mocks.ts"],"sourcesContent":["import {\n Product,\n Gender,\n UserState,\n MinisContentStatus,\n} from '@shopify/shop-minis-platform'\nimport {ShopActions} from '@shopify/shop-minis-platform/actions'\n\nconst SAMPLE_IMAGE_NAMES = [\n 'garnished.jpeg',\n 'bath.jpeg',\n 'teapot.jpg',\n 'shoes.jpeg',\n]\n\n// Simple hash function to get a deterministic index from a string\nconst hashString = (str: string): number => {\n let hash = 0\n for (let i = 0; i < str.length; i++) {\n hash = (hash << 5) - hash + str.charCodeAt(i)\n hash |= 0\n }\n return Math.abs(hash)\n}\n\n// Helper functions for common data structures\nexport const createProduct = (\n id: string,\n title: string,\n price = '99.99',\n compareAtPrice?: string\n): Product => {\n const imageIndex = hashString(id) % SAMPLE_IMAGE_NAMES.length\n const imageName = SAMPLE_IMAGE_NAMES[imageIndex]\n\n return {\n id,\n title,\n price: {amount: price, currencyCode: 'USD'},\n ...(compareAtPrice && {\n compareAtPrice: {amount: compareAtPrice, currencyCode: 'USD'},\n }),\n reviewAnalytics: {averageRating: 4.5, reviewCount: 10},\n shop: createShop('shop1', 'Mock Shop'),\n defaultVariantId: `variant-${id}`,\n isFavorited: false,\n featuredImage: {\n url: `https://cdn.shopify.com/static/sample-images/${imageName}`,\n altText: title,\n },\n }\n}\n\nexport const createShop = (\n id: string,\n name: string,\n options?: {\n themeType?: 'coverImage' | 'brandColor' | 'logoColor' | 'none'\n withBrandSettings?: boolean\n primaryColor?: string\n logoDominantColor?: string\n logoAverageColor?: string\n coverDominantColor?: string\n wordmarkUrl?: string\n coverImageUrl?: string\n featuredImagesLimit?: number\n }\n) => {\n // Determine theme configuration\n const themeType = options?.themeType || 'none'\n const shouldHaveBrandSettings =\n options?.withBrandSettings || themeType !== 'none'\n\n // Generate featured images\n const featuredImagesCount = options?.featuredImagesLimit || 3\n const featuredImages = Array.from({length: featuredImagesCount}, (_, i) => ({\n url: `https://picsum.photos/400/400?random=${id}-${i}`,\n sensitive: false,\n altText: `${name} featured image ${i + 1}`,\n }))\n\n // Configure colors based on theme type\n const getThemeColors = () => {\n switch (themeType) {\n case 'coverImage':\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor || '#FF6B35',\n }\n case 'brandColor':\n return {\n primary: options?.primaryColor || '#27AE60',\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n case 'logoColor':\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor || '#E74C3C',\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n default:\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n }\n }\n\n // Configure header theme\n const createHeaderTheme = () => {\n if (themeType === 'coverImage' || options?.coverImageUrl) {\n return {\n id: `header-theme-${id}`,\n coverImage: {\n url:\n options?.coverImageUrl ||\n 'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=800&h=400&fit=crop',\n altText: `${name} cover image`,\n sensitive: false,\n thumbhash: 'k9oGHQRnh493V4dIeHeXh4h3iIeI',\n },\n wordmark:\n options?.wordmarkUrl || themeType === 'coverImage'\n ? {\n url:\n options?.wordmarkUrl ||\n 'https://merrypeople.com/cdn/shop/files/Transparent_Background_1.png?v=1696465429&width=1024',\n altText: `${name} wordmark`,\n sensitive: false,\n }\n : undefined,\n }\n }\n\n if (options?.wordmarkUrl) {\n return {\n id: `header-theme-${id}`,\n wordmark: {\n url: options.wordmarkUrl,\n altText: `${name} wordmark`,\n sensitive: false,\n },\n }\n }\n\n return undefined\n }\n\n return {\n id,\n name,\n primaryDomain: {\n url: `https://${name.toLowerCase().replace(/\\s+/g, '-')}.com`,\n },\n reviewAnalytics: {averageRating: 4.3, reviewCount: 50},\n visualTheme: {\n id: `visual-theme-${id}`,\n featuredImages,\n logoImage: {\n url: `https://picsum.photos/100/100?random=${id}`,\n sensitive: false,\n },\n brandSettings: shouldHaveBrandSettings\n ? {\n id: `brand-settings-${id}`,\n colors: {\n id: `colors-${id}`,\n ...getThemeColors(),\n },\n headerTheme: createHeaderTheme(),\n }\n : undefined,\n },\n }\n}\n\nconst createPagination = (hasNext = false) => ({\n hasNextPage: hasNext,\n endCursor: hasNext ? 'cursor123' : null,\n})\n\nconst createProductList = (id: string, name: string, products: any[] = []) => ({\n id,\n publicId: `public-${id}`,\n name,\n products,\n})\n\n// Helper type to extract the data type from a ShopAction\ntype ShopActionDataType<T> = T extends (\n ...args: any[]\n) => Promise<{ok: true; data: infer R} | {ok: false; error: any}>\n ? R\n : never\n\n// Use window._mockLogs instead of console.log so logs aren't stripped in production builds\n// This allows e2e tests to verify mock actions are being called\nexport interface MockLog {\n action: string\n params?: unknown\n}\n\ndeclare global {\n interface Window {\n _mockLogs?: MockLog[]\n }\n}\n\nfunction logMockAction(action: string, params?: unknown) {\n window._mockLogs = window._mockLogs || []\n window._mockLogs.push({action, params})\n}\n\nfunction makeMockMethod<K extends keyof ShopActions>(\n key: K,\n result: ShopActionDataType<ShopActions[K]>\n): ShopActions[K] {\n return ((params: Parameters<ShopActions[K]>[0]) => {\n logMockAction(String(key), params)\n return Promise.resolve({\n ok: true as const,\n data: result,\n mocked: true,\n })\n }) as ShopActions[K]\n}\n\nexport function makeMockActions(): ShopActions {\n const results: {\n [K in keyof ShopActions]: ShopActionDataType<ShopActions[K]>\n } = {\n translateContentUp: undefined,\n translateContentDown: undefined,\n followShop: true,\n unfollowShop: false,\n favorite: undefined,\n unfavorite: undefined,\n getShopAppInformation: {\n appVersion: '1.0.0',\n buildNumber: '12345',\n buildId: 'dev-build-123',\n },\n productRecommendationImpression: undefined,\n productRecommendationClick: undefined,\n closeMini: undefined,\n getAccountInformation: {\n status: 'available',\n value: 'user@example.com',\n },\n getCurrentUser: {\n data: {\n displayName: 'John Doe',\n avatarImage: {url: 'https://example.com/avatar.jpg'},\n },\n },\n createOrderAttribution: undefined,\n addToCart: undefined,\n buyProduct: undefined,\n buyProducts: undefined,\n showErrorScreen: undefined,\n showErrorToast: undefined,\n getDeeplinkPaths: {\n matchers: ['/products', '/collections', '/cart'],\n },\n navigateToDeeplink: undefined,\n navigateToShop: undefined,\n navigateToProduct: undefined,\n navigateToOrder: undefined,\n navigateToCheckout: undefined,\n createImageUploadLink: {\n // This action is mocked in the actual hook. See `useImageUpload` for more details.\n targets: [\n {\n url: 'https://example.com/upload',\n resourceUrl: 'https://example.com/resource',\n parameters: [{name: 'key', value: 'upload-123'}],\n },\n ],\n },\n completeImageUpload: {\n files: [\n {\n id: 'file-123',\n fileStatus: 'READY',\n image: {\n url: 'https://example.com/image.jpg',\n },\n },\n ],\n },\n getPersistedItem: null,\n setPersistedItem: undefined,\n removePersistedItem: undefined,\n getAllPersistedKeys: ['key1', 'key2', 'key3'],\n clearPersistedItems: undefined,\n getInternalPersistedItem: null,\n setInternalPersistedItem: undefined,\n removeInternalPersistedItem: undefined,\n getAllInternalPersistedKeys: ['internal-key1', 'internal-key2'],\n clearInternalPersistedItems: undefined,\n getSecret: 'secret-value',\n setSecret: undefined,\n removeSecret: undefined,\n reportInteraction: undefined,\n reportImpression: undefined,\n reportContentImpression: undefined,\n getProductLists: {\n data: [\n createProductList('list-1', 'Wishlist'),\n createProductList('list-2', 'Favorites'),\n ],\n pageInfo: createPagination(),\n },\n getProductList: {\n data: createProductList('list-1', 'Wishlist', [\n createProduct('prod-1', 'Sample Product'),\n ]),\n pageInfo: createPagination(),\n },\n addProductList: createProductList('list-3', 'New List'),\n removeProductList: undefined,\n renameProductList: createProductList('list-1', 'Updated Wishlist'),\n addProductListItem: undefined,\n removeProductListItem: undefined,\n getRecommendedProducts: {\n data: [\n createProduct('rec-1', 'Recommended Product 1', '79.99'),\n createProduct('rec-2', 'Recommended Product 2', '129.99'),\n createProduct('rec-3', 'Recommended Product 3', '129.99'),\n createProduct('rec-4', 'Recommended Product 4', '29.99'),\n createProduct('rec-5', 'Recommended Product 5', '39.99'),\n createProduct('rec-6', 'Recommended Product 6', '49.99'),\n createProduct('rec-7', 'Recommended Product 7', '59.99'),\n createProduct('rec-8', 'Recommended Product 8', '69.99'),\n createProduct('rec-9', 'Recommended Product 9', '129.99'),\n ],\n pageInfo: createPagination(),\n },\n getRecommendedShops: {\n data: [\n createShop('shop-1', 'Amazing Store'),\n createShop('shop-2', 'Best Deals Shop'),\n createShop('shop-3', 'Great Products'),\n createShop('shop-4', 'Top Brands'),\n createShop('shop-5', 'Exclusive Offers'),\n ],\n pageInfo: createPagination(),\n },\n searchProductsByShop: {\n data: [\n createProduct('search-1', 'Search Result 1', '59.99'),\n createProduct('search-2', 'Search Result 2', '89.99'),\n createProduct('search-3', 'Search Result 3', '119.99'),\n createProduct('search-4', 'Search Result 4', '149.99'),\n createProduct('search-5', 'Search Result 5', '179.99'),\n ],\n pageInfo: createPagination(),\n },\n getOrders: {\n data: [\n {\n id: 'order-1',\n name: '#1001',\n lineItems: [\n {\n productTitle: 'Sample Product',\n variantTitle: 'Medium',\n quantity: 2,\n product: null,\n },\n ],\n shop: createShop('shop-1', 'Sample Shop'),\n },\n ],\n pageInfo: createPagination(),\n },\n getBuyerAttributes: {\n data: {\n genderAffinity: 'NEUTRAL' as Gender,\n categoryAffinities: [\n {id: 'cat1', name: 'Electronics'},\n {id: 'cat2', name: 'Clothing'},\n ],\n },\n },\n showFeedbackSheet: undefined,\n getPopularProducts: {\n data: [\n createProduct('pop-1', 'The Hero Snowboard', '702.95'),\n createProduct('pop-2', 'Snow Jacket', '605.95', '702.00'),\n createProduct('pop-3', 'Winter Gloves', '89.95'),\n createProduct('pop-4', 'Summer Gloves', '89.95'),\n createProduct('pop-5', 'Spring Gloves', '89.95'),\n createProduct('pop-6', 'Playstation 5', '499.95'),\n createProduct('pop-7', 'Xbox Series X', '499.95'),\n createProduct('pop-8', 'Nintendo Switch', '299.95'),\n createProduct('pop-9', 'Playstation 4', '299.95'),\n createProduct('pop-10', 'Nintendo 3DS', '89.95'),\n ],\n pageInfo: createPagination(),\n },\n share: {\n message: 'Shared!',\n success: true,\n },\n shareSingle: {\n message: 'Shared!',\n success: true,\n },\n getCuratedProducts: {\n data: [\n createProduct('cur-1', 'Curated Product 1', '79.99'),\n createProduct('cur-2', 'Curated Product 2', '129.99'),\n ],\n pageInfo: createPagination(),\n },\n getSavedProducts: {\n data: [\n createProduct('saved-1', 'Saved Product 1', '49.99'),\n createProduct('saved-2', 'Saved Product 2', '59.99'),\n createProduct('saved-3', 'Saved Product 3', '69.99'),\n createProduct('saved-4', 'Saved Product 4', '79.99'),\n createProduct('saved-5', 'Saved Product 5', '89.99'),\n ],\n pageInfo: createPagination(),\n },\n getRecentProducts: {\n data: [\n createProduct('recent-1', 'Recent Product 1', '59.99'),\n createProduct('recent-2', 'Recent Product 2', '69.99'),\n createProduct('recent-3', 'Recent Product 3', '79.99'),\n createProduct('recent-4', 'Recent Product 4', '89.99'),\n createProduct('recent-5', 'Recent Product 5', '99.99'),\n ],\n pageInfo: createPagination(),\n },\n getProductSearch: {\n data: [\n createProduct('search-1', 'Search Product 1', '39.99'),\n createProduct('search-2', 'Search Product 2', '19.99'),\n createProduct('search-3', 'Search Product 3', '29.99'),\n createProduct('search-4', 'Search Product 4', '49.99'),\n createProduct('search-5', 'Search Product 5', '9.99'),\n ],\n pageInfo: createPagination(),\n },\n getProducts: {\n data: [\n createProduct('prod-1', 'Product 1', '9.99'),\n createProduct('prod-2', 'Product 2', '19.99'),\n createProduct('prod-3', 'Product 3', '29.99'),\n createProduct('prod-4', 'Product 4', '39.99'),\n createProduct('prod-5', 'Product 5', '49.99'),\n ],\n },\n getProduct: {data: createProduct('prod-1', 'Sample Product')},\n getProductVariants: {\n data: [\n {\n id: 'variant-1',\n title: 'Variant 1',\n isFavorited: false,\n image: {url: 'https://example.com/variant-1.jpg'},\n price: {amount: '19.99', currencyCode: 'USD'},\n compareAtPrice: {amount: '29.99', currencyCode: 'USD'},\n },\n ],\n pageInfo: createPagination(),\n },\n getProductMedia: {\n data: [\n {\n id: 'media-1',\n image: {url: 'https://example.com/media-1.jpg'},\n mediaContentType: 'IMAGE',\n alt: 'Sample product image',\n },\n ],\n pageInfo: createPagination(),\n },\n getShop: {\n data: createShop('shop-1', 'Sample Shop', {featuredImagesLimit: 4}),\n },\n getRecentShops: {\n data: [\n createShop('recent-shop-1', 'Recent Shop 1'),\n createShop('recent-shop-2', 'Recent Shop 2'),\n createShop('recent-shop-3', 'Recent Shop 3'),\n ],\n pageInfo: createPagination(),\n },\n getFollowedShops: {\n data: [\n createShop('followed-shop-1', 'Followed Shop 1'),\n createShop('followed-shop-2', 'Followed Shop 2'),\n createShop('followed-shop-3', 'Followed Shop 3'),\n ],\n pageInfo: createPagination(),\n },\n previewProductInAr: undefined,\n createContent: {\n data: {\n publicId: 'content-123',\n externalId: null,\n image: {\n id: 'img-123',\n url: 'https://cdn.shopify.com/s/files/1/0633/6574/2742/files/Namnlosdesign-47.png?v=1740438079',\n width: 800,\n height: 600,\n },\n title: 'Mock Content',\n description: 'This is a mock content item',\n visibility: ['DISCOVERABLE'],\n shareableUrl: 'https://example.com/content/123',\n products: null,\n },\n },\n getContent: {\n data: [\n {\n publicId: 'content-123',\n image: {\n id: 'img-123',\n url: 'https://cdn.shopify.com/s/files/1/0633/6574/2742/files/Namnlosdesign-47.png?v=1740438079',\n width: 800,\n height: 600,\n },\n title: 'Mock Content',\n visibility: ['DISCOVERABLE'],\n status: MinisContentStatus.READY,\n },\n ],\n },\n generateUserToken: {\n data: {\n token: 'user-token-123',\n expiresAt: '2025-01-01',\n userState: UserState.VERIFIED,\n },\n },\n navigateToCart: undefined,\n requestPermission: {\n granted: true,\n },\n reportError: undefined,\n reportFetch: undefined,\n } as const\n\n const mock: Partial<ShopActions> = {}\n for (const key in results) {\n if (Object.prototype.hasOwnProperty.call(results, key)) {\n // @ts-expect-error: dynamic assignment is safe due to exhaustive mapping\n mock[key] = makeMockMethod(\n key as keyof ShopActions,\n results[key as keyof typeof results]\n )\n }\n }\n return mock as ShopActions\n}\n\n// Detect if running on a mobile device\nconst isMobile = (): boolean => {\n const userAgent = navigator.userAgent.toLowerCase()\n const isIOS = /iphone|ipad|ipod/.test(userAgent)\n const isAndroid = /android/.test(userAgent)\n\n return isIOS || isAndroid\n}\n\nexport const injectMocks = ({force}: {force?: boolean} = {}) => {\n // Only inject mocks if we aren't on a mobile device or we force it\n if (isMobile() && !force) {\n return\n }\n\n if (!window.minisSDK) {\n window.minisSDK = makeMockActions()\n window.minisParams = {\n handle: 'mock-handle',\n initialUrl: '/',\n platform: 'web',\n }\n }\n}\n"],"names":["SAMPLE_IMAGE_NAMES","hashString","str","hash","i","createProduct","id","title","price","compareAtPrice","imageIndex","imageName","createShop","name","options","themeType","shouldHaveBrandSettings","featuredImagesCount","featuredImages","_","getThemeColors","createHeaderTheme","createPagination","hasNext","createProductList","products","logMockAction","action","params","makeMockMethod","key","result","makeMockActions","results","MinisContentStatus","UserState","mock","isMobile","userAgent","isIOS","isAndroid","injectMocks","force"],"mappings":";;AAQA,MAAMA,IAAqB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAGMC,IAAa,CAACC,MAAwB;AAC1C,MAAIC,IAAO;AACX,WAASC,IAAI,GAAGA,IAAIF,EAAI,QAAQE;AAC9B,IAAAD,KAAQA,KAAQ,KAAKA,IAAOD,EAAI,WAAWE,CAAC,GACpCD,KAAA;AAEH,SAAA,KAAK,IAAIA,CAAI;AACtB,GAGaE,IAAgB,CAC3BC,GACAC,GACAC,IAAQ,SACRC,MACY;AACZ,QAAMC,IAAaT,EAAWK,CAAE,IAAIN,EAAmB,QACjDW,IAAYX,EAAmBU,CAAU;AAExC,SAAA;AAAA,IACL,IA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UACV,OAAO;AAAA,YACL,IAAI;AAAA,YACJ,KAAK;AAAA,YACL,OAAO;AAAA,YACP,QAAQ;AAAA,UACV;AAAA,UACA,OAAO;AAAA,UACP,YAAY,CAAC,cAAc;AAAA,UAC3B,QAAQY,EAAmB;AAAA,QAAA;AAAA,MAC7B;AAAA,IAEJ;AAAA,IACA,mBAAmB;AAAA,MACjB,MAAM;AAAA,QACJ,OAAO;AAAA,QACP,WAAW;AAAA,QACX,WAAWC,EAAU;AAAA,MAAA;AAAA,IAEzB;AAAA,IACA,gBAAgB;AAAA,IAChB,mBAAmB;AAAA,MACjB,SAAS;AAAA,IACX;AAAA,IACA,aAAa;AAAA,IACb,aAAa;AAAA,EACf,GAEMC,IAA6B,CAAC;AACpC,aAAWN,KAAOG;AAChB,IAAI,OAAO,UAAU,eAAe,KAAKA,GAASH,CAAG,MAEnDM,EAAKN,CAAG,IAAID;AAAA,MACVC;AAAA,MACAG,EAAQH,CAA2B;AAAA,IACrC;AAGG,SAAAM;AACT;AAGA,MAAMC,IAAW,MAAe;AACxB,QAAAC,IAAY,UAAU,UAAU,YAAY,GAC5CC,IAAQ,mBAAmB,KAAKD,CAAS,GACzCE,IAAY,UAAU,KAAKF,CAAS;AAE1C,SAAOC,KAASC;AAClB,GAEaC,IAAc,CAAC,EAAC,OAAAC,EAAK,IAAuB,OAAO;AAE1D,EAAAL,EAAA,KAAc,CAACK,KAId,OAAO,aACV,OAAO,WAAWV,EAAgB,GAClC,OAAO,cAAc;AAAA,IACnB,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"mocks.js","sources":["../src/mocks.ts"],"sourcesContent":["import {\n Product,\n ProductReview,\n Gender,\n UserState,\n MinisContentStatus,\n} from '@shopify/shop-minis-platform'\nimport {ShopActions} from '@shopify/shop-minis-platform/actions'\n\nconst SAMPLE_IMAGE_NAMES = [\n 'garnished.jpeg',\n 'bath.jpeg',\n 'teapot.jpg',\n 'shoes.jpeg',\n]\n\n// Simple hash function to get a deterministic index from a string\nconst hashString = (str: string): number => {\n let hash = 0\n for (let i = 0; i < str.length; i++) {\n hash = (hash << 5) - hash + str.charCodeAt(i)\n hash |= 0\n }\n return Math.abs(hash)\n}\n\n// Helper functions for common data structures\nexport const createProduct = (\n id: string,\n title: string,\n price = '99.99',\n compareAtPrice?: string\n): Product => {\n const imageIndex = hashString(id) % SAMPLE_IMAGE_NAMES.length\n const imageName = SAMPLE_IMAGE_NAMES[imageIndex]\n\n return {\n id,\n title,\n price: {amount: price, currencyCode: 'USD'},\n ...(compareAtPrice && {\n compareAtPrice: {amount: compareAtPrice, currencyCode: 'USD'},\n }),\n reviewAnalytics: {averageRating: 4.5, reviewCount: 10},\n shop: createShop('shop1', 'Mock Shop'),\n defaultVariantId: `variant-${id}`,\n isFavorited: false,\n featuredImage: {\n url: `https://cdn.shopify.com/static/sample-images/${imageName}`,\n altText: title,\n },\n }\n}\n\nexport const createProductReview = (\n id: string,\n overrides: Partial<ProductReview> = {}\n): ProductReview => {\n return {\n id,\n rating: 5,\n title: 'Great product',\n body: 'Loved it. Would buy again.',\n submittedAt: new Date().toISOString(),\n merchantReply: null,\n merchantRepliedAt: null,\n ...overrides,\n }\n}\n\nexport const createShop = (\n id: string,\n name: string,\n options?: {\n themeType?: 'coverImage' | 'brandColor' | 'logoColor' | 'none'\n withBrandSettings?: boolean\n primaryColor?: string\n logoDominantColor?: string\n logoAverageColor?: string\n coverDominantColor?: string\n wordmarkUrl?: string\n coverImageUrl?: string\n featuredImagesLimit?: number\n }\n) => {\n // Determine theme configuration\n const themeType = options?.themeType || 'none'\n const shouldHaveBrandSettings =\n options?.withBrandSettings || themeType !== 'none'\n\n // Generate featured images\n const featuredImagesCount = options?.featuredImagesLimit || 3\n const featuredImages = Array.from({length: featuredImagesCount}, (_, i) => ({\n url: `https://picsum.photos/400/400?random=${id}-${i}`,\n sensitive: false,\n altText: `${name} featured image ${i + 1}`,\n }))\n\n // Configure colors based on theme type\n const getThemeColors = () => {\n switch (themeType) {\n case 'coverImage':\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor || '#FF6B35',\n }\n case 'brandColor':\n return {\n primary: options?.primaryColor || '#27AE60',\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n case 'logoColor':\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor || '#E74C3C',\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n default:\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n }\n }\n\n // Configure header theme\n const createHeaderTheme = () => {\n if (themeType === 'coverImage' || options?.coverImageUrl) {\n return {\n id: `header-theme-${id}`,\n coverImage: {\n url:\n options?.coverImageUrl ||\n 'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=800&h=400&fit=crop',\n altText: `${name} cover image`,\n sensitive: false,\n thumbhash: 'k9oGHQRnh493V4dIeHeXh4h3iIeI',\n },\n wordmark:\n options?.wordmarkUrl || themeType === 'coverImage'\n ? {\n url:\n options?.wordmarkUrl ||\n 'https://merrypeople.com/cdn/shop/files/Transparent_Background_1.png?v=1696465429&width=1024',\n altText: `${name} wordmark`,\n sensitive: false,\n }\n : undefined,\n }\n }\n\n if (options?.wordmarkUrl) {\n return {\n id: `header-theme-${id}`,\n wordmark: {\n url: options.wordmarkUrl,\n altText: `${name} wordmark`,\n sensitive: false,\n },\n }\n }\n\n return undefined\n }\n\n return {\n id,\n name,\n primaryDomain: {\n url: `https://${name.toLowerCase().replace(/\\s+/g, '-')}.com`,\n },\n reviewAnalytics: {averageRating: 4.3, reviewCount: 50},\n visualTheme: {\n id: `visual-theme-${id}`,\n featuredImages,\n logoImage: {\n url: `https://picsum.photos/100/100?random=${id}`,\n sensitive: false,\n },\n brandSettings: shouldHaveBrandSettings\n ? {\n id: `brand-settings-${id}`,\n colors: {\n id: `colors-${id}`,\n ...getThemeColors(),\n },\n headerTheme: createHeaderTheme(),\n }\n : undefined,\n },\n }\n}\n\nconst createPagination = (hasNext = false) => ({\n hasNextPage: hasNext,\n endCursor: hasNext ? 'cursor123' : null,\n})\n\nconst createProductList = (id: string, name: string, products: any[] = []) => ({\n id,\n publicId: `public-${id}`,\n name,\n products,\n})\n\n// Helper type to extract the data type from a ShopAction\ntype ShopActionDataType<T> = T extends (\n ...args: any[]\n) => Promise<{ok: true; data: infer R} | {ok: false; error: any}>\n ? R\n : never\n\n// Use window._mockLogs instead of console.log so logs aren't stripped in production builds\n// This allows e2e tests to verify mock actions are being called\nexport interface MockLog {\n action: string\n params?: unknown\n}\n\ndeclare global {\n interface Window {\n _mockLogs?: MockLog[]\n }\n}\n\nfunction logMockAction(action: string, params?: unknown) {\n window._mockLogs = window._mockLogs || []\n window._mockLogs.push({action, params})\n}\n\nfunction makeMockMethod<K extends keyof ShopActions>(\n key: K,\n result: ShopActionDataType<ShopActions[K]>\n): ShopActions[K] {\n return ((params: Parameters<ShopActions[K]>[0]) => {\n logMockAction(String(key), params)\n return Promise.resolve({\n ok: true as const,\n data: result,\n mocked: true,\n })\n }) as ShopActions[K]\n}\n\nexport function makeMockActions(): ShopActions {\n const results: {\n [K in keyof ShopActions]: ShopActionDataType<ShopActions[K]>\n } = {\n translateContentUp: undefined,\n translateContentDown: undefined,\n followShop: true,\n unfollowShop: false,\n favorite: undefined,\n unfavorite: undefined,\n getShopAppInformation: {\n appVersion: '1.0.0',\n buildNumber: '12345',\n buildId: 'dev-build-123',\n },\n productRecommendationImpression: undefined,\n productRecommendationClick: undefined,\n closeMini: undefined,\n getAccountInformation: {\n status: 'available',\n value: 'user@example.com',\n },\n getCurrentUser: {\n data: {\n displayName: 'John Doe',\n avatarImage: {url: 'https://example.com/avatar.jpg'},\n },\n },\n createOrderAttribution: undefined,\n addToCart: undefined,\n buyProduct: undefined,\n buyProducts: undefined,\n showErrorScreen: undefined,\n showErrorToast: undefined,\n getDeeplinkPaths: {\n matchers: ['/products', '/collections', '/cart'],\n },\n navigateToDeeplink: undefined,\n navigateToShop: undefined,\n navigateToProduct: undefined,\n navigateToOrder: undefined,\n navigateToCheckout: undefined,\n createImageUploadLink: {\n // This action is mocked in the actual hook. See `useImageUpload` for more details.\n targets: [\n {\n url: 'https://example.com/upload',\n resourceUrl: 'https://example.com/resource',\n parameters: [{name: 'key', value: 'upload-123'}],\n },\n ],\n },\n completeImageUpload: {\n files: [\n {\n id: 'file-123',\n fileStatus: 'READY',\n image: {\n url: 'https://example.com/image.jpg',\n },\n },\n ],\n },\n getPersistedItem: null,\n setPersistedItem: undefined,\n removePersistedItem: undefined,\n getAllPersistedKeys: ['key1', 'key2', 'key3'],\n clearPersistedItems: undefined,\n getInternalPersistedItem: null,\n setInternalPersistedItem: undefined,\n removeInternalPersistedItem: undefined,\n getAllInternalPersistedKeys: ['internal-key1', 'internal-key2'],\n clearInternalPersistedItems: undefined,\n getSecret: 'secret-value',\n setSecret: undefined,\n removeSecret: undefined,\n reportInteraction: undefined,\n reportImpression: undefined,\n reportContentImpression: undefined,\n getProductLists: {\n data: [\n createProductList('list-1', 'Wishlist'),\n createProductList('list-2', 'Favorites'),\n ],\n pageInfo: createPagination(),\n },\n getProductList: {\n data: createProductList('list-1', 'Wishlist', [\n createProduct('prod-1', 'Sample Product'),\n ]),\n pageInfo: createPagination(),\n },\n addProductList: createProductList('list-3', 'New List'),\n removeProductList: undefined,\n renameProductList: createProductList('list-1', 'Updated Wishlist'),\n addProductListItem: undefined,\n removeProductListItem: undefined,\n getRecommendedProducts: {\n data: [\n createProduct('rec-1', 'Recommended Product 1', '79.99'),\n createProduct('rec-2', 'Recommended Product 2', '129.99'),\n createProduct('rec-3', 'Recommended Product 3', '129.99'),\n createProduct('rec-4', 'Recommended Product 4', '29.99'),\n createProduct('rec-5', 'Recommended Product 5', '39.99'),\n createProduct('rec-6', 'Recommended Product 6', '49.99'),\n createProduct('rec-7', 'Recommended Product 7', '59.99'),\n createProduct('rec-8', 'Recommended Product 8', '69.99'),\n createProduct('rec-9', 'Recommended Product 9', '129.99'),\n ],\n pageInfo: createPagination(),\n },\n getRecommendedShops: {\n data: [\n createShop('shop-1', 'Amazing Store'),\n createShop('shop-2', 'Best Deals Shop'),\n createShop('shop-3', 'Great Products'),\n createShop('shop-4', 'Top Brands'),\n createShop('shop-5', 'Exclusive Offers'),\n ],\n pageInfo: createPagination(),\n },\n searchProductsByShop: {\n data: [\n createProduct('search-1', 'Search Result 1', '59.99'),\n createProduct('search-2', 'Search Result 2', '89.99'),\n createProduct('search-3', 'Search Result 3', '119.99'),\n createProduct('search-4', 'Search Result 4', '149.99'),\n createProduct('search-5', 'Search Result 5', '179.99'),\n ],\n pageInfo: createPagination(),\n },\n getOrders: {\n data: [\n {\n id: 'order-1',\n name: '#1001',\n lineItems: [\n {\n productTitle: 'Sample Product',\n variantTitle: 'Medium',\n quantity: 2,\n product: null,\n },\n ],\n shop: createShop('shop-1', 'Sample Shop'),\n },\n ],\n pageInfo: createPagination(),\n },\n getBuyerAttributes: {\n data: {\n genderAffinity: 'NEUTRAL' as Gender,\n categoryAffinities: [\n {id: 'cat1', name: 'Electronics'},\n {id: 'cat2', name: 'Clothing'},\n ],\n },\n },\n showFeedbackSheet: undefined,\n getPopularProducts: {\n data: [\n createProduct('pop-1', 'The Hero Snowboard', '702.95'),\n createProduct('pop-2', 'Snow Jacket', '605.95', '702.00'),\n createProduct('pop-3', 'Winter Gloves', '89.95'),\n createProduct('pop-4', 'Summer Gloves', '89.95'),\n createProduct('pop-5', 'Spring Gloves', '89.95'),\n createProduct('pop-6', 'Playstation 5', '499.95'),\n createProduct('pop-7', 'Xbox Series X', '499.95'),\n createProduct('pop-8', 'Nintendo Switch', '299.95'),\n createProduct('pop-9', 'Playstation 4', '299.95'),\n createProduct('pop-10', 'Nintendo 3DS', '89.95'),\n ],\n pageInfo: createPagination(),\n },\n share: {\n message: 'Shared!',\n success: true,\n },\n shareSingle: {\n message: 'Shared!',\n success: true,\n },\n getSavedProducts: {\n data: [\n createProduct('saved-1', 'Saved Product 1', '49.99'),\n createProduct('saved-2', 'Saved Product 2', '59.99'),\n createProduct('saved-3', 'Saved Product 3', '69.99'),\n createProduct('saved-4', 'Saved Product 4', '79.99'),\n createProduct('saved-5', 'Saved Product 5', '89.99'),\n ],\n pageInfo: createPagination(),\n },\n getRecentProducts: {\n data: [\n createProduct('recent-1', 'Recent Product 1', '59.99'),\n createProduct('recent-2', 'Recent Product 2', '69.99'),\n createProduct('recent-3', 'Recent Product 3', '79.99'),\n createProduct('recent-4', 'Recent Product 4', '89.99'),\n createProduct('recent-5', 'Recent Product 5', '99.99'),\n ],\n pageInfo: createPagination(),\n },\n getProductSearch: {\n data: [\n createProduct('search-1', 'Search Product 1', '39.99'),\n createProduct('search-2', 'Search Product 2', '19.99'),\n createProduct('search-3', 'Search Product 3', '29.99'),\n createProduct('search-4', 'Search Product 4', '49.99'),\n createProduct('search-5', 'Search Product 5', '9.99'),\n ],\n pageInfo: createPagination(),\n },\n getProducts: {\n data: [\n createProduct('prod-1', 'Product 1', '9.99'),\n createProduct('prod-2', 'Product 2', '19.99'),\n createProduct('prod-3', 'Product 3', '29.99'),\n createProduct('prod-4', 'Product 4', '39.99'),\n createProduct('prod-5', 'Product 5', '49.99'),\n ],\n },\n getProduct: {data: createProduct('prod-1', 'Sample Product')},\n getProductVariants: {\n data: [\n {\n id: 'variant-1',\n title: 'Variant 1',\n isFavorited: false,\n image: {url: 'https://example.com/variant-1.jpg'},\n price: {amount: '19.99', currencyCode: 'USD'},\n compareAtPrice: {amount: '29.99', currencyCode: 'USD'},\n },\n ],\n pageInfo: createPagination(),\n },\n getProductMedia: {\n data: [\n {\n id: 'media-1',\n image: {url: 'https://example.com/media-1.jpg'},\n mediaContentType: 'IMAGE',\n alt: 'Sample product image',\n },\n ],\n pageInfo: createPagination(),\n },\n getProductReviews: {\n data: [\n createProductReview('review-1'),\n createProductReview('review-2', {rating: 4, title: 'Pretty good'}),\n createProductReview('review-3', {\n rating: 3,\n title: 'Okay',\n merchantReply: 'Thanks for the feedback!',\n merchantRepliedAt: new Date().toISOString(),\n }),\n ],\n pageInfo: createPagination(),\n },\n getShop: {\n data: createShop('shop-1', 'Sample Shop', {featuredImagesLimit: 4}),\n },\n getRecentShops: {\n data: [\n createShop('recent-shop-1', 'Recent Shop 1'),\n createShop('recent-shop-2', 'Recent Shop 2'),\n createShop('recent-shop-3', 'Recent Shop 3'),\n ],\n pageInfo: createPagination(),\n },\n getFollowedShops: {\n data: [\n createShop('followed-shop-1', 'Followed Shop 1'),\n createShop('followed-shop-2', 'Followed Shop 2'),\n createShop('followed-shop-3', 'Followed Shop 3'),\n ],\n pageInfo: createPagination(),\n },\n previewProductInAr: undefined,\n createContent: {\n data: {\n publicId: 'content-123',\n externalId: null,\n image: {\n id: 'img-123',\n url: 'https://cdn.shopify.com/s/files/1/0633/6574/2742/files/Namnlosdesign-47.png?v=1740438079',\n width: 800,\n height: 600,\n },\n title: 'Mock Content',\n description: 'This is a mock content item',\n visibility: ['DISCOVERABLE'],\n shareableUrl: 'https://example.com/content/123',\n products: null,\n },\n },\n getContent: {\n data: [\n {\n publicId: 'content-123',\n image: {\n id: 'img-123',\n url: 'https://cdn.shopify.com/s/files/1/0633/6574/2742/files/Namnlosdesign-47.png?v=1740438079',\n width: 800,\n height: 600,\n },\n title: 'Mock Content',\n visibility: ['DISCOVERABLE'],\n status: MinisContentStatus.READY,\n },\n ],\n },\n generateUserToken: {\n data: {\n token: 'user-token-123',\n expiresAt: '2025-01-01',\n userState: UserState.VERIFIED,\n },\n },\n navigateToCart: undefined,\n requestPermission: {\n granted: true,\n },\n reportError: undefined,\n reportFetch: undefined,\n } as const\n\n const mock: Partial<ShopActions> = {}\n for (const key in results) {\n if (Object.prototype.hasOwnProperty.call(results, key)) {\n // @ts-expect-error: dynamic assignment is safe due to exhaustive mapping\n mock[key] = makeMockMethod(\n key as keyof ShopActions,\n results[key as keyof typeof results]\n )\n }\n }\n return mock as ShopActions\n}\n\n// Detect if running on a mobile device\nconst isMobile = (): boolean => {\n const userAgent = navigator.userAgent.toLowerCase()\n const isIOS = /iphone|ipad|ipod/.test(userAgent)\n const isAndroid = /android/.test(userAgent)\n\n return isIOS || isAndroid\n}\n\nexport const injectMocks = ({force}: {force?: boolean} = {}) => {\n // Only inject mocks if we aren't on a mobile device or we force it\n if (isMobile() && !force) {\n return\n }\n\n if (!window.minisSDK) {\n window.minisSDK = makeMockActions()\n window.minisParams = {\n handle: 'mock-handle',\n initialUrl: '/',\n platform: 'web',\n }\n }\n}\n"],"names":["SAMPLE_IMAGE_NAMES","hashString","str","hash","i","createProduct","id","title","price","compareAtPrice","imageIndex","imageName","createShop","createProductReview","overrides","name","options","themeType","shouldHaveBrandSettings","featuredImagesCount","featuredImages","_","getThemeColors","createHeaderTheme","createPagination","hasNext","createProductList","products","logMockAction","action","params","makeMockMethod","key","result","makeMockActions","results","MinisContentStatus","UserState","mock","isMobile","userAgent","isIOS","isAndroid","injectMocks","force"],"mappings":";;AASA,MAAMA,IAAqB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAGMC,IAAa,CAACC,MAAwB;AAC1C,MAAIC,IAAO;AACX,WAASC,IAAI,GAAGA,IAAIF,EAAI,QAAQE;AAC9B,IAAAD,KAAQA,KAAQ,KAAKA,IAAOD,EAAI,WAAWE,CAAC,GACpCD,KAAA;AAEH,SAAA,KAAK,IAAIA,CAAI;AACtB,GAGaE,IAAgB,CAC3BC,GACAC,GACAC,IAAQ,SACRC,MACY;AACZ,QAAMC,IAAaT,EAAWK,CAAE,IAAIN,EAAmB,QACjDW,IAAYX,EAAmBU,CAAU;AAExC,SAAA;AAAA,IACL,IAAAJ;AAAA,IACA,OAAAC;AAAA,IACA,OAAO,EAAC,QAAQC,GAAO,cAAc,MAAK;A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;AAAA,IACR,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAEJ;"}
|
|
@@ -18,9 +18,6 @@
|
|
|
18
18
|
"useCreateImageContent": [
|
|
19
19
|
"CREATE_CONTENT"
|
|
20
20
|
],
|
|
21
|
-
"useCuratedProducts": [
|
|
22
|
-
"GET_CURATED_PRODUCTS"
|
|
23
|
-
],
|
|
24
21
|
"useCurrentUser": [
|
|
25
22
|
"GET_CURRENT_USER"
|
|
26
23
|
],
|
|
@@ -73,6 +70,9 @@
|
|
|
73
70
|
"useProductMedia": [
|
|
74
71
|
"GET_PRODUCT_MEDIA"
|
|
75
72
|
],
|
|
73
|
+
"useProductReviews": [
|
|
74
|
+
"GET_PRODUCT_REVIEWS"
|
|
75
|
+
],
|
|
76
76
|
"useProductSearch": [
|
|
77
77
|
"GET_PRODUCT_SEARCH"
|
|
78
78
|
],
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/shop-minis-react",
|
|
3
3
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typescript": ">=5.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@shopify/shop-minis-platform": "0.
|
|
49
|
+
"@shopify/shop-minis-platform": "0.9.0",
|
|
50
50
|
"@tailwindcss/vite": "4.1.8",
|
|
51
51
|
"@tanstack/react-query": "5.86.0",
|
|
52
52
|
"@types/color": "3.0.6",
|
package/src/hooks/index.ts
CHANGED
|
@@ -18,10 +18,10 @@ export * from './product/useProduct'
|
|
|
18
18
|
export * from './product/useProducts'
|
|
19
19
|
export * from './product/useProductVariants'
|
|
20
20
|
export * from './product/useProductMedia'
|
|
21
|
+
export * from './product/useProductReviews'
|
|
21
22
|
export * from './product/useProductSearch'
|
|
22
23
|
export * from './product/useRecommendedProducts'
|
|
23
24
|
export * from './product/usePopularProducts'
|
|
24
|
-
export * from './product/useCuratedProducts'
|
|
25
25
|
|
|
26
26
|
// - Storage Hooks
|
|
27
27
|
export * from './storage/useAsyncStorage'
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
|
|
2
|
+
import {useShopActions} from '../../internal/useShopActions'
|
|
3
|
+
import {
|
|
4
|
+
PaginatedDataHookOptionsBase,
|
|
5
|
+
PaginatedDataHookReturnsBase,
|
|
6
|
+
ProductReview,
|
|
7
|
+
} from '../../types'
|
|
8
|
+
|
|
9
|
+
export interface UseProductReviewsParams extends PaginatedDataHookOptionsBase {
|
|
10
|
+
/**
|
|
11
|
+
* The product ID to fetch reviews for.
|
|
12
|
+
*/
|
|
13
|
+
id: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface UseProductReviewsReturns extends PaginatedDataHookReturnsBase {
|
|
17
|
+
/**
|
|
18
|
+
* The product reviews returned from the query.
|
|
19
|
+
*/
|
|
20
|
+
reviews: ProductReview[] | null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const useProductReviews = (
|
|
24
|
+
params: UseProductReviewsParams
|
|
25
|
+
): UseProductReviewsReturns => {
|
|
26
|
+
const {getProductReviews} = useShopActions()
|
|
27
|
+
const {id, skip = false, ...restParams} = params
|
|
28
|
+
|
|
29
|
+
const {data, ...rest} = useShopActionInfiniteQuery(
|
|
30
|
+
['productReviews', id, restParams],
|
|
31
|
+
getProductReviews,
|
|
32
|
+
{id, ...restParams},
|
|
33
|
+
{skip}
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
...rest,
|
|
38
|
+
reviews: data,
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/mocks.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Product,
|
|
3
|
+
ProductReview,
|
|
3
4
|
Gender,
|
|
4
5
|
UserState,
|
|
5
6
|
MinisContentStatus,
|
|
@@ -51,6 +52,22 @@ export const createProduct = (
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
export const createProductReview = (
|
|
56
|
+
id: string,
|
|
57
|
+
overrides: Partial<ProductReview> = {}
|
|
58
|
+
): ProductReview => {
|
|
59
|
+
return {
|
|
60
|
+
id,
|
|
61
|
+
rating: 5,
|
|
62
|
+
title: 'Great product',
|
|
63
|
+
body: 'Loved it. Would buy again.',
|
|
64
|
+
submittedAt: new Date().toISOString(),
|
|
65
|
+
merchantReply: null,
|
|
66
|
+
merchantRepliedAt: null,
|
|
67
|
+
...overrides,
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
54
71
|
export const createShop = (
|
|
55
72
|
id: string,
|
|
56
73
|
name: string,
|
|
@@ -414,13 +431,6 @@ export function makeMockActions(): ShopActions {
|
|
|
414
431
|
message: 'Shared!',
|
|
415
432
|
success: true,
|
|
416
433
|
},
|
|
417
|
-
getCuratedProducts: {
|
|
418
|
-
data: [
|
|
419
|
-
createProduct('cur-1', 'Curated Product 1', '79.99'),
|
|
420
|
-
createProduct('cur-2', 'Curated Product 2', '129.99'),
|
|
421
|
-
],
|
|
422
|
-
pageInfo: createPagination(),
|
|
423
|
-
},
|
|
424
434
|
getSavedProducts: {
|
|
425
435
|
data: [
|
|
426
436
|
createProduct('saved-1', 'Saved Product 1', '49.99'),
|
|
@@ -485,6 +495,19 @@ export function makeMockActions(): ShopActions {
|
|
|
485
495
|
],
|
|
486
496
|
pageInfo: createPagination(),
|
|
487
497
|
},
|
|
498
|
+
getProductReviews: {
|
|
499
|
+
data: [
|
|
500
|
+
createProductReview('review-1'),
|
|
501
|
+
createProductReview('review-2', {rating: 4, title: 'Pretty good'}),
|
|
502
|
+
createProductReview('review-3', {
|
|
503
|
+
rating: 3,
|
|
504
|
+
title: 'Okay',
|
|
505
|
+
merchantReply: 'Thanks for the feedback!',
|
|
506
|
+
merchantRepliedAt: new Date().toISOString(),
|
|
507
|
+
}),
|
|
508
|
+
],
|
|
509
|
+
pageInfo: createPagination(),
|
|
510
|
+
},
|
|
488
511
|
getShop: {
|
|
489
512
|
data: createShop('shop-1', 'Sample Shop', {featuredImagesLimit: 4}),
|
|
490
513
|
},
|
package/src/test-utils.tsx
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useShopActions as u } from "../../internal/useShopActions.js";
|
|
2
|
-
import { useShopActionInfiniteQuery as n } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
|
|
3
|
-
const p = (o) => {
|
|
4
|
-
const { getCuratedProducts: r } = u(), { skip: s, ...t } = o ?? {}, { data: c, ...e } = n(
|
|
5
|
-
["curatedProducts", t],
|
|
6
|
-
r,
|
|
7
|
-
t,
|
|
8
|
-
{ skip: s }
|
|
9
|
-
);
|
|
10
|
-
return {
|
|
11
|
-
...e,
|
|
12
|
-
products: c
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
p as useCuratedProducts
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=useCuratedProducts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCuratedProducts.js","sources":["../../../src/hooks/product/useCuratedProducts.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n Product,\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n} from '../../types'\n\ninterface UseCuratedProductsParams extends PaginatedDataHookOptionsBase {\n handle: string\n requiredTags?: string[]\n anyOfTags?: string[]\n}\n\ninterface UseCuratedProductsReturns extends PaginatedDataHookReturnsBase {\n products: Product[] | null\n}\n\n/**\n * @param options - The options for the query\n */\nexport const useCuratedProducts = (\n params: UseCuratedProductsParams\n): UseCuratedProductsReturns => {\n const {getCuratedProducts} = useShopActions()\n const {skip, ...shopActionParams} = params ?? {}\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['curatedProducts', shopActionParams],\n getCuratedProducts,\n shopActionParams,\n {skip}\n )\n\n return {\n ...rest,\n products: data,\n }\n}\n"],"names":["useCuratedProducts","params","getCuratedProducts","useShopActions","skip","shopActionParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAqBa,MAAAA,IAAqB,CAChCC,MAC8B;AACxB,QAAA,EAAC,oBAAAC,EAAkB,IAAIC,EAAe,GACtC,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIJ,KAAU,CAAC,GAEzC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,mBAAmBH,CAAgB;AAAA,IACpCH;AAAA,IACAG;AAAA,IACA,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,UAAUD;AAAA,EACZ;AACF;"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
|
|
2
|
-
import {useShopActions} from '../../internal/useShopActions'
|
|
3
|
-
import {
|
|
4
|
-
Product,
|
|
5
|
-
PaginatedDataHookOptionsBase,
|
|
6
|
-
PaginatedDataHookReturnsBase,
|
|
7
|
-
} from '../../types'
|
|
8
|
-
|
|
9
|
-
interface UseCuratedProductsParams extends PaginatedDataHookOptionsBase {
|
|
10
|
-
handle: string
|
|
11
|
-
requiredTags?: string[]
|
|
12
|
-
anyOfTags?: string[]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface UseCuratedProductsReturns extends PaginatedDataHookReturnsBase {
|
|
16
|
-
products: Product[] | null
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @param options - The options for the query
|
|
21
|
-
*/
|
|
22
|
-
export const useCuratedProducts = (
|
|
23
|
-
params: UseCuratedProductsParams
|
|
24
|
-
): UseCuratedProductsReturns => {
|
|
25
|
-
const {getCuratedProducts} = useShopActions()
|
|
26
|
-
const {skip, ...shopActionParams} = params ?? {}
|
|
27
|
-
|
|
28
|
-
const {data, ...rest} = useShopActionInfiniteQuery(
|
|
29
|
-
['curatedProducts', shopActionParams],
|
|
30
|
-
getCuratedProducts,
|
|
31
|
-
shopActionParams,
|
|
32
|
-
{skip}
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
...rest,
|
|
37
|
-
products: data,
|
|
38
|
-
}
|
|
39
|
-
}
|