id
stringlengths
12
53
messages
listlengths
3
3
code_checkout-ui-custom_7ce65e3f
[ { "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 checkout-ui-custom/checkout-ui-custom/src/_scss/_components/_header.scss from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```scss\n// _global.scss\n\n\nbody {\n .main-header {\n padding:12px 0;\n text-align: center;\n border-bottom: 1px solid $muted4;\n position:relative; \n background-color: #FFF;\n margin-bottom:40px;\n\n &, > .container { \n display:flex;\n align-items: center;\n @media (max-width:$mobileWidth) {\n justify-content: center;\n }\n } \n > .container {\n &:before,\n &:after {display: none;}\n }\n\n\n .header-link {\n position:absolute;\n left:0px; \n top: calc(100% + 18px);\n display: none;\n a {\n height:20px;\n font-size:11px;\n line-height: 115%;\n padding-left:0px;\n color:$muted2;\n display: flex;\n align-items: center;\n\n &:before {\n display:block;\n float:left;\n width:10px;\n height: 10px;\n\n -webkit-mask:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pg0KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJDYXBhXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgNDQzLjUyIDQ0My41MiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNDQzLjUyIDQ0My41MjsiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPGc+DQoJPGc+DQoJCTxwYXRoIGQ9Ik0xNDMuNDkyLDIyMS44NjNMMzM2LjIyNiwyOS4xMjljNi42NjMtNi42NjQsNi42NjMtMTcuNDY4LDAtMjQuMTMyYy02LjY2NS02LjY2Mi0xNy40NjgtNi42NjItMjQuMTMyLDBsLTIwNC44LDIwNC44DQoJCQljLTYuNjYyLDYuNjY0LTYuNjYyLDE3LjQ2OCwwLDI0LjEzMmwyMDQuOCwyMDQuOGM2Ljc4LDYuNTQ4LDE3LjU4NCw2LjM2LDI0LjEzMi0wLjQyYzYuMzg3LTYuNjE0LDYuMzg3LTE3LjA5OSwwLTIzLjcxMg0KCQkJTDE0My40OTIsMjIxLjg2M3oiLz4NCgk8L2c+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8L3N2Zz4NCg==) no-repeat 50% 50%;\n mask:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pg0KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJDYXBhXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgNDQzLjUyIDQ0My41MiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNDQzLjUyIDQ0My41MjsiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPGc+DQoJPGc+DQoJCTxwYXRoIGQ9Ik0xNDMuNDkyLDIyMS44NjNMMzM2LjIyNiwyOS4xMjljNi42NjMtNi42NjQsNi42NjMtMTcuNDY4LDAtMjQuMTMyYy02LjY2NS02LjY2Mi0xNy40NjgtNi42NjItMjQuMTMyLDBsLTIwNC44LDIwNC44DQoJCQljLTYuNjYyLDYuNjY0LTYuNjYyLDE3LjQ2OCwwLDI0LjEzMmwyMDQuOCwyMDQuOGM2Ljc4LDYuNTQ4LDE3LjU4NCw2LjM2LDI0LjEzMi0wLjQyYzYuMzg3LTYuNjE0LDYuMzg3LTE3LjA5OSwwLTIzLjcxMg0KCQkJTDE0My40OTIsMjIxLjg2M3oiLz4NCgk8L2c+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8L3N2Zz4NCg==) no-repeat 50% 50%;\n -webkit-mask-size: cover;\n mask-size: cover;\n background-color: $muted2;\n content:\"\";\n }\n\n &.back-cart-link {display:none;}\n }\n @media (max-width:$mobileWidth) {\n top:50%;\n transform: translateY(-50%);\n a {\n max-width: 80px;\n &:before {\n width: 17px;\n height: 17px;\n }\n }\n }\n } \n \n .logo {\n max-width: calc(100% - 180px);\n\n svg.vtex-logo {\n height:50px;\n }\n }\n .logo,\n .logo img {\n display: inline-block;\n font-size:24px;\n border:none;\n line-height: 39px;\n\n }\n\n .checkout-steps {\n max-width: 540px;\n margin-left: auto;\n padding-right: 10px;\n }\n \n }\n\n &:not(.body-cart) {\n .main-header {\n @media (max-width: $mobileWidth) {\n padding:4px 0;\n margin-bottom: 10px;\n\n .v-custom-mhide {display: none !important;}\n \n &, > .container { \n background:none;\n border:none;\n justify-content: center;\n }\n\n .logo {\n \n cursor: default;\n pointer-events: none;\n font-weight: bold;\n\n svg,\n img {display: none !important;}\n &:before {\n content:\"checkout\";\n text-transform: uppercase;\n }\n\n &, &:hover {\n color:$muted1;\n font-size: 14px;\n }\n }\n \n .header-link {display: block;}\n a.buy-more-link {display:none;}\n a.back-cart-link {\n display:block !important;\n font-size: 0;\n &:before {\n background: $muted1;\n }\n }\n }\n }\n }\n}\n\n\n```" } ]
code_checkout-ui-custom_62aca4fb
[ { "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 checkout-ui-custom/checkout-ui-custom/src/_scss/_components/_card-flags.scss from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```scss\n.payment-group-item-cards {\n .card-flag {\n width: 32px !important;\n background-size: auto 20px;\n min-width: auto;\n height: 20px;\n }\n\n .card-flag.Visa {\n background-position: 0 0;\n }\n .card-flag.Mastercard {\n background-position: -32px 0;\n }\n .card-flag.Diners {\n background-position: -64px 0;\n }\n .card-flag.Amex,\n .card-flag.American {\n background-position: -96px 0;\n }\n .card-flag.Hipercard {\n background-position: -128px 0;\n }\n .card-flag.Discover {\n background-position: -160px 0;\n }\n .card-flag.Aura {\n background-position: -192px 0;\n }\n .card-flag.Banricompras {\n background-position: -224px 0;\n }\n .card-flag.Elo {\n background-position: -256px 0;\n }\n .card-flag.JCB {\n background-position: -288px 0;\n }\n .card-flag.Cabal {\n background-position: -320px 0;\n }\n .card-flag.Maestro {\n background-position: -352px 0;\n }\n .card-flag.Credz {\n background-position: -384px 0;\n }\n}\n```" } ]
code_checkout-ui-custom_e52ad4d4
[ { "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 checkout-ui-custom/public/metadata/messages/es-AR.json from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"Personalizador del Checkout\",\n \"headline\": \"Una forma sencilla de personalizar el checkout de su tienda por el administrador.\",\n \"overview\": \"El app Checkout UI Custom es responsable por personalizar el Checkout de su tienda por la interfaz de administrador. Con algunos campos es posible cambiar la fuente y los colores, cambiar la visualización de los medios de pago y la apariencia de la fecha de entrega, y aún ofrecer posibilidades de personalización si es necesario. Toda la interfaz de usuario se diseñó primero en mobile-first.\",\n \"features\": [\n \"Cambio de exposición de métodos de pago\",\n \"Fecha de envío simplificada\",\n \"Mostrar precio unitario del producto\",\n \"Mostrar campo 'notas'\",\n \"Cambiar estilos de texto\",\n \"Cambiar estilos de blocks\",\n \"Cambiar colores\",\n \"Área CSS avanzada\",\n \"Área avanzada de JavaScript\",\n \"Histórico de cambios\"\n ],\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_checkout-ui-custom_b6fb0c71
[ { "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 checkout-ui-custom/public/metadata/messages/pt-BR.json from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"Customizador do Checkout\",\n \"headline\": \"Personalize a interface do checkout da sua loja com facilidade pelo admin.\",\n \"overview\": \"O aplicativo Checkout UI Custom é responsável por personalizar a UI do Checkout de sua loja por meio da interface do administrador. Com alguns campos é possível mudar a fonte e cores, alterar a exibição dos meios de pagamentos e a aparência da data de entrega, e ainda fornece possibilidades para customizações se necessário. Toda a UI foi pensada em mobile-first, para facilitar o ato da compra.\",\n \"features\": [\n \"Alteração na exibição de métodos de pagamento\",\n \"Data de envio simplificada\",\n \"Mostrar preço unitário do item\",\n \"Mostrar campo 'notas'\",\n \"Alterar estilos de texto\",\n \"Alterar estilos de blocos\",\n \"Paleta de cores\",\n \"Área CSS avançada\",\n \"Área de Javascript avançado\",\n \"Histórico de alterações\"\n ],\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_checkout-ui-custom_bf31603a
[ { "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 checkout-ui-custom/public/metadata/messages/en-US.json from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"Checkout Customizer\",\n \"headline\": \"Easily customize your store's checkout interface by the admin.\",\n \"overview\": \"The Checkout UI Custom app is responsible for customizing your store's Checkout UI through the admin's interface. With some fields its possible to change the font and colors, change the display of the means of payment and the appearance of the delivery date, and still provide possibilities for customizations if necessary. The entire UI was designed in mobile-first, to facilitate the purchase flow.\",\n \"features\": [\n \"Change payment methods exhibition\",\n \"Simplified shipping date\",\n \"Show item's unit price\",\n \"Show 'notes' field\",\n \"Change Text styles\",\n \"Change blocks styles\",\n \"Change colors\",\n \"Advanced CSS area\",\n \"Advanced Javascript area\",\n \"Changes tracking\"\n ],\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_checkout-ui-custom_7adfda37
[ { "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 checkout-ui-custom/node/clients/server-settings.ts from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { AppClient } from '@vtex/api'\n\nexport class SaveVB extends AppClient {\n constructor(ctx: IOContext, options?: InstanceOptions) {\n super(`vtex.checkout-ui-settings-server@0.x`, ctx, options)\n }\n\n public saveVB = async (data: any) => {\n await this.http\n .post('/_v/checkout-ui-custom/savevb', data, {\n headers: { 'content-type': 'application/json' },\n })\n .catch(err => {\n throw new Error(err)\n })\n }\n}\n\n```" } ]
code_checkout-ui-custom_66853163
[ { "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 checkout-ui-custom/node/clients/LMClient.ts from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { ExternalClient } from '@vtex/api'\n\nexport default class LMClient extends ExternalClient {\n constructor(ctx: IOContext, options?: InstanceOptions) {\n super(`http://${ctx.account}.vtexcommercestable.com.br/`, ctx, {\n ...options,\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n VtexIdclientAutCookie: ctx.authToken,\n },\n })\n }\n\n public getUserAdminPermissions = async (account: string, userId: string) => {\n return this.get(\n `/api/license-manager/pvt/accounts/${encodeURI(\n account\n )}/logins/${encodeURI(userId)}/granted`\n ).then((res: any) => {\n return res\n })\n }\n\n public getUserRolePermissions = async (account: string,userId: string) => {\n return this.get(\n `/api/license-manager/pvt/users/${encodeURI(userId)}/resources?an=${account}`\n ).then((res: any) => {\n return res\n })\n }\n\n public getAccount = async () => {\n return this.get<GetAccountResponse>(`/api/license-manager/account`).then(\n (res) => {\n return res\n }\n )\n }\n\n protected get = <T>(url: string) => {\n return this.http.get<T>(url)\n }\n}\n\ninterface GetAccountResponse {\n isActive: boolean\n id: string\n name: string\n accountName: string\n lv: unknown\n isOperating: boolean\n defaultUrl: unknown\n district: unknown\n country: unknown\n complement: unknown\n compunknownName: string\n cnpj: string\n haveParentAccount: boolean\n parentAccountId: unknown\n parentAccountName: unknown\n city: unknown\n address: unknown\n logo: unknown\n hasLogo: boolean\n number: unknown\n postalCode: unknown\n state: unknown\n telephone: string\n tradingName: string\n licenses: unknown[]\n sponsor: {\n name: string\n email: string\n phone: string\n }\n contact: {\n name: string\n email: string\n phone: string\n }\n operationDate: unknown\n inactivationDate: unknown\n creationDate: string\n hosts: unknown[]\n sites: unknown[]\n appKeys: unknown[]\n}\n```" } ]
code_checkout-ui-custom_27f856c9
[ { "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 checkout-ui-custom/node/clients/index.ts from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nimport { SaveVB } from './server-settings'\nimport LMClient from './LMClient'\nimport IdentityClient from './IdentityClient'\n\n\n// Extend the default IOClients implementation with our own custom clients.\nexport class Clients extends IOClients {\n\n public get lm() {\n return this.getOrSet('lm', LMClient)\n }\n public get identity() {\n return this.getOrSet('identity', IdentityClient)\n }\n public get server() {\n return this.getOrSet('server', SaveVB)\n }\n}\n\n\n```" } ]
code_checkout-ui-custom_19045276
[ { "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 checkout-ui-custom/node/clients/IdentityClient.ts from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { JanusClient } from '@vtex/api'\n\nexport default class IdentityClient extends JanusClient {\n constructor(ctx: IOContext, options?: InstanceOptions) {\n super(ctx, {\n ...options,\n headers: {\n ...options?.headers,\n },\n })\n }\n\n public async validateToken({ token }: { token: string }): Promise<any> {\n return this.http.post('/api/vtexid/credential/validate', { token })\n }\n\n public async getToken({\n appkey,\n apptoken,\n }: {\n appkey: string\n apptoken: string\n }): Promise<any> {\n return this.http.post('/api/vtexid/apptoken/login', { appkey, apptoken })\n }\n}\n```" } ]
code_checkout-ui-custom_93561608
[ { "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 checkout-ui-custom/node/middlewares/holidays.ts from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable no-console */\n\nimport axios from 'axios'\n\nexport async function holidays(ctx: Context) {\n const {\n clients: {},\n vtex: { authToken },\n } = ctx\n\n const account = ctx.headers['x-vtex-account']\n\n // const { consultantId } = await json(req)\n\n const holidaysUrl = `http://${account}.vtexcommercestable.com.br/api/logistics/pvt/configuration/holidays`\n\n const { data: _holidays } = await axios.get(holidaysUrl, {\n headers: {\n 'VtexIdclientAutCookie': authToken,\n 'X-Vtex-Use-Https': 'true'\n },\n })\n\n ctx.set('Content-Type', 'application/json')\n ctx.set('Cache-Control', 'no-cache, no-store')\n\n let result = _holidays;\n if(!holidays) result = \"no holidays\"\n\n ctx.response.status = 200\n ctx.response.body = result\n}\n\n```" } ]
code_checkout-ui-custom_903aa3a1
[ { "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 checkout-ui-custom/node/middlewares/getCountryRules.ts from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { AddressRules } from '@vtex/address-form'\n\ninterface PromiseType {\n success: boolean\n errorMessage: string\n data: typeof AddressRules | undefined\n}\n\nexport async function getCountryRules(\n ctx: Context,\n next: () => Promise<PromiseType>\n) {\n const {\n vtex: { logger },\n } = ctx\n\n const { countryCode } = ctx.vtex.route.params\n\n if (!countryCode) {\n throw new Error(`Error getting request`)\n }\n\n const parsedCountryCode =\n countryCode !== 'default'\n ? (countryCode as string).toUpperCase()\n : countryCode\n\n try {\n const { default: rules } = await import(\n `@vtex/address-form/lib/country/${parsedCountryCode}`\n )\n\n ctx.status = 200\n ctx.set('Cache-Control', 'no-cache')\n ctx.body = {\n success: true,\n errorMessage: '',\n data: rules,\n }\n } catch (error) {\n ctx.status = 404\n ctx.set('Cache-Control', 'no-cache')\n ctx.body = {\n success: false,\n errorMessage: 'Country not found',\n data: {},\n }\n\n logger.error({\n message: 'getCountryRules-error',\n error,\n })\n }\n\n return next()\n}\n\n```" } ]
code_checkout-ui-custom_515d9410
[ { "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 checkout-ui-custom/node/graphql/helper.ts from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport const validateAdminToken = async (\n context: Context,\n adminUserAuthToken: string\n ): Promise<{\n hasAdminToken: boolean\n hasValidAdminToken: boolean\n hasCurrentValidAdminToken: boolean\n hasValidAdminRole: any\n }> => {\n const {\n clients: { identity, lm },\n vtex: { account, logger },\n } = context\n\n // check if has admin token and if it is valid\n const hasAdminToken = !!adminUserAuthToken\n let hasValidAdminToken = false\n let hasValidAdminRole = false\n let userRoles = []\n // this is used to check if the token is valid by current standards\n let hasCurrentValidAdminToken = false\n \n if (hasAdminToken) {\n \n try {\n \n const authUser = await identity.validateToken({\n token: adminUserAuthToken,\n })\n // we set this flag to true if the token is valid by current standards\n // in the future we should remove this line\n hasCurrentValidAdminToken = true\n \n if (authUser?.audience === 'admin' && authUser?.account === account) {\n hasValidAdminToken = await lm.getUserAdminPermissions(\n account,\n authUser.id\n )\n\n userRoles = await lm.getUserRolePermissions(\n account,\n authUser.id\n )\n\n hasValidAdminRole = userRoles.filter( (role : any) => role.resourceKey == \"SaveOrderFormConfiguration\").length ? true : false;\n\n }\n } catch (err) {\n // noop so we leave hasValidAdminToken as false\n logger.warn({\n message: 'Error validating admin token',\n err,\n })\n }\n }\n \n return { hasAdminToken, hasValidAdminToken, hasCurrentValidAdminToken, hasValidAdminRole }\n }\n```" } ]
code_checkout-ui-custom_baf0aed3
[ { "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 checkout-ui-custom/node/graphql/authcheck.ts from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ForbiddenError } from '@vtex/api'\nimport { validateAdminToken } from './helper'\n\nexport const authCheck = async (ctx: Context, app: string) => {\n const {\n vtex: { logger },\n } = ctx\n\n const version = app.split(`@`)[1]\n\n const cookie = ctx.headers?.cookie\n\n const vtexCredentials: any = cookie\n ? cookie\n .split('; ')\n .find((cookie: string) => cookie.startsWith('VtexIdclientAutCookie='))\n ?.split('=')[1] ?? ''\n : '';\n\n\n if (version <= `0.18.9`) {\n logger.warn({\n message: 'Error: Invalid version',\n })\n throw new ForbiddenError('Unauthorized version')\n }\n\n if (!vtexCredentials.trim()) {\n logger.warn({\n message: 'CheckAdminAccess: Invalid token',\n })\n throw new ForbiddenError('Unauthorized Access')\n }\n\n if (vtexCredentials) {\n const permission = await validateAdminToken(ctx, vtexCredentials)\n\n if (\n !permission.hasAdminToken ||\n !permission.hasValidAdminToken ||\n !permission.hasCurrentValidAdminToken ||\n !permission.hasValidAdminRole\n ) {\n logger.warn({\n message: 'CheckAdminAccess: Invalid store token',\n })\n throw new ForbiddenError('Unauthorized Access Token')\n }\n }\n \n}\n\n```" } ]
code_checkout-ui-custom_58bc4988
[ { "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 checkout-ui-custom/node/graphql/index.ts from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { promises as fs } from 'fs'\nimport * as path from 'path'\n\nimport { method } from '@vtex/api'\n\nimport { getCountryRules } from '../middlewares/getCountryRules'\nimport { holidays } from '../middlewares/holidays'\n\nimport { authCheck } from './authcheck'\nimport { validateAdminToken } from './helper'\n\n\nconst SCHEMA_VERSION = 'v0.1.3'\nconst DATA_ENTITY = 'checkoutcustom'\n\nconst routes = {\n getProfile: () =>\n `http://${process.env.VTEX_ACCOUNT}.vtexcommercestable.com.br/no-cache/profileSystem/getProfile`,\n baseUrl: () =>\n `http://${process.env.VTEX_ACCOUNT}.vtexcommercestable.com.br/api`,\n configEntity: () => `${routes.baseUrl()}/dataentities/${DATA_ENTITY}`,\n listConfig: () =>\n `${routes.configEntity()}/search?_schema=${SCHEMA_VERSION}&_fields=id,email,workspace,creationDate,appVersion&_sort=creationDate DESC`,\n getConfig: (id: string) =>\n `${routes.configEntity()}/documents/${id}?_fields=id,email,cartName,items,creationDate,subtotal,discounts,shipping,total,customData,address`,\n saveSchema: () => `${routes.configEntity()}/schemas/${SCHEMA_VERSION}`,\n}\n\nconst getAppId = (): string => {\n return process.env.VTEX_APP_ID ?? ''\n}\n\nconst schema = {\n properties: {\n email: {\n type: 'string',\n title: 'Email',\n },\n workspace: {\n type: 'string',\n title: 'Workspace',\n },\n creationDate: {\n type: 'string',\n title: 'Creation Date',\n },\n appVersion: {\n type: 'string',\n title: 'App Version',\n },\n layout: {\n type: ['null', 'object'],\n title: 'Layout',\n },\n colors: {\n type: ['null', 'object'],\n title: 'Colors',\n },\n javascript: {\n type: ['null', 'string'],\n title: 'Custom Javascript',\n },\n css: {\n type: ['null', 'string'],\n title: 'Custom CSS',\n },\n javascriptActive: {\n type: 'boolean',\n title: 'Activate custom Javascript',\n },\n cssActive: {\n type: 'boolean',\n title: 'Activate custom CSS',\n },\n javascriptBuild: {\n type: ['null', 'string'],\n title: 'Javascript Build',\n },\n cssBuild: {\n type: ['null', 'string'],\n title: 'CSS Build',\n },\n },\n 'v-indexed': ['email', 'workspace', 'creationDate', 'appVersion'],\n 'v-default-fields': ['email', 'workspace', 'creationDate', 'appVersion'],\n 'v-cache': false,\n}\n\nconst replacer = (template: string, keys: any) => {\n return template.replace(/\"?{{\\w+}}\"?/g, (key: string) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore: Object is possibly 'null'.\n return keys[key.match(/\\w+/)[0]] || 'false'\n })\n}\n\nexport const resolvers = {\n Routes: {\n apiGetCountryRules: method({\n GET: [getCountryRules],\n }),\n getHolidays: method({\n GET: [holidays],\n }),\n },\n Mutation: {\n saveChanges: async (_: any, params: any, ctx: Context) => {\n const {\n clients: { masterdata, server },\n vtex: { }\n } = ctx\n\n\n const app: string = getAppId()\n //authorization check\n await authCheck(ctx, app)\n\n const keys = { ...params.layout, ...params.colors }\n const cssTemplate = await fs.readFile(\n path.join(__dirname, '../templates/checkout6-custom.css'),\n {\n encoding: 'utf-8',\n }\n )\n\n const cssBuild =\n replacer(cssTemplate, keys) + String(params.cssActive ? params.css : '')\n\n const jsTemplate = await fs.readFile(\n path.join(__dirname, '../templates/checkout6-custom.js'),\n {\n encoding: 'utf-8',\n }\n )\n\n const javascriptBuild =\n replacer(jsTemplate, keys) +\n String(params.javascriptActive ? params.javascript : '')\n\n const creationDate = String(new Date().getTime())\n const appVersion = process.env.VTEX_APP_VERSION\n\n const data = await masterdata.createDocument({\n dataEntity: DATA_ENTITY,\n fields: {\n ...params,\n javascriptBuild,\n cssBuild,\n creationDate,\n appVersion,\n },\n schema: SCHEMA_VERSION,\n })\n\n server.saveVB({\n workspace: params.workspace,\n field: 'cssBuild',\n file: cssBuild,\n })\n\n server.saveVB({\n workspace: params.workspace,\n field: 'javascriptBuild',\n file: javascriptBuild,\n })\n\n return JSON.stringify(data)\n },\n },\n Query: {\n getSetupConfig: async (_: any, __: any, ctx: Context) => {\n const {\n clients: { masterdata, apps },\n } = ctx\n\n const app: string = getAppId()\n const settings = await apps.getAppSettings(app)\n\n if (\n !settings.adminSetup ||\n !settings.adminSetup?.hasSchema ||\n settings.adminSetup?.schemaVersion !== SCHEMA_VERSION\n ) {\n if (!settings.adminSetup) {\n settings.adminSetup = {}\n }\n\n try {\n await masterdata\n .createOrUpdateSchema({\n dataEntity: DATA_ENTITY,\n schemaName: SCHEMA_VERSION,\n schemaBody: schema,\n })\n .then(() => {\n settings.adminSetup.hasSchema = true\n settings.adminSetup.schemaVersion = SCHEMA_VERSION\n })\n .catch((e: any) => {\n settings.adminSetup.hasSchema = false\n // eslint-disable-next-line vtex/prefer-early-return\n if (e.response.status === 304) {\n settings.adminSetup.hasSchema = true\n settings.adminSetup.schemaVersion = SCHEMA_VERSION\n }\n })\n } catch (e) {\n settings.adminSetup.hasSchema = false\n }\n\n await apps.saveAppSettings(app, settings)\n }\n\n settings.adminSetup.appVersion = process.env.VTEX_APP_VERSION\n\n return settings\n },\n getHistory: async (_: any, __: any, ctx: any) => {\n const {\n clients: { masterdata },\n } = ctx\n\n const app: string = getAppId()\n //authorization check\n await authCheck(ctx, app)\n\n const data = await masterdata.searchDocuments({\n dataEntity: DATA_ENTITY,\n schema: SCHEMA_VERSION,\n fields: ['id', 'email', 'workspace', 'creationDate', 'appVersion'],\n sort: 'creationDate DESC',\n pagination: {\n page: 1,\n pageSize: 30,\n },\n })\n\n return data\n },\n getPermissions: async (_: any, __: any, ctx: any) => {\n\n const cookie = ctx.headers?.cookie\n\n const vtexCredentials: any = cookie\n ? cookie\n .split('; ')\n .find((cookie: string) => cookie.startsWith('VtexIdclientAutCookie='))\n ?.split('=')[1] ?? ''\n : '';\n\n const permission = await validateAdminToken(ctx, vtexCredentials)\n \n return {\n access: permission.hasValidAdminRole\n }\n },\n getById: async (_: any, params: any, ctx: any) => {\n const {\n clients: { masterdata },\n } = ctx\n\n const app: string = getAppId()\n //authorization check\n await authCheck(ctx, app)\n\n const data = await masterdata.getDocument({\n dataEntity: DATA_ENTITY,\n fields: [\n 'css',\n 'javascript',\n 'layout',\n 'colors',\n 'javascriptActive',\n 'cssActive',\n ],\n id: params.id,\n })\n\n return data\n },\n getLast: async (_: any, params: any, ctx: any) => {\n const {\n clients: { masterdata },\n } = ctx\n\n const app: string = getAppId()\n //authorization check\n await authCheck(ctx, app)\n\n const last = await masterdata\n .searchDocuments({\n dataEntity: DATA_ENTITY,\n schema: SCHEMA_VERSION,\n fields: ['id'],\n where: `workspace=${params.workspace}`,\n sort: 'creationDate DESC',\n pagination: {\n page: 1,\n pageSize: 1,\n },\n })\n .then((res: any) => res)\n\n if (!last.length) return {}\n\n const data = await masterdata.getDocument({\n dataEntity: DATA_ENTITY,\n id: last[0].id,\n fields: [\n 'id',\n 'email',\n 'workspace',\n 'creationDate',\n 'appVersion',\n 'layout',\n 'javascript',\n 'css',\n 'colors',\n 'javascriptActive',\n 'cssActive',\n ],\n })\n\n return data ?? {}\n },\n },\n}\n\n\n```" } ]
code_checkout-ui-custom_b2f7b974
[ { "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 checkout-ui-custom/react/mutations/saveConfiguration.gql from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation saveConfiguration(\n $email: String\n $workspace: String\n $layout: CustomFields\n $javascript: String\n $css: String\n $javascriptActive: Boolean\n $cssActive: Boolean\n $colors: CustomFields\n) {\n saveChanges(\n email: $email\n workspace: $workspace\n layout: $layout\n javascript: $javascript\n css: $css\n javascriptActive: $javascriptActive\n cssActive: $cssActive\n colors: $colors\n )\n}\n\n```" } ]
code_checkout-ui-custom_b9f09351
[ { "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 checkout-ui-custom/react/typings/storefront.d.ts from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* eslint-disable @typescript-eslint/ban-types */\nimport type { FunctionComponent } from 'react'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n getSchema?(props: P): object\n schema?: object\n }\n\n interface StorefrontComponent<P = {}, S = {}> extends Component<P, S> {\n getSchema?(props: P): object\n schema: object\n }\n}\n\n```" } ]
code_checkout-ui-custom_c0460535
[ { "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 checkout-ui-custom/react/typings/graphql.d.ts from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import type { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```" } ]
code_checkout-ui-custom_953573b3
[ { "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 checkout-ui-custom/react/typings/vtex.styleguide.d.ts from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n export const PageHeader\n export const Alert\n export const Modal\n export const Box\n export const Card\n export const Dropdown\n export const Spinner\n export const Table\n export const Button\n export const IconWarning\n export const IconCheck\n export const Input\n export const InputSearch\n export const IconCaretDown\n export const IconCaretUp\n export const IconArrowDown\n export const IconArrowBack\n export const IconArrowUp\n export const IconClose\n export const IconExternalLink\n export const IconSearch\n export const IconSuccess\n export const IconCopy\n export const IconCog\n export const Tooltip\n export const ToastConsumer\n export const ToastProvider\n export const withToast\n export const ButtonWithIcon\n export const Pagination\n export const Collapsible\n export const Textarea\n export const NumericStepper\n export const EmptyState\n export const Tab\n export const Tag\n export const Layout\n export const Tabs\n}\n\n```" } ]
code_checkout-ui-custom_456ea716
[ { "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 checkout-ui-custom/react/queries/getHistory.gql from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetHistory {\n getHistory {\n id\n email\n workspace\n creationDate\n appVersion\n }\n}\n\n```" } ]
code_checkout-ui-custom_8b6e4884
[ { "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 checkout-ui-custom/react/queries/getConfig.gql from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetConfig {\n getSetupConfig {\n adminSetup {\n hasSchema\n schemaVersion\n appVersion\n }\n }\n}\n\n```" } ]
code_checkout-ui-custom_2551c9e1
[ { "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 checkout-ui-custom/react/queries/getPermissions.gql from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery getUserPermissions {\n getPermissions {\n access\n }\n}\n\n```" } ]
code_checkout-ui-custom_81587386
[ { "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 checkout-ui-custom/react/queries/getById.gql from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetById($id: String) {\n getById(id: $id) {\n css\n javascript\n layout\n colors\n javascriptActive\n cssActive\n }\n}\n\n```" } ]
code_checkout-ui-custom_2f3472e8
[ { "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 checkout-ui-custom/react/queries/getLast.gql from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery GetLast($workspace: String) {\n getLast(workspace: $workspace) {\n css\n javascript\n layout\n colors\n javascriptActive\n cssActive\n appVersion\n }\n}\n\n```" } ]
code_checkout-ui-custom_a00a4fc2
[ { "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 checkout-ui-custom/react/components/Colors.tsx from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC } from 'react'\nimport React, { useState } from 'react'\nimport type { WrappedComponentProps } from 'react-intl'\nimport { injectIntl } from 'react-intl'\nimport PropTypes from 'prop-types'\nimport { ColorPicker } from 'vtex.styleguide'\n\nconst Colors: FC<WrappedComponentProps & any> = ({\n initialState,\n onChange,\n intl,\n}) => {\n const [state, setState] = useState<any>({\n ...initialState,\n history: [],\n })\n\n const handleChange = (color: any, picker: string) => {\n const { history } = state\n\n history.push(color)\n\n setState({\n ...state,\n history,\n [picker]: color.hex,\n })\n\n onChange({\n ...initialState,\n [picker]: color.hex,\n })\n }\n\n return (\n <div className=\"w-100 pa4\">\n <div className=\"w-50 mb-4\">\n <ColorPicker\n color={{ hex: state.base }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.base',\n })}\n onChange={(color: any) => {\n handleChange(color, 'base')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.baseInverted }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.baseInverted',\n })}\n onChange={(color: any) => {\n handleChange(color, 'baseInverted')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.actionPrimary }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.actionPrimary',\n })}\n onChange={(color: any) => {\n handleChange(color, 'actionPrimary')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.actionPrimaryDarken }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.actionPrimaryDarken',\n })}\n onChange={(color: any) => {\n handleChange(color, 'actionPrimaryDarken')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.actionSecondary }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.actionSecondary',\n })}\n onChange={(color: any) => {\n handleChange(color, 'actionSecondary')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.emphasis }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.emphasis',\n })}\n onChange={(color: any) => {\n handleChange(color, 'emphasis')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.disabled }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.disabled',\n })}\n onChange={(color: any) => {\n handleChange(color, 'disabled')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.success }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.success',\n })}\n onChange={(color: any) => {\n handleChange(color, 'success')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.successDarken }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.successDarken',\n })}\n onChange={(color: any) => {\n handleChange(color, 'successDarken')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.successFaded }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.successFaded',\n })}\n onChange={(color: any) => {\n handleChange(color, 'successFaded')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.danger }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.danger',\n })}\n onChange={(color: any) => {\n handleChange(color, 'danger')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.dangerFaded }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.dangerFaded',\n })}\n onChange={(color: any) => {\n handleChange(color, 'dangerFaded')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.warning }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.warning',\n })}\n onChange={(color: any) => {\n handleChange(color, 'warning')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.warningFaded }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.warningFaded',\n })}\n onChange={(color: any) => {\n handleChange(color, 'warningFaded')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.muted1 }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.muted1',\n })}\n onChange={(color: any) => {\n handleChange(color, 'muted1')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.muted2 }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.muted2',\n })}\n onChange={(color: any) => {\n handleChange(color, 'muted2')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.muted3 }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.muted3',\n })}\n onChange={(color: any) => {\n handleChange(color, 'muted3')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.muted4 }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.muted4',\n })}\n onChange={(color: any) => {\n handleChange(color, 'muted4')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.muted5 }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.muted5',\n })}\n onChange={(color: any) => {\n handleChange(color, 'muted5')\n }}\n />\n </div>\n\n <div className=\"w-50\">\n <ColorPicker\n color={{ hex: state.muted6 }}\n colorHistory={state.history}\n label={intl.formatMessage({\n id: 'admin/checkout-ui.color.muted6',\n })}\n onChange={(color: any) => {\n handleChange(color, 'muted6')\n }}\n />\n </div>\n </div>\n )\n}\n\nColors.propTypes = {\n onChange: PropTypes.func,\n initialState: PropTypes.any,\n intl: PropTypes.any,\n}\n\nexport default injectIntl(Colors)\n\n```" } ]
code_checkout-ui-custom_775cab4b
[ { "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 checkout-ui-custom/react/components/Javascript.tsx from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC } from 'react'\nimport React, { useState } from 'react'\nimport type { WrappedComponentProps } from 'react-intl'\nimport { defineMessages, injectIntl } from 'react-intl'\nimport PropTypes from 'prop-types'\nimport { Textarea, Toggle } from 'vtex.styleguide'\n\nimport Editor from '@monaco-editor/react'\n\nconst messages = defineMessages({\n label: {\n id: 'admin/checkout-ui.tab.javascript.label',\n defaultMessage: 'Custom Javascript',\n },\n helper: {\n id: 'admin/checkout-ui.tab.javascript.helper',\n defaultMessage: '// Changes here may impact your sales',\n },\n active: {\n id: 'admin/checkout-ui.toggle.active',\n defaultMessage: 'Active',\n },\n})\n\nconst Javascript: FC<WrappedComponentProps & any> = ({\n initialState,\n onChange,\n intl,\n}) => {\n const [state, setState] = useState<any>({\n value: initialState.value,\n active: initialState.active,\n theme: true // true for \"vs-dark\" and false for \"vs-light\"\n })\n\n const handleChange = (key: string, value: any) => {\n const newState = { ...state, [key]: value }\n\n onChange(newState)\n setState(newState)\n }\n\n const parseText = (text: string) => {\n if (text === null) return ''\n const newText = text.replace(/\\\\n/g, String.fromCharCode(13))\n\n return newText\n }\n\n const handleChangeToggle = (value: any, key: string) => {\n const newState = {\n ...state,\n [key]: value\n }\n setState(newState)\n onChange(newState)\n }\n\n\n return (\n <div className=\"w-100 pa4\">\n\n <div className=\"flex justify-between items-center\">\n <p>{intl.formatMessage(messages.label)}</p>\n <div className=\"dib\">\n <Toggle\n label={state.theme ? \"Dark Theme\" : \"Light Theme\"}\n checked={state.theme}\n onChange={() => {\n handleChangeToggle(\n !state.theme,\n 'theme'\n )\n }}\n />\n </div>\n </div>\n\n <Editor\n height=\"90vh\"\n defaultLanguage=\"javascript\"\n defaultValue={intl.formatMessage(messages.helper)}\n theme={state.theme ? \"vs-dark\" : \"vs-light\" }\n value={parseText(state.value)}\n onChange={(e: any) => handleChange('value', e)}\n />\n\n <div className=\"dn\">\n <Textarea\n size=\"large\"\n rows={30}\n value={parseText(state.value)}\n onChange={(e: any) => handleChange('value', e.target.value)}\n label={intl.formatMessage(messages.label)}\n helpText={intl.formatMessage(messages.helper)}\n />\n </div>\n\n <div className=\"mt6 dib\">\n <Toggle\n label={intl.formatMessage(messages.active)}\n size=\"large\"\n checked={state.active}\n onChange={(e: any) => handleChange('active', e.currentTarget.checked)}\n />\n </div>\n </div>\n )\n}\n\nJavascript.propTypes = {\n onChange: PropTypes.func,\n initialState: PropTypes.any,\n intl: PropTypes.any,\n}\n\nexport default injectIntl(Javascript)\n\n```" } ]
code_checkout-ui-custom_3172786e
[ { "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 checkout-ui-custom/react/components/History.tsx from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC } from 'react'\nimport React from 'react'\nimport type { WrappedComponentProps } from 'react-intl'\nimport { injectIntl, defineMessages, FormattedMessage } from 'react-intl'\nimport { useQuery, useLazyQuery } from 'react-apollo'\nimport PropTypes from 'prop-types'\nimport { Table, Button } from 'vtex.styleguide'\n\nimport query from '../queries/getHistory.gql'\nimport GET_BY_ID from '../queries/getById.gql'\n\nconst messages = defineMessages({\n email: {\n id: 'admin/checkout-ui.history.label.email',\n defaultMessage: 'Email',\n },\n workspace: {\n id: 'admin/checkout-ui.history.label.workspace',\n defaultMessage: 'Workspace',\n },\n version: {\n id: 'admin/checkout-ui.history.label.version',\n defaultMessage: 'App version',\n },\n date: {\n id: 'admin/checkout-ui.history.label.date',\n defaultMessage: 'Creation date',\n },\n load: {\n id: 'admin/checkout-ui.history.button.load',\n defaultMessage: 'Load',\n },\n})\n\nconst History: FC<any & WrappedComponentProps> = ({\n intl,\n onChange,\n initialState,\n}: any) => {\n const { loading, data } = useQuery(query)\n\n const [getConfig, { loading: loadingConfig }] = useLazyQuery(GET_BY_ID, {\n onCompleted: (res: any) => {\n onChange(res.getById)\n },\n })\n\n const load = (id: string) => {\n getConfig({\n variables: {\n id,\n },\n })\n }\n\n const customSchema = {\n properties: {\n email: {\n title: intl.formatMessage(messages.email),\n width: 300,\n },\n workspace: {\n title: intl.formatMessage(messages.workspace),\n width: 200,\n },\n appVersion: {\n title: intl.formatMessage(messages.version),\n width: 100,\n },\n creationDate: {\n title: intl.formatMessage(messages.date),\n width: 200,\n // eslint-disable-next-line react/display-name\n cellRenderer: ({ cellData }: any) => {\n const datetime = new Date(parseInt(cellData, 10))\n\n return (\n <span>\n {intl.formatDate(datetime, {\n day: 'numeric',\n month: 'numeric',\n year: 'numeric',\n })}{' '}\n {intl.formatTime(datetime, {\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n })}\n </span>\n )\n },\n },\n id: {\n title: ' ',\n width: 200,\n // eslint-disable-next-line react/display-name\n cellRenderer: ({ rowData }: any) => {\n return (\n <Button\n variation=\"tertiary\"\n size=\"small\"\n disabled={loadingConfig}\n onClick={() => {\n load(rowData.id)\n }}\n >\n {intl.formatMessage(messages.load)}\n </Button>\n )\n },\n },\n },\n }\n\n const items = data?.getHistory || []\n\n return (\n <div className=\"w-100 pt6\">\n <span>\n <FormattedMessage id=\"admin/checkout-ui.history.help.appversion\" />{' '}\n {initialState}\n </span>\n <Table\n fullWidth\n loading={loading}\n schema={customSchema}\n items={items}\n indexColumnLabel=\"#\"\n />\n </div>\n )\n}\n\nHistory.propTypes = {\n onChange: PropTypes.func,\n initialState: PropTypes.any,\n}\n\nexport default injectIntl(History)\n\n```" } ]
code_checkout-ui-custom_03d04e99
[ { "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 checkout-ui-custom/react/components/Layout.tsx from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable react/prop-types */\nimport type { FC } from 'react'\nimport React, { useState } from 'react'\nimport type { WrappedComponentProps } from 'react-intl'\nimport { injectIntl, FormattedMessage } from 'react-intl'\nimport PropTypes from 'prop-types'\nimport { Toggle, Slider, Input, Card, Divider } from 'vtex.styleguide'\n\nimport TabsOn from '../images/payments-tabs-on.png'\nimport TabsOff from '../images/payments-tabs-off.png'\nimport PriceOn from '../images/cart-quantity-price-on.png'\nimport PriceOff from '../images/cart-quantity-price-off.png'\nimport ShippingOff from '../images/shipping-date-number.png'\nimport ShippingOn from '../images/shipping-date-text.png'\nimport NotesOn from '../images/notes-field-on.png'\nimport NotesOff from '../images/notes-field-off.png'\nimport EmailStepOn from '../images/email-step-on.png'\nimport EmailStepOff from '../images/email-step-off.png'\nimport CustomAddresFormOn from '../images/usaddressform-on.png'\nimport CustomAddresFormOff from '../images/usaddressform-off.png'\n\nconst images: any = {\n tabsOn: TabsOn,\n tabsOff: TabsOff,\n shippingOn: ShippingOn,\n shippingOff: ShippingOff,\n priceOn: PriceOn,\n priceOff: PriceOff,\n notesOn: NotesOn,\n notesOff: NotesOff,\n emailStepOn: EmailStepOn,\n emailStepOff: EmailStepOff,\n customAddresFormOn: CustomAddresFormOn,\n customAddresFormOff: CustomAddresFormOff,\n}\n\nconst LayoutSettings: FC<WrappedComponentProps & any> = ({\n initialState,\n onChange,\n intl,\n}) => {\n const [state, setState] = useState<any>({\n ...initialState,\n currentPreview: initialState.accordionPayments ? TabsOff : TabsOn,\n })\n\n const changePreview = (item: string) => {\n const currentPreview = images[item]\n\n setState({\n ...state,\n currentPreview,\n })\n }\n\n const handleChange = (value: any, key: string, image?: string) => {\n const currentPreview = image ? images[image] : state.currentPreview\n const newState = {\n ...state,\n [key]: value,\n currentPreview,\n }\n\n setState(newState)\n onChange(newState)\n }\n\n return (\n <div className=\"w-100 pa4\">\n <div className=\"w-100 cf cb\">\n <div className=\"w-50 fl pr7\">\n <div\n className=\"mt6 db flex items-center\"\n onMouseEnter={() => {\n changePreview(state.accordionPayments ? 'tabsOff' : 'tabsOn')\n }}\n >\n <Toggle\n label={intl.formatMessage({\n id: 'admin/checkout-ui.layout.accordionPayments.label',\n })}\n size=\"large\"\n helpText={intl.formatMessage({\n id: 'admin/checkout-ui.layout.accordionPayments.help',\n })}\n checked={state.accordionPayments}\n onChange={(e: any) => {\n handleChange(\n !state.accordionPayments,\n 'accordionPayments',\n e.currentTarget.checked ? 'tabsOff' : 'tabsOn'\n )\n }}\n />\n </div>\n <br />\n\n <div\n className=\"mt6 db flex items-center\"\n onMouseEnter={() => {\n changePreview(\n state.deliveryDateFormat ? 'shippingOn' : 'shippingOff'\n )\n }}\n >\n <Toggle\n label={intl.formatMessage({\n id: 'admin/checkout-ui.layout.deliveryDateFormat.label',\n })}\n size=\"large\"\n helpText={intl.formatMessage({\n id: 'admin/checkout-ui.layout.deliveryDateFormat.help',\n })}\n checked={state.deliveryDateFormat}\n onChange={(e: any) =>\n handleChange(\n !state.deliveryDateFormat,\n 'deliveryDateFormat',\n e.currentTarget.checked ? 'shippingOn' : 'shippingOff'\n )\n }\n />\n </div>\n <br />\n\n <div\n className=\"mt6 db flex items-center\"\n onMouseEnter={() => {\n changePreview(\n state.showCartQuantityPrice ? 'priceOn' : 'priceOff'\n )\n }}\n >\n <Toggle\n label={intl.formatMessage({\n id: 'admin/checkout-ui.layout.showCartQuantityPrice.label',\n })}\n size=\"large\"\n helpText={intl.formatMessage({\n id: 'admin/checkout-ui.layout.showCartQuantityPrice.help',\n })}\n checked={state.showCartQuantityPrice}\n onChange={(e: any) =>\n handleChange(\n !state.showCartQuantityPrice,\n 'showCartQuantityPrice',\n e.currentTarget.checked ? 'priceOn' : 'priceOff'\n )\n }\n />\n </div>\n <br />\n <div\n className=\"mt6 db flex items-center\"\n onMouseEnter={() => {\n changePreview(state.showNoteField ? 'notesOn' : 'notesOff')\n }}\n >\n <Toggle\n label={intl.formatMessage({\n id: 'admin/checkout-ui.layout.showNoteField.label',\n })}\n size=\"large\"\n checked={state.showNoteField}\n onChange={(e: any) =>\n handleChange(\n !state.showNoteField,\n 'showNoteField',\n e.currentTarget.checked ? 'notesOn' : 'notesOff'\n )\n }\n />\n </div>\n <br />\n <div\n className=\"mt6 db flex items-center\"\n onMouseEnter={() => {\n changePreview(\n state.hideEmailStep ? 'emailStepOff' : 'emailStepOn'\n )\n }}\n >\n <Toggle\n label={intl.formatMessage({\n id: 'admin/checkout-ui.layout.hideEmailStep.label',\n })}\n size=\"large\"\n checked={state.hideEmailStep}\n onChange={(e: any) =>\n handleChange(\n !state.hideEmailStep,\n 'hideEmailStep',\n e.currentTarget.checked ? 'emailStepOn' : 'emailStepOff'\n )\n }\n />\n </div>\n <br />\n <div\n className=\"mt6 db flex items-center\"\n onMouseEnter={() => {\n changePreview(\n state.customAddressForm\n ? 'customAddresFormOn'\n : 'customAddresFormOff'\n )\n }}\n >\n <Toggle\n label={intl.formatMessage({\n id: 'admin/checkout-ui.layout.customAddressForm.label',\n })}\n size=\"large\"\n checked={state.customAddressForm}\n onChange={(e: any) =>\n handleChange(\n !state.customAddressForm,\n 'customAddressForm',\n e.currentTarget.checked\n ? 'customAddresFormOn'\n : 'customAddresFormOff'\n )\n }\n />\n <p\n style={{\n display: 'inline-block',\n background: '#f71963',\n margin: '0 0 0 10px',\n padding: '5px',\n borderRadius: '10px',\n color: '#FFF',\n float: 'left',\n fontSize: '13px',\n }}\n >\n BETA\n </p>\n </div>\n </div>\n <div className=\"w-50 fr\">\n <Card noPadding>\n <h3 className=\"pl6 pr6 pt6\">\n <FormattedMessage id=\"admin/checkout-ui.layout.preview.title\" />\n </h3>\n <img\n alt={intl.formatMessage({\n id: 'admin/checkout-ui.layout.preview.title',\n })}\n style={{ maxHeight: '260px', display: 'block', margin: '0 auto' }}\n src={state.currentPreview}\n />\n </Card>\n </div>\n </div>\n\n <div className=\"mv6\">\n <Divider orientation=\"horizontal\" />\n </div>\n\n <div className=\"w-100 cf cb\">\n <div className=\"w-50 fl pr7\">\n <div className=\"mt6 flex\">\n <div className=\"flex flex-column items-left w-50\">\n <div className=\"flex-col\">\n <span>\n <FormattedMessage id=\"admin/checkout-ui.layout.fontSize.label\" />\n </span>\n </div>\n <div className=\"flex-col\">\n <Slider\n onChange={(value: any) => {\n handleChange(`${value[0]}px`, 'fontSize')\n }}\n min={10}\n max={30}\n step={1}\n defaultValues={[state.fontSize.replace('px', '')]}\n alwaysShowCurrentValue={false}\n formatValue={(a: number) => `${a}px`}\n />\n </div>\n </div>\n </div>\n\n <div className=\"mt6 flex\">\n <div className=\"flex flex-column items-left w-50\">\n <div className=\"flex-col\">\n <span>\n <FormattedMessage id=\"admin/checkout-ui.layout.borderRadius.label\" />\n </span>\n </div>\n <div className=\"flex-col\">\n <Slider\n onChange={(value: any) => {\n handleChange(`${value[0]}px`, 'borderRadius')\n }}\n min={0}\n max={50}\n step={1}\n defaultValues={[state.borderRadius.replace('px', '')]}\n alwaysShowCurrentValue={false}\n formatValue={(a: number) => `${a}px`}\n />\n </div>\n </div>\n </div>\n\n <div className=\"mt6 flex\">\n <div className=\"flex flex-column items-left w-50\">\n <div className=\"flex-col\">\n <span>\n <FormattedMessage id=\"admin/checkout-ui.layout.btnBorderRadius.label\" />\n </span>\n </div>\n <div className=\"flex-col\">\n <Slider\n onChange={(value: any) => {\n handleChange(`${value[0]}px`, 'btnBorderRadius')\n }}\n min={0}\n max={50}\n step={1}\n defaultValues={[state.btnBorderRadius.replace('px', '')]}\n alwaysShowCurrentValue={false}\n formatValue={(a: number) => `${a}px`}\n />\n </div>\n </div>\n </div>\n\n <div className=\"mt6 flex\">\n <div className=\"flex flex-column items-left w-50\">\n <div className=\"flex-col\">\n <span>\n <FormattedMessage id=\"admin/checkout-ui.layout.inputHeight.label\" />\n </span>\n </div>\n <div className=\"flex-col\">\n <Slider\n onChange={(value: any) => {\n handleChange(`${value[0]}px`, 'inputHeight')\n }}\n min={0}\n max={50}\n step={1}\n defaultValues={[state.inputHeight.replace('px', '')]}\n alwaysShowCurrentValue={false}\n formatValue={(a: number) => `${a}px`}\n />\n </div>\n </div>\n </div>\n </div>\n\n <div className=\"w-50 fr\">\n <div\n className=\"summary-template-holder\"\n style={{\n boxShadow: 'rgba(61, 62, 64, 0.3) 0px 3px 9px 0px',\n padding: '20px',\n borderRadius: `${state.borderRadius}`,\n border: state.bordersContainers,\n fontFamily: state.fontFamily,\n }}\n >\n <h3>\n <FormattedMessage id=\"admin/checkout-ui.layout.preview.title\" />\n </h3>\n\n <p\n style={{\n fontFamily: state.fontFamily,\n fontSize: `${state.fontSize}`,\n }}\n >\n <FormattedMessage id=\"admin/checkout-ui.layout.preview.sample\" />\n </p>\n\n <p className=\"coupon-fields\">\n <span className=\"flex\">\n <input\n className=\"w-80\"\n type=\"text\"\n placeholder=\"Coupon Code\"\n style={{\n height: `${state.inputHeight}`,\n borderRadius: `${state.borderRadius}`,\n border: `1px solid #cacbcc`,\n fontSize: `${state.fontSize}`,\n padding: '0 10px',\n }}\n />\n <button\n className=\"bg-action-primary c-on-action-primary w-20 ml3\"\n style={{\n borderRadius: `${state.btnBorderRadius}`,\n height: `${state.inputHeight}`,\n border: `none`,\n padding: `5px 12px`,\n fontSize: `${state.fontSize}`,\n }}\n type=\"submit\"\n >\n <FormattedMessage id=\"admin/checkout-ui.layout.preview.button\" />\n </button>\n </span>\n </p>\n <div\n className=\"\"\n style={{\n fontFamily: state.fontFamily,\n fontSize: `${state.fontSize}`,\n }}\n >\n <div className=\"Items flex justify-around\">\n <div className=\"w-50 tl\">Subtotal</div>\n <div className=\"w-50 tr\">$ 64.35</div>\n </div>\n <div className=\"srp-summary-result flex justify-around\">\n <div className=\"w-50 tl\">Shipping</div>\n <div className=\"w-50 tr\">$ 3.00</div>\n </div>\n <div\n className=\"flex justify-around\"\n style={{\n fontSize: '18px',\n fontWeight: 'bold',\n padding: '14px 0',\n margin: '14px 0',\n borderTop: '1px solid #cbcbcb',\n }}\n >\n <div className=\"w-50 tl\">Total</div>\n <div className=\"w-50 tr\">$ 67.35</div>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <div className=\"mv7\">\n <Divider orientation=\"horizontal\" />\n </div>\n\n <div className=\"w-100 cf cb\">\n <div className=\"w-100 flex justify-between\">\n <div className=\"w-30\">\n <Input\n label={intl.formatMessage({\n id: 'admin/checkout-ui.layout.maxWrapper.label',\n })}\n value={state.maxWrapper}\n placeholder=\"980px, 90%, etc.\"\n onChange={(e: any) => {\n handleChange(e.target.value, 'maxWrapper')\n }}\n />\n </div>\n\n <div className=\"w-30\">\n <Input\n label={intl.formatMessage({\n id: 'admin/checkout-ui.layout.bordersContainers.label',\n })}\n value={state.bordersContainers}\n placeholder=\"2px solid #eee\"\n onChange={(e: any) => {\n handleChange(e.target.value, 'bordersContainers')\n }}\n />\n </div>\n\n <div className=\"w-30\">\n <Input\n label={intl.formatMessage({\n id: 'admin/checkout-ui.layout.fontFamily.label',\n })}\n value={state.fontFamily}\n placeholder=\"'Roboto', sans-serif\"\n onChange={(e: any) => {\n handleChange(e.target.value, 'fontFamily')\n }}\n />\n </div>\n </div>\n </div>\n </div>\n )\n}\n\nLayoutSettings.propTypes = {\n onChange: PropTypes.func,\n initialState: PropTypes.any,\n}\n\nexport default injectIntl(LayoutSettings)\n\n```" } ]
code_checkout-ui-custom_12e92532
[ { "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 checkout-ui-custom/react/components/Css.tsx from the checkout-ui-custom VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useState } from 'react'\nimport type { WrappedComponentProps } from 'react-intl'\nimport { defineMessages, injectIntl } from 'react-intl'\nimport PropTypes from 'prop-types'\nimport { Textarea, Toggle } from 'vtex.styleguide'\n\nimport Editor from '@monaco-editor/react'\n\nconst messages = defineMessages({\n label: {\n id: 'admin/checkout-ui.tab.css.label',\n defaultMessage: 'Custom CSS',\n },\n helper: {\n id: 'admin/checkout-ui.tab.css.helper',\n defaultMessage: '/* Changes here may impact your sales */',\n },\n active: {\n id: 'admin/checkout-ui.toggle.active',\n defaultMessage: 'Active',\n },\n})\n\nconst Css: StorefrontFunctionComponent<WrappedComponentProps & any> = ({\n initialState,\n onChange,\n intl,\n}) => {\n const [state, setState] = useState<any>({\n value: initialState.value,\n active: initialState.active,\n theme: true // true for \"vs-dark\" and false for \"vs-light\"\n })\n\n const handleChange = (key: string, value: any) => {\n const newState = { ...state, [key]: value }\n\n onChange(newState)\n setState(newState)\n }\n\n const parseText = (text: string) => {\n if (text === null) return ''\n const newText = text.replace(/\\\\n/g, String.fromCharCode(13))\n\n return newText\n }\n\n const handleChangeToggle = (value: any, key: string) => {\n const newState = {\n ...state,\n [key]: value\n }\n setState(newState)\n onChange(newState)\n }\n\n return (\n <div className=\"w-100 pa4\">\n\n <div className=\"flex justify-between items-center\">\n <p>{intl.formatMessage(messages.label)}</p>\n <div className=\"dib\">\n <Toggle\n label={state.theme ? \"Dark Theme\" : \"Light Theme\"}\n checked={state.theme}\n onChange={() => {\n handleChangeToggle(\n !state.theme,\n 'theme'\n )\n }}\n />\n </div>\n </div>\n\n\n <Editor\n height=\"90vh\"\n defaultLanguage=\"css\"\n defaultValue={intl.formatMessage(messages.helper)}\n theme={state.theme ? \"vs-dark\" : \"vs-light\" }\n value={parseText(state.value)}\n onChange={(e: any) => handleChange('value', e)}\n />\n\n <div className=\"dn\">\n <Textarea\n size=\"large\"\n rows={30}\n value={parseText(state.value)}\n onChange={(e: any) => handleChange('value', e.target.value)}\n label={intl.formatMessage(messages.label)}\n helpText={intl.formatMessage(messages.helper)}\n />\n </div>\n\n <div className=\"mt6 dib\">\n <Toggle\n label={intl.formatMessage(messages.active)}\n size=\"large\"\n checked={state.active}\n onChange={(e: any) => handleChange('active', e.currentTarget.checked)}\n />\n </div>\n </div>\n )\n}\n\nCss.propTypes = {\n onChange: PropTypes.func,\n initialState: PropTypes.any,\n intl: PropTypes.any,\n}\n\nexport default injectIntl(Css)\n\n```" } ]
code_tradetracker_be4dc5be
[ { "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 tradetracker/docs/README.md from the tradetracker VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Tradetracker\n\nVTEX Tradetracker first-party app\n\n## How to install\n\nOpen the VTEX App Store and install this app on your store.\n\nNow, open the app settings on your admin and fill in the Tradetracker options.\n\n```" } ]
code_tradetracker_b6c08ed8
[ { "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 tradetracker/react/index.tsx from the tradetracker VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { PixelMessage } from \"./typings/events\";\nimport { canUseDOM } from \"vtex.render-runtime\";\n\nfunction handleMessages(e: PixelMessage) {\n const {\n ttConversionOptions = [],\n __tradetracker: {\n tradeTrackerCampaignID: campaignID,\n tradeTrackerProductID: productID,\n tradeTrackerDescrMerchant: descrMerchant,\n tradeTrackerDescrAffiliate: descrAffiliate\n }\n } = window;\n switch (e.data.eventName) {\n case \"vtex:orderPlaced\": {\n const {\n transactionId: transactionID,\n currency,\n transactionTotal: transactionAmount,\n visitorContactInfo: [email]\n } = e.data;\n ttConversionOptions.push({\n type: \"sales\",\n quantity: \"1\",\n email,\n currency,\n campaignID,\n productID,\n transactionID,\n transactionAmount,\n descrMerchant,\n descrAffiliate\n });\n const tradeTrackerScriptTag = document.createElement(\"script\");\n tradeTrackerScriptTag.type = \"text/javascript\";\n tradeTrackerScriptTag.async = true;\n tradeTrackerScriptTag.src = \"//tm.tradetracker.net/conversion?s=\" + encodeURIComponent(campaignID) + \"&t=m\";\n const scriptTags = document.getElementsByTagName(\"script\");\n if (scriptTags && scriptTags.length) {\n const lastScriptTag = scriptTags[scriptTags.length - 1];\n if (lastScriptTag && lastScriptTag.parentNode) {\n lastScriptTag.parentNode.insertBefore(tradeTrackerScriptTag, lastScriptTag);\n }\n }\n break;\n }\n }\n}\n\nif (canUseDOM) {\n window.addEventListener(\"message\", handleMessages);\n}\n\n```" } ]
code_tradetracker_91d04ce9
[ { "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 tradetracker/react/package.json from the tradetracker VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.tradetracker\",\n \"version\": \"0.0.0\",\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty && tslint -c tslint.json './**/*.ts'\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^10.12.18\",\n \"tslint\": \"^5.11.0\",\n \"tslint-config-vtex\": \"^2.0.0\",\n \"tslint-eslint-rules\": \"^5.4.0\",\n \"typescript\": \"3.5.2\"\n }\n}\n\n```" } ]
code_tradetracker_90a1d354
[ { "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 tradetracker/store/interfaces.json from the tradetracker VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"pixel.tradetracker\": {\n \"component\": \"index\"\n }\n}\n\n```" } ]
code_tradetracker_f16538db
[ { "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 tradetracker/react/typings/events.d.ts from the tradetracker VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport interface PixelMessage extends MessageEvent {\n data:\n | ProductViewData\n | ProductClickData\n | OrderPlacedData\n | PageViewData\n | PageInfoData\n | ProductImpressionData\n | AddToCartData\n | RemoveToCartData\n | CategoryViewData\n | DepartmentViewData;\n}\n\nexport interface EventData {\n event: string;\n eventName: string;\n currency: string;\n}\n\nexport interface PageViewData extends EventData {\n event: \"pageView\";\n eventName: \"vtex:pageView\";\n pageTitle: string;\n pageUrl: string;\n referrer: string;\n}\n\nexport interface PageInfoData extends EventData {\n event: \"pageInfo\";\n eventName: \"vtex:pageInfo\";\n eventType: string;\n accountName: string;\n pageCategory: string;\n pageDepartment: string;\n pageFacets: string[];\n pageTitle: string;\n pageUrl: string;\n}\n\nexport interface CategoryViewData extends EventData {\n event: \"categoryView\";\n eventName: \"vtex:categoryView\";\n products: Product[];\n}\n\nexport interface DepartmentViewData extends EventData {\n event: \"departmentView\";\n eventName: \"vtex:departmentView\";\n products: Product[];\n}\n\nexport interface AddToCartData extends EventData {\n event: \"addToCart\";\n eventName: \"vtex:addToCart\";\n items: AddToCartProduct[];\n}\n\nexport interface RemoveToCartData extends EventData {\n event: \"removeFromCart\";\n eventName: \"vtex:removeFromCart\";\n items: any[];\n}\n\nexport interface OrderPlacedData extends Order, EventData {\n event: \"orderPlaced\";\n eventName: \"vtex:orderPlaced\";\n}\n\nexport interface ProductViewData extends EventData {\n event: \"productView\";\n eventName: \"vtex:productView\";\n product: Product;\n}\n\nexport interface ProductClickData extends EventData {\n event: \"productClick\";\n eventName: \"vtex:productClick\";\n product: Product;\n}\n\nexport interface ProductImpressionData extends EventData {\n event: \"productImpression\";\n eventName: \"vtex:productImpression\";\n product: Product;\n position: number;\n list: string;\n}\n\nexport interface Order {\n currency: string;\n accountName: string;\n orderGroup: string;\n salesChannel: string;\n coupon: string;\n visitorType: string;\n visitorContactInfo: string[];\n transactionId: string;\n transactionDate: string;\n transactionAffiliation: string;\n transactionTotal: number;\n transactionShipping: number;\n transactionTax: number;\n transactionCurrency: string;\n transactionPaymentType: PaymentType[];\n transactionShippingMethod: ShippingMethod[];\n transactionProducts: ProductOrder[];\n transactionPayment: {\n id: string;\n };\n}\n\ninterface PaymentType {\n group: string;\n paymentSystemName: string;\n installments: number;\n value: number;\n}\n\ninterface ShippingMethod {\n itemId: string;\n selectedSla: string;\n}\n\ninterface ProductOrder {\n id: string;\n name: string;\n sku: string;\n skuRefId: string;\n skuName: string;\n brand: string;\n brandId: string;\n seller: string;\n sellerId: string;\n category: string;\n categoryId: string;\n categoryTree: string[];\n categoryIdTree: string[];\n originalPrice: number;\n price: number;\n sellingPrice: number;\n tax: number;\n quantity: number;\n components: any[];\n measurementUnit: string;\n unitMultiplier: number;\n}\n\nexport interface Product {\n brand: string;\n categoryId?: string; // inconsistency\n categories: string[];\n productId: string;\n productName: string;\n selectedSku?: string; // inconsistency\n items: Item[];\n sku: Item;\n [key: string]: any;\n}\n\ninterface Item {\n itemId: string;\n name: string;\n seller?: Seller;\n [key: string]: any;\n}\n\ninterface Seller {\n commertialOffer: CommertialOffer;\n AvailableQuantity: number;\n [key: string]: any;\n}\n\ninterface CommertialOffer {\n Price: number;\n [key: string]: any;\n}\n\ninterface AddToCartProduct {\n brand: string;\n name: string;\n price: number;\n quantity: number;\n skuId: string;\n variant: string;\n category: string;\n}\n\n```" } ]
code_tradetracker_1a602f57
[ { "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 tradetracker/react/typings/vtex.render-runtime.d.ts from the tradetracker VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.render-runtime' {\n export const canUseDOM: boolean\n}\n\n```" } ]
code_tradetracker_31980a9d
[ { "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 tradetracker/react/typings/global.d.ts from the tradetracker VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare function fbq(s: string, t: string, o?: any): void;\n\ninterface Event extends Event {\n data: any;\n}\n\ninterface Window extends Window {\n ttConversionOptions: TradeTrackerEvent[];\n __tradetracker: {\n tradeTrackerCampaignID: string;\n tradeTrackerProductID: string;\n tradeTrackerDescrMerchant: string;\n tradeTrackerDescrAffiliate: string;\n };\n}\n\ninterface TradeTrackerEvent {\n type: \"sales\";\n quantity: string;\n email: string;\n currency: string;\n campaignID: string;\n productID: string;\n transactionID: string;\n transactionAmount: number;\n descrMerchant: string;\n descrAffiliate: string;\n}\n\ninterface TradeTrackerEventItemProduct {\n id: string;\n name: string;\n price: string;\n department: string;\n category: string;\n subcategory: string;\n brand: string;\n}\n\ninterface TradeTrackerEventItemKeyword {\n keyword: string;\n}\n\n```" } ]
code_countries-data_1c8ce29e
[ { "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 countries-data/scripts/jsconfig.json from the countries-data VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"compilerOptions\": {\n \"target\": \"es5\",\n \"module\": \"commonjs\",\n \"lib\": [\"es2018\"],\n \"checkJs\": true\n }\n}\n\n```" } ]
code_countries-data_f7376550
[ { "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 countries-data/scripts/create-country-app.js from the countries-data VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\n#!/usr/bin/env node\n\n/* eslint-disable no-console */\n\nconst fsp = require('fs').promises\nconst path = require('path')\n\nconst packagesDir = path.resolve(__dirname, '..', 'packages')\n\nconst SERVICE_APP_NAME = 'vtex.country-data-settings'\n\nconst CHANGELOG_TEMPLATE = `\n# Changelog\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n## [Unreleased]\n`.trim()\n\n/**\n * @param {string} [country] - Country\n */\nconst getManifestTemplate = (country) =>\n `\n{\n \"vendor\": \"vtex\",\n \"name\": \"country-data-${country}\",\n \"version\": \"0.0.0\",\n \"builders\": {\n ${JSON.stringify(SERVICE_APP_NAME)}: \"0.x\"\n },\n \"$schema\": \"https://raw.githubusercontent.com/vtex/node-vtex-api/master/gen/manifest.schema\"\n}\n`.trim()\n\nconst printHelp = () => {\n const [, scriptName] = process.argv\n const formattedAppName = path.relative(process.cwd(), scriptName)\n\n console.log(\n `\nUsage: ./${formattedAppName} [...countries]\n\nThis script creates the boilerplate for a country configuration app inside packages/[country]/.\n\nExamples:\n\n The command:\n\n ./${formattedAppName} bra\n\n Creates the \"bra\" directory in \"packages/\"\n\n The command:\n\n ./${formattedAppName} usa bol arg\n\n Creates the \"usa\", \"bol\" and \"arg\" directories in \"packages/\"\n`\n )\n}\n\nconst main = async () => {\n const [, , ...countries] = process.argv\n\n if (!countries.length) {\n printHelp()\n return\n }\n\n await Promise.all(\n countries.map(async (country) => {\n try {\n const manifest = getManifestTemplate(country)\n\n const appDir = path.join(packagesDir, country)\n\n try {\n await fsp.access(path.join(appDir, 'manifest.json'))\n\n console.log(`App for country \"${country}\" already exists.`)\n\n return\n } catch {\n // ignored\n }\n\n await fsp.mkdir(appDir)\n\n // create manifest.json file\n await fsp.writeFile(path.join(appDir, 'manifest.json'), manifest)\n\n await fsp.mkdir(path.join(appDir, SERVICE_APP_NAME))\n\n // create basic configuration.json file\n await fsp.writeFile(\n path.join(appDir, SERVICE_APP_NAME, 'configuration.json'),\n '{}'\n )\n\n // create CHANGELOG.md file\n await fsp.writeFile(\n path.join(appDir, 'CHANGELOG.md'),\n CHANGELOG_TEMPLATE\n )\n\n console.log(`Successfully bootstrapped app for country \"${country}\"`)\n } catch (err) {\n console.error(\n `An unexpected error occured when bootstrapping app for country \"${country}\"`\n )\n console.error(err)\n }\n })\n )\n}\n\nmain()\n\n```" } ]
code_countries-data_4d308059
[ { "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 countries-data/packages/usa/manifest.json from the countries-data VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"vendor\": \"vtex\",\n \"name\": \"country-data-usa\",\n \"version\": \"0.1.2\",\n \"builders\": {\n \"vtex.country-data-settings\": \"0.x\"\n },\n \"$schema\": \"https://raw.githubusercontent.com/vtex/node-vtex-api/master/gen/manifest.schema\"\n}\n\n```" } ]
code_countries-data_ef9b9408
[ { "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 countries-data/packages/bra/manifest.json from the countries-data VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"vendor\": \"vtex\",\n \"name\": \"country-data-bra\",\n \"version\": \"0.2.1\",\n \"title\": \"Brazil Data for Places Components\",\n \"builders\": {\n \"vtex.country-data-settings\": \"0.x\"\n },\n \"$schema\": \"https://raw.githubusercontent.com/vtex/node-vtex-api/master/gen/manifest.schema\"\n}\n\n```" } ]
code_countries-data_a7c8d6ad
[ { "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 countries-data/packages/bol/manifest.json from the countries-data VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"vendor\": \"vtex\",\n \"name\": \"country-data-bol\",\n \"version\": \"0.1.0\",\n \"builders\": {\n \"vtex.country-data-settings\": \"0.x\"\n },\n \"$schema\": \"https://raw.githubusercontent.com/vtex/node-vtex-api/master/gen/manifest.schema\"\n}\n\n```" } ]
code_countries-data_dc806323
[ { "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 countries-data/packages/arg/manifest.json from the countries-data VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"vendor\": \"vtex\",\n \"name\": \"country-data-arg\",\n \"version\": \"0.1.0\",\n \"builders\": {\n \"vtex.country-data-settings\": \"0.x\"\n },\n \"$schema\": \"https://raw.githubusercontent.com/vtex/node-vtex-api/master/gen/manifest.schema\"\n}\n\n```" } ]
code_countries-data_23db0727
[ { "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 countries-data/packages/usa/vtex.country-data-settings/configuration.json from the countries-data VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"countryISO\": \"USA\",\n \"addressFields\": {\n \"country\": {\n \"label\": \"country\",\n \"hidden\": true,\n \"maxLength\": 100\n },\n \"state\": {\n \"label\": \"stateAbbreviation\",\n \"maxLength\": 100,\n \"required\": true,\n \"options\": [\n {\n \"label\": \"AL\",\n \"value\": \"AL\"\n },\n {\n \"label\": \"AK\",\n \"value\": \"AK\"\n },\n {\n \"label\": \"AZ\",\n \"value\": \"AZ\"\n },\n {\n \"label\": \"AR\",\n \"value\": \"AR\"\n },\n {\n \"label\": \"CA\",\n \"value\": \"CA\"\n },\n {\n \"label\": \"CO\",\n \"value\": \"CO\"\n },\n {\n \"label\": \"CT\",\n \"value\": \"CT\"\n },\n {\n \"label\": \"DE\",\n \"value\": \"DE\"\n },\n {\n \"label\": \"DC\",\n \"value\": \"DC\"\n },\n {\n \"label\": \"FL\",\n \"value\": \"FL\"\n },\n {\n \"label\": \"GA\",\n \"value\": \"GA\"\n },\n {\n \"label\": \"HI\",\n \"value\": \"HI\"\n },\n {\n \"label\": \"ID\",\n \"value\": \"ID\"\n },\n {\n \"label\": \"IL\",\n \"value\": \"IL\"\n },\n {\n \"label\": \"IN\",\n \"value\": \"IN\"\n },\n {\n \"label\": \"IA\",\n \"value\": \"IA\"\n },\n {\n \"label\": \"KS\",\n \"value\": \"KS\"\n },\n {\n \"label\": \"KY\",\n \"value\": \"KY\"\n },\n {\n \"label\": \"LA\",\n \"value\": \"LA\"\n },\n {\n \"label\": \"ME\",\n \"value\": \"ME\"\n },\n {\n \"label\": \"MD\",\n \"value\": \"MD\"\n },\n {\n \"label\": \"MA\",\n \"value\": \"MA\"\n },\n {\n \"label\": \"MI\",\n \"value\": \"MI\"\n },\n {\n \"label\": \"MN\",\n \"value\": \"MN\"\n },\n {\n \"label\": \"MS\",\n \"value\": \"MS\"\n },\n {\n \"label\": \"MO\",\n \"value\": \"MO\"\n },\n {\n \"label\": \"MT\",\n \"value\": \"MT\"\n },\n {\n \"label\": \"NE\",\n \"value\": \"NE\"\n },\n {\n \"label\": \"NV\",\n \"value\": \"NV\"\n },\n {\n \"label\": \"NH\",\n \"value\": \"NH\"\n },\n {\n \"label\": \"NJ\",\n \"value\": \"NJ\"\n },\n {\n \"label\": \"NM\",\n \"value\": \"NM\"\n },\n {\n \"label\": \"NY\",\n \"value\": \"NY\"\n },\n {\n \"label\": \"NC\",\n \"value\": \"NC\"\n },\n {\n \"label\": \"ND\",\n \"value\": \"ND\"\n },\n {\n \"label\": \"OH\",\n \"value\": \"OH\"\n },\n {\n \"label\": \"OK\",\n \"value\": \"OK\"\n },\n {\n \"label\": \"OR\",\n \"value\": \"OR\"\n },\n {\n \"label\": \"PA\",\n \"value\": \"PA\"\n },\n {\n \"label\": \"PR\",\n \"value\": \"PR\"\n },\n {\n \"label\": \"RI\",\n \"value\": \"RI\"\n },\n {\n \"label\": \"SC\",\n \"value\": \"SC\"\n },\n {\n \"label\": \"SD\",\n \"value\": \"SD\"\n },\n {\n \"label\": \"TN\",\n \"value\": \"TN\"\n },\n {\n \"label\": \"TX\",\n \"value\": \"TX\"\n },\n {\n \"label\": \"UT\",\n \"value\": \"UT\"\n },\n {\n \"label\": \"VT\",\n \"value\": \"VT\"\n },\n {\n \"label\": \"VA\",\n \"value\": \"VA\"\n },\n {\n \"label\": \"WA\",\n \"value\": \"WA\"\n },\n {\n \"label\": \"WV\",\n \"value\": \"WV\"\n },\n {\n \"label\": \"WI\",\n \"value\": \"WI\"\n },\n {\n \"label\": \"WY\",\n \"value\": \"WY\"\n }\n ]\n },\n \"city\": {\n \"label\": \"city\",\n \"maxLength\": 100,\n \"required\": true\n },\n \"neighborhood\": {\n \"label\": \"neighborhood\",\n \"hidden\": true,\n \"maxLength\": 100\n },\n \"street\": {\n \"label\": \"streetRoadAvenue\",\n \"required\": true\n },\n \"number\": {\n \"label\": \"numberOption\",\n \"maxLength\": 750,\n \"hidden\": true,\n \"autoComplete\": \"off\"\n },\n \"complement\": {\n \"label\": \"complement\",\n \"maxLength\": 750\n },\n \"reference\": {\n \"label\": \"reference\",\n \"hidden\": true,\n \"maxLength\": 750\n },\n \"receiverName\": {\n \"label\": \"receiverName\",\n \"elementName\": \"receiver\",\n \"maxLength\": 750,\n \"required\": true\n },\n \"postalCode\": {\n \"label\": \"postalCode\",\n \"forgottenURL\": \"https://tools.usps.com/go/ZipLookupAction_input\"\n }\n },\n \"display\": {\n \"minimal\": [\n [\n {\n \"name\": \"postalCode\"\n }\n ]\n ],\n \"compact\": [\n [\n {\n \"name\": \"street\"\n }\n ],\n [\n {\n \"name\": \"city\"\n },\n {\n \"delimiter\": \" \",\n \"name\": \"state\"\n },\n {\n \"delimiter\": \" \",\n \"name\": \"postalCode\"\n }\n ]\n ],\n \"extended\": [\n [\n {\n \"name\": \"receiverName\"\n }\n ],\n [\n {\n \"name\": \"street\"\n },\n {\n \"delimiter\": \" \",\n \"name\": \"complement\"\n }\n ],\n [\n {\n \"name\": \"number\"\n },\n {\n \"delimiter\": \", \",\n \"name\": \"neighborhood\"\n }\n ],\n [\n {\n \"name\": \"city\"\n },\n {\n \"delimiter\": \" \",\n \"name\": \"state\"\n },\n {\n \"delimiter\": \" \",\n \"name\": \"postalCode\"\n }\n ]\n ]\n },\n \"phone\": {\n \"countryCode\": \"1\",\n \"mask\": \"999-999-9999\",\n \"pattern\": \"/^(?:(?:(?:\\\\+|)(?:1|))|)(?:1|)(?:2(?:0[1-9]|1[02-9]|2[4-9]|3[1469]|4[089]|5[01-46]|6[0279]|7[0468]|8[139])|3(?:0[1-9]|1[02-9]|2[01235]|3[014679]|4[01367]|5[12]|6[01459]|8[056])|4(?:0[1-9]|1[02-9]|2[345]|3[0-24578]|4[023578]|5[08]|6[49]|7[0589]|8[04]|50[1-57-9])|5(?:0[1-9]|1[02-9]|20|3[014]|4[01]|5[179]|6[1-47]|7[013-59]|8[01567])|6(?:0[1-9]|1[0234-9]|2[036-8]|3[0169]|4[167]|5[0179]|6[01279]|7[0189]|8[1249])|7(?:0[1-9]|1[2-9]|2[047]|3[01247]|4[07]|5[247]|6[02-59]|7[02-589]|8[01567])|8(?:0[1-8]|1[0-9]|28|3[0-25]|4[3578]|5[06-9]|6[02-57]|7[0238])|9(?:0[1-9]|1[02-9]|2[0578]|3[15-9]|4[0179]|5[124679]|7[0-3589]|8[045]|89))\\\\d{7}$/\"\n }\n}\n\n```" } ]
code_countries-data_0384f5e3
[ { "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 countries-data/packages/bra/vtex.country-data-settings/configuration.json from the countries-data VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"countryISO\": \"BRA\",\n \"addressFields\": {\n \"country\": {\n \"label\": \"country\",\n \"hidden\": true,\n \"maxLength\": 100\n },\n \"state\": {\n \"label\": \"stateAbbreviation\",\n \"maxLength\": 100,\n \"required\": true,\n \"optionsCaption\": \"UF\",\n \"options\": [\n {\n \"label\": \"AC\",\n \"value\": \"AC\"\n },\n {\n \"label\": \"AL\",\n \"value\": \"AL\"\n },\n {\n \"label\": \"AP\",\n \"value\": \"AP\"\n },\n {\n \"label\": \"AM\",\n \"value\": \"AM\"\n },\n {\n \"label\": \"BA\",\n \"value\": \"BA\"\n },\n {\n \"label\": \"CE\",\n \"value\": \"CE\"\n },\n {\n \"label\": \"DF\",\n \"value\": \"DF\"\n },\n {\n \"label\": \"ES\",\n \"value\": \"ES\"\n },\n {\n \"label\": \"GO\",\n \"value\": \"GO\"\n },\n {\n \"label\": \"MA\",\n \"value\": \"MA\"\n },\n {\n \"label\": \"MT\",\n \"value\": \"MT\"\n },\n {\n \"label\": \"MS\",\n \"value\": \"MS\"\n },\n {\n \"label\": \"MG\",\n \"value\": \"MG\"\n },\n {\n \"label\": \"PA\",\n \"value\": \"PA\"\n },\n {\n \"label\": \"PB\",\n \"value\": \"PB\"\n },\n {\n \"label\": \"PR\",\n \"value\": \"PR\"\n },\n {\n \"label\": \"PE\",\n \"value\": \"PE\"\n },\n {\n \"label\": \"PI\",\n \"value\": \"PI\"\n },\n {\n \"label\": \"RJ\",\n \"value\": \"RJ\"\n },\n {\n \"label\": \"RN\",\n \"value\": \"RN\"\n },\n {\n \"label\": \"RS\",\n \"value\": \"RS\"\n },\n {\n \"label\": \"RO\",\n \"value\": \"RO\"\n },\n {\n \"label\": \"RR\",\n \"value\": \"RR\"\n },\n {\n \"label\": \"SC\",\n \"value\": \"SC\"\n },\n {\n \"label\": \"SP\",\n \"value\": \"SP\"\n },\n {\n \"label\": \"SE\",\n \"value\": \"SE\"\n },\n {\n \"label\": \"TO\",\n \"value\": \"TO\"\n }\n ]\n },\n \"city\": {\n \"label\": \"city\",\n \"maxLength\": 100,\n \"required\": true\n },\n \"neighborhood\": {\n \"label\": \"neighborhood\",\n \"maxLength\": 100,\n \"required\": true\n },\n \"street\": {\n \"label\": \"streetRoadAvenue\",\n \"required\": true\n },\n \"number\": {\n \"label\": \"numberOption\",\n \"maxLength\": 750,\n \"required\": true,\n \"autoComplete\": \"off\"\n },\n \"complement\": {\n \"label\": \"complement\",\n \"maxLength\": 750\n },\n \"reference\": {\n \"label\": \"reference\",\n \"hidden\": true,\n \"maxLength\": 750\n },\n \"receiverName\": {\n \"label\": \"receiverName\",\n \"elementName\": \"receiver\",\n \"maxLength\": 750,\n \"required\": true\n },\n \"postalCode\": {\n \"mask\": \"99999-999\",\n \"pattern\": \"^(\\\\d){5}-?(\\\\d){3}$\",\n \"label\": \"postalCode\",\n \"forgottenURL\": \"https://buscacepinter.correios.com.br/app/endereco/index.php\"\n }\n },\n \"display\": {\n \"minimal\": [\n [\n {\n \"name\": \"postalCode\"\n }\n ]\n ],\n \"compact\": [\n [\n {\n \"name\": \"street\"\n },\n {\n \"delimiter\": \" \",\n \"name\": \"number\"\n }\n ],\n [\n {\n \"name\": \"neighborhood\"\n }\n ],\n [\n {\n \"name\": \"city\"\n },\n {\n \"delimiter\": \" - \",\n \"name\": \"state\"\n }\n ],\n [\n {\n \"name\": \"postalCode\"\n }\n ]\n ],\n \"extended\": [\n [\n {\n \"name\": \"receiverName\"\n }\n ],\n [\n {\n \"name\": \"street\"\n },\n {\n \"delimiter\": \" \",\n \"name\": \"number\"\n }\n ],\n [\n {\n \"name\": \"complement\"\n }\n ],\n [\n {\n \"name\": \"neighborhood\"\n }\n ],\n [\n {\n \"name\": \"city\"\n },\n {\n \"delimiter\": \" - \",\n \"name\": \"state\"\n }\n ],\n [\n {\n \"name\": \"postalCode\"\n }\n ]\n ]\n },\n \"phone\": {\n \"countryCode\": \"55\",\n \"mask\": \"(99) 9 9999-9999\",\n \"pattern\": \"^(?:(?:(?:\\\\+|)(?:55|)|))(?:0|)(?:(?:(?:1[1-9]|2[12478]|3[1-8]|6[1-9]|7[134579]|8[1-9]|9[1-9]|4[1-9]|5[1-5])(?:9\\\\d{8}|\\\\d{8})))$\"\n }\n}\n\n```" } ]
code_countries-data_c2f18946
[ { "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 countries-data/packages/bol/vtex.country-data-settings/configuration.json from the countries-data VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"countryISO\": \"BOL\",\n \"addressFields\": {\n \"country\": {\n \"hidden\": true,\n \"maxLength\": 100,\n \"label\": \"country\"\n },\n \"street\": {\n \"label\": \"street\",\n \"required\": true\n },\n \"number\": {\n \"maxLength\": 750,\n \"label\": \"number\",\n \"required\": true,\n \"autoComplete\": \"off\"\n },\n \"complement\": {\n \"maxLength\": 750,\n \"label\": \"complement\"\n },\n \"reference\": {\n \"hidden\": true,\n \"maxLength\": 750,\n \"label\": \"reference\"\n },\n \"receiverName\": {\n \"elementName\": \"receiver\",\n \"maxLength\": 750,\n \"label\": \"receiverName\",\n \"required\": true\n }\n },\n \"display\": {\n \"minimal\": [\n [\n {\n \"name\": \"city\"\n }\n ]\n ],\n \"compact\": [\n [\n {\n \"name\": \"street\"\n },\n {\n \"delimiter\": \" \",\n \"name\": \"number\"\n }\n ],\n [\n {\n \"name\": \"city\"\n }\n ]\n ],\n \"extended\": [\n [\n {\n \"name\": \"receiverName\"\n }\n ],\n [\n {\n \"name\": \"street\"\n },\n {\n \"delimiter\": \" \",\n \"name\": \"number\"\n }\n ],\n [\n {\n \"name\": \"complement\"\n }\n ],\n [\n {\n \"name\": \"city\"\n }\n ]\n ]\n },\n \"locationSelect\": {\n \"countryData\": {\n \"Beni\": {\n \"Cercado\": {\n \"Paititi\": \"10000\",\n \"Trinidad\": \"10001\",\n \"Yucumo\": \"10002\"\n },\n \"José Ballivián\": {\n \"Reyes\": \"10100\",\n \"Rurrenabaque\": \"10101\",\n \"San Borja\": \"10102\"\n },\n \"Mamore\": {\n \"San Ramon\": \"10200\"\n },\n \"Moxos\": {\n \"San Ignacio de Moxos\": \"10300\",\n \"San Joaquin\": \"10301\"\n },\n \"Vaca Díez\": {\n \"Guayaramerín\": \"10400\",\n \"Magdalena\": \"10401\",\n \"Riberalta\": \"10402\"\n },\n \"Yacuma\": {\n \"Santa Ana del Yacuma\": \"10500\",\n \"Santa Rosa de Yacuma\": \"10501\"\n }\n },\n \"Chuquisaca\": {\n \"Nor Cinti\": {\n \"Pelillojo\": \"20000\"\n },\n \"Luis Calvo\": {\n \"Machareti\": \"20100\"\n },\n \"Hernando Siles\": {\n \"Monteagudo\": \"20200\"\n },\n \"Oropeza\": {\n \"Yotala\": \"20300\"\n },\n \"Sucre\": {\n \"Sucre\": \"20400\"\n }\n },\n \"Cochabamba\": {\n \"Arani\": {\n \"Arani\": \"30000\",\n \"Vacas\": \"30001\"\n },\n \"Ayopaya\": {\n \"Morochata\": \"30100\",\n \"Villa Indedencia\": \"30101\"\n },\n \"Capinota\": {\n \"Capinota\": \"30200\",\n \"Irpa Irpa\": \"30201\",\n \"La Cantera\": \"30202\"\n },\n \"Carrasco\": {\n \"Bulo Bulo\": \"30300\",\n \"Chimoré\": \"30301\",\n \"Entre Ríos\": \"30302\",\n \"Ivirgarzama\": \"30303\",\n \"Puerto Villaroel\": \"30304\",\n \"Totora\": \"30305\",\n \"Villa Tunari\": \"30306\"\n },\n \"Cercado\": {\n \"Cochabamba\": \"30400\"\n },\n \"Chapare\": {\n \"Colomi\": \"30500\",\n \"Epizana\": \"30501\",\n \"Eterazama\": \"30502\",\n \"Huayllani\": \"30503\",\n \"Sacaba\": \"30504\",\n \"San Gabriel\": \"30505\",\n \"Shinaota\": \"30506\"\n },\n \"Esteban Arze\": {\n \"Anzaldo\": \"30600\",\n \"Arbieto\": \"30601\",\n \"Tarata\": \"30602\"\n },\n \"Germán Jordán\": {\n \"Cliza\": \"30700\"\n },\n \"Mizque\": {\n \"Mizque\": \"30800\"\n },\n \"Narciso Campero\": {\n \"Aiquile\": \"30900\"\n },\n \"Punata\": {\n \"Punata\": \"31000\",\n \"San Benito\": \"31001\",\n \"Valle Alto\": \"31002\"\n },\n \"Quillacollo\": {\n \"Apote\": \"31100\",\n \"Colcapirhua\": \"31101\",\n \"Quillacollo\": \"31102\",\n \"Sipe Sipe\": \"31103\",\n \"Tapacarí\": \"31104\",\n \"Tiquipaya\": \"31105\",\n \"Vinto\": \"31106\"\n },\n \"Tiraque\": {\n \"Tiraque\": \"31200\"\n }\n },\n \"La Paz\": {\n \"Aroma\": {\n \"Ayo Ayo\": \"40000\",\n \"Capaja\": \"40001\",\n \"Patacamaya\": \"40002\",\n \"Pucara\": \"40003\",\n \"Sica Sica\": \"40004\"\n },\n \"Camacho\": {\n \"Escoma\": \"40100\",\n \"Mocomoco\": \"40101\",\n \"Puerto Acosta\": \"40102\"\n },\n \"Caranavi\": {\n \"Caranavi\": \"40200\",\n \"Taipiplaya\": \"40201\"\n },\n \"Franz Tamayo\": {\n \"Apolo\": \"40300\"\n },\n \"Ingavi\": {\n \"Calamarca\": \"40400\",\n \"Desaguadero\": \"40401\",\n \"Guaqui\": \"40402\",\n \"Jesus de Machaca\": \"40403\",\n \"Tiahuanacu\": \"40404\",\n \"Viacha\": \"40405\"\n },\n \"Inquisivi\": {\n \"Colquiri\": \"40500\",\n \"Quime\": \"40501\"\n },\n \"La Paz\": {\n \"Achacachi\": \"40600\"\n },\n \"Larecaja\": {\n \"Guanay\": \"40700\",\n \"Mapiri\": \"40701\",\n \"Mayaya\": \"40702\",\n \"Sorata\": \"40703\",\n \"Tacacoma\": \"40704\",\n \"Tipuani\": \"40705\"\n },\n \"Los Andes\": {\n \"Batallas\": \"40800\",\n \"El Lago\": \"40801\",\n \"Laja\": \"40802\",\n \"Pucarani\": \"40803\"\n },\n \"Manco Kapac\": {\n \"Copacabana\": \"40900\",\n \"Tiquina San Pablo\": \"40901\"\n },\n \"Murillo\": {\n \"Palca\": \"41000\"\n },\n \"Muñecas\": {\n \"Chuma\": \"41100\"\n },\n \"Nor Yungas\": {\n \"Coripata\": \"41200\",\n \"Coroico\": \"41201\"\n },\n \"Omasuyos\": {\n \"Ancoraimes\": \"41300\",\n \"Huarina\": \"41301\"\n },\n \"Pacajes\": {\n \"Charaña\": \"41400\"\n },\n \"Pedro Domingo Murillo\": {\n \"Achocalla\": \"41500\",\n \"El Alto\": \"41501\",\n \"La Paz\": \"41502\",\n \"Valencia\": \"41503\"\n },\n \"Sud Yungas\": {\n \"Chulumani\": \"41600\",\n \"Irupana\": \"41601\",\n \"Ixiamas\": \"41602\",\n \"La Asunta\": \"41603\",\n \"Palos Blancos\": \"41604\"\n },\n \"Yungas\": {\n \"Cruz Loma\": \"41700\"\n }\n },\n \"Oruro\": {\n \"Cercado\": {\n \"Caracollo\": \"50000\",\n \"Oruro\": \"50001\"\n },\n \"Oruro\": {\n \"Challapata\": \"50100\"\n },\n \"Pantaleón Dalence\": {\n \"Huanuni\": \"50200\"\n },\n \"Poopo\": {\n \"Poopo\": \"50300\"\n },\n \"Sebastián Pagador\": {\n \"Santiago de Huari\": \"50400\"\n }\n },\n \"Pando\": {\n \"Nicolás Suárez\": {\n \"Cobija\": \"60000\",\n \"El Porvenir\": \"60001\"\n }\n },\n \"Potosí\": {\n \"Antonio Quijarro\": {\n \"Uyuni\": \"70000\"\n },\n \"Linares\": {\n \"Puna\": \"70100\"\n },\n \"Modesto Omiste\": {\n \"Villazón\": \"70200\"\n },\n \"Rafael Bustillo\": {\n \"Llallagua\": \"70300\",\n \"Siglo XX\": \"70301\",\n \"Uncia\": \"70302\"\n },\n \"Saavedra\": {\n \"Betanzos\": \"70400\"\n },\n \"Sud Chichas\": {\n \"Tupiza\": \"70500\"\n },\n \"Tomás Frías\": {\n \"Plahipo\": \"70600\",\n \"Potosí\": \"70601\",\n \"Pulquipunta\": \"70602\"\n }\n },\n \"Santa Cruz\": {\n \"Andrés Ibañez\": {\n \"Buena Vista\": \"80000\",\n \"Cotoca\": \"80001\",\n \"El Carmen Rivero Torrez\": \"80002\",\n \"El Torno\": \"80003\",\n \"Jorochito\": \"80004\",\n \"La Angostura\": \"80005\",\n \"La Guardia\": \"80006\",\n \"Paurito\": \"80007\",\n \"Porongo\": \"80008\",\n \"San Jose del Torno\": \"80009\",\n \"Santa Cruz\": \"80010\",\n \"Santa Marta\": \"80011\",\n \"Santa Rita\": \"80012\"\n },\n \"Angel Sandóval\": {\n \"San Matías\": \"80100\"\n },\n \"Caballero\": {\n \"Comarapa\": \"80200\",\n \"Palizada\": \"80201\",\n \"Saipina\": \"80202\"\n },\n \"Chiquitos\": {\n \"Cañada Larga\": \"80300\",\n \"Chihuahua\": \"80301\",\n \"Pailas\": \"80302\",\n \"Pailón\": \"80303\",\n \"Roboré\": \"80304\",\n \"San José de Chiquitos\": \"80305\"\n },\n \"Cordillera\": {\n \"Abapo\": \"80400\",\n \"Basilio\": \"80401\",\n \"Boyuibe\": \"80402\",\n \"Cabezas\": \"80403\",\n \"Camiri\": \"80404\",\n \"Charagua\": \"80405\",\n \"Gutierrez\": \"80406\",\n \"Mora\": \"80407\",\n \"Rio Seco\": \"80408\",\n \"Zanja Honda\": \"80409\"\n },\n \"Florida\": {\n \"Mairana\": \"80500\",\n \"Mataral\": \"80501\",\n \"Samaipata\": \"80502\"\n },\n \"Germán Bush\": {\n \"Puerto Suárez\": \"80600\"\n },\n \"Guarayos\": {\n \"Ascensión de Guarayos\": \"80700\",\n \"El Puente\": \"80701\",\n \"Urubichá\": \"80702\",\n \"Yotau\": \"80703\"\n },\n \"Ichilo\": {\n \"Buen Retiro\": \"80800\",\n \"Nuevo Horizontes\": \"80801\",\n \"San Carlos\": \"80802\",\n \"Santa fe de Yapacani\": \"80803\",\n \"Yapacani\": \"80804\"\n },\n \"Ignacio Warnes\": {\n \"Okinawa\": \"80900\",\n \"Okinawa 2\": \"80901\",\n \"Warnes\": \"80902\"\n },\n \"José Miguel de Velasco\": {\n \"San Ignacio\": \"81000\",\n \"San Rafael\": \"81001\",\n \"TX San Antonio\": \"81002\",\n \"TX Santa Ana\": \"81003\"\n },\n \"Manuel María Caballero\": {\n \"Pulquina\": \"81100\"\n },\n \"Ñuflo de Chávez\": {\n \"4 Cañadas\": \"81200\",\n \"Cerro Pelado\": \"81201\",\n \"Concepción\": \"81202\",\n \"Los Troncos\": \"81203\",\n \"Puerto Rico\": \"81204\",\n \"San Javier\": \"81205\",\n \"San Juan de Yapacaní\": \"81206\",\n \"San Julian\": \"81207\",\n \"San Ramón\": \"81208\"\n },\n \"Obispo Santiesteban\": {\n \"Canandoa\": \"81300\",\n \"Chané\": \"81301\",\n \"Colonia Pirai\": \"81302\",\n \"Hardeman\": \"81303\",\n \"Litoral\": \"81304\",\n \"Mineros\": \"81305\",\n \"Montero\": \"81306\",\n \"Saavedra\": \"81307\",\n \"San Pedro\": \"81308\"\n },\n \"Sara\": {\n \"Portachuelo\": \"81400\",\n \"Puente San Pablo\": \"81401\",\n \"Santa Rosa del Sara\": \"81402\"\n },\n \"Valle Grande\": {\n \"Trigal\": \"81500\",\n \"Vallegrande\": \"81501\"\n },\n \"Velasco\": {\n \"San Miguel de Velasco\": \"81600\"\n }\n },\n \"Tarija\": {\n \"Aniceto Arce\": {\n \"Padcaya\": \"90000\"\n },\n \"Burnet O'Connor\": {\n \"Entre Rios\": \"90100\"\n },\n \"Cercado\": {\n \"Tarija\": \"90200\"\n },\n \"Gran Chaco\": {\n \"Sanandita\": \"90300\"\n },\n \"Méndez\": {\n \"Canasmoro\": \"90400\",\n \"San Lorenzo\": \"90401\",\n \"Tomatitas\": \"90402\"\n },\n \"Tarija\": {\n \"Bermejo\": \"90500\",\n \"Villamontes\": \"90501\",\n \"Yacuiba\": \"90502\"\n }\n }\n },\n \"fields\": [\n {\n \"name\": \"state\",\n \"label\": \"department\"\n },\n {\n \"name\": \"city\",\n \"label\": \"province\"\n },\n {\n \"name\": \"neighborhood\",\n \"label\": \"city\"\n }\n ]\n },\n \"phone\": {\n \"countryCode\": \"591\",\n \"mask\": \"9 999-9999\",\n \"pattern\": \"/^(?:(?:(?:\\\\+|)591)|)(?:0|)[23467]\\\\d{7}$/\"\n }\n}\n\n```" } ]
code_store-link_1d33b762
[ { "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-link/messages/pt.json from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.link.label.title\": \"Texto do link\",\n \"admin/editor.link.label.description\": \"Qualquer texto ex. \\\"Categorias\\\", \\\"Sobre nós\\\", etc.\",\n \"admin/editor.link.href.description\": \"URL para o link ex. \\\"https://www.google.com\\\", \\\"/sobre-nos\\\", etc\",\n \"admin/editor.product-link.title\": \"Link de produto\",\n \"admin/editor.link.target.title\": \"Onde abrir o link\",\n \"admin/editor.link.target.description\": \"Você pode checar as opções disponíveis em: https://developer.mozilla.org/docs/Web/HTML/Element/a\",\n \"admin/editor.link.rel.attribute.title\": \"\\\"rel\\\" atributo\",\n \"admin/editor.link.rel.attribute.description\": \"Você pode checar as opções disponíveis em: https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types\"\n}\n```" } ]
code_store-link_273e39e8
[ { "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-link/messages/en.json from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.link.label.title\": \"Link text\",\n \"admin/editor.link.label.description\": \"Any text e.g. \\\"Categories\\\", \\\"About us\\\", etc.\",\n \"admin/editor.link.href.description\": \"The actual link e.g. \\\"https://www.google.com\\\", \\\"/about-us\\\", etc\",\n \"admin/editor.product-link.title\": \"Product Link\",\n \"admin/editor.link.target.title\": \"Where to open the link\",\n \"admin/editor.link.target.description\": \"You can check the options available at: https://developer.mozilla.org/docs/Web/HTML/Element/a\",\n \"admin/editor.link.rel.attribute.title\": \"\\\"rel\\\" attribute\",\n \"admin/editor.link.rel.attribute.description\": \"You can check the options available at: https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types\"\n}\n\n```" } ]
code_store-link_43dc8b38
[ { "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-link/messages/context.json from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.link.label.title\": \"Link text\",\n \"admin/editor.link.label.description\": \"Any text e.g. \\\"Categories\\\", \\\"About us\\\", etc.\",\n \"admin/editor.link.href.description\": \"The actual link e.g. \\\"https://www.google.com\\\", \\\"/about-us\\\", etc\",\n \"admin/editor.product-link.title\": \"Product Link\",\n \"admin/editor.link.target.title\": \"Where to open the link\",\n \"admin/editor.link.target.description\": \"You can check the options available at: https://developer.mozilla.org/docs/Web/HTML/Element/a\",\n \"admin/editor.link.rel.attribute.title\": \"\\\"rel\\\" attribute\",\n \"admin/editor.link.rel.attribute.description\": \"You can check the options available at: https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types\"\n}\n```" } ]
code_store-link_b5f93b86
[ { "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-link/messages/es.json from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.link.label.title\": \"Texto del link\",\n \"admin/editor.link.label.description\": \"Cualquier mensaje de texto p. Ej. \\\"Categorías \\\", \\\"Acerca de nosotros \\\", etc.\",\n \"admin/editor.link.href.description\": \"El Link real, p. \\\"https://www.google.com\\\", \\\"/about-us \\\", etc.\",\n \"admin/editor.product-link.title\": \"Link de producto\",\n \"admin/editor.link.target.title\": \"Donde abrir el link\",\n \"admin/editor.link.target.description\": \"Puede consultar las opciones disponibles en: https://developer.mozilla.org/docs/Web/HTML/Element/a\",\n \"admin/editor.link.rel.attribute.title\": \"\\\"rel\\\" atributo\",\n \"admin/editor.link.rel.attribute.description\": \"Puedes consultar las opciones disponibles aquí: https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types\"\n}\n\n```" } ]
code_store-link_b3471967
[ { "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-link/docs/README.md from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/product-summary) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Store Link\n\n<!-- DOCS-IGNORE:start -->\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n<!-- DOCS-IGNORE:end -->\n\nThe Store Link app provides blocks for displaying links in other theme blocks, such as Product Summary.\n\n![image](https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/vtex-store-link-0.png)\n\n## Configurating the store link\n\n1. Add the `store-link` app to your theme dependencies in the `manifest.json` file. Then, you can use all the [blocks](#blocks) exported by the `store-link` app and its respective [props](#props).\n\n```diff\n \"dependencies\": {\n+ \"vtex.store-link\": \"0.x\"\n }\n```\n\n2. Choose one of the [blocks](#blocks) exported by the `store-link` app and declare it in the block where the link will be displayed. See below an example of a `link.product` being used in the [`product-summary`](https://developers.vtex.com/docs/apps/vtex.product-summary) block to display the \"More details\" link.\n\n```jsonc\n{\n \"link.product#product-page\": {\n \"props\": {\n \"href\": \"/{slug}/p\",\n \"label\": \"More details >\"\n }\n },\n \"product-summary.shelf\": {\n \"children\": [\n \"product-summary-image\",\n \"product-summary-name\",\n \"product-rating-inline\",\n \"product-summary-space\",\n \"product-summary-price\",\n \"link.product#product-page\"\n ]\n },\n}\n```\n> ⚠️ Note that you must place the `link.product` block inside a block that provides a product context (e.g., [`ProductSummary`](https://developers.vtex.com/docs/apps/vtex.product-summary)). From the previous example, note that a `{slug}` placeholder is being passed onto the `href` prop. When rendered, this placeholder is overwritten by the value accrued from the closest product context, generating a link like `/everyday-necessaire/p`.\n\n## Blocks\n\n| Block | Description |\n| -------------- | ------------------------------------------------ |\n| `link.product` | A link that uses the product context, such as a product slug or department. For example, `/{slug}/p`. |\n| `link` | A regular link that does not require the product context to function. For example, `/home`. |\n\n## Props\n\nAll blocks exported by `store-link` share the same props:\n\n| Prop name | Type | Description | Default value |\n| ----------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------- |\n| `label` | `string` | Link text. | `undefined` |\n| `href` | `string` | Link URL. | `#` |\n| `scrollTo` | `string` | Element anchor to scroll after navigation. (E.g. `\"#footer\"`) | `undefined` |\n| `target` | `string` | Where the linked URL will be displayed. This prop works the same way as the target from [HTML `<a>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a). Since the [*anchor* element's target](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target) default is `_self`, this prop will be set to `_self` if it is undefined. | `undefined` |\n| `displayMode` | `enum` | How the link will be displayed. Possible values are: `anchor` (displays a normal link with no styles) or `button` (displays a button that can be customized using the `buttonProps` prop). | `anchor` |\n| `buttonProps` | `object` | How the link button will be displayed. Use this prop only when the `displayMode` prop is set as `button`. | `{ variant: primary, size: regular }` |\n| `escapeLinkRegex` | `string` | RegExp, with global match, used to remove special characters within product specifications (e.g., if you want to use `/[%]/g` then `escapeLinkRegex` = `[%]`). | `undefined` |\n| `rel` | `string` | This prop specifies the relationship between the current document and linked ones for better SEO. This prop works the same way as the `rel` attribute from `<a>`, the [HTML anchor element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a). You can see supported values [here](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types). | `undefined` |\n\n- `buttonProps` object:\n\n| Prop name | Type | Description | Default value |\n| --------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |\n| `variant` | `enum` | Link button that has visual prominence. Possible values are: `primary` or `secondary` (values are set following the [VTEX Styleguide](https://styleguide.vtex.com/#/Components/Forms/Button)). | `primary` |\n| `size` | `enum` | Link button size. Possible values are: `small`, `regular` or `large` (values are set following the [VTEX Styleguide](https://styleguide.vtex.com/#/Components/Forms/Button)). | `regular` |\n\n## App Behavior\n\nWhen creating an URL link using the `href` prop, you can add custom query string values, as shown in the example below:\n\n```json\n{\n \"link#foo\": {\n \"props\": {\n \"href\": \"/login?returnUrl={queryString.returnUrl}\",\n \"label\": \"Sign in\"\n }\n }\n}\n```\n\nConsidering the `href` prop from the previous example, note that the URL link will be built correctly if the current page has the `returnUrl` query string. Otherwise, it will be built with an empty value.\n\nDepending on the context that the `link.product` block uses, you can use product variables to structure different URL paths for the `href` prop. For example, you could create a link to a specific product department (`/{department}`).\n\n| Product variable | Description |\n| ---------------- | ---------------------------------------------- |\n| `brand` | Product brand name. |\n| `brandId` | Product brand ID. |\n| `category1` | Highest level category in the category tree. |\n| `category2` | Second highest level category. |\n| `category3` | Third highest level category. |\n| `category4` | Fourth highest level category. |\n| `department` | Product department. |\n| `productId` | Product ID. |\n| `skuId` | Currently selected SKU ID. |\n| `slug` | The link text used to create the product link. |\n\nTo build URLs with variables related to product specifications, use the following format: `{specificationGroups.groupName.specifications.specificationName}`. Replace `groupName` and `specificationName` with the specification group and the product specification names accordingly. For example:\n\n```jsonc\n{\n \"link.product#vtex\": {\n \"props\": {\n \"href\": \"{specificationGroups.Design.specifications.Dimensions}\",\n \"label\": \"VTEX\"\n }\n }\n}\n```\n\nIn the example above, `Design` is the specification group name, and `Dimensions` is the product specification name.\n\n## Customization\n\nTo apply CSS customizations in this and other blocks, see the [Using CSS handles for store customization](https://developers.vtex.com/docs/guides/vtex-io-documentation-using-css-handles-for-store-customization) guide. All blocks have the same handles.\n\n| CSS handles |\n| ------------------- |\n| `childrenContainer` |\n| `label` |\n| `link` |\n\n<!-- DOCS-IGNORE:start -->\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<table>\n <tr>\n <td align=\"center\"><a href=\"https://github.com/anto90fg\"><img src=\"https://avatars.githubusercontent.com/u/73878310?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>anto90fg</b></sub></a><br /><a href=\"https://github.com/vtex-apps/store-link/commits?author=anto90fg\" title=\"Code\">💻</a></td>\n </tr>\n</table>\n\n<!-- markdownlint-restore -->\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_store-link_78a5f771
[ { "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-link/react/ProductLink.tsx from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useMemo } from 'react'\nimport classnames from 'classnames'\nimport { Link } from 'vtex.render-runtime'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { useProduct } from 'vtex.product-context'\nimport { formatIOMessage } from 'vtex.native-types'\nimport { useIntl } from 'react-intl'\n\nimport { Props, defaultButtonProps } from './StoreLink'\nimport hasChildren from './modules/hasChildren'\nimport { AvailableContext } from './modules/mappings'\nimport useButtonClasses from './modules/useButtonClasses'\nimport { useInterpolatedLink } from './modules/useInterpolatedLink'\n\nconst CSS_HANDLES = [\n 'link',\n 'label',\n 'childrenContainer',\n 'buttonLink',\n] as const\n\nfunction ProductLink(props: Props) {\n const {\n label,\n href,\n escapeLinkRegex,\n children,\n target,\n displayMode = 'anchor',\n buttonProps = defaultButtonProps,\n rel,\n } = props\n\n const intl = useIntl()\n const productContext = useProduct()\n const handles = useCssHandles(CSS_HANDLES)\n\n const extraContexts = useMemo(() => {\n return [\n {\n type: AvailableContext.product,\n context: productContext,\n },\n ]\n }, [productContext])\n\n const memoizedEscapeLinkRegex = useMemo(() => {\n if (!escapeLinkRegex) {\n return undefined\n }\n\n return new RegExp(escapeLinkRegex, 'g')\n }, [escapeLinkRegex])\n\n const resolvedLink = useInterpolatedLink(\n href,\n memoizedEscapeLinkRegex,\n extraContexts\n )\n\n const localizedLabel = formatIOMessage({\n id: label,\n intl,\n })\n\n const {\n size = defaultButtonProps.size,\n variant = defaultButtonProps.variant,\n } = buttonProps\n const classes = useButtonClasses({ variant, size })\n\n const rootClasses = classnames(handles.link, {\n [`${handles.buttonLink} ${classes.container}`]: displayMode === 'button',\n })\n\n const labelClasses = classnames(handles.label, {\n [classes.label]: displayMode === 'button',\n })\n\n return (\n <Link target={target} to={resolvedLink} className={rootClasses} rel={rel}>\n {label && <span className={labelClasses}>{localizedLabel}</span>}\n {hasChildren(children) && displayMode === 'anchor' && (\n <div className={handles.childrenContainer}>{children}</div>\n )}\n </Link>\n )\n}\n\nProductLink.schema = { title: 'admin/editor.product-link.title' }\n\nexport default ProductLink\n\n```" } ]
code_store-link_56cd76a4
[ { "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-link/react/package.json from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"lint\": \"tsc --noEmit && eslint --quiet --fix --ext ts,tsx .\",\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"@vtex/slugify\": \"^1.0.3\",\n \"classnames\": \"^2.2.6\",\n \"react\": \"^16.8.6\",\n \"react-apollo\": \"^2.5.8\",\n \"react-dom\": \"^16.8.6\",\n \"react-intl\": \"^3.11.0\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^4.0.0\",\n \"@types/classnames\": \"^2.2.9\",\n \"@types/graphql\": \"^14.5.0\",\n \"@types/jest\": \"^25.1.0\",\n \"@types/node\": \"^13.1.8\",\n \"@types/react\": \"^16.9.19\",\n \"@vtex/test-tools\": \"^3.3.2\",\n \"@vtex/tsconfig\": \"^0.4.4\",\n \"husky\": \"^5.0.9\",\n \"typescript\": \"3.9.7\",\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.native-types\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.native-types@0.7.5/public/@types/vtex.native-types\",\n \"vtex.product-context\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.product-context@0.10.0/public/@types/vtex.product-context\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.131.0/public/@types/vtex.render-runtime\",\n \"vtex.store-link\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-link@0.7.6/public/@types/vtex.store-link\"\n },\n \"version\": \"0.9.5\"\n}\n\n```" } ]
code_store-link_b54e4991
[ { "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-link/react/StoreLink.tsx from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport classnames from 'classnames'\nimport { Link } from 'vtex.render-runtime'\nimport { defineMessages, useIntl } from 'react-intl'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { formatIOMessage } from 'vtex.native-types'\n\nimport hasChildren from './modules/hasChildren'\nimport useButtonClasses, { Variant } from './modules/useButtonClasses'\nimport { useInterpolatedLink } from './modules/useInterpolatedLink'\n\ntype DisplayMode = 'anchor' | 'button'\ntype Size = 'small' | 'regular' | 'large'\n\nexport interface ButtonProps {\n variant: Variant\n size: Size\n}\n\n// https://stackoverflow.com/a/49725198/11274053\ntype RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<\n T,\n Exclude<keyof T, Keys>\n> &\n {\n [K in Keys]-?: Required<Pick<T, K>> &\n Partial<Record<Exclude<Keys, K>, undefined>>\n }[Keys]\n\ninterface AllProps {\n href?: string\n label: string\n target?: string\n scrollTo?: string\n escapeLinkRegex?: string\n children: React.ReactNode\n displayMode?: DisplayMode\n buttonProps?: Partial<ButtonProps>\n rel?: string\n}\n\nexport type Props = RequireOnlyOne<AllProps, 'label' | 'children'>\n\ndefineMessages({\n labelTitle: {\n id: 'admin/editor.link.label.title',\n defaultMessage: '',\n },\n})\n\nexport const defaultButtonProps: ButtonProps = {\n variant: 'primary',\n size: 'regular',\n}\n\nconst CSS_HANDLES = ['link', 'label', 'childrenContainer', 'buttonLink']\n\nfunction StoreLink(props: Props) {\n const {\n label,\n href,\n target,\n children,\n buttonProps = defaultButtonProps,\n scrollTo,\n displayMode = 'anchor',\n rel,\n } = props\n const { variant, size } = {\n ...defaultButtonProps,\n ...buttonProps,\n }\n const intl = useIntl()\n const handles = useCssHandles(CSS_HANDLES)\n const classes = useButtonClasses({\n variant,\n size,\n })\n const resolvedLink = useInterpolatedLink(href)\n\n const rootClasses = classnames(handles.link, {\n [`${handles.buttonLink} ${classes.container}`]: displayMode === 'button',\n })\n\n const labelClasses = classnames(handles.label, {\n [classes.label]: displayMode === 'button',\n })\n\n const scrollOptions = scrollTo ? { baseElementId: scrollTo } : undefined\n\n const localizedLabel = formatIOMessage({\n id: label,\n intl,\n })\n\n return (\n <Link\n to={resolvedLink}\n target={target}\n className={rootClasses}\n scrollOptions={scrollOptions}\n rel={rel}\n >\n {label && <span className={labelClasses}>{localizedLabel}</span>}\n {hasChildren(children) && (\n <div className={handles.childrenContainer}>{children}</div>\n )}\n </Link>\n )\n}\n\nStoreLink.schema = {\n title: 'Link',\n}\n\nexport default StoreLink\n\n```" } ]
code_store-link_120d2e9f
[ { "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-link/store/contentSchemas.json from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"definitions\": {\n \"StoreLink\": {\n \"title\": \"Link\",\n \"type\": \"object\",\n \"required\": [\n \"href\",\n \"label\"\n ],\n \"properties\": {\n \"label\": {\n \"title\": \"admin/editor.link.label.title\",\n \"description\": \"admin/editor.link.label.description\",\n \"$ref\": \"app:vtex.native-types#/definitions/text\"\n },\n \"href\": {\n \"title\": \"Link\",\n \"type\": \"string\",\n \"description\": \"admin/editor.link.href.description\"\n },\n \"target\": {\n \"title\": \"admin/editor.link.target.title\",\n \"type\": \"string\",\n \"description\": \"admin/editor.link.target.description\"\n },\n \"rel\": {\n \"title\": \"admin/editor.link.rel.attribute.title\",\n \"type\": \"string\",\n \"description\": \"admin/editor.link.rel.attribute.description\"\n }\n }\n },\n \"ProductLink\": {\n \"title\": \"admin/editor.product-link.title\",\n \"$ref\": \"app:vtex.store-link#/definitions/StoreLink\"\n }\n }\n}\n\n```" } ]
code_store-link_bf4099f2
[ { "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-link/store/interfaces.json from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"link\": {\n \"component\": \"StoreLink\",\n \"composition\": \"children\",\n \"content\": {\n \"$ref\": \"app:vtex.store-link#/definitions/StoreLink\"\n }\n },\n \"link.product\": {\n \"component\": \"ProductLink\",\n \"composition\": \"children\",\n \"content\": {\n \"$ref\": \"app:vtex.store-link#/definitions/ProductLink\"\n }\n }\n}\n\n```" } ]
code_store-link_2c870154
[ { "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-link/react/typings/types.ts from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { ProductTypes } from 'vtex.product-context'\n\nimport { AvailableContext } from '../modules/mappings'\n\n// https://stackoverflow.com/questions/46176165/ways-to-get-string-literal-type-of-array-values-without-enum-overhead\nconst inferType = <T extends string>(...args: T[]) => args\n\nconst productVariables = inferType(\n 'slug',\n 'skuId',\n 'department',\n 'category1',\n 'category2',\n 'category3',\n 'category4',\n 'productId',\n 'brand',\n 'brandId'\n)\nexport type ProductVariable = typeof productVariables[0]\n\nexport const PRODUCT_VARIABLES: ProductVariable[] = [\n 'slug',\n 'skuId',\n 'department',\n 'category1',\n 'category2',\n 'category3',\n 'category4',\n 'productId',\n 'brand',\n 'brandId',\n]\n\nexport interface Context {\n type: AvailableContext\n namespace?: string\n context:\n | Partial<ProductTypes.ProductContextState>\n | Record<string, any>\n | undefined\n}\n\n```" } ]
code_store-link_0252b3d7
[ { "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-link/react/__tests__/ProductLink.test.tsx from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { screen, render } from '@vtex/test-tools/react'\nimport { useProduct } from 'vtex.product-context'\n\nimport ProductLink from '../ProductLink'\n\nconst mockedUseProduct = useProduct as jest.Mock\n\nfunction mockProduct({ brand, specificationGroups = [] }: any) {\n mockedUseProduct.mockImplementation(() => {\n return {\n selectedItem: { itemId: 'itemId' },\n product: {\n categories: ['category1', 'category2'],\n specificationGroups,\n linkText: 'linkText',\n productId: 'productId',\n brand,\n brandId: 'brandId',\n },\n }\n })\n}\n\ntest('slugifies interpolated brand name', () => {\n mockProduct({\n brand: 'brand name with lots of spaces',\n })\n\n render(<ProductLink href=\"/custom-link-{brand}\" label=\"See brand\" />)\n\n expect(screen.getByText('See brand').closest('a')).toHaveAttribute(\n 'href',\n '/custom-link-brand-name-with-lots-of-spaces'\n )\n})\n\n```" } ]
code_store-link_08916eff
[ { "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-link/react/modules/hasChildren.ts from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport React, { Children } from 'react'\n\nexport default function hasChildren(children: React.ReactNode) {\n if (!children) {\n return false\n }\n\n return Children.toArray(children).length > 0\n}\n\n```" } ]
code_store-link_b79d559a
[ { "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-link/react/modules/mappings.ts from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { searchSlugify } from '@vtex/slugify'\nimport type { ProductTypes } from 'vtex.product-context'\n\nimport { PRODUCT_VARIABLES, ProductVariable } from '../typings/types'\n\nfunction mapCategories(rawCategories: string[]) {\n const categoriesSorted = rawCategories\n .slice()\n .sort((a, b) => a.length - b.length)\n\n return categoriesSorted\n .map(categories => {\n return categories\n .replace(/^\\//, '')\n .replace(/\\/$/, '')\n .split('/')\n .reverse()[0]\n })\n .filter(Boolean)\n}\n\ninterface SpecificationGroup {\n originalName: string\n specifications?: Array<{ originalName?: string; values: string[] }>\n}\n\nfunction mapSpecifications(specificationGroups: SpecificationGroup[]) {\n const mappedSpecifications: Record<string, string> = {}\n specificationGroups.forEach(\n ({ originalName: groupName, specifications = [] }) => {\n specifications.forEach(({ originalName: specificationName, values }) => {\n const key = `specificationGroups.${groupName}.specifications.${specificationName}`\n const [value] = values\n mappedSpecifications[key] = value ?? ''\n })\n }\n )\n\n return mappedSpecifications\n}\n\nexport function mapProductValues(\n context: Partial<ProductTypes.ProductContextState> | undefined\n) {\n const { product, selectedItem } = context ?? {}\n\n if (!product) {\n return {}\n }\n\n if (!selectedItem) {\n return {}\n }\n\n const categories = mapCategories(product.categories)\n const specifications = mapSpecifications(product.specificationGroups)\n const variables: Record<Partial<ProductVariable>, string | number> = {\n slug: product.linkText,\n skuId: selectedItem.itemId,\n department: categories[0],\n category1: categories[1],\n category2: categories[2],\n category3: categories[3],\n category4: categories[4],\n productId: product.productId,\n brand: searchSlugify(product.brand),\n brandId: product.brandId,\n }\n\n const output: Record<string, string> = specifications\n for (const key of PRODUCT_VARIABLES) {\n if (variables[key]) {\n if (typeof variables[key] === 'number') {\n output[key] = variables[key].toString()\n } else {\n output[key] = variables[key] as string\n }\n }\n }\n\n return output\n}\n\nfunction mapQueryStringValues(context?: Record<string, any>) {\n return context ?? {}\n}\n\nexport enum AvailableContext {\n product = 'product',\n queryString = 'queryString',\n}\n\nexport function getMappingFn(\n contextType: AvailableContext\n): typeof mapProductValues | typeof mapQueryStringValues {\n switch (contextType) {\n case AvailableContext.product:\n return mapProductValues\n case AvailableContext.queryString:\n return mapQueryStringValues\n default:\n return () => ({})\n }\n}\n\n```" } ]
code_store-link_4677bc92
[ { "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-link/react/modules/useButtonClasses.ts from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useMemo } from 'react'\nimport classnames from 'classnames'\n\nimport { ButtonProps } from '../StoreLink'\n\nexport type Variant = 'primary' | 'secondary'\n\ninterface Options {\n variant?: Variant\n disabled?: boolean\n size?: ButtonProps['size']\n}\n\nconst LINK_CLASSES = 'inline-flex items-center no-underline'\nconst BASE_CONTAINER_CLASSES = 'bw1 fw5 ba v-mid pa0 lh-solid br2'\nconst LABEL_BASE = 'w-100 tc'\n\nconst PRIMARY_ENABLED =\n 'bg-action-primary b--action-primary c-on-action-primary hover-bg-action-primary hover-b--action-primary hover-c-on-action-primary'\nconst PRIMARY_DISABLED = 'bg-disabled b--muted-5 c-on-disabled'\n\nconst SECONDARY_ENABLED =\n 'bg-action-secondary b--action-secondary c-on-action-secondary hover-bg-action-secondary hover-b--action-secondary hover-c-on-action-secondary'\n\nconst SMALL = 'min-h-small t-action--small'\nconst REGULAR = 'min-h-regular t-action'\nconst LARGE = 'min-h-large t-action--large'\nconst LABEL_SMALL = 'ph5'\nconst LABEL_REGULAR = 'ph6'\nconst LABEL_LARGE = 'ph7'\n\nfunction getClassesByVariant(variant: Variant, disabled: boolean) {\n let container\n\n // eslint-disable-next-line default-case\n switch (variant) {\n case 'primary':\n container = disabled ? PRIMARY_DISABLED : PRIMARY_ENABLED\n break\n case 'secondary':\n container = SECONDARY_ENABLED\n break\n }\n\n return { container }\n}\n\nfunction getClassesBySize(size: ButtonProps['size']) {\n let container\n let label\n\n switch (size) {\n case 'small':\n container = SMALL\n label = LABEL_SMALL\n break\n case 'large':\n container = LARGE\n label = LABEL_LARGE\n break\n default:\n container = REGULAR\n label = LABEL_REGULAR\n break\n }\n\n return { container, label }\n}\n\nexport default function useButtonClasses(options: Options) {\n return useMemo(() => {\n const { variant = 'primary', disabled = false, size = 'regular' } = options\n const variantClasses = getClassesByVariant(variant, disabled)\n const sizeClasses = getClassesBySize(size)\n const classes = {\n container: classnames(\n BASE_CONTAINER_CLASSES,\n LINK_CLASSES,\n variantClasses.container,\n sizeClasses.container\n ),\n label: classnames(LABEL_BASE, sizeClasses.label),\n }\n\n return classes\n }, [options])\n}\n\n```" } ]
code_store-link_3a8d60d6
[ { "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-link/react/modules/useInterpolatedLink.ts from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useRuntime } from 'vtex.render-runtime'\nimport { useEffect, useState } from 'react'\n\nimport interpolateLink from './interpolateLink'\nimport { AvailableContext } from './mappings'\nimport type { Context } from '../typings/types'\n\nexport const useInterpolatedLink = (\n href?: string,\n escapeLinkRegex?: RegExp,\n extraContexts?: Context[]\n) => {\n const [resolvedLink, setResolvedLink] = useState('#')\n const {\n route: { queryString },\n } = useRuntime()\n\n useEffect(() => {\n if (!href) {\n return\n }\n\n const contexts: Context[] = [\n {\n type: AvailableContext.queryString,\n namespace: 'queryString',\n context: queryString,\n },\n ...(extraContexts ?? []),\n ]\n\n const newLink = contexts.reduce((acc, contextInfo) => {\n return interpolateLink({\n link: acc,\n namespace: contextInfo.namespace,\n context: contextInfo.context,\n contextType: contextInfo.type,\n escapeLinkRegex,\n })\n }, href)\n\n setResolvedLink(newLink)\n }, [href, escapeLinkRegex, extraContexts, queryString])\n\n return resolvedLink\n}\n\n```" } ]
code_store-link_b3365178
[ { "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-link/react/modules/interpolateLink.ts from the store-link VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { getMappingFn, AvailableContext } from './mappings'\nimport type { Context } from '../typings/types'\n\ninterface Params {\n link: string\n namespace?: string\n context: Context['context']\n contextType: AvailableContext\n escapeLinkRegex?: RegExp\n}\n\nexport default function interpolateLink(params: Params) {\n const { link, namespace, context, contextType, escapeLinkRegex } = params\n\n const mapValues = getMappingFn(contextType)\n const variables = mapValues(context)\n\n let resolvedLink = link\n\n for (const key of Object.keys(variables)) {\n let newKey = key\n if (escapeLinkRegex) {\n newKey = key.replace(escapeLinkRegex, '')\n }\n const regex = new RegExp(\n `{${namespace ? `${namespace}.${newKey}` : newKey}}`,\n 'g'\n )\n\n // we slugify the context value so we don't end up with invalid characters on the URL\n resolvedLink = resolvedLink.replace(regex, variables[key])\n }\n // Replace not found variables with empty string\n if (namespace) {\n const missingKeys = new RegExp(`{${namespace}.(.*)}`)\n resolvedLink = resolvedLink.replace(missingKeys, () => '')\n }\n\n return resolvedLink\n}\n\n```" } ]
code_country-data-settings_0c312bef
[ { "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 country-data-settings/configuration/schema.json from the country-data-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"definitions\": {\n \"addressDisplay\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"enum\": [\n \"city\",\n \"complement\",\n \"country\",\n \"neighborhood\",\n \"number\",\n \"postalCode\",\n \"receiverName\",\n \"reference\",\n \"state\",\n \"street\"\n ]\n },\n \"delimiter\": { \"type\": \"string\" },\n \"delimiterAfter\": { \"type\": \"string\" }\n },\n \"required\": [\"name\"]\n }\n }\n },\n \"addressField\": {\n \"type\": \"object\",\n \"properties\": {\n \"label\": { \"type\": \"string\" },\n \"name\": {\n \"type\": \"string\",\n \"enum\": [\n \"addressType\",\n \"city\",\n \"complement\",\n \"country\",\n \"neighborhood\",\n \"number\",\n \"postalCode\",\n \"receiverName\",\n \"reference\",\n \"state\",\n \"street\"\n ]\n },\n \"hidden\": { \"type\": \"boolean\" },\n \"maxLength\": { \"type\": \"number\" },\n \"size\": { \"type\": \"string\" },\n \"required\": { \"type\": \"boolean\" },\n \"autoComplete\": { \"type\": \"string\" },\n \"optionsCaption\": { \"type\": \"string\" },\n \"options\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"label\": { \"type\": \"string\" },\n \"value\": { \"type\": \"string\" }\n }\n }\n },\n \"elementName\": { \"type\": \"string\" },\n \"mask\": {\n \"type\": \"string\",\n \"description\": \"Optional mask to format the field for display.\"\n },\n \"pattern\": {\n \"type\": \"string\",\n \"description\": \"Regex used for the field validation.\"\n }\n },\n \"required\": [\"label\"]\n }\n },\n \"type\": \"object\",\n \"properties\": {\n \"countryISO\": { \"type\": \"string\" },\n \"addressFields\": {\n \"type\": \"object\",\n \"properties\": {\n \"country\": { \"$ref\": \"#/definitions/addressField\" },\n \"street\": { \"$ref\": \"#/definitions/addressField\" },\n \"number\": { \"$ref\": \"#/definitions/addressField\" },\n \"complement\": { \"$ref\": \"#/definitions/addressField\" },\n \"reference\": { \"$ref\": \"#/definitions/addressField\" },\n \"neighborhood\": { \"$ref\": \"#/definitions/addressField\" },\n \"state\": { \"$ref\": \"#/definitions/addressField\" },\n \"city\": { \"$ref\": \"#/definitions/addressField\" },\n \"receiverName\": { \"$ref\": \"#/definitions/addressField\" },\n \"postalCode\": {\n \"allOf\": [\n { \"$ref\": \"#/definitions/addressField\" },\n { \"properties\": { \"forgottenURL\": { \"type\": \"string\" } } }\n ]\n }\n }\n },\n \"display\": {\n \"type\": \"object\",\n \"properties\": {\n \"minimal\": {\n \"$ref\": \"#/definitions/addressDisplay\"\n },\n \"compact\": {\n \"$ref\": \"#/definitions/addressDisplay\"\n },\n \"extended\": {\n \"$ref\": \"#/definitions/addressDisplay\"\n }\n },\n \"required\": [\"minimal\", \"compact\", \"extended\"]\n },\n \"locationSelect\": {\n \"type\": \"object\",\n \"properties\": {\n \"countryData\": { \"type\": \"object\" },\n \"fields\": {\n \"type\": \"array\",\n \"items\": { \"$ref\": \"#/definitions/addressField\" }\n }\n }\n },\n \"phone\": {\n \"type\": \"object\",\n \"properties\": {\n \"countryCode\": {\n \"type\": \"string\",\n \"description\": \"The country calling code. E.g.: 55 for Brazil and 1 for USA\"\n },\n \"mask\": {\n \"type\": \"string\",\n \"description\": \"Phone number mask for value display.\"\n },\n \"pattern\": {\n \"type\": \"string\",\n \"description\": \"Regex used for the phone number validation\"\n }\n },\n \"required\": [\"countryCode\", \"pattern\"]\n },\n \"legalPersonTaxId\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"description\": \"The name of the document in the specific country. E.g.: Cadastro Nacional da Pessoa Jurídica for Brazil and Employer Identification Number for the USA\"\n },\n \"abbreviation\": {\n \"type\": \"string\",\n \"description\": \"Abbreviation for the document name, such as CNPJ for Brazil.\"\n },\n \"mask\": {\n \"type\": \"string\",\n \"description\": \"Tax ID mask for value display\"\n }\n },\n \"required\": [\"name\", \"abbreviation\", \"mask\"]\n }\n },\n \"required\": [\"countryISO\", \"addressFields\", \"display\", \"phone\"]\n}\n\n```" } ]
code_country-data-settings_51627842
[ { "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 country-data-settings/graphql/schema.graphql from the country-data-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nscalar JSON\nscalar JSONObject\n\n# https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/\ntype LegalPersonTaxIdData {\n name: String!\n abbreviation: String!\n mask: String!\n}\n\ntype PhoneData {\n countryCode: String!\n mask: String\n pattern: String!\n}\n\ntype DisplayDefinition {\n name: String!\n delimiter: String\n delimiterAfter: String\n}\n\ntype DisplayData {\n minimal: [[DisplayDefinition!]!]!\n compact: [[DisplayDefinition!]!]!\n extended: [[DisplayDefinition!]!]!\n}\n\ntype AddressFieldsData {\n city: Field\n complement: Field\n country: Field\n neighborhood: Field\n number: Field\n postalCode: Field\n receiverName: Field\n reference: Field\n state: Field\n street: Field\n}\n\ntype LocationSelectData {\n fields: [Field!]!\n countryData: JSON\n}\n\ntype CountryData {\n countryISO: String!\n addressFields: AddressFieldsData!\n display: DisplayData!\n locationSelect: LocationSelectData\n phone: PhoneData!\n legalPersonTaxId: LegalPersonTaxIdData\n}\n\ntype Query {\n countryData(country: String!): CountryData\n @settings(settingsType: \"workspace\")\n @cacheControl(scope: PUBLIC, maxAge: SHORT)\n\n countriesData(countries: [String!]!): [CountryData!]!\n @settings(settingsType: \"workspace\")\n @cacheControl(scope: PUBLIC, maxAge: SHORT)\n\n allCountriesData: [CountryData!]!\n @settings(settingsType: \"workspace\")\n @cacheControl(scope: PUBLIC, maxAge: SHORT)\n}\n\n```" } ]
code_country-data-settings_3290c438
[ { "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 country-data-settings/node/service.json from the country-data-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"routes\": {\n \"countrySettings\": {\n \"path\": \"/country-settings/:country\",\n \"settingsType\": \"workspace\",\n \"access\": \"public\",\n \"policies\": [\n {\n \"effect\": \"allow\",\n \"actions\": [\"get\"],\n \"principals\": [\"vrn:apps:*:{{account}}:{{workspace}}:app/vtex.*\"]\n }\n ]\n },\n \"allCountrySettings\": {\n \"path\": \"/country-settings/\",\n \"settingsType\": \"workspace\",\n \"access\": \"public\",\n \"policies\": [\n {\n \"effect\": \"allow\",\n \"actions\": [\"get\"],\n \"principals\": [\"vrn:apps:*:{{account}}:{{workspace}}:app/vtex.*\"]\n }\n ]\n }\n }\n}\n\n```" } ]
code_country-data-settings_f8240eb7
[ { "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 country-data-settings/node/package.json from the country-data-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.country-data-settings\",\n \"private\": true,\n \"license\": \"UNLICENSED\",\n \"devDependencies\": {\n \"@types/graphql-type-json\": \"^0.3.2\",\n \"@vtex/api\": \"6.41.0\",\n \"@vtex/tsconfig\": \"^0.5.0\"\n },\n \"dependencies\": {\n \"graphql\": \"^14.6.0\",\n \"graphql-type-json\": \"^0.3.2\"\n },\n \"version\": \"0.5.0\"\n}\n\n```" } ]
code_country-data-settings_2fe1f5dc
[ { "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 country-data-settings/node/index.ts from the country-data-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { Service, method } from '@vtex/api'\n\nimport resolvers from './resolvers'\nimport { countrySettings } from './middlewares/countrySettings'\nimport { allCountrySettings } from './middlewares/allCountrySettings'\n\nexport default new Service({\n routes: {\n countrySettings: method({ GET: [countrySettings] }),\n allCountrySettings: method({ GET: [allCountrySettings] }),\n },\n graphql: {\n resolvers,\n },\n})\n\n```" } ]
code_country-data-settings_0f85eee4
[ { "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 country-data-settings/graphql/types/Field.graphql from the country-data-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\ntype PostalCodeData {\n forgottenURL: String\n}\n\nunion AdditionalFieldData = PostalCodeData\n\ntype FieldOptionData {\n label: String!\n value: String!\n}\n\ntype Field {\n label: String!\n name: String\n hidden: Boolean\n maxLength: Int\n size: String\n required: Boolean\n autoComplete: String\n optionsCaption: String\n options: [FieldOptionData!]\n elementName: String\n mask: String\n additionalData: AdditionalFieldData\n pattern: String\n}\n\n```" } ]
code_country-data-settings_0a4a7f7d
[ { "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 country-data-settings/node/typings/global.d.ts from the country-data-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare global {\n interface Configuration {\n declarer: string\n [declarerAppName: string]: CountryDataConfiguration\n }\n\n type AddressField =\n | 'city'\n | 'complement'\n | 'country'\n | 'neighborhood'\n | 'number'\n | 'postalCode'\n | 'receiverName'\n | 'reference'\n | 'state'\n | 'street'\n\n interface CountryDataConfiguration {\n countryISO: string\n addressFields: AddressFieldsConfiguration\n display: DisplayData\n phone: PhoneConfiguration\n }\n\n interface DisplayData {\n minimal: DisplayDefinition[][]\n compact: DisplayDefinition[][]\n expanded: DisplayDefinition[][]\n }\n\n interface DisplayDefinition {\n name: AddressField\n delimiter: string\n delimiterAfter: string\n }\n\n type PostalCodeField = AddressFieldsConfiguration & PostalCodeConfiguration\n\n interface AddressFieldsConfiguration {\n [field in AddressField]: AddressFieldConfiguration\n postalCode?: AddressFieldConfiguration & PostalCodeConfiguration\n }\n\n interface PostalCodeConfiguration {\n forgottenURL?: string\n }\n\n interface AddressFieldConfiguration {\n label: string\n name?: AddressField | 'addressType'\n hidden?: boolean\n maxLength?: number\n size?: string\n required?: boolean\n autoComplete?: string\n optionsCaption?: string\n options?: AddressOption[]\n elementName?: string\n mask?: string\n }\n\n interface AddressOption {\n label: string\n value: string\n }\n\n interface PhoneConfiguration {\n countryCode: string\n mask?: string\n }\n}\n\nexport {}\n\n```" } ]
code_country-data-settings_6e4d2ab8
[ { "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 country-data-settings/node/middlewares/countrySettings.ts from the country-data-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ServiceContext } from '@vtex/api'\n\nimport { getSettingsByCountry } from '../utils/getSettingsByCountry'\n\nexport function countrySettings(ctx: ServiceContext) {\n const country = ctx.vtex.route.params.country as string\n\n const allSettings = getSettingsByCountry(ctx.vtex.settings)\n\n ctx.body = allSettings[country]\n}\n\n```" } ]
code_country-data-settings_240b8ade
[ { "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 country-data-settings/node/middlewares/allCountrySettings.ts from the country-data-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ServiceContext } from '@vtex/api'\n\nimport { getSettingsByCountry } from '../utils/getSettingsByCountry'\n\nexport function allCountrySettings(ctx: ServiceContext) {\n const allSettings = getSettingsByCountry(ctx.vtex.settings)\n\n ctx.body = Object.values(allSettings)\n}\n\n```" } ]
code_country-data-settings_5fd7133a
[ { "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 country-data-settings/node/utils/getSettingsByCountry.ts from the country-data-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport const getSettingsByCountry = (settings: Configuration[]) => {\n const settingsByCountry = settings.reduce<{\n [country: string]: CountryDataConfiguration\n }>((groupedConfigs, configuration) => {\n const { declarer } = configuration\n\n const [declarerAppName] = declarer.split('@')\n\n if (!configuration[declarerAppName]) {\n return groupedConfigs\n }\n\n const countryConfig = configuration[declarerAppName]\n\n groupedConfigs[countryConfig.countryISO] = countryConfig\n\n return groupedConfigs\n }, {})\n\n return settingsByCountry\n}\n\n```" } ]
code_country-data-settings_69850a5a
[ { "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 country-data-settings/node/resolvers/country.ts from the country-data-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ServiceContext } from '@vtex/api'\n\nimport { getSettingsByCountry } from '../utils/getSettingsByCountry'\n\nexport const root = {\n AdditionalFieldData: {\n __resolveType: (additionalData: any) => {\n if ('forgottenURL' in additionalData) {\n return 'PostalCodeData'\n }\n\n return null\n },\n },\n Field: {\n additionalData: (field: AddressFieldsConfiguration | PostalCodeField) => {\n if ('forgottenURL' in field) {\n return {\n forgottenURL: field.forgottenURL,\n }\n }\n\n return null\n },\n },\n}\n\nexport const queries = {\n countryData: (\n _: void,\n { country }: { country: string },\n ctx: ServiceContext\n ) => {\n const data = getSettingsByCountry(ctx.vtex.settings.dependenciesSettings)[\n country\n ]\n\n return data\n },\n countriesData: (\n _: void,\n { countries }: { countries: string[] },\n ctx: ServiceContext\n ) => {\n return Object.values(\n getSettingsByCountry(ctx.vtex.settings.dependenciesSettings)\n ).filter(countryConfiguration =>\n countries.includes(countryConfiguration.countryISO)\n )\n },\n allCountriesData: (_: void, __: void, ctx: ServiceContext) => {\n return Object.values(\n getSettingsByCountry(ctx.vtex.settings.dependenciesSettings)\n )\n },\n}\n\n```" } ]
code_country-data-settings_78b76008
[ { "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 country-data-settings/node/resolvers/index.ts from the country-data-settings VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { GraphQLJSON, GraphQLJSONObject } from 'graphql-type-json'\n\nimport { root as countryRoot, queries as countryQueries } from './country'\n\nexport default {\n JSON: GraphQLJSON,\n JSONObject: GraphQLJSONObject,\n ...countryRoot,\n Query: {\n ...countryQueries,\n },\n}\n\n```" } ]
code_render-session_4cc81aac
[ { "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 render-session/docs/README.md from the render-session VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# render-session\n> External session provider for vtex.render-runtime\n\n## Developing\nTo build run:\n```\nyarn && yarn clean && yarn build\n```\n\nThis will build the app and generate a bundle in the `/dist` folder. \n\nTo test it, run\n```\nyarn && yarn start\n```\n\nthis will start a webserver serving the file in the `/dist` folder.\n\n### Testing\nSet the `http:localhost:8080/index.min.js` in the render-runtime's externals and get ready for the fun :)\n\n> If your web browser complains about CORS, be sure to add [this extension](https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en) to chrome\n\n```" } ]
code_render-session_0f9aae5b
[ { "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 render-session/src/constants.ts from the render-session VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport const ITEMS = [\n \"account.id\",\n \"account.accountName\",\n \"store.channel\",\n \"store.countryCode\",\n \"store.cultureInfo\",\n \"store.currencyCode\",\n \"store.currencySymbol\",\n \"store.admin_cultureInfo\",\n \"creditControl.creditAccounts\",\n \"creditControl.deadlines\",\n \"creditControl.minimumInstallmentValue\",\n \"authentication.storeUserId\",\n \"authentication.storeUserEmail\",\n \"profile.firstName\",\n \"profile.document\",\n \"profile.email\",\n \"profile.id\",\n \"profile.isAuthenticated\",\n \"profile.lastName\",\n \"profile.phone\",\n \"public.favoritePickup\",\n \"public.utm_source\",\n \"public.utm_medium\",\n \"public.utm_campaign\",\n \"public.utmi_cp\",\n \"public.utmi_p\",\n \"public.utmi_pc\",\n];\n\n```" } ]
code_render-session_fd41d709
[ { "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 render-session/src/index.ts from the render-session VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ITEMS } from './constants'\nimport { tryRefreshTokenRenew, setFirstOrRemoveRenewKey } from './refreshtoken'\nimport { SessionResponse } from './interfaces'\n\nconst delay = (ms: number): Promise<void> => {\n return new Promise(resolve => setTimeout(resolve, ms))\n}\n\nconst bindingChanged = window.__RUNTIME__ && window.__RUNTIME__.bindingChanged\nconst bindingId = window.__RUNTIME__ && window.__RUNTIME__.binding && window.__RUNTIME__.binding.id\nconst supportedLocales = window.__RUNTIME__ && window.__RUNTIME__.culture && window.__RUNTIME__.culture.availableLocales || []\nconst rootPath = window.__RUNTIME__ && window.__RUNTIME__.rootPath || ''\n\nconst RETRY_STATUSES = [ 408, 425, 429, 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511 ]\nconst FETCH_TIMEOUT = 7000\n\nconst canRetry = (status: number) => RETRY_STATUSES.includes(status)\n\nconst fetchWithRetry = (url: string, init: RequestInit, maxRetries: number = 3) => {\n let status = 500\n let didTimeout = false\n const callFetch = (attempt: number = 0): Promise<SessionResponse> =>\n new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n didTimeout = true\n reject(new Error('Fetch timed out'))\n }, FETCH_TIMEOUT)\n fetch(url, init).then(response => {\n clearTimeout(timeout)\n if (!didTimeout) {\n resolve(response)\n }\n }).catch(err => {\n clearTimeout(timeout)\n if (didTimeout) {\n return\n }\n reject(err)\n })\n }).then((response: any) => {\n status = response.status\n return response.json()\n .then((data: any) => ({response: data, error: null}))\n }).catch((error) => {\n console.error(error)\n\n if (attempt >= maxRetries || !canRetry(status) || didTimeout) {\n return {response: null, error: {message: 'Maximum number of attempts achieved or request timed out'}} as SessionResponse\n }\n\n const ms = (2 ** attempt) * 500\n return delay(ms)\n .then(() => callFetch(++attempt))\n })\n\n return callFetch()\n}\n\nconst patchSession = (data?: any) => fetchWithRetry(`${rootPath}/api/sessions${window.location.search}`, {\n body: data ? JSON.stringify(data) : '{}',\n credentials: 'same-origin',\n headers: new Headers({ 'Content-Type': 'application/json' }),\n method: 'PATCH',\n}).catch(err => console.log('Error while patching session with error: ', err))\n\nconst supportedLocalesSearch = supportedLocales.length > 0\n ? `&supportedLocales=${supportedLocales.join(',')}`\n : ''\n\nconst bindingIdSearch = bindingId\n ? `&__bindingId=${bindingId}`\n : ''\n\nconst createInitialSessionRequest = () => {\n const items = `${window.location.search ? '&' : '?'}items=${ITEMS.join(',')}`\n return fetchWithRetry(`${rootPath}/api/sessions${window.location.search}${items}${supportedLocalesSearch}${bindingIdSearch}`, {\n body: '{}',\n credentials: 'same-origin',\n headers: new Headers({ 'Content-Type': 'application/json' }),\n method: 'POST',\n })\n}\n\nconst clearSession = () => {\n return fetchWithRetry(`${rootPath}/api/sessions/invalidToken?items=*`, {\n credentials: 'same-origin',\n headers: new Headers({ 'Content-Type': 'application/json' }),\n method: 'GET',\n }, 1)\n}\n\nconst onError = (err: any) => console.log('Error while loading session with error: ', err)\n\nlet sessionPromise: Promise<void | SessionResponse>\n\nif (bindingChanged) {\n sessionPromise = tryRefreshTokenRenew()\n .then(clearSession)\n .then(createInitialSessionRequest)\n .then(setFirstOrRemoveRenewKey)\n .catch(onError);\n} else {\n sessionPromise = tryRefreshTokenRenew()\n .then(createInitialSessionRequest)\n .then(setFirstOrRemoveRenewKey)\n .catch(onError);\n}\n\n(window as any).__RENDER_7_SESSION__ = (window as any).__RENDER_8_SESSION__ = {\n patchSession,\n sessionPromise,\n}\n\nexport {}\n\n```" } ]
code_render-session_c0228502
[ { "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 render-session/src/refreshtoken.ts from the render-session VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { SessionResponse, SessionResponseData, RefreshTokenRenewResponse } from './interfaces'\n\nconst rootPath = window.__RUNTIME__ && window.__RUNTIME__.rootPath || ''\nconst REFRESH_TOKEN_API = `${rootPath}/api/vtexid/refreshtoken/webstore`\nconst LOCAL_STORAGE_KEY = 'vid_rt_webstore'\nconst STATUS = {\n SUCCESS: 'success',\n INVALID_SESSION: 'invalidsession',\n ERROR: 'error'\n}\nconst TTL_30_MIN = 30 * 60 * 1000\nconst TTL_12_HOURS = 12 * 60 * 60 * 1000\nconst APPNAME = 'render-session'\nconst TIMEOUT = 2000\n\nconst setItem = (status: string, refreshAfter: Date) =>\n localStorage.setItem(\n LOCAL_STORAGE_KEY,\n JSON.stringify({ status, refreshAfter })\n )\n\nconst removeKey = () => {\n localStorage.removeItem(LOCAL_STORAGE_KEY)\n}\n\nconst setError = () =>\n setItem(STATUS.ERROR, new Date(new Date().getTime() + TTL_30_MIN))\n\nconst fetchWithTimeout = (url: string, options: RequestInit | undefined, timeout: number): Promise<Response> => {\n return new Promise((resolve, reject) => {\n setTimeout(() => reject(new Error(\"timeout\")), timeout)\n fetch(url, options).then(resolve, reject)\n })\n}\n\nexport const setFirstOrRemoveRenewKey = (sessionResponse: SessionResponse) => {\n try {\n const localStorage = window.localStorage\n if (!localStorage) return\n \n const profile = (sessionResponse.response as SessionResponseData).namespaces.profile;\n const isAuthenticated = profile && profile.isAuthenticated.value === \"true\"\n const keyExists = localStorage.getItem(LOCAL_STORAGE_KEY)\n \n if (isAuthenticated && !keyExists) {\n setItem(STATUS.SUCCESS, new Date(new Date().getTime() + TTL_12_HOURS))\n }\n if (!isAuthenticated && keyExists) {\n removeKey()\n }\n }\n finally {\n return sessionResponse\n }\n}\n\nexport const tryRefreshTokenRenew = async () => {\n const localStorage = window.localStorage\n if (!localStorage) return\n\n try {\n const now = new Date()\n\n const curr = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY) || 'null')\n if (!curr || now < new Date(curr.refreshAfter)) return\n\n const response = await fetchWithTimeout(REFRESH_TOKEN_API, {\n method: 'POST',\n headers: {\n 'vtex-id-ui-version': APPNAME,\n 'content-type': 'application/json'\n },\n body: '{}',\n }, TIMEOUT)\n\n const data: RefreshTokenRenewResponse = await response.json();\n\n if (!data || !data.status) {\n setError()\n return\n }\n\n const status = data.status.toLowerCase()\n\n if (status === STATUS.INVALID_SESSION) {\n removeKey()\n return\n }\n\n if (status === STATUS.SUCCESS) { \n const { refreshAfter } = data\n setItem(status, new Date(refreshAfter as string))\n return\n }\n \n setError()\n } catch {\n setError()\n }\n}\n\n```" } ]
code_render-session_f0579cea
[ { "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 render-session/src/interfaces.ts from the render-session VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare global {\n export interface Window {\n __RUNTIME__: {\n binding?: {\n id: string\n },\n bindingChanged?: boolean,\n culture: {\n availableLocales: string[]\n }\n rootPath?: string\n }\n }\n}\n\nexport interface SessionResponse {\n response: SessionResponseData | null,\n error: any,\n}\n\nexport interface SessionResponseData {\n namespaces: {\n profile: {\n isAuthenticated: {\n value: string\n }\n }\n }\n}\n\nexport interface RefreshTokenRenewResponse {\n status: string,\n userId: string | null,\n refreshAfter: string | null,\n}\n\n```" } ]
code_external-promotions-example_066f4c43
[ { "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 external-promotions-example/docs/README.md from the external-promotions-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# External Promotions Example\n\nThis app is an example to merchants on how to implment their own external promotions customization backend apps. It should expose an API that will recceive the context that is needed to calculate the external promotions on 3rd-party providers, transform this data to the expected contract defined by VTEX and call the VTEX's internal app responsible for applying the external promotions.\n\nHere is what we expect to be the context on each supported scenario:\n\n| Scenario | Context |\n| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| PDP | The details of the item in display, such as the sku id, original seling price, etc, alongside with the shopper's session. |\n| PLP | The details of items in the search result, similarly to the PDP scenario, but for multiple independent items, alongside with the shopper's session. Please beware that this is not a shopping cart with multiple items, but a collection of independent items. |\n| Checkout | WIP |\n\n## API\n\nHere we'll give an overview of how this API should be implemented by the merchants.\n\n### Calculate External Promotions endpoint\n\nThis is a public method that will be called by the storefront customizations and it's responsible for making a request to the 3rd-party external provider and send this data to the VTEX platform, respecting the defined protocol. This app is agnostic from the store's implementation, meaning that we don't see a reason why it shouldn't work in all current store frameworks supported by VTEX (Portal, SF, and FastStore). However, from a product perspective, we'll foment the usage of our latest technologies and suggest using FastStore for your store's implementation.\n\n**Overview**\n\n| Property | Value |\n| -------------------- | -------------------------------- |\n| Method | `POST` |\n| URL | `/promotions/external/calculate` |\n| Auth required | No |\n| Permissions required | None |\n| Request body | `application/json` |\n| Response | `application/json` |\n\n**Request body**\n| Property | Type | Required | Description |\n|---------------------- |------------------------- | ---------- | ---------- |\n| sessionId | string | yes | The id of the shopper's active session. |\n| promotionalContext | PromotionalContext | yes | The context that should be used for calculating the external promotions. This data is completely customizable and its format is entirely up to the merchant. For the example we'll use a simple array of items with its' sku ids and original prices. |\n\n**PromotionalContext**\n| Property | Type | Required | Description |\n|---------------------- |------------------------- | ---------- | ---------- |\n| items | Item[] | yes | An array of product items that will be used for calculating the external promotions. |\n\n**Item**\n| Property | Type | Required | Description |\n|---------------------- |------------------------- | ---------- | ---------- |\n| id | string | yes | The unique identifier for the item, aka SKU ID. |\n| sellingPrice | number | yes | The original selling price of the item. By original we mean that we expect this to be the selling price of the item before any discounts are applied |\n\n**Request body example**\n\nProvide name of Account to be created.\n\n```json\n{\n \"sessionId\": \"session_id\",\n \"promotionalContext\": {\n \"items\": [\n {\n \"id\": \"1\",\n \"sellingPrice\": 1000\n }\n ]\n }\n}\n```\n\n**VTEX External Promotions data contract**\n\n| Property | Type | Required | Description |\n| ---------- | -------------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| version | \"v1\" | yes | The version of the data contract. |\n| type | \"page\", \"cart\" | yes | The type of the data contract. <br> \"page\" means that the data being sent is valid for page contexts (PDP/PLP). <br> \"cart\" means that the data being sent is valid to art contexts (Checkout). |\n| exp | number | no | The unix time (milliseconds) until the sent data becomes invalid. |\n| cartHash | string | yes (for \"cart\" type only) | A hash key for the cart in which this promotions data is valid for. This will be used for matching the promotional data when navigating to chekout and when placing the order. |\n| sessionId | string | yes | An unique identifier of the shopper's active session in which the promotional data is valid. |\n| promotions | Promotion[] | yes | An array of valid promotions that need to be applied for the specified context. |\n\n**Promotion**\n| Property | Type |Required | Description |\n|---------------------- | ------------------------- |-------- | ---------- |\n| identifier | string | yes | An identifier for the promotion. |\n| effect | Effect | yes | The discount definition that will be applied. |\n| scope | Scope[] | yes | The definition of on which items the discount should be applied. |\n\n**Effect**\n| Property | Type |Required | Description |\n|---------------------- |------------------------- |-------- | ---------- |\n| type | \"nominal\" | yes | The type of discount that is being given. |\n| settings | Settings | yes | The definition of the discount itself to be applied. |\n\n**Settings**\n| Property | Type |Required | Description |\n|---------------------- |------------------------- |-------- | ---------- |\n| value | number | yes | The amount/value of the discount |\n| applyMode | \"OnEachItem\", \"SharedAmongItems\" | yes | How the discount will be appliend on the items described in the scope. <br> \"OnEachItem\" means that the whole amount will be applied to all matching items. <br> \"SharedAmongItems\" means that the amount will be split and shared evenly among the matching items. |\n\n**Scope**\n| Property | Type | Required | Description |\n|---------------------- |------------------------- | -------- | ---------- |\n| skuId | string | yes |The unique identifier of the item on which the disount should be applied. |\n| quantity | number | yes | The quantity of same items on which the discount should be applied. |\n\nFor more information see the External Promotion Fields Explanation on this [RFC](https://docs.google.com/document/d/1BPkfRz3t2BENqZaVMwToDALK5ePRoDWAlHoyD2qM5WU/edit#heading=h.1kydlntegy7j).\n\n**Response example**\n\n```json\n{\n \"version\": \"v1\",\n \"type\": \"page\",\n \"exp\": 1680812032408,\n \"cartHash\": \"cart_hash\",\n \"sessionId\": \"session_id\",\n \"promotions\": [\n {\n \"identifier\": \"mocked-external-promotion\",\n \"effect\": {\n \"type\": \"nominal\",\n \"settings\": {\n \"value\": 90,\n \"applyMode\": \"OnEachItem\"\n }\n },\n \"scope\": [\n {\n \"skuId\": \"1\",\n \"quantity\": 1\n }\n ]\n }\n ]\n}\n```\n\n```" } ]
code_external-promotions-example_b5487a02
[ { "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 external-promotions-example/node/service.json from the external-promotions-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"memory\": 256,\n \"ttl\": 10,\n \"timeout\": 300,\n \"minReplicas\": 2,\n \"maxReplicas\": 4,\n \"workers\": 1,\n \"routes\": {\n \"calculateExternalPromotions\": {\n \"path\": \"/_v/promotions/external/calculate\",\n \"public\": true\n }\n }\n}\n\n```" } ]
code_external-promotions-example_8a749eb7
[ { "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 external-promotions-example/node/package.json from the external-promotions-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 },\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 \"@vtex/api\": \"6.45.15\",\n \"@vtex/test-tools\": \"^1.0.0\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"typescript\": \"3.9.7\"\n },\n \"resolutions\": {\n \"@types/testing-library__dom\": \"6.12.1\",\n \"@types/express\": \"4.16.0\",\n \"@types/express-serve-static-core\": \"4.16.0\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty\"\n },\n \"version\": \"0.2.21\"\n}\n\n```" } ]
code_external-promotions-example_ea044259
[ { "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 external-promotions-example/node/index.ts from the external-promotions-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 { calculate } from './middlewares/promotions/external/calculate'\n\nconst TIMEOUT_MS = 2000\n\n// This is the configuration for clients available in `ctx.clients`.\nconst clients: ClientsConfig<Clients> = {\n // We pass our custom implementation of the clients bag, containing the Status client.\n implementation: Clients,\n options: {\n // All IO Clients will be initialized with these options, unless otherwise specified.\n default: {\n retries: 2,\n timeout: TIMEOUT_MS,\n },\n },\n}\n\ndeclare global {\n // We declare a global Context type just to avoid re-writing ServiceContext<Clients, State> in every handler and resolver\n type Context = ServiceContext<Clients, State>\n\n // The shape of our State object found in `ctx.state`. This is used as state bag to communicate between middlewares.\n interface State extends RecorderState {\n code: number\n }\n}\n\n// Export a service that defines route handlers and client options.\nexport default new Service({\n clients,\n routes: {\n // `status` is the route ID from service.json. It maps to an array of middlewares (or a single handler).\n calculateExternalPromotions: method({\n POST: [calculate],\n }),\n },\n})\n\n```" } ]
code_external-promotions-example_496885fe
[ { "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 external-promotions-example/node/clients/vtex-external-promotions-app.ts from the external-promotions-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { AppClient } from '@vtex/api'\n\nexport interface VTEXExternalPromotionsDataContract {\n items: Item[]\n sessionId: string\n externalPromotions: ExternalPromotion[]\n}\n\ninterface Item {\n id: string\n quantity: number\n seller: string\n}\n\ninterface ExternalPromotion {\n version: DataContractVersion\n exp: number\n type: DataContractType\n cartHash?: string\n promotions: Promotion[]\n}\n\nexport const enum DataContractVersion {\n v1 = 'v1',\n}\n\nexport const enum DataContractType {\n cart = 'cart',\n page = 'page',\n}\n\nexport interface Promotion {\n identifier: string\n effect: PromotionEffect\n scope: PromotionScope[]\n}\n\ninterface PromotionEffect {\n type: string\n settings: PromotionEffectSettings\n}\n\ninterface PromotionEffectSettings {\n value: number\n applyMode: PromotionEffectSettingsApplyMode\n}\n\nconst enum PromotionEffectSettingsApplyMode {\n onEachItem = 'OnEachItem',\n sharedAmongItems = 'SharedAmongItems',\n}\n\ninterface PromotionScope {\n skuId: string\n quantity: number\n}\n\nexport type ApplyPromotionsResponse = Record<string, unknown>\n\nexport class VTEXExternalPromotionsApp extends AppClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super('vtex.external-promotions-middleware@0.x', context, options)\n }\n\n public applyExternalPromotions(data: VTEXExternalPromotionsDataContract) {\n // this may change when we implment the app on VTEX's side\n return this.http.post<ApplyPromotionsResponse>(\n '/_v/promotions/external/apply/page',\n data,\n {\n metric: 'apply-external-promotions',\n }\n )\n }\n}\n\n```" } ]
code_external-promotions-example_72fdef67
[ { "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 external-promotions-example/node/clients/index.ts from the external-promotions-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOClients } from '@vtex/api'\n\nimport { Provider } from './provider'\nimport { VTEXExternalPromotionsApp } from './vtex-external-promotions-app'\n\n// Extend the default IOClients implementation with our own custom clients.\nexport class Clients extends IOClients {\n public get provider() {\n return this.getOrSet('provider', Provider)\n }\n\n // this may change when we implment the app on VTEX's side\n public get vtexExternalPromotionsApp() {\n return this.getOrSet('vtexExternalPromotionsApp', VTEXExternalPromotionsApp)\n }\n}\n\n```" } ]
code_external-promotions-example_c0993f6a
[ { "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 external-promotions-example/node/clients/provider.ts from the external-promotions-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { InstanceOptions, IOContext } from '@vtex/api'\nimport { ExternalClient } from '@vtex/api'\n\nimport type { Promotion } from './vtex-external-promotions-app'\n\nexport interface ExternalPromotionsProviderRequest {\n items: Item[]\n}\n\ninterface Item {\n sku: string\n price: number\n}\n\nexport interface ExternalPromotionsProviderResponse {\n promotions: Promotion[]\n}\n\nexport class Provider extends ExternalClient {\n constructor(context: IOContext, options?: InstanceOptions) {\n super(\n `http://${context.workspace}--${context.account}.myvtex.com`,\n context,\n options\n )\n }\n\n public calculateExternalPromotions(data: ExternalPromotionsProviderRequest) {\n return this.http.post<ExternalPromotionsProviderResponse>(\n '/_v/promotions/calculate',\n data,\n {\n metric: 'calculate-promotions-external-provider',\n }\n )\n }\n}\n\n```" } ]
code_external-promotions-example_b3058a76
[ { "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 external-promotions-example/node/__tests__/simple.test.ts from the external-promotions-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n// You can import your files here for testing them\n//\n// More info: https://github.com/sapegin/jest-cheat-sheet\n\ndescribe('simpleTest', () => {\n it('one test case', async () => {\n expect(0.2 + 0.1).not.toBe(0.3)\n })\n})\n\n```" } ]
code_external-promotions-example_95d3899f
[ { "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 external-promotions-example/node/middlewares/promotions/external/calculate.ts from the external-promotions-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { json } from 'co-body'\n\nimport type {\n ExternalPromotionsProviderRequest,\n ExternalPromotionsProviderResponse,\n} from '../../../clients/provider'\nimport type {\n ApplyPromotionsResponse,\n VTEXExternalPromotionsDataContract,\n} from '../../../clients/vtex-external-promotions-app'\nimport {\n DataContractType,\n DataContractVersion,\n} from '../../../clients/vtex-external-promotions-app'\n\ninterface CalculateExternalPromotionsRequest {\n sessionId: string\n promotionalContext: PromotionalContext\n}\n\ninterface PromotionalContext {\n items: Item[]\n}\n\ninterface Item {\n id: string\n quantity: number\n seller: string\n sellingPrice: number\n}\n\nexport async function calculate(\n ctx: Context,\n next: () => Promise<ApplyPromotionsResponse>\n) {\n const {\n sessionId,\n promotionalContext,\n }: CalculateExternalPromotionsRequest = await json(ctx.req)\n\n const {\n clients: { provider, vtexExternalPromotionsApp },\n } = ctx\n\n const data: ExternalPromotionsProviderRequest = {\n items: promotionalContext.items.map((item) => ({\n sku: item.id,\n price: item.sellingPrice,\n })),\n }\n\n return provider\n .calculateExternalPromotions(data)\n .then((externalPromotionsDataResult) => {\n return vtexExternalPromotionsApp\n .applyExternalPromotions(\n transformToVTEXExternalPromotionsDataContract(\n promotionalContext,\n sessionId,\n externalPromotionsDataResult\n )\n )\n .then((applyExternalPromotionsResult) => {\n // this may change when we implment the app on VTEX's side\n ctx.status = 200\n ctx.body = applyExternalPromotionsResult\n\n return next()\n })\n .catch((error) => {\n const msg =\n 'an unexpected error occurred while applying external promotions'\n\n console.error(msg, { data: externalPromotionsDataResult, error })\n ctx.status = 500\n ctx.body = msg\n\n return next()\n })\n })\n .catch((error) => {\n const msg =\n 'an unexpected error occurred while calling the external provider to calculate promotions'\n\n console.error(msg, { data, error })\n ctx.status = 500\n ctx.body = msg\n\n return next()\n })\n}\n\nfunction transformToVTEXExternalPromotionsDataContract(\n promotionalContext: PromotionalContext,\n sessionId: string,\n externalPromotions: ExternalPromotionsProviderResponse\n): VTEXExternalPromotionsDataContract {\n const now = new Date()\n\n return {\n items: promotionalContext.items.map((item) => ({\n id: item.id,\n quantity: item.quantity,\n seller: item.seller,\n })),\n sessionId: sessionId,\n externalPromotions: [\n {\n version: DataContractVersion.v1,\n type: DataContractType.page,\n exp: now.setHours(now.getHours() + 1), // this should be the unix time when the promotion becomes invalid,\n promotions: externalPromotions.promotions,\n },\n ],\n }\n}\n\n```" } ]
code_experimental__visibility-layout_26bb335d
[ { "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 experimental__visibility-layout/messages/pt.json from the experimental__visibility-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.visibilityLayout.title\": \"Controle de Visibilidade\",\n \"admin/editor.visibilityLayout.visible.title\": \"Visível\"\n}\n```" } ]
code_experimental__visibility-layout_1d117ecc
[ { "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 experimental__visibility-layout/messages/en.json from the experimental__visibility-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.visibilityLayout.title\": \"Visibility Control\",\n \"admin/editor.visibilityLayout.visible.title\": \"Visible\"\n}\n```" } ]
code_experimental__visibility-layout_0e1c6d33
[ { "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 experimental__visibility-layout/messages/context.json from the experimental__visibility-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.visibilityLayout.title\": \"Visibility Control\",\n \"admin/editor.visibilityLayout.visible.title\": \"Visible\"\n}\n```" } ]
code_experimental__visibility-layout_02174cc8
[ { "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 experimental__visibility-layout/messages/es.json from the experimental__visibility-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.visibilityLayout.title\": \"Control de visibilidad\",\n \"admin/editor.visibilityLayout.visible.title\": \"Visible\"\n}\n```" } ]
code_experimental__visibility-layout_940fbe9b
[ { "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 experimental__visibility-layout/docs/README.md from the experimental__visibility-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# EXPERIMENTAL Visibility Layout\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\n🚧 Under Construction 🚧\n\nThis app might have breaking changes at any moment.\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<!-- 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```" } ]
code_experimental__visibility-layout_d63b6963
[ { "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 experimental__visibility-layout/react/Experimental__VisibilityLayout.tsx from the experimental__visibility-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment } from 'react'\n\nconst Experimental__VisibilityLayout: StorefrontFunctionComponent<VisibilityLayoutProps> = ({\n visible = true,\n children\n}) => {\n if (visible === false) {\n return null\n }\n\n return <Fragment>{children}</Fragment>\n}\n\ninterface VisibilityLayoutProps {\n visible: boolean\n}\n\nExperimental__VisibilityLayout.schema = {\n title: 'admin/editor.visibilityLayout.title'\n}\n\nexport default Experimental__VisibilityLayout\n\n```" } ]
code_experimental__visibility-layout_729d4f29
[ { "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 experimental__visibility-layout/react/package.json from the experimental__visibility-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\",\n \"lint\": \"tsc --noEmit && eslint --ext ts,tsx .\"\n },\n \"dependencies\": {\n \"@vtex/css-handles\": \"^1.0.0\",\n \"classnames\": \"^2.2.6\",\n \"ramda\": \"^0.26.1\",\n \"react\": \"^16.8.3\",\n \"react-dom\": \"^16.8.3\",\n \"react-intl\": \"^2.7.2\"\n },\n \"devDependencies\": {\n \"@types/classnames\": \"^2.2.7\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.7.5\",\n \"@types/prop-types\": \"^15.7.0\",\n \"@types/ramda\": \"^0.26.5\",\n \"@types/react\": \"^16.9.2\",\n \"@vtex/test-tools\": \"^1.1.0\",\n \"apollo-client\": \"^2.5.1\",\n \"eslint\": \"^5.16.0\",\n \"eslint-config-vtex-react\": \"^4.1.0\",\n \"prettier\": \"^1.18.2\",\n \"tslint-eslint-rules\": \"^5.4.0\",\n \"typescript\": \"3.5.2\"\n },\n \"version\": \"0.2.1\"\n}\n\n```" } ]
code_experimental__visibility-layout_3ea79279
[ { "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 experimental__visibility-layout/store/interfaces.json from the experimental__visibility-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"experimental__visibility-layout\": {\n \"allowed\": \"*\",\n \"composition\": \"children\",\n \"component\": \"Experimental__VisibilityLayout\",\n \"content\": {\n \"properties\": {\n \"visible\": {\n \"title\": \"admin/editor.visibilityLayout.visible.title\",\n \"type\": \"boolean\",\n \"default\": true\n }\n }\n }\n }\n}\n```" } ]
code_experimental__visibility-layout_53cf818c
[ { "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 experimental__visibility-layout/react/typings/storefront.d.ts from the experimental__visibility-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent } from 'react'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n getSchema?(props: P): object\n schema?: object\n }\n\n interface StorefrontComponent<P = {}, S = {}> extends Component<P, S> {\n getSchema?(props: P): object\n schema: object\n }\n}\n\n```" } ]
code_experimental__visibility-layout_304c2b78
[ { "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 experimental__visibility-layout/react/typings/vtex.render-runtime.d.ts from the experimental__visibility-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ComponentType, ReactElement, ReactType } from 'react'\n\n export interface NavigationOptions {\n page: string\n params?: any\n }\n\n export interface RenderContextProps {\n runtime: {\n navigate: (options: NavigationOptions) => void\n }\n }\n\n interface ExtensionPointProps {\n id: string\n [key: string]: any\n }\n\n export const ExtensionPoint: ComponentType<ExtensionPointProps>\n\n interface ChildBlockProps {\n id: string\n }\n\n export const ChildBlock: ComponentType<ChildBlockProps>\n export const useChildBlock = function({ id: string }): object {}\n\n export const Helmet: ReactElement\n export const Link: ReactType\n export const NoSSR: ReactElement\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const withRuntimeContext: <TOriginalProps extends {}>(\n Component: ComponentType<TOriginalProps & RenderContextProps>\n ) => ComponentType<TOriginalProps>\n}\n\n```" } ]
code_experimental__visibility-layout_4ab2d851
[ { "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 experimental__visibility-layout/react/typings/css.d.ts from the experimental__visibility-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const css: any\n export default css\n}\n\n```" } ]
code_experimental__visibility-layout_fdf14dac
[ { "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 experimental__visibility-layout/react/typings/graphql.d.ts from the experimental__visibility-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.graphql' {\n import { DocumentNode } from 'graphql'\n\n const value: DocumentNode\n export default value\n}\n\n```" } ]
code_experimental__visibility-layout_274fe54c
[ { "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 experimental__visibility-layout/react/typings/vtex.styleguide.d.ts from the experimental__visibility-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n import { ComponentType } from 'react'\n\n export const Input: ComponentType<InputProps>\n\n interface InputProps {\n [key: string]: any\n }\n}\n\n```" } ]