@shopify/shop-minis-react 0.0.0-snapshot.20251222174301 → 0.0.0-snapshot.20251224113248

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.
Files changed (44) hide show
  1. package/dist/hooks/intents/useInvokeIntentAction.js +10 -0
  2. package/dist/hooks/intents/useInvokeIntentAction.js.map +1 -0
  3. package/dist/hooks/intents/useQueryIntents.js +10 -0
  4. package/dist/hooks/intents/useQueryIntents.js.map +1 -0
  5. package/dist/hooks/intents/useSelectProduct.js +21 -0
  6. package/dist/hooks/intents/useSelectProduct.js.map +1 -0
  7. package/dist/index.js +127 -133
  8. package/dist/index.js.map +1 -1
  9. package/dist/mocks.js +42 -7
  10. package/dist/mocks.js.map +1 -1
  11. package/dist/shop-minis-platform/src/actions/scopes.js +36 -0
  12. package/dist/shop-minis-platform/src/actions/scopes.js.map +1 -0
  13. package/package.json +2 -2
  14. package/src/hooks/intents/index.ts +21 -25
  15. package/src/hooks/intents/useInvokeIntentAction.ts +12 -0
  16. package/src/hooks/intents/useQueryIntents.ts +25 -0
  17. package/src/hooks/intents/useSelectProduct.ts +48 -0
  18. package/src/mocks.ts +35 -0
  19. package/dist/hooks/intents/useBarcodeScanner.js +0 -10
  20. package/dist/hooks/intents/useBarcodeScanner.js.map +0 -1
  21. package/dist/hooks/intents/useContentShare.js +0 -10
  22. package/dist/hooks/intents/useContentShare.js.map +0 -1
  23. package/dist/hooks/intents/useImageCapture.js +0 -10
  24. package/dist/hooks/intents/useImageCapture.js.map +0 -1
  25. package/dist/hooks/intents/useLocationSelection.js +0 -10
  26. package/dist/hooks/intents/useLocationSelection.js.map +0 -1
  27. package/dist/hooks/intents/usePaymentRequest.js +0 -10
  28. package/dist/hooks/intents/usePaymentRequest.js.map +0 -1
  29. package/dist/hooks/intents/useProductSelection.js +0 -10
  30. package/dist/hooks/intents/useProductSelection.js.map +0 -1
  31. package/dist/internal/useHandleIntent.js +0 -26
  32. package/dist/internal/useHandleIntent.js.map +0 -1
  33. package/dist/internal/useShopIntents.js +0 -7
  34. package/dist/internal/useShopIntents.js.map +0 -1
  35. package/dist/shop-minis-platform/src/intents/shared.js +0 -19
  36. package/dist/shop-minis-platform/src/intents/shared.js.map +0 -1
  37. package/src/hooks/intents/useBarcodeScanner.ts +0 -43
  38. package/src/hooks/intents/useContentShare.ts +0 -47
  39. package/src/hooks/intents/useImageCapture.ts +0 -45
  40. package/src/hooks/intents/useLocationSelection.ts +0 -45
  41. package/src/hooks/intents/usePaymentRequest.ts +0 -47
  42. package/src/hooks/intents/useProductSelection.ts +0 -45
  43. package/src/internal/useHandleIntent.ts +0 -101
  44. package/src/internal/useShopIntents.ts +0 -13
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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AAO,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 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 queryIntents: {\n intents: [\n {\n intentType: 'select:shopify/Product',\n provider: 'shop',\n providerName: 'Shop',\n displayName: 'Select Products',\n description: 'Let user select products from catalog',\n category: 'commerce',\n version: '1.0.0',\n inputSchema: {\n type: 'object',\n properties: {\n multiSelect: {type: 'boolean', default: false},\n maxSelections: {type: 'number', minimum: 1},\n },\n },\n outputSchema: {\n type: 'object',\n properties: {\n type: {const: 'product'},\n ids: {type: 'array', items: {type: 'string'}},\n },\n required: ['type', 'ids'],\n },\n },\n ],\n },\n invokeIntent: {\n resultCode: 'SUCCESS',\n output: {\n type: 'product',\n ids: ['mock-product-1', 'mock-product-2'],\n },\n },\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;AA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,OAAO,UAAS;AAAA,cACvB,KAAK,EAAC,MAAM,SAAS,OAAO,EAAC,MAAM,SAAS,EAAA;AAAA,YAC9C;AAAA,YACA,UAAU,CAAC,QAAQ,KAAK;AAAA,UAAA;AAAA,QAC1B;AAAA,MACF;AAAA,IAEJ;AAAA,IACA,cAAc;AAAA,MACZ,YAAY;AAAA,MACZ,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,KAAK,CAAC,kBAAkB,gBAAgB;AAAA,MAAA;AAAA,IAC1C;AAAA,EAEJ,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;"}
@@ -0,0 +1,36 @@
1
+ var E = /* @__PURE__ */ ((_) => (_.OPENID = "openid", _.USER_SETTINGS_READ = "user_settings:read", _.PROFILE = "profile", _.PRODUCTS_RECENT_READ = "products:recent:read", _.PRODUCTS_RECOMMENDATIONS_READ = "products:recommendations:read", _.SHOPS_RECENT_READ = "shops:recent:read", _.SHOPS_FOLLOWS = "shops:follows", _.SHOPS_FOLLOWS_READ = "shops:follows:read", _.SHOPS_FOLLOWS_WRITE = "shops:follows:write", _.SHOPS_RECOMMENDATIONS_READ = "shops:recommendations:read", _.ORDERS = "orders", _.PRODUCT_LIST = "product_list", _.PRODUCT_LIST_READ = "product_list:read", _.PRODUCT_LIST_WRITE = "product_list:write", _.PRODUCT_LIST_ITEM_WRITE = "product_list_item:write", _))(E || {});
2
+ const r = {
3
+ // User
4
+ GENERATE_USER_TOKEN: "openid",
5
+ GET_ACCOUNT_INFORMATION: "profile",
6
+ GET_BUYER_ATTRIBUTES: "profile",
7
+ GET_CURRENT_USER: "user_settings:read",
8
+ // Shops
9
+ GET_FOLLOWED_SHOPS: "shops:follows:read",
10
+ GET_RECENT_SHOPS: "shops:recent:read",
11
+ GET_RECOMMENDED_SHOPS: "shops:recommendations:read",
12
+ FOLLOW_SHOP: "shops:follows:write",
13
+ UNFOLLOW_SHOP: "shops:follows:write",
14
+ // Products
15
+ GET_RECENT_PRODUCTS: "products:recent:read",
16
+ GET_RECOMMENDED_PRODUCTS: "products:recommendations:read",
17
+ // Orders
18
+ GET_ORDERS: "orders",
19
+ // Product lists
20
+ ADD_PRODUCT_LIST: "product_list:write",
21
+ ADD_PRODUCT_LIST_ITEM: "product_list_item:write",
22
+ FAVORITE: "product_list:write",
23
+ UNFAVORITE: "product_list:write",
24
+ REMOVE_PRODUCT_LIST: "product_list:write",
25
+ REMOVE_PRODUCT_LIST_ITEM: "product_list_item:write",
26
+ RENAME_PRODUCT_LIST: "product_list:write",
27
+ GET_SAVED_PRODUCTS: "product_list:read",
28
+ GET_PRODUCT_LIST: "product_list:read",
29
+ GET_PRODUCT_LISTS: "product_list:read"
30
+ /* PRODUCT_LIST_READ */
31
+ };
32
+ export {
33
+ r as ActionToScopesMapping,
34
+ E as Scope
35
+ };
36
+ //# sourceMappingURL=scopes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopes.js","sources":["../../../../../shop-minis-platform/src/actions/scopes.ts"],"sourcesContent":["import {ShopActionEvents} from '@shopify/shop-minis-platform/actions'\n\n// This enum should always match `MiniScopeEnum` in `shop-types`\n/* eslint-disable @shopify/typescript/prefer-pascal-case-enums */\nexport enum Scope {\n // User\n OPENID = 'openid',\n USER_SETTINGS_READ = 'user_settings:read',\n PROFILE = 'profile',\n\n // Products\n PRODUCTS_RECENT_READ = 'products:recent:read',\n PRODUCTS_RECOMMENDATIONS_READ = 'products:recommendations:read',\n\n // Shops\n SHOPS_RECENT_READ = 'shops:recent:read',\n SHOPS_FOLLOWS = 'shops:follows',\n SHOPS_FOLLOWS_READ = 'shops:follows:read',\n SHOPS_FOLLOWS_WRITE = 'shops:follows:write',\n SHOPS_RECOMMENDATIONS_READ = 'shops:recommendations:read',\n\n // Orders\n ORDERS = 'orders',\n\n // Product lists\n PRODUCT_LIST = 'product_list',\n PRODUCT_LIST_READ = 'product_list:read',\n PRODUCT_LIST_WRITE = 'product_list:write',\n PRODUCT_LIST_ITEM_WRITE = 'product_list_item:write',\n}\n/* eslint-enable @shopify/typescript/prefer-pascal-case-enums */\n\nexport const ActionToScopesMapping: {\n [key in keyof ShopActionEvents]?: Scope\n} = {\n // User\n GENERATE_USER_TOKEN: Scope.OPENID,\n GET_ACCOUNT_INFORMATION: Scope.PROFILE,\n GET_BUYER_ATTRIBUTES: Scope.PROFILE,\n GET_CURRENT_USER: Scope.USER_SETTINGS_READ,\n\n // Shops\n GET_FOLLOWED_SHOPS: Scope.SHOPS_FOLLOWS_READ,\n GET_RECENT_SHOPS: Scope.SHOPS_RECENT_READ,\n GET_RECOMMENDED_SHOPS: Scope.SHOPS_RECOMMENDATIONS_READ,\n FOLLOW_SHOP: Scope.SHOPS_FOLLOWS_WRITE,\n UNFOLLOW_SHOP: Scope.SHOPS_FOLLOWS_WRITE,\n\n // Products\n GET_RECENT_PRODUCTS: Scope.PRODUCTS_RECENT_READ,\n GET_RECOMMENDED_PRODUCTS: Scope.PRODUCTS_RECOMMENDATIONS_READ,\n\n // Orders\n GET_ORDERS: Scope.ORDERS,\n\n // Product lists\n ADD_PRODUCT_LIST: Scope.PRODUCT_LIST_WRITE,\n ADD_PRODUCT_LIST_ITEM: Scope.PRODUCT_LIST_ITEM_WRITE,\n FAVORITE: Scope.PRODUCT_LIST_WRITE,\n UNFAVORITE: Scope.PRODUCT_LIST_WRITE,\n REMOVE_PRODUCT_LIST: Scope.PRODUCT_LIST_WRITE,\n REMOVE_PRODUCT_LIST_ITEM: Scope.PRODUCT_LIST_ITEM_WRITE,\n RENAME_PRODUCT_LIST: Scope.PRODUCT_LIST_WRITE,\n GET_SAVED_PRODUCTS: Scope.PRODUCT_LIST_READ,\n GET_PRODUCT_LIST: Scope.PRODUCT_LIST_READ,\n GET_PRODUCT_LISTS: Scope.PRODUCT_LIST_READ,\n} as const\n"],"names":["Scope","ActionToScopesMapping"],"mappings":"AAIY,IAAAA,sBAAAA,OAEVA,EAAA,SAAS,UACTA,EAAA,qBAAqB,sBACrBA,EAAA,UAAU,WAGVA,EAAA,uBAAuB,wBACvBA,EAAA,gCAAgC,iCAGhCA,EAAA,oBAAoB,qBACpBA,EAAA,gBAAgB,iBAChBA,EAAA,qBAAqB,sBACrBA,EAAA,sBAAsB,uBACtBA,EAAA,6BAA6B,8BAG7BA,EAAA,SAAS,UAGTA,EAAA,eAAe,gBACfA,EAAA,oBAAoB,qBACpBA,EAAA,qBAAqB,sBACrBA,EAAA,0BAA0B,2BAxBhBA,IAAAA,KAAA,CAAA,CAAA;AA4BL,MAAMC,IAET;AAAA;AAAA,EAEF,qBAAqB;AAAA,EACrB,yBAAyB;AAAA,EACzB,sBAAsB;AAAA,EACtB,kBAAkB;AAAA;AAAA,EAGlB,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,aAAa;AAAA,EACb,eAAe;AAAA;AAAA,EAGf,qBAAqB;AAAA,EACrB,0BAA0B;AAAA;AAAA,EAG1B,YAAY;AAAA;AAAA,EAGZ,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,qBAAqB;AAAA,EACrB,0BAA0B;AAAA,EAC1B,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA;AACrB;"}
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.0.0-snapshot.20251222174301",
4
+ "version": "0.0.0-snapshot.20251224113248",
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.0.0-snapshot.20251222174301",
49
+ "@shopify/shop-minis-platform": "0.0.0-snapshot.20251224113248",
50
50
  "@tailwindcss/vite": "4.1.8",
