id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_store-icons_4405486a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconHeart.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconHeart = (props: IconProps) => {\n return <Icon id=\"mpa-heart\" handle=\"heartIcon\" {...props} />\n}\n\nexport default IconHeart\n\n```"
}
] |
code_store-icons_6e134b33
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconPlus.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconPlus = (props: IconProps) => {\n return <Icon id=\"nav-plus\" handle=\"plusIcon\" {...props} />\n}\n\nexport default IconPlus\n\n```"
}
] |
code_store-icons_74630c61
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconSingleGrid.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconSingleGrid = (props: IconProps) => {\n return <Icon id=\"mpa-single-item\" handle=\"singleGridIcon\" {...props} />\n}\n\nexport default IconSingleGrid\n\n```"
}
] |
code_store-icons_46ec8495
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconCaret.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport classnames from 'classnames'\nimport Icon from './components/Icon'\nimport { getOrientation } from './utils/helpers'\n\nconst IconCaret = ({ orientation, thin = false, ...props }: CaretProps) => {\n const orientationModifier = getOrientation(orientation)\n const id: string = classnames({\n [`nav-thin-caret${orientationModifier}`]: thin,\n [`nav-caret${orientationModifier}`]: !thin,\n })\n return <Icon id={id} handle=\"caretIcon\" {...props} />\n}\n\nexport default IconCaret\n\n```"
}
] |
code_store-icons_9c120427
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconPause.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconPause = (props: IconProps) => {\n return <Icon id=\"mpa-pause\" handle=\"pauseIcon\" {...props} />\n}\n\nexport default IconPause\n\n```"
}
] |
code_store-icons_870b922d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconExpand.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconExpand = (props: IconProps) => {\n return <Icon id=\"mpa-expand\" handle=\"expandIcon\" {...props} />\n}\n\nexport default IconExpand\n\n```"
}
] |
code_store-icons_87962d70
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconVolumeOn.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconVolumeOn = (props: IconProps) => {\n return <Icon id=\"sti-volume-on\" handle=\"volumeOnIcon\" {...props} />\n}\n\nexport default IconVolumeOn\n\n```"
}
] |
code_store-icons_f84daebb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconLocationMarker.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconLocationMarker = (props: IconProps) => {\n return (\n <Icon id=\"hpa-location-marker\" handle=\"locationMarkerIcon\" {...props} />\n )\n}\n\nexport default IconLocationMarker\n\n```"
}
] |
code_store-icons_47309b99
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconInlineGrid.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconInlineGrid = (props: IconProps) => {\n return <Icon id=\"mpa-list-items\" handle=\"inlineGridIcon\" {...props} />\n}\n\nexport default IconInlineGrid\n\n```"
}
] |
code_store-icons_a0676c1a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconCart.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconCart = (props: IconProps) => {\n return <Icon id=\"hpa-cart\" handle=\"cartIcon\" {...props} />\n}\n\nexport default IconCart\n\n```"
}
] |
code_store-icons_e96842a4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconEyeSight.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\nimport { getType, getState } from './utils/helpers'\n\nconst IconEyeSight = ({ type, state, ...props }: EnhancedIconProps) => {\n const typeModifier = getType(type, 'filled, outline')\n const stateModifier = getState(state)\n return (\n <Icon\n id={`mpa-eyesight${typeModifier}${stateModifier}`}\n handle=\"eyeSightIcon\"\n {...props}\n />\n )\n}\n\nexport default IconEyeSight\n\n```"
}
] |
code_store-icons_55eab134
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconGlobe.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconGlobe = (props: IconProps) => {\n return <Icon id=\"mpa-globe\" handle=\"globeIcon\" {...props} />\n}\n\nexport default IconGlobe\n\n```"
}
] |
code_store-icons_443143cc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconBookmark.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\nimport { getType } from './utils/helpers'\n\nconst IconBoomark = ({ type = 'outline', ...props }: EnhancedIconProps) => {\n const typeModifier = getType(type, 'filled, outline')\n return <Icon id={`mpa-bookmark${typeModifier}`} {...props} />\n}\n\nexport default IconBoomark\n\n```"
}
] |
code_store-icons_4f340246
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconEquals.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconEquals = (props: IconProps) => {\n return <Icon id=\"sti-equals\" handle=\"equalsIcon\" {...props} />\n}\n\nexport default IconEquals\n\n```"
}
] |
code_store-icons_6b379d7e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/Icon.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport Icon from './components/Icon'\n\nexport default Icon\n\n```"
}
] |
code_store-icons_44edb5e4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconSearch.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconSearch = (props: IconProps) => {\n return <Icon id=\"hpa-search\" handle=\"searchIcon\" {...props} />\n}\n\nexport default IconSearch\n\n```"
}
] |
code_store-icons_fb5bef1a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconHome.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconHome = (props: IconProps) => {\n return <Icon id=\"nav-home\" handle=\"homeIcon\" {...props} />\n}\n\nexport default IconHome\n\n```"
}
] |
code_store-icons_529a7cbd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconClose.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\nimport { getType } from './utils/helpers'\n\nconst IconClose = ({ type = 'filled', ...props }: EnhancedIconProps) => {\n const typeModifier = getType(type)\n return <Icon handle=\"closeIcon\" id={`sti-close${typeModifier}`} {...props} />\n}\n\nexport default IconClose\n\n```"
}
] |
code_store-icons_17e6434d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconGrid.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconGrid = (props: IconProps) => {\n return <Icon id=\"mpa-gallery\" handle=\"gridIcon\" {...props} />\n}\n\nexport default IconGrid\n\n```"
}
] |
code_store-icons_f0eb2e88
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconCheck.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { getType } from './utils/helpers'\n\nimport Icon from './components/Icon'\n\nconst IconCheck = ({ type, ...props }: EnhancedIconProps) => {\n const typeModifier = getType(type)\n return <Icon handle=\"checkIcon\" id={`sti-check${typeModifier}`} {...props} />\n}\n\nexport default IconCheck\n\n```"
}
] |
code_store-icons_dc01cfea
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconDelete.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconDelete = (props: IconProps) => {\n return <Icon id=\"hpa-delete\" handle=\"deleteIcon\" {...props} />\n}\n\nexport default IconDelete\n\n```"
}
] |
code_store-icons_dafbe339
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconSwap.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconSwap = (props: IconProps) => {\n return <Icon id=\"mpa-swap\" handle=\"swapIcon\" {...props} />\n}\n\nexport default IconSwap\n\n```"
}
] |
code_store-icons_9eb7e59c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconArrowBack.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconArrowBack = (props: IconProps) => {\n return <Icon id=\"hpa-arrow-back\" handle=\"arrowBackIcon\" {...props} />\n}\n\nexport default IconArrowBack\n\n```"
}
] |
code_store-icons_895257da
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconMenu.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconMenu = (props: IconProps) => {\n return <Icon id=\"hpa-hamburguer-menu\" handle=\"menuIcon\" {...props} />\n}\n\nexport default IconMenu\n\n```"
}
] |
code_store-icons_f9ba5f74
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconRemove.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconRemove = (props: IconProps) => {\n return <Icon id=\"mpa-remove\" handle=\"removeIcon\" {...props} />\n}\n\nexport default IconRemove\n\n```"
}
] |
code_store-icons_2bd67335
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconFilter.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconFilter = (props: IconProps) => {\n return <Icon id=\"mpa-filter-settings\" handle=\"filterIcon\" {...props} />\n}\n\nexport default IconFilter\n\n```"
}
] |
code_store-icons_3f8f151b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/package.json from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.store-icons\",\n \"version\": \"0.18.1\",\n \"description\": \"React components that encapsules store icons\",\n \"scripts\": {\n \"pretest\": \"yarn\",\n \"test\": \"vtex-test-tools test\",\n \"test:watch\": \"vtex-test-tools test --watch\",\n \"lint\": \"tsc --noEmit --pretty && tslint -c tslint.json './**/*.ts'\"\n },\n \"files\": [\n \"react\"\n ],\n \"dependencies\": {\n \"classnames\": \"^2.2.6\",\n \"ramda\": \"^0.26.1\",\n \"react\": \"^16.9.0\",\n \"react-dom\": \"^16.9.0\"\n },\n \"devDependencies\": {\n \"@babel/core\": \"^7.3.4\",\n \"@babel/preset-env\": \"^7.3.4\",\n \"@types/classnames\": \"^2.2.7\",\n \"@types/jest\": \"^24.0.9\",\n \"@types/node\": \"^11.10.0\",\n \"@types/ramda\": \"^0.25.51\",\n \"@types/react\": \"^16.8.6\",\n \"@vtex/test-tools\": \"^1.1.0\",\n \"babel-preset-react-app\": \"^7.0.2\",\n \"tslint\": \"^5.11.0\",\n \"tslint-config-vtex\": \"^2.0.0\",\n \"tslint-eslint-rules\": \"^5.4.0\",\n \"typescript\": \"3.8.3\"\n },\n \"resolutions\": {\n \"babel-core\": \"^7.0.0-bridge.0\"\n }\n}\n\n```"
}
] |
code_store-icons_b83de92b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconAssistantSales.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconAssistantSales = (props: IconProps) => {\n return <Icon id=\"hpa-telemarketing\" handle=\"assistantSalesIcon\" {...props} />\n}\n\nexport default IconAssistantSales\n\n```"
}
] |
code_store-icons_d7d0d280
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconSocial.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\nimport { getShape } from './utils/helpers'\n\ninterface Props extends EnhancedIconProps {\n readonly network: string\n readonly background: string\n}\n\nconst IconSocial = ({ network, size, background, shape, ...props }: Props) => {\n const { wrapperProps, reducedIconSize } = getShape(size!, background, shape)\n\n return (\n <span {...wrapperProps}>\n <Icon\n id={`bnd-${network}`}\n handle=\"socialIcon\"\n size={reducedIconSize}\n {...props}\n />\n </span>\n )\n}\n\nIconSocial.defautProps = {\n size: 16,\n viewBox: '0 0 16 16',\n}\n\nexport default IconSocial\n\n```"
}
] |
code_store-icons_bcc605a9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconVolumeOff.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconVolumeOff = (props: IconProps) => {\n return <Icon id=\"sti-volume-off\" handle=\"volumeOffIcon\" {...props} />\n}\n\nexport default IconVolumeOff\n\n```"
}
] |
code_store-icons_00246c3e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconStar.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconStar = (props: IconProps) => {\n return <Icon id=\"inf-star\" handle=\"starIcon\" {...props} />\n}\n\nexport default IconStar\n\n```"
}
] |
code_store-icons_2984c2c5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconProfile.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconProfile = (props: IconProps) => {\n return <Icon id=\"hpa-profile\" handle=\"profileIcon\" {...props} />\n}\n\nexport default IconProfile\n\n```"
}
] |
code_store-icons_1c3e15af
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconPlay.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconPlay = (props: IconProps) => {\n return <Icon id=\"mpa-play\" handle=\"playIcon\" {...props} />\n}\n\nexport default IconPlay\n\n```"
}
] |
code_store-icons_5b484caf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/IconLocationInput.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Icon from './components/Icon'\n\nconst IconLocationInput = (props: IconProps) => {\n return <Icon id=\"mpa-location-input\" handle=\"locationInputIcon\" {...props} />\n}\n\nexport default IconLocationInput\n\n```"
}
] |
code_store-icons_bc0d27ec
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/store/interfaces.json from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"icon\": {\n \"component\": \"Icon\"\n },\n \"icon-arrow-back\": {\n \"component\": \"IconArrowBack\"\n },\n \"icon-assistant-sales\": {\n \"component\": \"IconAssistantSales\"\n },\n \"icon-caret\": {\n \"component\": \"IconCaret\"\n },\n \"icon-cart\": {\n \"component\": \"IconCart\"\n },\n \"icon-check\": {\n \"component\": \"IconCheck\"\n },\n \"icon-close\": {\n \"component\": \"IconClose\"\n },\n \"icon-delete\": {\n \"component\": \"IconDelete\"\n },\n \"icon-equals\": {\n \"component\": \"IconEquals\"\n },\n \"icon-eye-sight\": {\n \"component\": \"IconEyeSight\"\n },\n \"icon-filter\": {\n \"component\": \"IconFilter\"\n },\n \"icon-globe\": {\n \"component\": \"IconGlobe\"\n },\n \"icon-grid\": {\n \"component\": \"IconGrid\"\n },\n \"icon-heart\": {\n \"component\": \"IconHeart\"\n },\n \"icon-home\": {\n \"component\": \"IconHome\"\n },\n \"icon-inline-grid\": {\n \"component\": \"IconInlineGrid\"\n },\n \"icon-location-input\": {\n \"component\": \"IconLocationInput\"\n },\n \"icon-location-marker\": {\n \"component\": \"IconLocationMarker\"\n },\n \"icon-menu\": {\n \"component\": \"IconMenu\"\n },\n \"icon-minus\": {\n \"component\": \"IconMinus\"\n },\n \"icon-plus\": {\n \"component\": \"IconPlus\"\n },\n \"icon-profile\": {\n \"component\": \"IconProfile\"\n },\n \"icon-remove\": {\n \"component\": \"IconRemove\"\n },\n \"icon-search\": {\n \"component\": \"IconSearch\"\n },\n \"icon-single-grid\": {\n \"component\": \"IconSingleGrid\"\n },\n \"icon-social\": {\n \"component\": \"IconSocial\"\n },\n \"icon-star\": {\n \"component\": \"IconStar\"\n },\n \"icon-swap\": {\n \"component\": \"IconSwap\"\n },\n \"icon-bookmark\": {\n \"component\": \"IconBookmark\"\n },\n \"icon-expand\": {\n \"component\": \"IconExpand\"\n },\n \"icon-volume-on\": {\n \"component\": \"IconVolumeOn\"\n },\n \"icon-volume-off\": {\n \"component\": \"IconVolumeOff\"\n },\n \"icon-play\": {\n \"component\": \"IconPlay\"\n },\n \"icon-pause\": {\n \"component\": \"IconPause\"\n }\n}\n\n```"
}
] |
code_store-icons_aedf6fe5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/docs/script/scrap-svg.js from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nconst cheerio = require('cheerio');\nconst fs = require('fs');\nconst path = require('path');\n\nconst PRODUCTION_ICON_PACK = path.join(__dirname, '..', '..', 'styles', 'iconpacks', 'iconpack.svg')\n\nconst body = fs.readFileSync(PRODUCTION_ICON_PACK)\n\nconst $ = cheerio.load(body);\nconst svgs = {}\n\n$('g').toArray().map(element => {\n let id = element.attribs.id.trim()\n let htmlG = $(`#${id}`).html().trim().replace(new RegExp('currentColor', 'g'), '#000000')\n svgs[id] = htmlG\n let template = `<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 16 16\">\n <g id=\"${id}\">\n ${htmlG}\n </g>\n </svg>`\n\n fs.writeFileSync(path.join(__dirname, '..', id + '.svg'), template)\n})\n\nconst BASELINE_PATH = path.join(__dirname, 'baseline.md')\nconst ICONPACK_PATH = path.join(__dirname, '..', 'ICONPACK.md')\n\nfs.copyFile(BASELINE_PATH, ICONPACK_PATH, (err) => {\n if (err) throw err\n for (id in svgs) {\n fs.appendFileSync(ICONPACK_PATH, `|  | ${id} | \\n`)\n }\n})\n```"
}
] |
code_store-icons_4fe79c75
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/typings/global.d.ts from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface IconProps {\n readonly id: string\n readonly handle: string\n readonly isActive?: boolean\n readonly size?: number\n readonly viewBox?: string\n readonly activeClassName?: string\n readonly mutedClassName?: string\n}\n\ninterface EnhancedIconProps extends IconProps {\n readonly orientation?: string\n readonly state?: string\n readonly shape?: string\n readonly type?: string\n}\n\ninterface CaretProps extends EnhancedIconProps {\n readonly thin?: boolean\n}\n\ninterface Enhancement {\n id: string\n modifier: string\n}\n\n```"
}
] |
code_store-icons_d2029113
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/utils/helpers.ts from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { contains, find, propEq } from 'ramda'\nimport { ORIENTATIONS, SHAPES, STATES, TYPES } from './enhancements'\n\n/**\n * Get the modifer from any collection matching the rule collection{id, modifier}\n * @param {*} id\n * @param {*} collection\n */\nexport const getModifier = (collection: Enhancement[], id?: string) => {\n const foundItem = find(propEq('id', id), collection)\n return !!foundItem ? foundItem.modifier : id\n}\n\n/**\n * Get a subset of the collections with given ids (passed with commas)\n * @param {*} tokens\n * @param {*} collection\n */\nexport const getSubset = (tokens: string, collection: Enhancement[]) => {\n const ids = tokens.split(',').join('')\n return collection.filter((item: any) => contains(item.id, ids))\n}\n\n/**\n * Get enhancement modifier\n * @param enhancementList list of enhancements\n * @param enhancement desired enhancement\n * @param supported all supported enhancement list\n */\nexport const getEnhancement = (\n enhancementList: Enhancement[],\n enhancement?: string,\n supported?: string\n) => {\n const supportedEnhancements = !!supported\n ? getSubset(supported, enhancementList)\n : enhancementList\n const modifier = getModifier(supportedEnhancements, enhancement)\n return modifier\n}\n\n/**\n * Get orientation modifier\n * @param orientation desired orientation\n * @param supported suported orientations\n */\nexport const getOrientation = (orientation?: string, supported?: string) =>\n getEnhancement(ORIENTATIONS, orientation, supported)\n\n/**\n * Get type modifier\n * @param type desired type\n * @param supported suported types\n */\nexport const getType = (type?: string, supported?: string) =>\n getEnhancement(TYPES, type, supported)\n\n/**\n * Get state modifier\n * @param state desirend state\n * @param supported suported states\n */\nexport const getState = (state?: string, supported?: string) =>\n getEnhancement(STATES, state, supported)\n\n/**\n * Get shape modifier\n * @param size icon size\n * @param background background color\n * @param shape desired shape\n * @param supported suported shapes\n */\nexport const getShape = (\n size: number,\n background: string,\n shape?: string,\n supported?: string\n) => {\n const REDUCTION_PERCENTAGE = 0.4\n const getReduction = (size: number) => size * REDUCTION_PERCENTAGE\n const modifiers = getEnhancement(SHAPES, shape, supported)\n const reduction = getReduction(size)\n const padding = reduction / 2\n const reducedIconSize = size - reduction\n\n const wrapperProps = [\n { className: `${modifiers} flex` },\n { style: { padding, backgroundColor: background } },\n ]\n\n return { wrapperProps, reducedIconSize }\n}\n\n```"
}
] |
code_store-icons_f7244595
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/utils/enhancements.ts from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const SHAPES = [\n {\n id: 'square',\n modifier: 'br1',\n },\n {\n id: 'rounded',\n modifier: 'br3',\n },\n {\n id: 'circle',\n modifier: 'br-100',\n },\n]\n\nexport const ORIENTATIONS = [\n {\n id: 'up',\n modifier: '--up',\n },\n {\n id: 'down',\n modifier: '--down',\n },\n {\n id: 'right',\n modifier: '--right',\n },\n {\n id: 'left',\n modifier: '--left',\n },\n]\n\nexport const STATES = [\n {\n id: 'on',\n modifier: '--on',\n },\n {\n id: 'off',\n modifier: '--off',\n },\n]\n\nexport const TYPES = [\n {\n id: 'filled',\n modifier: '--filled',\n },\n {\n id: 'outline',\n modifier: '--outline',\n },\n {\n id: 'line',\n modifier: '--line',\n },\n]\n\n```"
}
] |
code_store-icons_d2e320f7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/components/Icon.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport Svg from './Svg'\nimport Use from './Use'\n\nconst CSS_HANDLES = [\n 'arrowBackIcon',\n 'assistantSalesIcon',\n 'caretIcon',\n 'cartIcon',\n 'checkIcon',\n 'closeIcon',\n 'deleteIcon',\n 'equalsIcon',\n 'expandIcon',\n 'eyeSightIcon',\n 'filterIcon',\n 'globeIcon',\n 'gridIcon',\n 'heartIcon',\n 'homeIcon',\n 'inlineGridIcon',\n 'locationInputIcon',\n 'locationMarkerIcon',\n 'menuIcon',\n 'minusIcon',\n 'plusIcon',\n 'profileIcon',\n 'removeIcon',\n 'searchIcon',\n 'singleGridIcon',\n 'socialIcon',\n 'starIcon',\n 'swapIcon',\n 'playIcon',\n 'pauseIcon',\n 'volumeOnIcon',\n 'volumeOffIcon',\n] as const\n\nconst Icon = ({\n id,\n handle,\n isActive,\n size,\n viewBox,\n activeClassName,\n mutedClassName,\n}: IconProps) => {\n const handles = useCssHandles(CSS_HANDLES)\n\n return (\n <Svg\n fill=\"none\"\n width={size}\n height={size}\n viewBox={viewBox}\n className={`${isActive ? activeClassName || '' : mutedClassName || ''} ${\n handles[handle] || ''\n }`}\n >\n <Use id={id} />\n </Svg>\n )\n}\n\nIcon.defaultProps = {\n isActive: true,\n size: 16,\n viewBox: '0 0 16 16',\n}\n\nexport default Icon\n\n```"
}
] |
code_store-icons_e7160799
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/components/Use.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\ninterface Props {\n id: string\n}\n\nconst Use = ({ id }: Props) => <use href={`#${id}`} xlinkHref={`#${id}`} />\n\nexport default Use\n\n```"
}
] |
code_store-icons_597bb9e5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/components/Svg.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { ReactNode } from 'react'\n\ninterface Props {\n readonly fill?: string\n readonly width?: number\n readonly height?: number\n readonly viewBox?: string\n readonly className?: string\n readonly xmlns?: string\n readonly xmlnsXlink?: string\n readonly children?: ReactNode\n}\n\nconst Svg = ({ children, ...props }: Props) => <svg {...props}>{children}</svg>\n\nSvg.defaultProps = {\n xmlns: 'http://www.w3.org/2000/svg',\n xmlnsXlink: 'http://www.w3.org/1999/xlink',\n}\n\nexport default Svg\n\n```"
}
] |
code_store-icons_3c3f6e80
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/__tests__/Svg.test.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\nimport Svg from '../components/Svg'\n\ndescribe('Svg', () => {\n it('should match snapshot', () => {\n const component = render(\n <Svg fill=\"black\">\n <path />\n </Svg>\n ).asFragment()\n expect(component).toMatchSnapshot()\n })\n})\n\n```"
}
] |
code_store-icons_6299b35e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/__tests__/Icon.test.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\n\nimport Icon from '../components/Icon'\n\ndescribe('Icon', () => {\n it('should match snapshot', () => {\n const component = render(<Icon id=\"tst-snapshot\" size={20} />).asFragment()\n expect(component).toMatchSnapshot()\n })\n})\n\n```"
}
] |
code_store-icons_13953fee
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/__tests__/Use.test.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\nimport Use from '../components/Use'\n\ndescribe('Use', () => {\n it('should match snapshot', () => {\n const component = render(\n <svg>\n <Use id=\"tst-snapshot\" />\n </svg>\n ).asFragment()\n expect(component).toMatchSnapshot()\n })\n})\n\n```"
}
] |
code_store-icons_3d838f67
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/__tests__/Enhancements.test.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport {\n getSubset,\n getShape,\n getOrientation,\n getState,\n getType,\n} from '../utils/helpers'\nimport { SHAPES, ORIENTATIONS } from '../utils/enhancements'\n\ndescribe('Enhancements', () => {\n it('should allow supported enhancements', () => {\n const shapes = getSubset('square', SHAPES)\n const orientations = getSubset('down, right', ORIENTATIONS)\n\n expect(shapes).toEqual([\n {\n id: 'square',\n modifier: 'br1',\n },\n ])\n\n expect(orientations).toEqual([\n {\n id: 'down',\n modifier: '--down',\n },\n {\n id: 'right',\n modifier: '--right',\n },\n ])\n })\n\n it('should get the correct shape', () => {\n const square = getShape(16, 'red', 'square')\n const rounded = getShape(20, 'green', 'rounded')\n const circle = getShape(24, 'blue', 'circle')\n\n expect(square.reducedIconSize).toBeLessThan(16)\n expect(rounded.reducedIconSize).toBeLessThan(20)\n expect(circle.reducedIconSize).toBeLessThan(24)\n\n expect(square.wrapperProps).toHaveLength(2)\n expect(rounded.wrapperProps).toHaveLength(2)\n expect(circle.wrapperProps).toHaveLength(2)\n\n expect(square.wrapperProps[0].className).toContain('br1')\n expect(rounded.wrapperProps[0].className).toContain('br3')\n expect(circle.wrapperProps[0].className).toContain('br-100')\n\n expect(square.wrapperProps[1].style!.backgroundColor).toEqual('red')\n expect(rounded.wrapperProps[1].style!.backgroundColor).toEqual('green')\n expect(circle.wrapperProps[1].style!.backgroundColor).toEqual('blue')\n })\n\n it('should get the correct orientation', () => {\n const up = getOrientation('up')\n const down = getOrientation('down')\n const left = getOrientation('left')\n const right = getOrientation('right')\n\n expect(up).toEqual('--up')\n expect(down).toEqual('--down')\n expect(left).toEqual('--left')\n expect(right).toEqual('--right')\n })\n\n it('should get the correct state', () => {\n const on = getState('on')\n const off = getState('off')\n\n expect(on).toEqual('--on')\n expect(off).toEqual('--off')\n })\n\n it('should get the correct type', () => {\n const filled = getType('filled')\n const outline = getType('outline')\n const line = getType('line')\n\n expect(filled).toEqual('--filled')\n expect(outline).toEqual('--outline')\n expect(line).toEqual('--line')\n })\n})\n\n```"
}
] |
code_store-icons_b2e3b45d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-icons/react/testUtils/setupTests.tsx from the store-icons VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\n// react-testing-library renders your components to document.body,\n// this will ensure they're removed after each test.\nimport 'react-testing-library/cleanup-after-each'\n\n// this adds jest-dom's custom assertions\nimport 'jest-dom/extend-expect'\n\n```"
}
] |
code_buybox-graphql_214bb441
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of buybox-graphql/docs/README.md from the buybox-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# Buybox GraphQL\n\n> ⚠️ This app is no longer maintained by VTEX. This means support and maintenance are no longer provided.\n\nThis app exports a GraphQL schema to sort sellers on [buybox-context](https://github.com/vtex-apps/buybox-context).\n\n### Installation\n\nTo use it in your app, add the following dependency in the `manifest.json` file:\n```json\n \"dependencies\": {\n \"vtex.buybox-graphql\": \"0.x\"\n }\n```\n\n> This app is used on [buybox-context](https://github.com/vtex-apps/buybox-context), but do you may then use it in your front end component as well.\n\nTo resolve this query, you must have installed in your workspace an app that implements the GraphQL interface. Currently, those are the available resolvers:\n\n- [buybox-resolver](https://github.com/vtex-apps/buybox-resolver)\n\n> 📣 Having zero or more than one resolver installed will result in an error.\n\n### Examples\n\nUsing this resolver do you can provide informations about the `Product` and `Shipping` to get an array with sorted sellers. The array returned is a list of `sellerId`.\n\n```graphql\nquery SortSellersProtocol {\n sortSellers(skuId: \"33\", postalCode: \"00000000\", country: \"BRA\", salesChannel: 1) {\n sellers\n }\n}\n```\n\nThis returns sellers id's inside the `Product`. Here's a possible response for the execution of this query:\n\n```graphql\n{\n \"data\": {\n \"sortSellers\": {\n sellers: [\"seller1\", \"seller3\", \"seller4\", \"otherSeller\"]\n }\n }\n}\n```\n\n```"
}
] |
code_buybox-graphql_250e1067
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of buybox-graphql/graphql/schema.graphql from the buybox-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```graphql\ntype Query {\n sortSellers(\n skuId: ID!\n salesChannel: Int\n country: String\n postalCode: String\n ): SortedSellers @cacheControl(scope: SEGMENT, maxAge: SHORT) @withSegment\n}\n\n```"
}
] |
code_buybox-graphql_2693b0a2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of buybox-graphql/node/package.json from the buybox-graphql VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"buybox-graphql\",\n \"description\": \"Don't delete this file, it's necessary to generate the TypeScript types of the GraphQL\"\n}\n\n```"
}
] |
code_antifraud-provider-example_025df024
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of antifraud-provider-example/node/service.json from the antifraud-provider-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"memory\": 256,\n \"ttl\": 10,\n \"timeout\": 2,\n \"minReplicas\": 2,\n \"maxReplicas\": 4,\n \"workers\": 1,\n \"routes\": {\n \"sendAntifraudData\": {\n \"path\": \"/fake-antifraud/transactions\",\n \"public\": true\n },\n \"listManifest\": {\n \"path\": \"/fake-antifraud/manifest\",\n \"public\": true\n },\n \"getAntifraudStatus\": {\n \"path\": \"/fake-antifraud/transactions/:transactionId\",\n \"public\": true\n },\n \"preAnalysis\": {\n \"path\": \"/fake-antifraud/pre-analysis\",\n \"public\": true\n },\n \"changeTransactionStatus\": {\n \"path\": \"/fake-antifraud/transactions/:transactionId/:newStatus\",\n \"public\": true\n }\n }\n}\n\n```"
}
] |
code_antifraud-provider-example_7ae7d371
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of antifraud-provider-example/node/types.ts from the antifraud-provider-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport interface Minicart {\n buyer: Buyer\n shipping: Shipping\n items: Item[]\n listRegistry?: ListRegistry\n}\n\ninterface Buyer {\n id: string\n firstName: string\n lastName: string\n document: string\n documentType: string\n email: string\n phone: string\n address: Address\n}\n\ninterface Shipping {\n value: number\n estimatedDate: string\n address: Address\n}\n\ninterface Item {\n id: string\n name: string\n price: number\n quantity: number\n deliveryType: string\n deliverySlaInMinutes: number\n categoryId: number\n categoryName: string\n discount: string\n sellerId: string\n taxValue: number\n}\n\ninterface ListRegistry {\n name: string\n deliveryToOwner: boolean\n}\n\nexport interface Payments {\n id: string\n method: string\n name: string\n value: number\n currencyIso4217: string\n installments: number\n details: PaymentsDetails\n}\n\ninterface PaymentsDetails {\n bin: string\n lastDigits: string\n holder: string\n}\n\ninterface Address {\n country: string\n street: string\n number: string\n complement: string\n neighborhood: string\n postalCode: string\n city: string\n state: string\n}\n\n```"
}
] |
code_antifraud-provider-example_2eb5cfae
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of antifraud-provider-example/node/package.json from the antifraud-provider-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"co-body\": \"^6.0.0\",\n \"ramda\": \"^0.25.0\",\n \"uuid\": \"^8.3.2\",\n \"@vtex/clients\": \"^2.19.4\"\n },\n \"devDependencies\": {\n \"@types/co-body\": \"^0.0.3\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.0.0\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@types/uuid\": \"^8.3.4\",\n \"@vtex/api\": \"6.45.21\",\n \"@vtex/test-tools\": \"^1.0.0\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"typescript\": \"3.9.7\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty\"\n },\n \"version\": \"0.2.0\"\n}\n\n```"
}
] |
code_antifraud-provider-example_1df32237
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of antifraud-provider-example/node/index.ts from the antifraud-provider-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { ClientsConfig, ServiceContext, RecorderState } from '@vtex/api'\nimport { method, Service } from '@vtex/api'\n\nimport { Clients } from './clients'\nimport { getAntifraudStatus } from './middlewares/getAntifraudStatus'\nimport { listManifest } from './middlewares/listManifest'\nimport { preAnalysis } from './middlewares/preAnalysis'\nimport { sendAntifraudData } from './middlewares/sendAntifraudData'\nimport { Minicart, Payments } from './types'\n\nconst TIMEOUT_MS = 800\n\nconst clients: ClientsConfig<Clients> = {\n implementation: Clients,\n options: {\n default: {\n retries: 2,\n timeout: TIMEOUT_MS,\n },\n },\n}\n\ndeclare global {\n type Context = ServiceContext<Clients, AntifraudRequestState>\n\n interface AntifraudRequestState extends RecorderState {\n reference: string\n id: string\n value: string\n ip: string\n deviceFingerprint?: string\n store: string\n miniCart: Minicart\n payments: Payments\n hook: string\n transactionStartDate: string\n }\n}\n\nexport default new Service({\n clients,\n routes: {\n sendAntifraudData: method({\n POST: [sendAntifraudData],\n }),\n listManifest: method({\n GET: [listManifest],\n }),\n getAntifraudStatus: method({\n GET: [getAntifraudStatus],\n }),\n preAnalysis: method({\n POST: [preAnalysis],\n }),\n },\n})\n\n```"
}
] |
code_antifraud-provider-example_efba26e7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of antifraud-provider-example/node/clients/index.ts from the antifraud-provider-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\nimport { vbaseFor } from '@vtex/clients'\n\nexport const TRANSACTION_BUCKET = 'transaction'\n\nexport interface AntifraudTransactionResponse {\n id: string\n tid: string\n status: string\n score: number | null\n analysisType: string\n responses: Record<string, string>\n code: string\n message: string\n _metadata?: Record<string, any>\n}\n\nexport const AntifraudTransactionsStorage = vbaseFor<\n string,\n AntifraudTransactionResponse\n>(TRANSACTION_BUCKET)\nexport type AntifraudTransactionsStorage = InstanceType<\n typeof AntifraudTransactionsStorage\n>\n\nexport class Clients extends IOClients {\n public get antifraudTransactionStorage() {\n return this.getOrSet(\n 'antifraudTransactionStorage',\n AntifraudTransactionsStorage\n )\n }\n}\n\n```"
}
] |
code_antifraud-provider-example_d413bd87
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of antifraud-provider-example/node/middlewares/preAnalysis.ts from the antifraud-provider-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { UserInputError } from '@vtex/api'\nimport { json } from 'co-body'\nimport { v4 as uuidv4 } from 'uuid'\n\nimport { AntifraudTransactionResponse } from '../clients'\nimport { approvedRequest, deniedRequest } from './utils'\n\nexport async function preAnalysis(ctx: Context, next: () => Promise<any>) {\n ctx.state = await json(ctx.req)\n\n const { id, miniCart } = ctx.state\n const tid = uuidv4()\n\n let response: AntifraudTransactionResponse\n\n switch (miniCart?.buyer?.firstName) {\n case 'Error500':\n throw new Error('Invalid transaction')\n case 'Error400':\n throw new UserInputError('Invalid transaction')\n case 'Risky':\n response = deniedRequest(id, tid)\n break\n default:\n response = approvedRequest(id, tid)\n break\n }\n\n ctx.body = response\n ctx.status = 200\n await next()\n}\n\n```"
}
] |
code_antifraud-provider-example_fb86280d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of antifraud-provider-example/node/middlewares/utils.ts from the antifraud-provider-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { AntifraudTransactionResponse } from '../clients'\n\nexport const approvedRequest = (id: string, tid: string, code?: string) => {\n return {\n id,\n tid,\n status: 'approved',\n code: code ?? '2000',\n message: 'Low risk of fraud',\n analysisType: 'automatic',\n score: 5.01,\n responses: {\n customIdentifier: 'test',\n },\n }\n}\n\nexport const receivedRequest = (id: string, tid: string, code?: string) => {\n return {\n id,\n tid,\n status: 'received',\n code: code ?? '2001',\n message: 'Low risk of fraud',\n analysisType: 'automatic',\n score: 5.01,\n responses: {\n customIdentifier: 'test',\n },\n }\n}\n\nexport const deniedRequest = (id: string, tid: string, code?: string) => {\n return {\n id,\n tid,\n status: 'denied',\n code: code ?? '4001',\n message: 'Extremely risky',\n analysisType: 'automatic',\n score: 99.01,\n responses: {\n customIdentifier: 'test',\n },\n }\n}\n\nexport const getTransactionStatus = (\n transaction: AntifraudTransactionResponse\n): AntifraudTransactionResponse => {\n const firstPaymentLastFourDigits =\n transaction._metadata?.payments[0]?.details?.lastDigits\n\n const { _metadata, ...transactionResponse } = transaction\n\n if (transaction.status !== 'received' && transaction.status !== 'undefined') {\n return transactionResponse\n }\n\n if (firstPaymentLastFourDigits === '1234') {\n return deniedRequest(transaction.id, transaction.tid)\n }\n\n if (transaction._metadata?.counter === 5) {\n return approvedRequest(transaction.id, transaction.tid)\n }\n\n return transactionResponse\n}\n\nconst lastCharFromString = (item: string) => {\n return item.charAt(item.length - 1)\n}\n\nexport const handleTestSuiteTransaction = (id: string, tid: string) => {\n if (lastCharFromString(id) === '1') {\n return approvedRequest(id, tid)\n }\n\n if (lastCharFromString(id) === '2') {\n return deniedRequest(id, tid)\n }\n\n if (lastCharFromString(id) === '3' || lastCharFromString(id) === '5') {\n return approvedRequest(id, tid, 'async')\n }\n\n if (lastCharFromString(id) === '4' || lastCharFromString(id) === '6') {\n return deniedRequest(id, tid, 'async')\n }\n\n return receivedRequest(id, tid)\n}\n\nexport const possibleStatus = ['received', 'undefined', 'approved', 'denied']\n\n```"
}
] |
code_antifraud-provider-example_1aa2d3aa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of antifraud-provider-example/node/middlewares/getAntifraudStatus.ts from the antifraud-provider-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { UserInputError } from '@vtex/api'\n\nimport { TRANSACTION_BUCKET } from '../clients'\nimport { getTransactionStatus, handleTestSuiteTransaction } from './utils'\n\nexport async function getAntifraudStatus(\n ctx: Context,\n next: () => Promise<any>\n) {\n const { antifraudTransactionStorage } = ctx.clients\n const { transactionId } = ctx.vtex.route.params\n const headers = ctx.header\n\n if (typeof transactionId !== 'string') {\n throw new UserInputError(\n 'The transactionId route parameter must be a string'\n )\n }\n\n const transaction = await antifraudTransactionStorage.get(transactionId)\n\n const transactionStatus = getTransactionStatus(transaction)\n\n const isTestSuite = headers['x-provider-api-is-testsuite'] === 'true'\n\n ctx.status = 200\n ctx.set('Cache-Control', 'no-cache, no-store')\n\n if (isTestSuite) {\n const antifraudTransaction = handleTestSuiteTransaction(\n transaction.id,\n transaction.tid\n )\n\n if (\n antifraudTransaction.code === 'async' &&\n transaction.status === 'received'\n ) {\n await antifraudTransactionStorage.saveJSON(\n TRANSACTION_BUCKET,\n transactionId,\n {\n ...antifraudTransaction,\n }\n )\n transaction.status = 'undefined'\n\n ctx.body = transaction\n await next()\n\n return\n }\n\n ctx.body = antifraudTransaction\n await next()\n\n return\n }\n\n if (transactionStatus.status === 'received') {\n transactionStatus.status = 'undefined'\n }\n\n if (!isTestSuite) {\n antifraudTransactionStorage.saveJSON(TRANSACTION_BUCKET, transactionId, {\n ...transactionStatus,\n _metadata: {\n counter: (transaction._metadata?.counter as number) + 1,\n payments: transaction._metadata?.payments,\n },\n })\n }\n\n delete transactionStatus._metadata\n\n ctx.body = transactionStatus\n\n await next()\n}\n\n```"
}
] |
code_antifraud-provider-example_351dff14
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of antifraud-provider-example/node/middlewares/sendAntifraudData.ts from the antifraud-provider-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { UserInputError } from '@vtex/api'\nimport { json } from 'co-body'\nimport { v4 as uuidv4 } from 'uuid'\n\nimport { AntifraudTransactionResponse, TRANSACTION_BUCKET } from '../clients'\nimport { approvedRequest, deniedRequest, receivedRequest } from './utils'\n\nexport async function sendAntifraudData(\n ctx: Context,\n next: () => Promise<any>\n) {\n const headers = ctx.header\n ctx.state = await json(ctx.req)\n\n const isTestSuite = headers['x-provider-api-is-testsuite'] === 'true'\n\n const { antifraudTransactionStorage } = ctx.clients\n\n const { id, miniCart, payments } = ctx.state\n const tid = uuidv4()\n\n if (isTestSuite) {\n const testSuiteTransaction = receivedRequest(id, tid)\n ctx.body = testSuiteTransaction\n ctx.status = 200\n\n await antifraudTransactionStorage.saveJSON(TRANSACTION_BUCKET, id, {\n ...testSuiteTransaction,\n _metadata: {\n counter: 1,\n payments,\n },\n })\n\n await next()\n return\n }\n\n let response: AntifraudTransactionResponse\n\n switch (miniCart?.buyer?.firstName) {\n case 'Error500':\n throw new Error('Invalid transaction')\n case 'Error400':\n throw new UserInputError('Invalid transaction')\n case 'NotRisky':\n response = approvedRequest(id, tid)\n break\n case 'Risky':\n response = deniedRequest(id, tid)\n break\n default:\n response = receivedRequest(id, tid)\n break\n }\n\n const transaction = {\n ...response,\n _metadata: {\n counter: 1,\n payments,\n },\n }\n\n await antifraudTransactionStorage.saveJSON(\n TRANSACTION_BUCKET,\n id,\n transaction\n )\n\n ctx.body = response\n ctx.status = 200\n await next()\n}\n\n```"
}
] |
code_antifraud-provider-example_51a80653
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of antifraud-provider-example/node/middlewares/listManifest.ts from the antifraud-provider-example VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport async function listManifest(ctx: Context, next: () => Promise<any>) {\n ctx.body = {\n customFields: [\n {\n name: 'Test 1',\n type: 'text',\n },\n {\n name: 'Test select',\n type: 'select',\n options: [\n {\n text: 'Test select 1',\n value: 'Test select 1',\n },\n {\n text: 'Test select 1',\n value: 'Test select 2',\n },\n ],\n },\n ],\n }\n ctx.status = 200\n await next()\n}\n\n```"
}
] |
code_events-example-publisher_a42155fb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-publisher/docs/README.md from the events-example-publisher VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# Events Example\n\nApp in VTEX IO designed to send events using a time interval and IO's Events system.\n\n### How it works?\n\n```"
}
] |
code_events-example-publisher_3ddf94c8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-publisher/node/service.json from the events-example-publisher VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"memory\": 128,\n \"ttl\": 10,\n \"timeout\": 2,\n \"minReplicas\": 2,\n \"maxReplicas\": 10,\n \"workers\": 4,\n \"routes\": {\n \"notify\": {\n \"path\": \"/_v/app/events-example-publisher/notify\",\n \"public\": true\n }\n }\n}\n```"
}
] |
code_events-example-publisher_316dccb5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-publisher/node/package.json from the events-example-publisher VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"co-body\": \"^6.0.0\",\n \"jwt-decode\": \"^3.1.2\"\n },\n \"devDependencies\": {\n \"@types/co-body\": \"^0.0.3\",\n \"@types/node\": \"12.x\",\n \"@vtex/api\": \"6.45.12\",\n \"eslint\": \"^6.3.0\",\n \"eslint-config-vtex\": \"^11.0.0\",\n \"prettier\": \"^1.18.2\",\n \"typescript\": \"3.9.7\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty && eslint -c .eslintrc.json --fix './**/*.ts'\"\n },\n \"version\": \"0.7.2\"\n}\n\n```"
}
] |
code_events-example-publisher_6348ab9b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-publisher/node/constants.ts from the events-example-publisher VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const ENABLED_GLOBALLY = true\n\nexport const EVENT_EXAMPLE = 'random-number-generated'\n\nexport const TIME_INTERVAL = 10\n\n```"
}
] |
code_events-example-publisher_9f68e1dc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-publisher/node/index.ts from the events-example-publisher VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {\n Service,\n IOClients,\n ParamsContext,\n ServiceContext,\n RecorderState,\n method,\n} from '@vtex/api'\nimport { createSendEvent } from './routes/notify'\n\nconst TREE_SECONDS_MS = 3 * 1000\nconst CONCURRENCY = 10\n\ndeclare global {\n type Context = ServiceContext<IOClients, State>\n\n interface State extends RecorderState {\n code: number\n }\n}\n\nexport default new Service<IOClients, State, ParamsContext>({\n clients: {\n options: {\n events: {\n //Informações opcionais\n exponentialTimeoutCoefficient: 2,\n exponentialBackoffCoefficient: 2,\n initialBackoffDelay: 50,\n retries: 1,\n timeout: TREE_SECONDS_MS,\n concurrency: CONCURRENCY,\n },\n },\n },\n routes: {\n notify: method({\n POST: [createSendEvent]\n }),\n },\n})\n\n```"
}
] |
code_events-example-publisher_bb2d01a2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-publisher/node/utils/randomNumber.ts from the events-example-publisher VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function getRandomNumber() {\n return Math.round(Math.random() * 100)\n}\n\n```"
}
] |
code_events-example-publisher_2e00f182
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of events-example-publisher/node/routes/notify.ts from the events-example-publisher VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { getRandomNumber } from '../utils/randomNumber'\n\nexport async function createSendEvent(ctx: Context) {\n const random = getRandomNumber().toString()\n await ctx.clients.events.sendEvent('', 'random-number-generated', {\n random\n })\n ctx.status = 200\n ctx.body = 'Evento disparado com o payload ' + random\n}\n\n```"
}
] |
code_responsive-layout_7d05253f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of responsive-layout/messages/pt.json from the responsive-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"teste\",\n \"store/test\": \"teste\"\n}\n```"
}
] |
code_responsive-layout_dd2bd5b6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of responsive-layout/messages/en.json from the responsive-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"test\",\n \"store/test\": \"test\"\n}\n\n```"
}
] |
code_responsive-layout_faf79975
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of responsive-layout/messages/es.json from the responsive-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/test\": \"teste\",\n \"store/test\": \"teste\"\n}\n```"
}
] |
code_responsive-layout_1a46848c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of responsive-layout/docs/README.md from the responsive-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n# Responsive Layout\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\nResponsive Layout allows you to declare layout structures that will only be rendered in a specific screen-size breakpoint.\n\n\n\nThis app defines and exports four blocks:\n\n- `responsive-layout.desktop`\n- `responsive-layout.mobile`\n- `responsive-layout.tablet`\n- `responsive-layout.phone`\n\nEach block has `composition: children`, which means that it expects to receive an array of `children` blocks for rendering if the current screen-size is right for its breakpoint.\n\n## Configuration\n\n1. Import the Responsive Layout app to your theme dependencies in the `manifest.json`. For example:\n\n```json\n \"dependencies\": {\n \"vtex.responsive-layout\": \"0.x\"\n }\n```\n\n2. Add the `responsive-layout` block to your theme. For example:\n\n```json\n \"store.custom#about-us\": {\n \"blocks\": [\n \"responsive-layout.desktop\",\n \"responsive-layout.tablet\",\n \"responsive-layout.phone\"\n ]\n },\n\n \"responsive-layout.desktop\": {\n \"children\": [\"rich-text#desktop\"]\n },\n \"responsive-layout.tablet\": {\n \"children\": [\"rich-text#tablet\"]\n },\n \"responsive-layout.phone\": {\n \"children\": [\"rich-text#phone\"]\n },\n\n \"rich-text#desktop\": {\n \"props\": {\n \"text\": \"# This will only show up on desktop.\",\n \"blockClass\": \"title\"\n }\n },\n \"rich-text#tablet\": {\n \"props\": {\n \"text\": \"# This will only show up on tablet.\",\n \"blockClass\": \"title\"\n }\n },\n \"rich-text#phone\": {\n \"props\": {\n \"text\": \"# This will only show up on phone.\",\n \"blockClass\": \"title\"\n }\n },\n```\n\nNote that you could use _any_ array of blocks as `children`, given that they are allowed by the `block` that is directly above `responsive-layout`.\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n <tr>\n <td align=\"center\"><a href=\"http://gabenna.io\"><img src=\"https://avatars1.githubusercontent.com/u/4580524?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Micael Pereira</b></sub></a><br /><a href=\"https://github.com/vtex-apps/responsive-layout/commits?author=micas06gua\" title=\"Documentation\">📖</a></td>\n </tr>\n</table>\n\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n```"
}
] |
code_responsive-layout_f72e6a8b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of responsive-layout/react/ResponsiveLayoutDummy.tsx from the responsive-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nconst ResponsiveLayoutDummy = () => {\n console.error(\n 'You are inserting the `responsive-layout` block directly. Please use `responsive-layout.desktop`, `responsive-layout.mobile`, `responsive-layout.tablet` or `responsive-layout.phone` instead.'\n )\n\n return null\n}\n\nexport default ResponsiveLayoutDummy\n\n```"
}
] |
code_responsive-layout_707f9bb2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of responsive-layout/react/ResponsiveLayoutDesktop.tsx from the responsive-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, FC } from 'react'\nimport { useDevice } from 'vtex.device-detector'\n\nconst ResponsiveLayoutDesktop: FC = ({ children }) => {\n const { device } = useDevice()\n\n return device === 'desktop' ? <Fragment>{children}</Fragment> : null\n}\n\nexport default ResponsiveLayoutDesktop\n\n```"
}
] |
code_responsive-layout_f896689b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of responsive-layout/react/package.json from the responsive-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"lint\": \"tsc --noEmit && eslint --ext ts,tsx .\",\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"apollo-client\": \"^2.6.3\",\n \"react\": \"^16.8.6\",\n \"react-apollo\": \"^2.5.8\",\n \"react-dom\": \"^16.8.6\",\n \"react-intl\": \"^2.9.0\"\n },\n \"devDependencies\": {\n \"@types/graphql\": \"^14.2.2\",\n \"@types/react\": \"^16.8.22\",\n \"@types/react-intl\": \"^2.3.18\",\n \"@vtex/test-tools\": \"^0.3.2\",\n \"@vtex/tsconfig\": \"^0.2.0\",\n \"eslint\": \"5.x\",\n \"eslint-config-vtex-react\": \"^5.0.1\",\n \"prettier\": \"^1.18.2\",\n \"typescript\": \"3.7.3\"\n },\n \"version\": \"0.1.4\"\n}\n\n```"
}
] |
code_responsive-layout_152e4707
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of responsive-layout/react/ResponsiveLayoutTablet.tsx from the responsive-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, FC } from 'react'\nimport { useDevice } from 'vtex.device-detector'\n\nconst ResponsiveLayoutTablet: FC = ({ children }) => {\n const { device } = useDevice()\n\n return device === 'tablet' ? <Fragment>{children}</Fragment> : null\n}\n\nexport default ResponsiveLayoutTablet\n\n```"
}
] |
code_responsive-layout_8b705933
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of responsive-layout/react/ResponsiveLayoutPhone.tsx from the responsive-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, FC } from 'react'\nimport { useDevice } from 'vtex.device-detector'\n\nconst ResponsiveLayoutPhone: FC = ({ children }) => {\n const { device } = useDevice()\n\n return device === 'phone' ? <Fragment>{children}</Fragment> : null\n}\n\nexport default ResponsiveLayoutPhone\n\n```"
}
] |
code_responsive-layout_a00ee75e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of responsive-layout/react/ResponsiveLayoutMobile.tsx from the responsive-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, FC } from 'react'\nimport { useDevice } from 'vtex.device-detector'\n\nconst ResponsiveLayoutMobile: FC = ({ children }) => {\n const { isMobile } = useDevice()\n\n return isMobile ? <Fragment>{children}</Fragment> : null\n}\n\nexport default ResponsiveLayoutMobile\n\n```"
}
] |
code_responsive-layout_3b1353dc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of responsive-layout/store/interfaces.json from the responsive-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"responsive-layout\": {\n \"component\": \"ResponsiveLayoutDummy\"\n },\n \"responsive-layout.desktop\": {\n \"component\": \"ResponsiveLayoutDesktop\",\n \"composition\": \"children\",\n \"device\": \"desktop\"\n },\n \"responsive-layout.mobile\": {\n \"component\": \"ResponsiveLayoutMobile\",\n \"composition\": \"children\",\n \"device\": \"mobile\"\n },\n \"responsive-layout.tablet\": {\n \"component\": \"ResponsiveLayoutTablet\",\n \"composition\": \"children\",\n \"device\": \"tablet\"\n },\n \"responsive-layout.phone\": {\n \"component\": \"ResponsiveLayoutPhone\",\n \"composition\": \"children\",\n \"device\": \"phone\"\n }\n}\n\n```"
}
] |
code_responsive-layout_1fd31117
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of responsive-layout/react/typings/vtex.render-runtime.d.ts from the responsive-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint @typescript-eslint/no-explicit-any: 0 */\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ReactElement } from 'react'\n\n export interface RenderContextProps {\n runtime: {\n account: string\n }\n }\n\n export interface InjectedRuntime {\n runtime: RenderRuntime\n }\n\n interface Pages {\n [name: string]: Page\n }\n\n interface Route {\n domain: string\n blockId: string\n canonicalPath?: string\n id: string\n params: Record<string, string>\n path: string\n title?: string\n }\n\n interface Culture {\n availableLocales: string[]\n locale: string\n language: string\n country: string\n currency: string\n }\n\n export interface RenderRuntime {\n account: string\n accountId: string\n appsEtag: string\n workspace: string\n disableSSR: boolean\n hints: {\n desktop: boolean\n mobile: boolean\n phone: boolean\n tablet: boolean\n }\n page: string\n route: Route\n version: string\n culture: Culture\n pages: Pages\n preview: boolean\n production: boolean\n publicEndpoint: string\n renderMajor: number\n query?: Record<string, string>\n start: boolean\n runtimeMeta: {\n version: string\n config?: any\n }\n settings: {\n [app: string]: any\n }\n segmentToken: string\n rootPath?: string\n workspaceCookie: string\n hasNewExtensions: boolean\n }\n\n export const Link: any\n export const NoSSR: any\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const withRuntimeContext: any\n export const Helmet: any\n export const useRuntime: () => RenderRuntime\n export const ExtensionPoint: any\n}\n\n```"
}
] |
code_responsive-layout_fb40fecd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of responsive-layout/react/__tests__/index.test.tsx from the responsive-layout VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\ndescribe('Orders List Scenarios', () => {\n it('should work', () => {\n expect(1).toBe(1)\n })\n})\n\n```"
}
] |
code_recommendation-shelf_24b5710a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/messages/pt.json from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.recommendation-shelf\": \"Vitrine de Recomendação\",\n \"admin/editor.recommendation-shelf.description\": \"A Vitrine de Recomendação é um componente que exibe uma coleção de itens recomendados ao usuário com base em diversos algoritmos e dados de contexto.\",\n \"admin/editor.recommendation-shelf.title\": \"Título da Vitrine\",\n \"admin/editor.recommendation-shelf.campaign-vrn\": \"VRN da Campanha\",\n \"admin/editor.recommendation-shelf.display-title\": \"Mostrar Título\",\n \"admin/editor.recommendation-shelf.items-context\": \"Contexto dos Itens\",\n \"admin/editor.recommendation-shelf.items-context.description\": \"De onde recuperar os itens que serão usados como contexto na requisição de recomendação\",\n \"admin/editor.recommendation-shelf.items-context.cart\": \"Carrinho\",\n \"admin/editor.recommendation-shelf.items-context.pdp\": \"Página de Produto\"\n}\n\n```"
}
] |
code_recommendation-shelf_2158915e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/messages/en.json from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.recommendation-shelf\": \"Recommendation Shelf\",\n \"admin/editor.recommendation-shelf.description\": \"Recommendation Shelf is a component that displays a collection of items that are recommended to the user based on various algorithms and context data.\",\n \"admin/editor.recommendation-shelf.title\": \"Shelf title\",\n \"admin/editor.recommendation-shelf.campaign-vrn\": \"Campaign VRN\",\n \"admin/editor.recommendation-shelf.display-title\": \"Display title\",\n \"admin/editor.recommendation-shelf.items-context\": \"Items Context\",\n \"admin/editor.recommendation-shelf.items-context.description\": \"From where to retrieve the items that will be used as context in the Recommendation request\",\n \"admin/editor.recommendation-shelf.items-context.cart\": \"Cart\",\n \"admin/editor.recommendation-shelf.items-context.pdp\": \"Product Page\"\n}\n\n```"
}
] |
code_recommendation-shelf_c5bb2b49
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/messages/context.json from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.recommendation-shelf\": \"Recommendation Shelf\",\n \"admin/editor.recommendation-shelf.description\": \"Recommendation Shelf is a component that displays a collection of items that are recommended to the user based on various algorithms and context data.\",\n \"admin/editor.recommendation-shelf.title\": \"Shelf title\",\n \"admin/editor.recommendation-shelf.campaign-vrn\": \"Campaign VRN\",\n \"admin/editor.recommendation-shelf.display-title\": \"Display title\",\n \"admin/editor.recommendation-shelf.items-context\": \"Items Context\",\n \"admin/editor.recommendation-shelf.items-context.description\": \"From where to retrieve the items that will be used as context in the Recommendation request\",\n \"admin/editor.recommendation-shelf.items-context.cart\": \"Cart\",\n \"admin/editor.recommendation-shelf.items-context.pdp\": \"Product Page\"\n}\n\n```"
}
] |
code_recommendation-shelf_982ba227
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/messages/es.json from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.recommendation-shelf\": \"Estantería de recomendaciones\",\n \"admin/editor.recommendation-shelf.description\": \"La estantería de recomendaciones es un componente que muestra una colección de artículos recomendados al usuario según varios algoritmos y datos de contexto.\",\n \"admin/editor.recommendation-shelf.title\": \"Título de la estantería\",\n \"admin/editor.recommendation-shelf.campaign-vrn\": \"Campaña VRN\",\n \"admin/editor.recommendation-shelf.display-title\": \"Mostrar título\",\n \"admin/editor.recommendation-shelf.items-context\": \"Contexto de los artículos\",\n \"admin/editor.recommendation-shelf.items-context.description\": \"Contexto de los artículos\",\n \"admin/editor.recommendation-shelf.items-context.cart\": \"Carrito\",\n \"admin/editor.recommendation-shelf.items-context.pdp\": \"Página de producto\"\n}\n\n```"
}
] |
code_recommendation-shelf_f7fec000
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/docs/README.md from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n> 📢 Use this project, [contribute](https://github.com/vtex-apps/recommendation-shelf) to it, or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Recommendation Shelf\n\n> ⚠️ This app is currently under development and research by the VTEX Search and Personalization team. During this phase, it should only be installed on selected accounts participating in the closed beta phase of the [Product Recommendations](https://help.vtex.com/en/tutorial/product-recommendations-beta--2QIexbD2FSXBxELUnFtg7g) feature. For other accounts, installing this app will not have any effect. If you want to adopt this feature for your business, please contact [our Support](https://support.vtex.com/hc/en-us/requests).\n\nThe Recommendation Shelf app is a store component that displays a collection of products using recommendation strategies.\n\n\n\n> ℹ️ Learn more about [Product Recommendations](https://help.vtex.com/en/tutorial/product-recommendations-beta--2QIexbD2FSXBxELUnFtg7g).\n\n## Before you begin\n\nMost recommendation strategies rely on user navigation data as input. Therefore, your store must be configured with our pixel for the `recommendation-shelf` to work properly. This configuration is managed by the VTEX team, so please wait for our confirmation before proceeding with the integration.\n\n## Installation\n\nThis app uses our store builder with the blocks architecture. To learn more about Store Builder, [click here.](https://help.vtex.com/en/tutorial/understanding-storebuilder-and-stylesbuilder#structuring-and-configuring-our-store-with-object-object)\n\nFollow these steps to use the Recommendation Shelf app in your store:\n\n1. Add the app as a dependency in your store theme. In your `manifest.json` file, add the following to the `dependencies` section:\n\n ```json\n \"dependencies\": {\n \"vtex.recommendation-shelf\": \"2.x\"\n }\n ```\n\n2. Add the `recommendation-shelf` block into your app theme where you want the shelf to appear.\n\n3. Customize the behavior of the shelf block.\n\n The example below shows the following configuration of the `recommendation-shelf` block and its supporting blocks:\n\n - It creates a `recommendation-shelf#visual-similarity` block that uses the \"VISUAL_SIMILARITY\" recommendation strategy and sets the shelf title to \"Similar items\".\n - It defines a `list-context.product-list-static` block, which includes the `product-summary.shelf` block and a child slider layout.\n - It configures the `slider-layout#recommendation-slider` block to control how many items are shown per page on desktop, tablet, and phone, and enables infinite scrolling.\n\n Example:\n\n ```json\n \"recommendation-shelf#visual-similarity\": {\n \"blocks\": [\"list-context.product-list-static\"],\n \"props\": {\n \"campaignVrn\": \"vrn:recommendations:biggy:rec-similar-v2:00318b68-cb1b-4d5a-8b0f-cc7fbcdd014b\",\n \"title\": \"Similar items\"\n }\n },\n \"list-context.product-list-static\": {\n \"blocks\": [\n \"product-summary.shelf\"\n ],\n \"children\": [\n \"slider-layout#recommendation-slider\"\n ]\n },\n \"slider-layout#recommendation-slider\": {\n \"props\": {\n \"itemsPerPage\": {\n \"desktop\": 5,\n \"tablet\": 3,\n \"phone\": 2\n },\n \"infinite\": true\n }\n }\n ```\n\n4. Customize the product summary (optional).\n\n The Recommendation Shelf relies on the `slider-layout` and `product-summary.shelf` components. You can further customize the shelf by creating a custom product summary, for example:\n\n ```json\n \"product-summary.shelf#custom\": {\n \"children\": [\n \"product-summary-name\",\n \"product-summary-description\",\n \"product-summary-image\",\n \"product-summary-price\",\n \"product-summary-sku-selector\",\n \"product-summary-buy-button\"\n ]\n }\n ```\n\n For more information, see the [Product Summary API configuration](https://github.com/vtex-apps/product-summary/blob/master/README.md#configuration).\n\n### Configuration\n\nYou can configure the `recommendation-shelf` block in your theme app using the following props:\n\n### Props\n\nConfigure the `recommendation-shelf` block using the following properties:\n\n| Prop name | Type | Description | Default value |\n| -------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------- |\n| `title` | `string` | Shelf title displayed to users. | - |\n| `campaignVrn` | `string` | VRN identifier for the recommendation campaign. | - |\n| `displayTitle` | `boolean` | Whether to show the shelf title (`true`) or hide it (`false`). | `true` |\n| `itemsContext` | `array` | Context source for items in the recommendation request (`PDP` or `CART`). Useful for enabling shelves on the cart page with `CROSS_SELL`. | `['PDP']` |\n\n## Recommendation strategies\n\nBelow are the available recommendation strategies that can be used to fetch product suggestions:\n\n| `strategy` | Description | Pages |\n| ------------------- | ----------------------------------------------------------------------------------------- | --------------- |\n| `TOP_ITEMS` | Returns the most bought products in the store. | Any |\n| `PERSONALIZED` | Returns recommended products based on the last products clicked by the user in the store. | Any |\n| `LAST_SEEN` | Returns recommended products based on the last products viewed by the user in the store. | Any |\n| `CROSS_SELL` | Returns complementary products related to the current product or the items in the cart. | Any |\n| `VISUAL_SIMILARITY` | Returns products considered visually similar to the current product. | `store.product` |\n| `SIMILAR_ITEMS` | Returns products considered most similar to the current product. | `store.product` |\n\n## Troubleshooting\n\nCheck if others have encountered similar issues [here](https://github.com/vtex-apps/recommendation-shelf/issues). Feel free to [open issues](https://github.com/vtex-apps/recommendation-shelf/issues/new) or contribute with pull requests.\n\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n\n[](#contributors-)\n\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n \n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n\n<!-- DOCS-IGNORE:end -->\n\n```"
}
] |
code_recommendation-shelf_08e5d771
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/examples/cart.js from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nconst querySelector = '.checkout-container'\nconst workspaceCookie = 'VtexWorkspace'\nconst targetWorkspace = 'master'\n\nfunction getCookie(name) {\n const regex = new RegExp(`(^|;)[ ]*${name}=([^;]*)`)\n const match = regex.exec(document.cookie)\n\n return match ? decodeURIComponent(match[2]) : null\n}\n\nfunction insertIframeAfterCheckoutContainer() {\n const container = document.querySelector(querySelector)\n\n if (!container) return\n\n const iframeContainer = document.createElement('div')\n\n iframeContainer.className = 'recommendations-embedded-shelf'\n iframeContainer.style.width = '100%'\n iframeContainer.style.height = '750px'\n iframeContainer.style.overflow = 'hidden'\n\n const iframe = document.createElement('iframe')\n // URL defined in the store-theme.\n const iframeUrl = '/_v/public/recommendations-embedded-shelf/'\n\n iframe.src = iframeUrl\n iframe.style.width = '100%'\n iframe.style.height = '100%'\n iframe.style.border = 'none'\n iframe.style.marginTop = '-125px'\n iframe.scrolling = 'no'\n iframe.id = 'recommendations-embedded-shelf-iframe'\n\n // Skip displaying the iframe if the current workspace is not the target workspace. Used for A/B testing\n\n // const currentWorkspace = getCookie(workspaceCookie)\n // if (currentWorkspace === null || (currentWorkspace && !currentWorkspace.includes(targetWorkspace))) return\n\n iframeContainer.appendChild(iframe)\n container.parentNode.insertBefore(iframeContainer, container.nextSibling)\n\n setInterval(() => {\n // Validates if the iframe is on the correct page\n if (\n !iframe.contentWindow.location.href.includes(iframeUrl) &&\n !iframe.contentWindow.location.pathname.endsWith('/p') // it should allow redirects to pdp\n ) {\n iframe.contentWindow.location.href =\n iframe.contentWindow.location.origin + iframeUrl\n }\n }, 1000)\n // Syncronize the iframe url with the parent window to allow some navigations...\n iframe.contentWindow.navigation.addEventListener(\n 'navigate',\n function handleIframeNavigate(navigate) {\n if (!navigate.destination.url.includes(iframeUrl)) {\n window.location.href = navigate.destination.url\n }\n\n if (navigate.destination.url.includes('/checkout/#/cart')) {\n window.location.reload()\n }\n }\n )\n}\n\nfunction tryInsertIframe(retries = 100, interval = 75) {\n const container = document.querySelector(querySelector)\n\n if (container) {\n insertIframeAfterCheckoutContainer()\n } else if (retries > 0) {\n setTimeout(() => tryInsertIframe(retries - 1, interval), interval)\n }\n}\n\nwindow.addEventListener('load', () => tryInsertIframe())\n\n```"
}
] |
code_recommendation-shelf_076f2a30
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/react/RecommendationShelf.tsx from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { defineMessages } from 'react-intl'\n\nimport { RecommendationShelfErrorBoundary } from './components/RecommendationShelfErrorBoundary'\nimport { RecommendationShelfContainer } from './components/RecommendationShelfContainer'\n\ndefineMessages({\n shelf: {\n id: 'admin/editor.recommendation-shelf',\n defaultMessage: 'Recommendation Shelf',\n },\n description: {\n id: 'admin/editor.recommendation-shelf.description',\n defaultMessage:\n 'Recommendation Shelf is a component that displays a collection of items that are recommended to the user based on various algorithms and context data.',\n },\n title: {\n id: 'admin/editor.recommendation-shelf.title',\n defaultMessage: 'Shelf title',\n },\n campaignVrn: {\n id: 'admin/editor.recommendation-shelf.campaign-vrn',\n defaultMessage: 'Campaign VRN',\n },\n displayTitle: {\n id: 'admin/editor.recommendation-shelf.display-title',\n defaultMessage: 'Display Title',\n },\n itemsContext: {\n id: 'admin/editor.recommendation-shelf.items-context',\n defaultMessage: 'Items Context',\n },\n itemsContextDescription: {\n id: 'admin/editor.recommendation-shelf.items-context.description',\n defaultMessage:\n 'From where to retrieve the items that will be used as context in the Recommendation request',\n },\n itemsContextCart: {\n id: 'admin/editor.recommendation-shelf.items-context.cart',\n defaultMessage: 'Cart',\n },\n itemsContextPdp: {\n id: 'admin/editor.recommendation-shelf.items-context.pdp',\n defaultMessage: 'Product Page',\n },\n})\n\ntype Props = {\n campaignVrn: string\n title?: string\n displayTitle: boolean\n itemsContext: ItemContextType[]\n}\n\nconst RecommendationShelf: StorefrontFunctionComponent<Props> = ({\n campaignVrn,\n title,\n displayTitle,\n itemsContext,\n}) => {\n if (!campaignVrn) return null\n\n return (\n <RecommendationShelfErrorBoundary>\n <RecommendationShelfContainer\n campaignVrn={campaignVrn}\n title={title}\n displayTitle={displayTitle}\n itemsContext={itemsContext}\n />\n </RecommendationShelfErrorBoundary>\n )\n}\n\nRecommendationShelf.schema = {\n title: 'admin/editor.recommendation-shelf',\n description: 'admin/recommendation-shelf.description',\n type: 'object',\n properties: {\n title: {\n title: 'admin/editor.recommendation-shelf.title',\n type: 'string',\n },\n campaignVrn: {\n title: 'admin/editor.recommendation-shelf.campaign-vrn',\n type: 'string',\n },\n displayTitle: {\n title: 'admin/editor.recommendation-shelf.display-title',\n type: 'boolean',\n default: true,\n },\n itemsContext: {\n title: 'admin/editor.recommendation-shelf.items-context',\n description:\n 'admin/editor.recommendation-shelf.items-context.description',\n type: 'array',\n items: {\n type: 'string',\n enum: ['PDP', 'CART'],\n enumNames: [\n 'admin/editor.recommendation-shelf.items-context.pdp',\n 'admin/editor.recommendation-shelf.items-context.cart',\n ],\n },\n default: ['PDP'],\n },\n },\n}\n\nexport default RecommendationShelf\n\n```"
}
] |
code_recommendation-shelf_13059c3a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/react/package.json from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"name\": \"search-bar\",\n \"version\": \"2.14.2\",\n \"private\": true,\n \"dependencies\": {\n \"react\": \"^16.8.6\",\n \"react-apollo\": \"^3.1.5\",\n \"react-intl\": \"^3.12.0\"\n },\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"browserslist\": {\n \"production\": [\n \">0.2%\",\n \"not dead\",\n \"not op_mini all\"\n ],\n \"development\": [\n \"last 1 chrome version\",\n \"last 1 firefox version\",\n \"last 1 safari version\"\n ]\n },\n \"devDependencies\": {\n \"@types/graphql\": \"^14.5.0\",\n \"@types/node\": \"^14.18.0\",\n \"@vtex/test-tools\": \"^3.4.3\",\n \"@vtex/tsconfig\": \"^0.6.0\",\n \"braces\": \"^3.0.3\",\n \"form-data\": \"^2.5.4\",\n \"js-yaml\": \"^3.14.2\",\n \"micromatch\": \"^4.0.8\",\n \"node-notifier\": \"^8.0.1\",\n \"tough-cookie\": \"^4.1.3\",\n \"typescript\": \"3.9.7\",\n \"vtex.add-to-cart-button\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.add-to-cart-button@0.30.2/public/@types/vtex.add-to-cart-button\",\n \"vtex.css-handles\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@0.4.4/public/@types/vtex.css-handles\",\n \"vtex.flex-layout\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.flex-layout@0.21.4/public/@types/vtex.flex-layout\",\n \"vtex.order-manager\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.order-manager@0.12.0/public/@types/vtex.order-manager\",\n \"vtex.product-context\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.product-context@0.10.1/public/@types/vtex.product-context\",\n \"vtex.product-price\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.product-price@1.31.2/public/@types/vtex.product-price\",\n \"vtex.product-summary\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.product-summary@2.90.4/public/@types/vtex.product-summary\",\n \"vtex.recommendation-bff\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.recommendation-bff@0.22.0/public/@types/vtex.recommendation-bff\",\n \"vtex.recommendation-shelf\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.recommendation-shelf@2.3.1/public/@types/vtex.recommendation-shelf\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.136.1/public/@types/vtex.render-runtime\",\n \"vtex.search-page-context\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.search-page-context@0.2.0/public/@types/vtex.search-page-context\",\n \"vtex.slider-layout\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.slider-layout@0.24.7/public/@types/vtex.slider-layout\"\n },\n \"volta\": {\n \"node\": \"20.16.0\",\n \"yarn\": \"1.19.2\"\n }\n}\n\n```"
}
] |
code_recommendation-shelf_501764c3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/store/contentSchemas.json from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"definitions\": {\n \"RecommendationShelf\": {\n \"type\": \"object\",\n \"properties\": {\n \"title\": {\n \"title\": \"admin/editor.recommendation-shelf.title\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n },\n \"campaignVrn\": {\n \"title\": \"admin/editor.recommendation-shelf.campaign-vrn\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n },\n \"displayTitle\": {\n \"title\": \"admin/editor.recommendation-shelf.display-title\",\n \"type\": \"boolean\",\n \"default\": true\n },\n \"itemsContext\": {\n \"title\": \"admin/editor.recommendation-shelf.items-context\",\n \"type\": \"array\",\n \"default\": [\"PDP\"],\n \"items\": {\n \"title\": \"admin/editor.recommendation-shelf.items-context\",\n \"type\": \"string\",\n \"enum\": [\"PDP\", \"CART\"],\n \"enumNames\": [\n \"admin/editor.recommendation-shelf.items-context.pdp\",\n \"admin/editor.recommendation-shelf.items-context.cart\"\n ]\n }\n }\n }\n }\n }\n}\n\n```"
}
] |
code_recommendation-shelf_44368e17
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/store/blocks.json from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"product-installments#summary\": {\n \"props\": {\n \"blockClass\": \"summary\"\n }\n },\n \"product-price-savings#summary\": {\n \"props\": {\n \"markers\": [\"discount\"],\n \"blockClass\": \"summary\"\n }\n },\n \"product-selling-price#summary\": {\n \"props\": {\n \"blockClass\": \"summary\"\n }\n },\n \"flex-layout.row#selling-price-savings\": {\n \"props\": {\n \"colGap\": 2,\n \"preserveLayoutOnMobile\": true,\n \"preventHorizontalStretch\": true,\n \"marginBottom\": 4\n },\n \"children\": [\n \"product-selling-price#summary\",\n \"product-price-savings#summary\"\n ]\n },\n \"product-list-price#summary\": {\n \"props\": {\n \"blockClass\": \"summary\"\n }\n },\n \"product-summary-image#shelf\": {\n \"props\": {\n \"showBadge\": false,\n \"aspectRatio\": \"1:1\",\n \"maxHeight\": 300\n }\n },\n \"product-summary.shelf\": {\n \"children\": [\n \"product-summary-image#shelf\",\n \"product-summary-name\",\n \"product-summary-space\",\n \"product-list-price#summary\",\n \"flex-layout.row#selling-price-savings\",\n \"product-installments#summary\",\n \"add-to-cart-button\"\n ]\n },\n \"slider-layout#shelf\": {\n \"props\": {\n \"itemsPerPage\": {\n \"desktop\": 5,\n \"tablet\": 3,\n \"phone\": 1\n },\n \"infinite\": true,\n \"fullWidth\": false,\n \"blockClass\": \"shelf\"\n }\n },\n \"list-context.product-list-static\": {\n \"blocks\": [\"product-summary.shelf\"],\n \"children\": [\"slider-layout#shelf\"]\n },\n \"recommendation-shelf\": {\n \"blocks\": [\"list-context.product-list-static\"]\n }\n}\n\n```"
}
] |
code_recommendation-shelf_9ef35075
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/store/interfaces.json from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```json\n{\n \"recommendation-shelf\": {\n \"component\": \"RecommendationShelf\",\n \"required\": [\"list-context.product-list-static\"],\n \"content\": {\n \"$ref\": \"#/definitions/RecommendationShelf\"\n }\n }\n}\n\n```"
}
] |
code_recommendation-shelf_40f639d6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/react/typings/vtex.search-page-context.d.ts from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.search-page-context/SearchPageContext' {\n export const useSearchPage\n}\n\n```"
}
] |
code_recommendation-shelf_0f2ef60d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/react/typings/vtex.order-manager.d.ts from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.order-manager/OrderForm' {\n export * from 'vtex.order-manager/react/OrderForm'\n export { default } from 'vtex.order-manager/react/OrderForm'\n}\n\n```"
}
] |
code_recommendation-shelf_89fc229b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/react/typings/global.d.ts from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport type { FunctionComponent } from 'react'\n\ndeclare global {\n /* eslint-disable @typescript-eslint/ban-types */\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n schema?: object\n getSchema?(props?: P): object\n }\n\n interface Window {\n __RUNTIME__?: {\n account?: string\n // add other properties if needed\n }\n }\n\n export type RecommendationType =\n | 'CROSS_SELL'\n | 'SIMILAR_ITEMS'\n | 'PERSONALIZED'\n | 'TOP_ITEMS'\n | 'LAST_SEEN'\n | 'VISUAL_SIMILARITY'\n | 'SEARCH_BASED'\n\n export type ItemContextType = 'PDP' | 'CART'\n}\n\n```"
}
] |
code_recommendation-shelf_45402162
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/react/typings/css.d.ts from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const styles: {\n [key: string]: string\n }\n\n export default styles\n}\n\n```"
}
] |
code_recommendation-shelf_6362626d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/react/typings/recommend-bff.d.ts from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'recommend-bff' {\n export type Product = {\n productId: string\n items: Array<{\n itemId: string\n }>\n }\n\n export type RecommendationsV2RequestQuery = {\n an: string\n userId: string\n campaignVrn: string\n products?: string\n }\n\n export type RecommendationsV2Response = {\n products: Product[]\n correlationId: string\n campaign: {\n id: string\n title?: string\n type: RecommendationType\n }\n }\n}\n\n```"
}
] |
code_recommendation-shelf_1920a0f9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/react/utils/requests.ts from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function generateRecOriginHeader(account: string) {\n return {\n 'x-vtex-rec-origin': `${account}/storefront/vtex.recommendation-shelf@2.x`,\n }\n}\n\n```"
}
] |
code_recommendation-shelf_bcd38baa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/react/utils/vrn.ts from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint-disable padding-line-between-statements */\n\ntype RecommendationVrnType =\n | 'rec-cross-v1'\n | 'rec-similar-v1'\n | 'rec-persona-v1'\n | 'rec-last-v1'\n | 'rec-top-items-v1'\n | 'rec-cross-v2'\n | 'rec-similar-v2'\n | 'rec-persona-v2'\n | 'rec-last-v2'\n | 'rec-top-items-v2'\n | 'rec-search-v2'\n\nconst vrnPattern =\n /^vrn:recommendations:[^:]+:(rec-cross-v1|rec-similar-v1|rec-persona-v1|rec-last-v1|rec-top-items-v1|rec-cross-v2|rec-similar-v2|rec-persona-v2|rec-last-v2|rec-top-items-v2|rec-search-v2):[^:]+$/\n\nexport function isValidVrn(campaignVrn: string): boolean {\n return vrnPattern.test(campaignVrn)\n}\n\nfunction parseCampaignVrn(campaignVrn: string) {\n const [_, __, accountName, campaignType, campaignId] = campaignVrn.split(':')\n\n return {\n accountName,\n campaignId,\n campaignVrnType: campaignType as RecommendationVrnType,\n }\n}\n\n// Cross-sell: rec-cross-v1, rec-cross-v2\n// Similar-items: rec-similar-v1, rec-similar-v2\n// Cart Recommmendations: rec-cart-v1, rec-cart-v2\n// Personalized: rec-persona-v1, rec-persona-v2\n// Last Seen: rec-last-v1, rec-last-v2\n// Top items: rec-top-items-v1, rec-top-items-v2\n// Recent interactions: rec-recent-int-v1, rec-recent-int-v2\nexport function getTypeFromVrn(campaignVrn: string): RecommendationType {\n const { campaignVrnType } = parseCampaignVrn(campaignVrn)\n\n switch (campaignVrnType) {\n case 'rec-cross-v1':\n case 'rec-cross-v2':\n return 'CROSS_SELL'\n\n case 'rec-similar-v1':\n case 'rec-similar-v2':\n return 'SIMILAR_ITEMS'\n\n case 'rec-persona-v1':\n case 'rec-persona-v2':\n return 'PERSONALIZED'\n\n case 'rec-last-v1':\n case 'rec-last-v2':\n return 'LAST_SEEN'\n\n case 'rec-top-items-v1':\n case 'rec-top-items-v2':\n return 'TOP_ITEMS'\n\n case 'rec-search-v2':\n return 'SEARCH_BASED'\n\n default:\n throw new Error(`Unknown campaign type: ${campaignVrnType}`)\n }\n}\n\n```"
}
] |
code_recommendation-shelf_2838b044
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/react/utils/logger.ts from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { generateRecOriginHeader } from './requests'\n\ntype LogLevel = 'info' | 'warn' | 'error' | 'debug'\n\ntype LoggerOptions = {\n message: string\n data?: Record<\n string,\n number | string | boolean | undefined | null | object[] | Error\n > // Changed to Record for better type safety\n sendLog?: boolean\n}\n\nfunction getAccount() {\n return window.__RUNTIME__?.account\n}\n\nclass Logger {\n private prefix: string\n\n constructor() {\n this.prefix = '[vtex.recommendation-shelf@2.x]'\n }\n\n public log(level: LogLevel, args: LoggerOptions) {\n const message = `${this.prefix} ${args.message}`\n /* eslint-disable padding-line-between-statements */\n switch (level) {\n case 'info':\n console.info(message, args.data)\n break\n case 'warn':\n console.warn(message, args.data)\n break\n case 'error':\n console.error(message, args.data)\n break\n default:\n // eslint-disable-next-line no-console\n console.log(message, args.data)\n }\n\n // Send log to service if sendLog is true\n if (args.sendLog) {\n this.sendLogToService(level, args)\n }\n }\n\n private async sendLogToService(level: LogLevel, args: LoggerOptions) {\n const account = getAccount()\n if (!account) {\n console.warn('No account found, skipping log sending')\n return\n }\n\n try {\n await fetch(`/api/recommend-bff/logs?an=${account}`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...generateRecOriginHeader(account),\n },\n body: JSON.stringify({\n app: 'vtex.recommendation-shelf',\n message: args.message,\n level,\n url: window.document.URL,\n ...args.data,\n }),\n })\n } catch (error) {\n // Silent fail to avoid logging loops\n console.error(\n `${this.prefix} Failed to send log to service: (${args.message})`,\n error\n )\n }\n }\n\n public info(args: LoggerOptions) {\n this.log('info', args)\n }\n\n public warn(args: LoggerOptions) {\n this.log('warn', args)\n }\n\n public error(args: LoggerOptions) {\n this.log('error', args)\n }\n\n public debug(args: LoggerOptions) {\n this.log('debug', args)\n }\n}\n\nexport const logger = new Logger()\n\n```"
}
] |
code_recommendation-shelf_cc9b82fa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of recommendation-shelf/react/utils/getWithRetry.ts from the recommendation-shelf VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function getWithRetry<T>(\n getFn: () => T,\n retries = 30,\n delay = 200\n): Promise<T> {\n return new Promise((resolve, reject) => {\n function attempt(n: number) {\n try {\n const result = getFn()\n\n if (!result) {\n throw new Error('Result is undefined or null')\n }\n\n resolve(result)\n } catch (error) {\n if (n <= 1) {\n reject(error)\n } else {\n setTimeout(() => attempt(n - 1), delay + (retries - n) * delay)\n }\n }\n }\n\n attempt(retries)\n })\n}\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.