51
51
  "@tanstack/react-query": "5.86.0",
52
52
  "@types/color": "3.0.6",
@@ -1,21 +1,28 @@
1
1
  /**
2
2
  * Shop Intents Hooks
3
3
  *
4
- * React hooks for triggering interactive flows in the Shop app.
5
- * Each hook wraps an intent and provides a clean API for handling results.
4
+ * React hooks for discovering and invoking intents.
6
5
  *
7
6
  * @example
8
- * import { useProductSelection } from '@shopify/shop-minis-react'
7
+ * import { useQueryIntents, useInvokeIntentAction } from '@shopify/shop-minis-react'
9
8
  *
10
9
  * const MyComponent = () => {
11
- * const selectProducts = useProductSelection({
12
- * onCancel: () => console.log('User cancelled')
13
- * })
10
+ * const queryIntents = useQueryIntents()
11
+ * const invokeIntent = useInvokeIntentAction()
14
12
  *
15
13
  * const handleSelect = async () => {
16
- * const result = await selectProducts({ multiSelect: true })
17
- * if (result) {
18
- * console.log('Selected:', result.products)
14
+ * // Query available intents
15
+ * const intents = await queryIntents({category: 'commerce'})
16
+ *
17
+ * // Invoke intent
18
+ * const result = await invokeIntent({
19
+ * provider: 'shop',
20
+ * intentType: 'select:shopify/Product',
21
+ * input: {multiSelect: true}
22
+ * })
23
+ *
24
+ * if (result.resultCode === 'SUCCESS') {
25
+ * console.log('Selected:', result.output.ids)
19
26
  * }
20
27
  * }
21
28
  *
@@ -23,20 +30,9 @@
23
30
  * }
24
31
  */
25
32
 
26
- export {useProductSelection} from './useProductSelection'
27
- export type {ProductSelectionFunction} from './useProductSelection'
28
-
29
- export {useImageCapture} from './useImageCapture'
30
- export type {ImageCaptureFunction} from './useImageCapture'
31
-
32
- export {useContentShare} from './useContentShare'
33
- export type {ContentShareFunction} from './useContentShare'
34
-
35
- export {useLocationSelection} from './useLocationSelection'
36
- export type {LocationSelectionFunction} from './useLocationSelection'
37
-
38
- export {useBarcodeScanner} from './useBarcodeScanner'
39
- export type {BarcodeScannerFunction} from './useBarcodeScanner'
33
+ // Core intent actions
34
+ export {useQueryIntents} from './useQueryIntents'
35
+ export {useInvokeIntentAction} from './useInvokeIntentAction'
40
36
 
41
- export {usePaymentRequest} from './usePaymentRequest'
42
- export type {PaymentRequestFunction} from './usePaymentRequest'
37
+ // Convenience hooks (wrap invokeIntent with specific intent types)
38
+ export {useSelectProduct} from './useSelectProduct'
@@ -0,0 +1,12 @@
1
+ import {useHandleAction} from '../../internal/useHandleAction'
2
+ import {useShopActions} from '../../internal/useShopActions'
3
+
4
+ /**
5
+ * Hook to invoke an intent
6
+ *
7
+ * Unified API for invoking intents.
8
+ */
9
+ export const useInvokeIntentAction = () => {
10
+ const actions = useShopActions()
11
+ return useHandleAction(actions.invokeIntent)
12
+ }
@@ -0,0 +1,25 @@
1
+ import {useHandleAction} from '../../internal/useHandleAction'
2
+ import {useShopActions} from '../../internal/useShopActions'
3
+
4
+ /**
5
+ * Hook to query available intents
6
+ *
7
+ * Returns intents that match the query criteria.
8
+ * Works for both first-party Shop intents and third-party Mini intents.
9
+ *
10
+ * @example
11
+ * const queryIntents = useQueryIntents()
12
+ *
13
+ * // Get all intents
14
+ * const allIntents = await queryIntents()
15
+ *
16
+ * // Filter by category
17
+ * const mediaIntents = await queryIntents({category: 'media'})
18
+ *
19
+ * // Search
20
+ * const results = await queryIntents({search: 'product'})
21
+ */
22
+ export const useQueryIntents = () => {
23
+ const actions = useShopActions()
24
+ return useHandleAction(actions.queryIntents)
25
+ }
@@ -0,0 +1,48 @@
1
+ import {useCallback} from 'react'
2
+
3
+ import {useInvokeIntentAction} from './useInvokeIntentAction'
4
+
5
+ /**
6
+ * Convenience hook for selecting products
7
+ *
8
+ * Wraps the unified invokeIntent action with product-specific defaults.
9
+ *
10
+ * @example
11
+ * const selectProduct = useSelectProduct()
12
+ *
13
+ * const result = await selectProduct({
14
+ * multiSelect: true,
15
+ * maxSelections: 5
16
+ * })
17
+ *
18
+ * if (result) {
19
+ * console.log('Selected IDs:', result.ids)
20
+ * }
21
+ */
22
+ export const useSelectProduct = () => {
23
+ const invokeIntent = useInvokeIntentAction()
24
+
25
+ return useCallback(
26
+ async (input: {
27
+ multiSelect?: boolean
28
+ maxSelections?: number
29
+ title?: string
30
+ subtitle?: string
31
+ shopId?: string
32
+ categories?: string[]
33
+ }) => {
34
+ const result = await invokeIntent({
35
+ provider: 'shop',
36
+ intentType: 'select:shopify/Product',
37
+ input,
38
+ })
39
+
40
+ if (result.resultCode === 'SUCCESS') {
41
+ return result.output as {type: 'product'; ids: string[]}
42
+ }
43
+
44
+ return undefined
45
+ },
46
+ [invokeIntent]
47
+ )
48
+ }
package/src/mocks.ts CHANGED
@@ -551,6 +551,41 @@ export function makeMockActions(): ShopActions {
551
551
  },
552
552
  reportError: undefined,
553
553
  reportFetch: undefined,
554
+ queryIntents: {
555
+ intents: [
556
+ {
557
+ intentType: 'select:shopify/Product',
558
+ provider: 'shop',
559
+ providerName: 'Shop',
560
+ displayName: 'Select Products',
561
+ description: 'Let user select products from catalog',
562
+ category: 'commerce',
563
+ version: '1.0.0',
564
+ inputSchema: {
565
+ type: 'object',
566
+ properties: {
567
+ multiSelect: {type: 'boolean', default: false},
568
+ maxSelections: {type: 'number', minimum: 1},
569
+ },
570
+ },
571
+ outputSchema: {
572
+ type: 'object',
573
+ properties: {
574
+ type: {const: 'product'},
575
+ ids: {type: 'array', items: {type: 'string'}},
576
+ },
577
+ required: ['type', 'ids'],
578
+ },
579
+ },
580
+ ],
581
+ },
582
+ invokeIntent: {
583
+ resultCode: 'SUCCESS',
584
+ output: {
585
+ type: 'product',
586
+ ids: ['mock-product-1', 'mock-product-2'],
587
+ },
588
+ },
554
589
  } as const
555
590
 
556
591
  const mock: Partial<ShopActions> = {}
@@ -1,10 +0,0 @@
1
- import { useHandleIntent as t } from "../../internal/useHandleIntent.js";
2
- import { useShopIntents as o } from "../../internal/useShopIntents.js";
3
- const c = (n) => {
4
- const e = o();
5
- return t(e.scanBarcode, n);
6
- };
7
- export {
8
- c as useBarcodeScanner
9
- };
10
- //# sourceMappingURL=useBarcodeScanner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBarcodeScanner.js","sources":["../../../src/hooks/intents/useBarcodeScanner.ts"],"sourcesContent":["import {\n useHandleIntent,\n HandleIntentOptions,\n} from '../../internal/useHandleIntent'\nimport {useShopIntents} from '../../internal/useShopIntents'\n\nimport type {\n ScanBarcodeIntentParams,\n ScanBarcodeIntentResult,\n} from '@shopify/shop-minis-platform'\n\n/**\n * Hook to scan barcodes or QR codes\n *\n * This intent opens the camera to scan barcodes or QR codes.\n *\n * @example\n * const scanBarcode = useBarcodeScanner({\n * onCancel: () => console.log('User cancelled'),\n * })\n *\n * const result = await scanBarcode({\n * types: ['qr', 'ean13'],\n * instruction: 'Scan product barcode'\n * })\n *\n * if (result) {\n * console.log('Scanned:', result.barcodes)\n * }\n */\nexport const useBarcodeScanner = (\n options?: HandleIntentOptions<ScanBarcodeIntentResult>\n) => {\n const intents = useShopIntents()\n return useHandleIntent(intents.scanBarcode, options)\n}\n\n/**\n * Type helper for the barcode scanner function\n */\nexport type BarcodeScannerFunction = (\n params: ScanBarcodeIntentParams\n) => Promise<ScanBarcodeIntentResult | void>\n"],"names":["useBarcodeScanner","options","intents","useShopIntents","useHandleIntent"],"mappings":";;AA8Ba,MAAAA,IAAoB,CAC/BC,MACG;AACH,QAAMC,IAAUC,EAAe;AACxB,SAAAC,EAAgBF,EAAQ,aAAaD,CAAO;AACrD;"}
@@ -1,10 +0,0 @@
1
- import { useHandleIntent as e } from "../../internal/useHandleIntent.js";
2
- import { useShopIntents as o } from "../../internal/useShopIntents.js";
3
- const m = (t) => {
4
- const n = o();
5
- return e(n.shareContent, t);
6
- };
7
- export {
8
- m as useContentShare
9
- };
10
- //# sourceMappingURL=useContentShare.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useContentShare.js","sources":["../../../src/hooks/intents/useContentShare.ts"],"sourcesContent":["import {\n useHandleIntent,\n HandleIntentOptions,\n} from '../../internal/useHandleIntent'\nimport {useShopIntents} from '../../internal/useShopIntents'\n\nimport type {\n ShareContentIntentParams,\n ShareContentIntentResult,\n} from '@shopify/shop-minis-platform'\n\n/**\n * Hook to share content via the Shop app's native share sheet\n *\n * This intent opens the native share sheet to let the user\n * share content to various platforms.\n *\n * @example\n * const shareContent = useContentShare({\n * onCancel: () => console.log('User cancelled sharing'),\n * })\n *\n * const result = await shareContent({\n * type: 'product',\n * content: {\n * title: 'Check out this product!',\n * url: 'https://shop.app/products/123'\n * }\n * })\n *\n * if (result?.shared) {\n * console.log('Content shared to:', result.platform)\n * }\n */\nexport const useContentShare = (\n options?: HandleIntentOptions<ShareContentIntentResult>\n) => {\n const intents = useShopIntents()\n return useHandleIntent(intents.shareContent, options)\n}\n\n/**\n * Type helper for the content share function\n */\nexport type ContentShareFunction = (\n params: ShareContentIntentParams\n) => Promise<ShareContentIntentResult | void>\n"],"names":["useContentShare","options","intents","useShopIntents","useHandleIntent"],"mappings":";;AAkCa,MAAAA,IAAkB,CAC7BC,MACG;AACH,QAAMC,IAAUC,EAAe;AACxB,SAAAC,EAAgBF,EAAQ,cAAcD,CAAO;AACtD;"}
@@ -1,10 +0,0 @@
1
- import { useHandleIntent as n } from "../../internal/useHandleIntent.js";
2
- import { useShopIntents as r } from "../../internal/useShopIntents.js";
3
- const m = (t) => {
4
- const e = r();
5
- return n(e.captureImage, t);
6
- };
7
- export {
8
- m as useImageCapture
9
- };
10
- //# sourceMappingURL=useImageCapture.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useImageCapture.js","sources":["../../../src/hooks/intents/useImageCapture.ts"],"sourcesContent":["import {\n useHandleIntent,\n HandleIntentOptions,\n} from '../../internal/useHandleIntent'\nimport {useShopIntents} from '../../internal/useShopIntents'\n\nimport type {\n CaptureImageIntentParams,\n CaptureImageIntentResult,\n} from '@shopify/shop-minis-platform'\n\n/**\n * Hook to request user to capture or select images\n *\n * This intent opens the camera or photo gallery to let the user\n * capture or select one or more images.\n *\n * @example\n * const captureImage = useImageCapture({\n * onCancel: () => console.log('User cancelled'),\n * })\n *\n * const result = await captureImage({\n * source: 'camera',\n * quality: 0.8,\n * maxWidth: 1920\n * })\n *\n * if (result) {\n * console.log('Captured images:', result.images)\n * }\n */\nexport const useImageCapture = (\n options?: HandleIntentOptions<CaptureImageIntentResult>\n) => {\n const intents = useShopIntents()\n return useHandleIntent(intents.captureImage, options)\n}\n\n/**\n * Type helper for the image capture function\n */\nexport type ImageCaptureFunction = (\n params: CaptureImageIntentParams\n) => Promise<CaptureImageIntentResult | void>\n"],"names":["useImageCapture","options","intents","useShopIntents","useHandleIntent"],"mappings":";;AAgCa,MAAAA,IAAkB,CAC7BC,MACG;AACH,QAAMC,IAAUC,EAAe;AACxB,SAAAC,EAAgBF,EAAQ,cAAcD,CAAO;AACtD;"}
@@ -1,10 +0,0 @@
1
- import { useHandleIntent as n } from "../../internal/useHandleIntent.js";
2
- import { useShopIntents as o } from "../../internal/useShopIntents.js";
3
- const c = (t) => {
4
- const e = o();
5
- return n(e.selectLocation, t);
6
- };
7
- export {
8
- c as useLocationSelection
9
- };
10
- //# sourceMappingURL=useLocationSelection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLocationSelection.js","sources":["../../../src/hooks/intents/useLocationSelection.ts"],"sourcesContent":["import {\n useHandleIntent,\n HandleIntentOptions,\n} from '../../internal/useHandleIntent'\nimport {useShopIntents} from '../../internal/useShopIntents'\n\nimport type {\n SelectLocationIntentParams,\n SelectLocationIntentResult,\n} from '@shopify/shop-minis-platform'\n\n/**\n * Hook to request user to select a location\n *\n * This intent shows a map interface where the user can select\n * a location and optionally get address information.\n *\n * @example\n * const selectLocation = useLocationSelection({\n * onCancel: () => console.log('User cancelled'),\n * })\n *\n * const result = await selectLocation({\n * title: 'Select delivery location',\n * locationType: 'address'\n * })\n *\n * if (result) {\n * console.log('Selected location:', result.coordinates)\n * console.log('Address:', result.address?.formattedAddress)\n * }\n */\nexport const useLocationSelection = (\n options?: HandleIntentOptions<SelectLocationIntentResult>\n) => {\n const intents = useShopIntents()\n return useHandleIntent(intents.selectLocation, options)\n}\n\n/**\n * Type helper for the location selection function\n */\nexport type LocationSelectionFunction = (\n params: SelectLocationIntentParams\n) => Promise<SelectLocationIntentResult | void>\n"],"names":["useLocationSelection","options","intents","useShopIntents","useHandleIntent"],"mappings":";;AAgCa,MAAAA,IAAuB,CAClCC,MACG;AACH,QAAMC,IAAUC,EAAe;AACxB,SAAAC,EAAgBF,EAAQ,gBAAgBD,CAAO;AACxD;"}
@@ -1,10 +0,0 @@
1
- import { useHandleIntent as n } from "../../internal/useHandleIntent.js";
2
- import { useShopIntents as s } from "../../internal/useShopIntents.js";
3
- const m = (t) => {
4
- const e = s();
5
- return n(e.requestPayment, t);
6
- };
7
- export {
8
- m as usePaymentRequest
9
- };
10
- //# sourceMappingURL=usePaymentRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePaymentRequest.js","sources":["../../../src/hooks/intents/usePaymentRequest.ts"],"sourcesContent":["import {\n useHandleIntent,\n HandleIntentOptions,\n} from '../../internal/useHandleIntent'\nimport {useShopIntents} from '../../internal/useShopIntents'\n\nimport type {\n RequestPaymentIntentParams,\n RequestPaymentIntentResult,\n} from '@shopify/shop-minis-platform'\n\n/**\n * Hook to request payment from user\n *\n * This intent opens the Shop app's payment flow to process a payment.\n *\n * **Note:** This intent requires special permissions and may have rate limits.\n *\n * @example\n * const requestPayment = usePaymentRequest({\n * onCancel: () => console.log('User cancelled payment'),\n * onError: (error) => console.error('Payment failed:', error)\n * })\n *\n * const result = await requestPayment({\n * amount: 999, // $9.99 in cents\n * currency: 'USD',\n * description: 'Premium subscription'\n * })\n *\n * if (result) {\n * console.log('Payment successful:', result.transactionId)\n * }\n */\nexport const usePaymentRequest = (\n options?: HandleIntentOptions<RequestPaymentIntentResult>\n) => {\n const intents = useShopIntents()\n return useHandleIntent(intents.requestPayment, options)\n}\n\n/**\n * Type helper for the payment request function\n */\nexport type PaymentRequestFunction = (\n params: RequestPaymentIntentParams\n) => Promise<RequestPaymentIntentResult | void>\n"],"names":["usePaymentRequest","options","intents","useShopIntents","useHandleIntent"],"mappings":";;AAkCa,MAAAA,IAAoB,CAC/BC,MACG;AACH,QAAMC,IAAUC,EAAe;AACxB,SAAAC,EAAgBF,EAAQ,gBAAgBD,CAAO;AACxD;"}
@@ -1,10 +0,0 @@
1
- import { useHandleIntent as n } from "../../internal/useHandleIntent.js";
2
- import { useShopIntents as o } from "../../internal/useShopIntents.js";
3
- const c = (t) => {
4
- const e = o();
5
- return n(e.selectProduct, t);
6
- };
7
- export {
8
- c as useProductSelection
9
- };
10
- //# sourceMappingURL=useProductSelection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useProductSelection.js","sources":["../../../src/hooks/intents/useProductSelection.ts"],"sourcesContent":["import {\n useHandleIntent,\n HandleIntentOptions,\n} from '../../internal/useHandleIntent'\nimport {useShopIntents} from '../../internal/useShopIntents'\n\nimport type {\n SelectProductIntentParams,\n SelectProductIntentResult,\n} from '@shopify/shop-minis-platform'\n\n/**\n * Hook to request user to select products\n *\n * This intent shows a product selection screen where the user can browse\n * and select one or more products from the Shop catalog.\n *\n * @example\n * const selectProducts = useProductSelection({\n * onCancel: () => console.log('User cancelled'),\n * })\n *\n * const result = await selectProducts({\n * multiSelect: true,\n * maxSelections: 5,\n * title: 'Choose your favorites'\n * })\n *\n * if (result) {\n * console.log('Selected products:', result.products)\n * }\n */\nexport const useProductSelection = (\n options?: HandleIntentOptions<SelectProductIntentResult>\n) => {\n const intents = useShopIntents()\n return useHandleIntent(intents.selectProduct, options)\n}\n\n/**\n * Type helper for the product selection function\n */\nexport type ProductSelectionFunction = (\n params: SelectProductIntentParams\n) => Promise<SelectProductIntentResult | void>\n"],"names":["useProductSelection","options","intents","useShopIntents","useHandleIntent"],"mappings":";;AAgCa,MAAAA,IAAsB,CACjCC,MACG;AACH,QAAMC,IAAUC,EAAe;AACxB,SAAAC,EAAgBF,EAAQ,eAAeD,CAAO;AACvD;"}
@@ -1,26 +0,0 @@
1
- import { useCallback as s } from "react";
2
- import { IntentResultCode as t } from "../shop-minis-platform/src/intents/shared.js";
3
- const c = (n, r) => s(
4
- async (...a) => {
5
- const e = await n(...a);
6
- switch (e.resultCode) {
7
- case t.SUCCESS:
8
- return e.data;
9
- case t.CANCELLED:
10
- return r?.onCancel ? r.onCancel() : void 0;
11
- case t.FAILED:
12
- if (r?.onError)
13
- return r.onError(e.error);
14
- throw new Error(e.error?.message || "Intent failed");
15
- default: {
16
- const o = e.resultCode;
17
- throw new Error(`Unhandled result code: ${o}`);
18
- }
19
- }
20
- },
21
- [n, r]
22
- );
23
- export {
24
- c as useHandleIntent
25
- };
26
- //# sourceMappingURL=useHandleIntent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useHandleIntent.js","sources":["../../src/internal/useHandleIntent.ts"],"sourcesContent":["import {useCallback} from 'react'\n\nimport {IntentResultCode} from '@shopify/shop-minis-platform'\n\nimport type {ShopIntentResult} from '@shopify/shop-minis-platform'\n\n/**\n * Options for handling intent results\n */\nexport interface HandleIntentOptions<T> {\n /**\n * Handler called when user cancels the intent\n * If not provided, cancellation is treated as a no-op (returns undefined)\n */\n onCancel?: () => T | void\n /**\n * Handler called when intent fails\n * If not provided, throws the error\n */\n onError?: (error: {message: string; code?: string}) => T | void\n}\n\n/**\n * Wrapper to handle intent results\n *\n * Unlike actions which can reject, intents ALWAYS resolve with a result code.\n * This hook provides a cleaner API for handling intent results:\n *\n * - SUCCESS: Returns the data\n * - CANCELLED: Calls onCancel or returns undefined\n * - FAILED: Calls onError or throws the error\n *\n * @example\n * const selectProduct = useHandleIntent(intents.selectProduct, {\n * onCancel: () => console.log('User cancelled'),\n * onError: (error) => console.error('Selection failed:', error)\n * })\n *\n * const result = await selectProduct({multiSelect: true})\n * // result is the data, or undefined if cancelled\n */\nexport const useHandleIntent = <T, Args extends unknown[]>(\n intent: (...args: Args) => Promise<ShopIntentResult<T>>,\n options?: HandleIntentOptions<T>\n) => {\n return useCallback(\n async (...args: Args): Promise<T | void> => {\n const result = await intent(...args)\n\n switch (result.resultCode) {\n case IntentResultCode.SUCCESS:\n return result.data!\n\n case IntentResultCode.CANCELLED:\n if (options?.onCancel) {\n return options.onCancel()\n }\n return undefined\n\n case IntentResultCode.FAILED:\n if (options?.onError) {\n return options.onError(result.error!)\n }\n\n throw new Error(result.error?.message || 'Intent failed')\n\n default: {\n // Exhaustiveness check\n const _exhaustive: never = result.resultCode\n throw new Error(`Unhandled result code: ${_exhaustive}`)\n }\n }\n },\n [intent, options]\n )\n}\n\n/**\n * Alternative: Manual result handling without throwing\n *\n * Use this when you want to handle all result codes explicitly\n * without throwing errors.\n *\n * @example\n * const selectProduct = useHandleIntentManual(intents.selectProduct)\n *\n * const result = await selectProduct({multiSelect: true})\n * if (result.resultCode === 'SUCCESS') {\n * console.log(result.data)\n * }\n */\nexport const useHandleIntentManual = <T, Args extends unknown[]>(\n intent: (...args: Args) => Promise<ShopIntentResult<T>>\n) => {\n return useCallback(\n (...args: Args) => {\n return intent(...args)\n },\n [intent]\n )\n}\n"],"names":["useHandleIntent","intent","options","useCallback","args","result","IntentResultCode","_exhaustive"],"mappings":";;AAyCa,MAAAA,IAAkB,CAC7BC,GACAC,MAEOC;AAAA,EACL,UAAUC,MAAkC;AAC1C,UAAMC,IAAS,MAAMJ,EAAO,GAAGG,CAAI;AAEnC,YAAQC,EAAO,YAAY;AAAA,MACzB,KAAKC,EAAiB;AACpB,eAAOD,EAAO;AAAA,MAEhB,KAAKC,EAAiB;AACpB,eAAIJ,GAAS,WACJA,EAAQ,SAAS,IAEnB;AAAA,MAET,KAAKI,EAAiB;AACpB,YAAIJ,GAAS;AACJ,iBAAAA,EAAQ,QAAQG,EAAO,KAAM;AAGtC,cAAM,IAAI,MAAMA,EAAO,OAAO,WAAW,eAAe;AAAA,MAE1D,SAAS;AAEP,cAAME,IAAqBF,EAAO;AAClC,cAAM,IAAI,MAAM,0BAA0BE,CAAW,EAAE;AAAA,MAAA;AAAA,IACzD;AAAA,EAEJ;AAAA,EACA,CAACN,GAAQC,CAAO;AAClB;"}
@@ -1,7 +0,0 @@
1
- function n() {
2
- return window.minisIntents;
3
- }
4
- export {
5
- n as useShopIntents
6
- };
7
- //# sourceMappingURL=useShopIntents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useShopIntents.js","sources":["../../src/internal/useShopIntents.ts"],"sourcesContent":["import type {ShopIntents} from '@shopify/shop-minis-platform'\n\n/**\n * Internal hook to access Shop Intents\n *\n * This provides direct access to window.minisIntents\n * Use specific intent hooks (like useProductSelection) instead of this hook directly\n *\n * @internal\n */\nexport function useShopIntents(): ShopIntents {\n return window.minisIntents\n}\n"],"names":["useShopIntents"],"mappings":"AAUO,SAASA,IAA8B;AAC5C,SAAO,OAAO;AAChB;"}
@@ -1,19 +0,0 @@
1
- var e = /* @__PURE__ */ ((E) => (E.SUCCESS = "SUCCESS", E.CANCELLED = "CANCELLED", E.FAILED = "FAILED", E))(e || {});
2
- function L(E, C) {
3
- switch (E.resultCode) {
4
- case "SUCCESS":
5
- return C.SUCCESS(E.data);
6
- case "CANCELLED":
7
- return C.CANCELLED();
8
- case "FAILED":
9
- return C.FAILED(E.error);
10
- default:
11
- const r = E.resultCode;
12
- throw new Error(`Unhandled result code: ${r}`);
13
- }
14
- }
15
- export {
16
- e as IntentResultCode,
17
- L as handleIntentResult
18
- };
19
- //# sourceMappingURL=shared.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shared.js","sources":["../../../../../shop-minis-platform/src/intents/shared.ts"],"sourcesContent":["/**\n * Shared types for the Shop Minis Intent system\n *\n * Intents allow Minis to trigger interactive flows in the parent Shop app\n * (or other Minis in the future) and receive structured responses.\n */\n\n/**\n * Intent result codes, similar to Android's Activity result codes\n */\nexport enum IntentResultCode {\n /**\n * The intent completed successfully\n */\n SUCCESS = 'SUCCESS',\n\n /**\n * The intent was cancelled by the user\n * (e.g., user closed the modal, pressed back button)\n */\n CANCELLED = 'CANCELLED',\n\n /**\n * The intent failed due to an error\n */\n FAILED = 'FAILED',\n}\n\n/**\n * Common wrapper for all intent responses\n *\n * @template T - The type of the intent-specific response data\n */\nexport interface ShopIntentResult<T = void> {\n /**\n * Result code indicating success, cancellation, or failure\n */\n resultCode: IntentResultCode\n\n /**\n * Intent-specific response data\n * Only present when resultCode is SUCCESS\n */\n data?: T\n\n /**\n * Error information\n * Only present when resultCode is FAILED\n */\n error?: {\n /** Human-readable error message */\n message: string\n /** Optional error code for programmatic handling */\n code?: string\n }\n}\n\n/**\n * Generic type representing any intent handler\n *\n * @template P - The params type for the intent\n * @template R - The result data type for the intent\n *\n * Unlike actions which can reject, intents always resolve with a\n * ShopIntentResult that contains the result code and optional data/error\n */\nexport type ShopIntent<P, R> = (\n params: P\n) => Promise<ShopIntentResult<R>>\n\n/**\n * Utility type to convert SNAKE_CASE to camelCase\n * Example: 'SELECT_PRODUCT' -> 'selectProduct'\n */\nexport type SnakeToCamelCase<S extends string> =\n S extends `${infer Head}_${infer Tail}`\n ? `${Lowercase<Head>}${Capitalize<SnakeToCamelCase<Tail>>}`\n : Lowercase<S>\n\n/**\n * Helper type to ensure intent result codes are handled exhaustively\n */\nexport type IntentResultHandler<T, R> = {\n [IntentResultCode.SUCCESS]: (data: T) => R\n [IntentResultCode.CANCELLED]: () => R\n [IntentResultCode.FAILED]: (error: {message: string; code?: string}) => R\n}\n\n/**\n * Helper function to handle intent results in a type-safe way\n *\n * @example\n * const result = await minisIntents.selectProduct({...});\n * const products = handleIntentResult(result, {\n * SUCCESS: (data) => data.products,\n * CANCELLED: () => [],\n * FAILED: (error) => { console.error(error); return []; }\n * });\n */\nexport function handleIntentResult<T, R>(\n result: ShopIntentResult<T>,\n handlers: IntentResultHandler<T, R>\n): R {\n switch (result.resultCode) {\n case IntentResultCode.SUCCESS:\n return handlers[IntentResultCode.SUCCESS](result.data!)\n case IntentResultCode.CANCELLED:\n return handlers[IntentResultCode.CANCELLED]()\n case IntentResultCode.FAILED:\n return handlers[IntentResultCode.FAILED](result.error!)\n default:\n // Exhaustiveness check\n const _exhaustive: never = result.resultCode\n throw new Error(`Unhandled result code: ${_exhaustive}`)\n }\n}\n\n"],"names":["IntentResultCode","handleIntentResult","result","handlers","_exhaustive"],"mappings":"AAUY,IAAAA,sBAAAA,OAIVA,EAAA,UAAU,WAMVA,EAAA,YAAY,aAKZA,EAAA,SAAS,UAfCA,IAAAA,KAAA,CAAA,CAAA;AAyFI,SAAAC,EACdC,GACAC,GACG;AACH,UAAQD,EAAO,YAAY;AAAA,IACzB,KAAK;AACH,aAAOC,EAAS,QAA0BD,EAAO,IAAK;AAAA,IACxD,KAAK;AACI,aAAAC,EAAS,UAA4B;AAAA,IAC9C,KAAK;AACH,aAAOA,EAAS,OAAyBD,EAAO,KAAM;AAAA,IACxD;AAEE,YAAME,IAAqBF,EAAO;AAClC,YAAM,IAAI,MAAM,0BAA0BE,CAAW,EAAE;AAAA,EAAA;AAE7D;"}