id
stringlengths
12
53
messages
listlengths
3
3
code_store-sitemap_824e38ff
[ { "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-sitemap/node/middlewares/generateMiddlewares/prepare.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { CONFIG_BUCKET, GENERATION_CONFIG_FILE } from '../../utils'\n\nexport async function prepare(ctx: EventContext, next: () => Promise<void>) {\n const {\n body,\n vtex: { logger },\n clients: { vbase },\n state: { isCrossBorder },\n } = ctx\n\n const { generationId } = body\n\n if (!isCrossBorder) {\n logger.info({\n message: 'Skipping generation for non-cross-border tenant',\n payload: body,\n })\n\n return\n }\n\n if (!generationId) {\n logger.error({ message: 'Missing generation id', payload: body })\n return\n }\n const { generationId: currentGenerationId } = await vbase.getJSON<GenerationConfig>(CONFIG_BUCKET, GENERATION_CONFIG_FILE, true)\n || { generationId: null }\n if (generationId !== currentGenerationId) {\n logger.debug({ message: 'Invalid generation id', payload: body })\n return\n }\n await next()\n}\n\n```" } ]
code_store-sitemap_41044b02
[ { "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-sitemap/node/middlewares/generateMiddlewares/generateRewriterRoutes.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { Binding } from '@vtex/api'\nimport { path as Rpath, startsWith } from 'ramda'\nimport { Internal } from 'vtex.rewriter'\n\nimport { getBucket, getStoreBindings, hashString } from '../../utils'\nimport { Clients } from '../../clients/index'\nimport { Rewriter } from '../../clients/rewriter'\nimport {\n createFileName,\n currentDate,\n GENERATE_REWRITER_ROUTES_EVENT,\n GROUP_ENTRIES_EVENT,\n initializeSitemap,\n RAW_DATA_PREFIX,\n REWRITER_ROUTES_INDEX,\n SitemapEntry,\n SitemapIndex,\n} from './utils'\n\nconst LIST_LIMIT = 300\n\ntype RoutesByBinding = Record<string, Record<string, Route[]>>\n\nconst createRoutesByBinding = (routes: Internal[], report: Record<string, number>, storeBindings: Binding[], disableRoutesTerm: string) => {\n const storeBindingsIds = storeBindings.map(({ id }) => id)\n return routes.reduce(\n (acc, internal) => {\n report[internal.type] = (report[internal.type] || 0) + 1\n let validRoute =\n !startsWith('notFound', internal.type) &&\n internal.type !== 'product' &&\n !internal.disableSitemapEntry &&\n storeBindingsIds.includes(internal.binding)\n if (disableRoutesTerm) {\n validRoute = validRoute && !internal.from.includes(disableRoutesTerm)\n }\n if (validRoute) {\n const { binding } = internal\n const bindingRoutes: Route[] = Rpath([binding, internal.type], acc) || []\n const route: Route = {\n id: internal.id,\n imagePath: internal.imagePath || undefined,\n imageTitle: internal.imageTitle || undefined,\n path: internal.from,\n }\n acc[binding] = {\n ...acc[binding] || {},\n [internal.type]: bindingRoutes.concat(route),\n }\n }\n return acc\n },\n {} as RoutesByBinding\n )\n}\n\nconst completeRoute = (rewriter: Rewriter, type: string) => async (route: Route) => {\n const routesById = await rewriter.routesById({\n id: route.id,\n type,\n })\n const alternates = routesById.map(({ route: path, binding: bindingId }) => ({ path, bindingId }))\n return {\n ...route,\n alternates,\n }\n}\n\nconst saveRoutes = (routesByBinding: RoutesByBinding, count: number, clients: Clients) => async (bindingId: string) => {\n const { vbase, rewriter } = clients\n const bucket = getBucket(RAW_DATA_PREFIX, hashString(bindingId))\n const groupedRoutes = routesByBinding[bindingId]\n const newEntries = await Promise.all(\n Object.keys(groupedRoutes).map(async entityType => {\n const entityRoutes = await Promise.all(\n routesByBinding[bindingId][entityType].map(completeRoute(rewriter, entityType))\n )\n const entry = createFileName(entityType, count)\n const lastUpdated = currentDate()\n await vbase.saveJSON<SitemapEntry>(bucket, entry, {\n lastUpdated,\n routes: entityRoutes,\n })\n return entry\n })\n )\n const { index } = await vbase.getJSON<SitemapIndex>(bucket, REWRITER_ROUTES_INDEX, true)\n await vbase.saveJSON<SitemapIndex>(bucket, REWRITER_ROUTES_INDEX, {\n index: [...index, ...newEntries],\n lastUpdated: currentDate(),\n })\n}\n\nexport async function generateRewriterRoutes(\n ctx: EventContext,\n nextMiddleware: () => Promise<void>\n) {\n if (!ctx.body.count) {\n await initializeSitemap(ctx, REWRITER_ROUTES_INDEX)\n }\n const {\n clients: { rewriter, tenant },\n body,\n } = ctx\n const {\n count,\n disableRoutesTerm,\n generationId,\n next,\n report,\n }: RewriterRoutesGenerationEvent = body!\n\n const response = await rewriter.listInternalsWithRetry(LIST_LIMIT, next)\n const routes: Internal[] = response.routes || []\n const responseNext = response.next\n\n const storeBindings = await getStoreBindings(tenant)\n const routesByBinding = createRoutesByBinding(routes, report, storeBindings, disableRoutesTerm)\n\n await Promise.all(\n Object.keys(routesByBinding).map(saveRoutes(routesByBinding, count, ctx.clients))\n )\n\n if (responseNext) {\n const payload: RewriterRoutesGenerationEvent = {\n count: count + 1,\n disableRoutesTerm,\n generationId,\n next: responseNext,\n report,\n }\n ctx.state.nextEvent = {\n event: GENERATE_REWRITER_ROUTES_EVENT,\n payload,\n }\n } else {\n ctx.vtex.logger.info({\n message: 'Rewriter routes complete',\n report,\n type: GENERATE_REWRITER_ROUTES_EVENT,\n })\n ctx.state.nextEvent = {\n event: GROUP_ENTRIES_EVENT,\n payload: {\n from: 0,\n generationId,\n indexFile: REWRITER_ROUTES_INDEX,\n },\n }\n }\n await nextMiddleware()\n}\n\n\n\n```" } ]
code_store-sitemap_031ba75f
[ { "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-sitemap/node/middlewares/generateMiddlewares/generateSitemap.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { startSitemapGeneration } from '../../utils'\nimport { MultipleSitemapGenerationError } from './../../errors'\n\nimport {\n GENERATE_APPS_ROUTES_EVENT,\n GENERATE_PRODUCT_ROUTES_EVENT,\n GENERATE_REWRITER_ROUTES_EVENT,\n} from './utils'\n\nexport async function generateSitemapFromREST(ctx: Context) {\n ctx.status = 200\n try {\n await startSitemapGeneration(ctx, ctx.query.__force !== undefined)\n } catch (err) {\n if (err instanceof MultipleSitemapGenerationError) {\n ctx.status = 202\n ctx.body = err.message\n return\n }\n throw err\n }\n}\n\nconst DEFAULT_REWRITER_ROUTES_PAYLOAD = {\n count: 0,\n next: null,\n report: {},\n}\n\nexport async function generateSitemap(ctx: EventContext) {\n const { clients: { events }, body: { generationId }, state: { settings } } = ctx\n const disableRoutesTerm = settings.disableRoutesTerm\n if (settings.enableNavigationRoutes) {\n events.sendEvent('', GENERATE_REWRITER_ROUTES_EVENT, {\n ...DEFAULT_REWRITER_ROUTES_PAYLOAD,\n disableRoutesTerm,\n generationId,\n } as RewriterRoutesGenerationEvent)\n }\n\n if (settings.enableProductRoutes) {\n events.sendEvent('', GENERATE_PRODUCT_ROUTES_EVENT, {\n generationId,\n invalidProducts: 0,\n page: 1,\n processedProducts: 0,\n } as ProductRoutesGenerationEvent)\n }\n\n if (settings.enableAppsRoutes) {\n events.sendEvent('', GENERATE_APPS_ROUTES_EVENT, { generationId })\n }\n}\n\n```" } ]
code_store-sitemap_b227b2bd
[ { "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-sitemap/node/middlewares/generateMiddlewares/generateAppsRoutes.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { Apps, VBase } from '@vtex/api'\nimport { flatten, splitEvery } from 'ramda'\n\nimport {\n CONFIG_BUCKET,\n CONFIG_FILE,\n getBucket,\n hashString,\n TENANT_CACHE_TTL_S\n} from '../../utils'\nimport {\n APPS_ROUTES_INDEX,\n completeRoutes,\n createFileName,\n currentDate,\n DEFAULT_CONFIG,\n SitemapEntry,\n SitemapIndex,\n} from './utils'\n\nconst APP_ROUTES_ENTITY = 'appsRoutes'\nconst STORE_SITEMAP_BUILD_FILE =`/dist/vtex.store-sitemap/build.json`\nconst FILE_LIMIT = 5000\n\ninterface SitemapBuild {\n entries: string[]\n}\n\nconst getRoutes = async (apps: Apps): Promise<string[]> => {\n const deps = await apps.getAppsMetaInfos()\n const routes = await Promise.all(\n deps.map(async dep => {\n const build = await apps.getAppJSON<SitemapBuild | null>(dep.id, STORE_SITEMAP_BUILD_FILE, true)\n return build ? build.entries || [] : []\n }\n ))\n return flatten<string>(routes)\n}\n\nconst saveRoutes = async (routes: string[], idx: number, bucket: string, vbase: VBase) => {\n const sitemapRoutes = routes.map(route => ({ id: route, path: route }))\n const entry = createFileName(APP_ROUTES_ENTITY, idx)\n await vbase.saveJSON<SitemapEntry>(bucket, entry, {\n lastUpdated: currentDate(),\n routes: sitemapRoutes,\n })\n return entry\n}\n\nexport async function generateAppsRoutes(ctx: EventContext) {\n const { clients: { apps, tenant, vbase }, vtex: { logger } } = ctx\n\n const { bindings } = await tenant.info({\n forceMaxAge: TENANT_CACHE_TTL_S,\n })\n const { generationPrefix } = await vbase.getJSON<Config>(CONFIG_BUCKET, CONFIG_FILE, true) || DEFAULT_CONFIG\n\n const appsRoutes = await getRoutes(apps)\n\n await Promise.all(bindings.map(async binding => {\n const bucket = getBucket(generationPrefix, hashString(binding.id))\n const splittedRoutes = splitEvery(FILE_LIMIT, appsRoutes)\n const index = await Promise.all(splittedRoutes.map((routes, idx) => saveRoutes(routes, idx, bucket, vbase)))\n await vbase.saveJSON<SitemapIndex>(bucket, APPS_ROUTES_INDEX, {\n index,\n lastUpdated: currentDate(),\n })\n }))\n\n await completeRoutes(APPS_ROUTES_INDEX, vbase)\n logger.info({\n message: 'Apps routes complete',\n numberOfroutes: appsRoutes.length,\n type: 'apps-routes',\n })\n}\n\n```" } ]
code_store-sitemap_f728dae8
[ { "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-sitemap/node/middlewares/generateMiddlewares/utils.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { Binding, LINKED, Logger, Tenant, VBase } from '@vtex/api'\nimport { uniqBy } from 'ramda'\nimport { Product, SalesChannel } from 'vtex.catalog-graphql'\n\nimport { Messages } from '../../clients/messages'\nimport { CONFIG_BUCKET, getBucket, hashString, TENANT_CACHE_TTL_S } from '../../utils'\n\nexport const RAW_DATA_PREFIX = `${LINKED ? 'L' : ''}C`\n\nexport const REWRITER_ROUTES_INDEX = 'rewriterRoutesIndex.json'\nexport const PRODUCT_ROUTES_INDEX = 'productRoutesIndex.json'\nexport const APPS_ROUTES_INDEX = 'appsRoutesIndex.json'\n\nexport const GENERATE_SITEMAP_EVENT = 'sitemap.generate'\nexport const GENERATE_REWRITER_ROUTES_EVENT = 'sitemap.generate:rewriter-routes'\nexport const GENERATE_PRODUCT_ROUTES_EVENT = 'sitemap.generate:product-routes'\nexport const GENERATE_APPS_ROUTES_EVENT = 'sitemap.generate:apps-routes'\nexport const GROUP_ENTRIES_EVENT = 'sitemap.generate:group-entries'\n\nexport const DEFAULT_CONFIG: Config = {\n generationPrefix: `${LINKED ? 'L' : ''}B`,\n productionPrefix: `${LINKED ? 'L' : ''}A`,\n}\n\nexport interface SitemapIndex {\n index: string[]\n lastUpdated: string\n}\n\nexport interface SitemapEntry {\n routes: Route[]\n lastUpdated: string\n}\n\nexport interface Message {\n content: string\n context: string\n}\n\nexport const uniq = <T>(array: T[]) => array.filter((value, idx) => array.indexOf(value) === idx)\n\nexport const createFileName = (entity: string, count: number) => `${entity}-${count}`\n\nexport const splitFileName = (file: string) => file.split('-')\n\nexport const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))\n\nexport const currentDate = (): string => new Date().toISOString()\n\nexport const initializeSitemap = async (ctx: EventContext, indexFile: string) => {\n const { tenant, vbase } = ctx.clients\n const { bindings } = await tenant.info({\n forceMaxAge: TENANT_CACHE_TTL_S,\n })\n\n await Promise.all(bindings.map(\n binding => vbase.saveJSON<SitemapIndex>(getBucket(RAW_DATA_PREFIX, hashString(binding.id)), indexFile, {\n index: [] as string[],\n lastUpdated: '',\n })\n ))\n}\n\nexport const getAccountSalesChannels = (\n bindings: Binding[]\n): string[] | undefined => {\n const salesChannels = bindings.reduce((acc, binding) => {\n const bindingSC: number | undefined =\n binding.extraContext.portal?.salesChannel\n if (bindingSC) {\n acc.push(bindingSC.toString())\n }\n return acc\n }, [] as string[])\n // Has one binding with one sales channel\n if (bindings.length === 1 && salesChannels.length === 1) {\n return\n }\n return uniqBy(i => i, salesChannels)\n}\n\nexport const filterBindingsBySalesChannel = (\n storeBindings: Binding[],\n salesChannels: Product['salesChannel']\n): Tenant['bindings'] => {\n const salesChannelsSet = salesChannels?.reduce((acc: Set<string>, sc: Maybe<SalesChannel>) => {\n if (sc?.id) {\n acc.add(sc.id)\n }\n return acc\n }, new Set<string>())\n\n return storeBindings.filter(binding => {\n const bindingSC: number | undefined =\n binding.extraContext.portal?.salesChannel\n const productActiveInBindingSC =\n bindingSC && salesChannelsSet?.has(bindingSC.toString())\n if (productActiveInBindingSC || !salesChannelsSet) {\n return true\n }\n return false\n })\n}\n\nexport const slugify = (str: string) =>\n str\n .toLowerCase()\n .normalize('NFD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .replace(/[*+~.()'\"!:@&\\[\\]`,/ %$#?{}|><=_^]/g, '-')\n\nexport type Translator = (from: string, to: string, messages: Message[]) => Promise<string[]>\n\nexport const createTranslator = (service: Messages) => async (\n from: string,\n to: string,\n messages: Message[]\n): Promise<string[]> => {\n if (from.toLowerCase() === to.toLowerCase()) {\n return messages.map(({ content }) => content)\n }\n const translations = await service.translateNoCache({\n indexedByFrom: [\n {\n from,\n messages,\n },\n ],\n to,\n })\n return translations\n}\n\n\nexport const isSitemapComplete = async (enabledIndexFiles: string[], vbase: VBase, logger: Logger) => {\n const indexFiles = await Promise.all(enabledIndexFiles.map(\n indexFile =>\n vbase.getJSON(CONFIG_BUCKET, indexFile, true)\n ))\n logger.debug({\n enabledIndexFiles,\n indexFiles,\n })\n return allTruthy(indexFiles)\n}\n\nexport const completeRoutes = async (file: string, vbase: VBase) =>\n vbase.saveJSON(CONFIG_BUCKET, file, 'OK')\n\nexport const cleanConfigBucket = async (enabledIndexFiles: string[], vbase: VBase) =>\n Promise.all([\n ...enabledIndexFiles.map(\n indexFile => vbase.deleteFile(CONFIG_BUCKET, indexFile)),\n ])\n\nconst allTruthy = <T>(array: T[]) => !array.some(e => !e)\n\n```" } ]
code_store-sitemap_c2fb2b8c
[ { "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-sitemap/node/middlewares/generateMiddlewares/generateSitemap.test.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { Events, IOContext, Logger } from '@vtex/api'\nimport * as TypeMoq from 'typemoq'\n\nimport { Clients } from '../../clients'\nimport { generateSitemap } from './generateSitemap'\nimport {\n GENERATE_APPS_ROUTES_EVENT,\n GENERATE_PRODUCT_ROUTES_EVENT,\n GENERATE_REWRITER_ROUTES_EVENT,\n} from './utils'\n\nconst eventsTypeMock = TypeMoq.Mock.ofInstance(Events)\nconst contextMock = TypeMoq.Mock.ofType<EventContext>()\nconst ioContext = TypeMoq.Mock.ofType<IOContext>()\nconst state = TypeMoq.Mock.ofType<State>()\nconst loggerMock = TypeMoq.Mock.ofType<Logger>()\n\nconst eventSent = jest.fn()\n\nconst DEFAULT_APPS_ROUTES_PAYLOAD = {\n generationId: '1',\n}\n\nconst DEFAULT_REWRITER_ROUTES_PAYLOAD = {\n count: 0,\n generationId: '1',\n next: null,\n report: {},\n}\n\nconst DEFAULT_PRODUCT_ROUTES_PAYLOAD: ProductRoutesGenerationEvent = {\n generationId: '1',\n invalidProducts: 0,\n page: 1,\n processedProducts: 0,\n}\n\ndescribe('Test generate sitemap', () => {\n let context: EventContext\n const events = class EventsMock extends eventsTypeMock.object {\n constructor() {\n super(ioContext.object)\n }\n\n public sendEvent = async (\n _: any,\n route: string,\n message?: any,\n __?: any\n ) => {\n eventSent(_, route, message)\n }\n }\n\n beforeEach(() => {\n // tslint:disable-next-line:max-classes-per-file\n const ClientsImpl = class ClientsMock extends Clients {\n get events() {\n return this.getOrSet('events', events)\n }\n }\n\n jest.clearAllMocks()\n\n context = {\n ...contextMock.object,\n body: {\n generationId: '1',\n },\n clients: new ClientsImpl({}, ioContext.object),\n state: {\n ...state.object,\n settings: {\n disableRoutesTerm: '',\n enableAppsRoutes: true,\n enableNavigationRoutes: true,\n enableProductRoutes: true,\n ignoreBindings: false,\n },\n },\n vtex: {\n ...ioContext.object,\n logger: loggerMock.object,\n },\n }\n })\n\n it('Should send both events', async () => {\n await generateSitemap(context)\n expect(eventSent).toHaveBeenCalledWith(\n '',\n GENERATE_REWRITER_ROUTES_EVENT,\n DEFAULT_REWRITER_ROUTES_PAYLOAD\n )\n expect(eventSent).toHaveBeenCalledWith(\n '',\n GENERATE_PRODUCT_ROUTES_EVENT,\n DEFAULT_PRODUCT_ROUTES_PAYLOAD\n )\n expect(eventSent).toHaveBeenCalledWith(\n '',\n GENERATE_APPS_ROUTES_EVENT,\n DEFAULT_APPS_ROUTES_PAYLOAD\n )\n })\n\n it('Should send only enabled events', async () => {\n context.state.settings = {\n disableRoutesTerm: '',\n enableAppsRoutes: true,\n enableNavigationRoutes: true,\n enableProductRoutes: false,\n ignoreBindings: false,\n }\n\n await generateSitemap(context)\n expect(eventSent).toHaveBeenCalledWith(\n '',\n GENERATE_REWRITER_ROUTES_EVENT,\n DEFAULT_REWRITER_ROUTES_PAYLOAD\n )\n expect(eventSent).toHaveBeenCalledWith(\n '',\n GENERATE_APPS_ROUTES_EVENT,\n DEFAULT_APPS_ROUTES_PAYLOAD\n )\n expect(eventSent).toHaveBeenCalledTimes(2)\n\n jest.clearAllMocks()\n context.state.settings = {\n disableRoutesTerm: '',\n enableAppsRoutes: false,\n enableNavigationRoutes: false,\n enableProductRoutes: true,\n ignoreBindings: false,\n }\n\n await generateSitemap(context)\n expect(eventSent).toHaveBeenCalledWith(\n '',\n GENERATE_PRODUCT_ROUTES_EVENT,\n DEFAULT_PRODUCT_ROUTES_PAYLOAD\n )\n expect(eventSent).toHaveBeenCalledTimes(1)\n })\n})\n\n```" } ]
code_store-sitemap_425a3b3d
[ { "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-sitemap/node/middlewares/generateMiddlewares/sendNextEvent.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { sleep } from './utils'\n\nexport async function sendNextEvent(ctx: EventContext) {\n const { clients: { events }, state: { nextEvent } } = ctx\n const { payload, event } = nextEvent\n const timeToSleep = Math.ceil(Math.random() * 100)\n await sleep(timeToSleep)\n events.sendEvent('', event, payload)\n}\n\n\n```" } ]
code_store-sitemap_9ad86ed0
[ { "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-sitemap/node/middlewares/generateMiddlewares/isCrossBorder.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { getStoreBindings } from '../../utils'\n\nexport async function isCrossBorder(\n ctx: Context | EventContext,\n next: () => Promise<void>\n) {\n const {\n clients: { tenant },\n state,\n } = ctx\n\n const storefrontsBindings = await getStoreBindings(tenant)\n state.isCrossBorder = storefrontsBindings?.length > 1\n\n await next()\n}\n\n```" } ]
code_store-sitemap_a0653e3e
[ { "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-sitemap/node/middlewares/generateMiddlewares/prepare.test.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOContext, Logger, VBase, VBaseSaveResponse } from '@vtex/api'\nimport * as TypeMoq from 'typemoq'\nimport { Clients } from '../../clients'\nimport { CONFIG_BUCKET, GENERATION_CONFIG_FILE } from '../../utils'\nimport { prepare } from './prepare'\n\nconst vbaseTypeMock = TypeMoq.Mock.ofInstance(VBase)\nconst contextMock = TypeMoq.Mock.ofType<EventContext>()\nconst ioContext = TypeMoq.Mock.ofType<IOContext>()\nconst state = TypeMoq.Mock.ofType<State>()\nconst loggerMock = TypeMoq.Mock.ofType<Logger>()\n\nconst next = jest.fn()\n\ndescribe('Test generation prepare', () => {\n let context: EventContext\n\n const vbase = class VBaseMock extends vbaseTypeMock.object {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private jsonData: Record<string, any> = {}\n\n constructor() {\n super(ioContext.object)\n }\n\n public getJSON = async <T>(\n bucket: string,\n file: string,\n nullOrUndefined?: boolean | undefined\n ): Promise<T> => {\n if (!this.jsonData[bucket]?.[file] && nullOrUndefined) {\n return (null as unknown) as T\n }\n return Promise.resolve(this.jsonData[bucket][file] as T)\n }\n\n public saveJSON = async <T>(\n bucket: string,\n file: string,\n data: T\n ): Promise<VBaseSaveResponse> => {\n if (!this.jsonData[bucket]) {\n this.jsonData[bucket] = {}\n }\n this.jsonData[bucket][file] = data\n return Promise.resolve([{ path: file, hash: 'mocked-hash' }])\n }\n }\n beforeEach(() => {\n // tslint:disable-next-line:max-classes-per-file\n const ClientsImpl = class ClientsMock extends Clients {\n get vbase() {\n return this.getOrSet('vbase', vbase)\n }\n }\n context = {\n ...contextMock.object,\n body: {\n generationId: '1',\n },\n clients: new ClientsImpl({}, ioContext.object),\n state: {\n ...state.object,\n },\n vtex: {\n ...ioContext.object,\n logger: loggerMock.object,\n },\n }\n })\n\n it('Shouldnt continue if genereationId isnt found', async () => {\n const thisContext = {\n ...context,\n body: {\n generationId: undefined,\n },\n }\n await prepare(thisContext, next)\n expect(next).toHaveBeenCalledTimes(0)\n })\n\n it('Shouldnt continue if generationId is not the one in VBae', async () => {\n const { vbase: vbaseClient } = context.clients\n await vbaseClient.saveJSON(CONFIG_BUCKET, GENERATION_CONFIG_FILE, {\n generationId: '2',\n })\n await prepare(context, next)\n expect(next).toHaveBeenCalledTimes(0)\n })\n\n it('Shouldnt continue if no config file is found', async () => {\n await prepare(context, next)\n expect(next).toHaveBeenCalledTimes(0)\n })\n\n it('Should continue if generationId matches the config', async () => {\n const { vbase: vbaseClient } = context.clients\n await vbaseClient.saveJSON(CONFIG_BUCKET, GENERATION_CONFIG_FILE, {\n generationId: '1',\n })\n await prepare(context, next)\n expect(next).toBeCalled()\n })\n\n})\n\n```" } ]
code_store-sitemap_29be164e
[ { "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-sitemap/node/middlewares/generateMiddlewares/generateCustomRoutes.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { getDefaultStoreBinding } from '../../resources/bindings'\nimport { clearCustomRoutesGenerationLock } from '../customRoutes'\nimport { getAppsRoutes, getUserRoutes } from '../../services/routes'\nimport { CUSTOM_ROUTES_BUCKET, CUSTOM_ROUTES_FILENAME } from '../../utils'\n\nexport async function generateCustomRoutes(ctx: Context) {\n const {\n clients: { vbase, tenant },\n vtex: { logger },\n } = ctx\n\n const startTime = process.hrtime()\n\n try {\n logger.info({\n message: 'Starting custom routes generation',\n type: 'custom-routes-generation',\n })\n\n // Get default store binding for the account\n const defaultBindingId = await getDefaultStoreBinding(ctx)\n\n // Get tenant info to construct binding object\n const tenantInfo = await tenant.info()\n const binding = tenantInfo.bindings?.find(b => b.id === defaultBindingId)\n\n // Create a minimal context-like object for the route functions\n // Always include binding in state, even if null (extended routes require it)\n const routeCtx = {\n clients: ctx.clients,\n state: {\n ...ctx.state,\n binding: binding ?? null,\n },\n vtex: ctx.vtex,\n } as Context\n\n const [appsRoutes, userRoutes] = await Promise.all([\n getAppsRoutes(routeCtx),\n getUserRoutes(routeCtx),\n ])\n\n logger.info({\n message: 'Routes fetched',\n appsRoutesCount: appsRoutes.length,\n userRoutesCount: userRoutes.length,\n })\n\n const customRoutesData: CustomRoutesData = {\n timestamp: Date.now(),\n data: [\n { name: 'apps-routes', routes: appsRoutes },\n { name: 'user-routes', routes: userRoutes },\n ],\n }\n\n // Save to VBase using custom-routes bucket\n await vbase.saveJSON<CustomRoutesData>(\n CUSTOM_ROUTES_BUCKET,\n CUSTOM_ROUTES_FILENAME,\n customRoutesData\n )\n\n logger.info({\n message: 'Custom routes saved',\n appsRoutesCount: appsRoutes.length,\n userRoutesCount: userRoutes.length,\n fileName: CUSTOM_ROUTES_FILENAME,\n })\n\n // Clear generation lock after successful completion\n await clearCustomRoutesGenerationLock(vbase, logger)\n\n const timeDiff = process.hrtime(startTime)\n logger.info({\n message: 'Custom routes generation complete',\n type: 'custom-routes-generation-complete',\n duration: timeDiff,\n })\n } catch (error) {\n // Clear generation lock on error as well\n await clearCustomRoutesGenerationLock(vbase, logger)\n\n const timeDiff = process.hrtime(startTime)\n logger.error({\n message: 'Error generating custom routes',\n error,\n type: 'custom-routes-generation-error',\n duration: timeDiff,\n })\n throw error\n }\n}\n\n```" } ]
code_store-sitemap_e92144cc
[ { "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-sitemap/node/middlewares/generateMiddlewares/groupEntries.test.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOContext, Logger, RequestConfig, Tenant, TenantClient, VBase, VBaseSaveResponse } from '@vtex/api'\nimport * as TypeMoq from 'typemoq'\n\nimport { Clients } from '../../clients'\nimport {\n CONFIG_BUCKET,\n GENERATION_CONFIG_FILE,\n getBucket,\n hashString,\n STORE_PRODUCT\n} from './../../utils'\nimport { FILE_LIMIT, FILE_PROCESS_LIMIT, groupEntries } from './groupEntries'\nimport {\n DEFAULT_CONFIG,\n GROUP_ENTRIES_EVENT,\n PRODUCT_ROUTES_INDEX,\n RAW_DATA_PREFIX,\n REWRITER_ROUTES_INDEX,\n SitemapEntry,\n SitemapIndex\n} from './utils'\n\nconst vbaseTypeMock = TypeMoq.Mock.ofInstance(VBase)\nconst contextMock = TypeMoq.Mock.ofType<EventContext>()\nconst ioContext = TypeMoq.Mock.ofType<IOContext>()\nconst state = TypeMoq.Mock.ofType<State>()\nconst loggerMock = TypeMoq.Mock.ofType<Logger>()\nconst tenantTypeMock = TypeMoq.Mock.ofInstance(TenantClient)\n\nconst BANANA_PRODUCT_ROUTE = {\n alternates: [\n { bindingId: '1', path: '/banana/p' },\n ],\n id: '1',\n path: '/banana/p',\n}\n\nconst APPLE_PRODUCT_ROUTE = {\n alternates: [\n { bindingId: '1', path: '/apple/p' },\n ],\n id: '2',\n path: '/apple/p',\n}\n\n\nlet next: any\n\ndescribe('Test group entries', () => {\n let context: EventContext\n let jsonData: Record<string, any> = {}\n\n const vbase = class VBaseMock extends vbaseTypeMock.object {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n\n constructor() {\n super(ioContext.object)\n }\n\n public getJSON = async <T>(\n bucket: string,\n file: string,\n nullOrUndefined?: boolean | undefined\n ): Promise<any> => {\n if (!jsonData[bucket]?.[file] && nullOrUndefined) {\n return (null as unknown) as T\n }\n return Promise.resolve(jsonData[bucket][file] as T)\n }\n\n public saveJSON = async <T>(\n bucket: string,\n file: string,\n data: T\n ): Promise<VBaseSaveResponse> => {\n if (!jsonData[bucket]) {\n jsonData[bucket] = {}\n }\n jsonData[bucket][file] = data\n return Promise.resolve(({\n updated: true,\n } as unknown) as VBaseSaveResponse)\n }\n\n public deleteFile = async (bucket: string, file: string, _: any, __: any): Promise<any> => {\n jsonData[bucket][file] = undefined\n return\n }\n }\n\n // tslint:disable-next-line:max-classes-per-file\n const tenant = class TenantMock extends tenantTypeMock.object {\n constructor() {\n super(ioContext.object)\n }\n\n public info = async (_?: RequestConfig) => {\n return {\n bindings: [\n {\n id: '1',\n targetProduct: STORE_PRODUCT,\n },\n ],\n } as Tenant\n }\n }\n\n beforeEach(() => {\n // tslint:disable-next-line:max-classes-per-file\n const ClientsImpl = class ClientsMock extends Clients {\n get vbase() {\n return this.getOrSet('vbase', vbase)\n }\n\n get vbaseWithCache() {\n return this.getOrSet('vbaseWithCache', vbase)\n }\n\n get tenant() {\n return this.getOrSet('tenant', tenant)\n }\n }\n\n jest.clearAllMocks()\n next = jest.fn()\n jsonData = {}\n\n context = {\n ...contextMock.object,\n clients: new ClientsImpl({}, ioContext.object),\n state: {\n ...state.object,\n enabledIndexFiles: [REWRITER_ROUTES_INDEX, PRODUCT_ROUTES_INDEX],\n },\n vtex: {\n ...ioContext.object,\n logger: loggerMock.object,\n },\n }\n const rawBucket = getBucket(RAW_DATA_PREFIX, hashString('1'))\n const { vbase: vbaseClient } = context.clients\n vbaseClient.saveJSON(rawBucket, PRODUCT_ROUTES_INDEX, { index: [] })\n vbaseClient.saveJSON(rawBucket, REWRITER_ROUTES_INDEX, { index: [] })\n })\n\n it('Should complete', async () => {\n const { vbase: vbaseClient } = context.clients\n\n context.body = { from: 0, indexFile: PRODUCT_ROUTES_INDEX }\n await groupEntries(context, next)\n\n let productCompleteFile = await vbaseClient.getJSON(CONFIG_BUCKET, PRODUCT_ROUTES_INDEX)\n expect(productCompleteFile).toBe('OK')\n\n context.body = { from: 0, indexFile: REWRITER_ROUTES_INDEX }\n await groupEntries(context, next)\n\n productCompleteFile = await vbaseClient.getJSON(CONFIG_BUCKET, PRODUCT_ROUTES_INDEX, true)\n const rewriterCompleteFile = await vbaseClient.getJSON(CONFIG_BUCKET, REWRITER_ROUTES_INDEX, true)\n const configCompleteFile = await vbaseClient.getJSON(CONFIG_BUCKET, GENERATION_CONFIG_FILE, true)\n expect(productCompleteFile).toBeNull()\n expect(rewriterCompleteFile).toBeNull()\n expect(configCompleteFile).toBeNull()\n })\n\n it('Should complete if enabled files were processed', async () => {\n const { vbase: vbaseClient } = context.clients\n context.state.enabledIndexFiles = [PRODUCT_ROUTES_INDEX]\n\n context.body = { from: 0, indexFile: PRODUCT_ROUTES_INDEX }\n await groupEntries(context, next)\n\n const productCompleteFile = await vbaseClient.getJSON(CONFIG_BUCKET, PRODUCT_ROUTES_INDEX, true)\n let configCompleteFile = await vbaseClient.getJSON(CONFIG_BUCKET, GENERATION_CONFIG_FILE, true)\n expect(productCompleteFile).toBeNull()\n expect(configCompleteFile).toBeNull()\n\n\n context.body = { from: 0, indexFile: REWRITER_ROUTES_INDEX }\n context.state.enabledIndexFiles = [REWRITER_ROUTES_INDEX]\n await groupEntries(context, next)\n\n const rewriterCompleteFile = await vbaseClient.getJSON(CONFIG_BUCKET, REWRITER_ROUTES_INDEX, true)\n configCompleteFile = await vbaseClient.getJSON(CONFIG_BUCKET, GENERATION_CONFIG_FILE, true)\n expect(rewriterCompleteFile).toBeNull()\n expect(configCompleteFile).toBeNull()\n })\n\n it('Should group data', async () => {\n const { vbase: vbaseClient } = context.clients\n context.body = { from: 0, indexFile: PRODUCT_ROUTES_INDEX }\n const { generationPrefix } = DEFAULT_CONFIG\n\n // Saves two product routes in different files\n const rawBucket = getBucket(RAW_DATA_PREFIX, hashString('1'))\n await vbaseClient.saveJSON(rawBucket, 'product-0', { routes: [BANANA_PRODUCT_ROUTE] })\n await vbaseClient.saveJSON(rawBucket, 'product-1', { routes: [APPLE_PRODUCT_ROUTE] })\n await vbaseClient.saveJSON(rawBucket, PRODUCT_ROUTES_INDEX, { index: ['product-0', 'product-1'] })\n\n await groupEntries(context, next)\n const bucket = getBucket(generationPrefix, hashString('1'))\n const { index } = await vbaseClient.getJSON<SitemapIndex>(bucket, PRODUCT_ROUTES_INDEX, true)\n const expectedIndex = ['product-0']\n expect(index).toStrictEqual(expectedIndex)\n const { routes } = await vbaseClient.getJSON<SitemapEntry>(bucket, expectedIndex[0])\n expect(routes).toStrictEqual([BANANA_PRODUCT_ROUTE, APPLE_PRODUCT_ROUTE])\n })\n\n it('Should create new file if one gets too big', async () => {\n const { vbase: vbaseClient } = context.clients\n context.body = { from: 0, indexFile: PRODUCT_ROUTES_INDEX }\n const { generationPrefix } = DEFAULT_CONFIG\n\n // Saves two product routes in different files\n const rawBucket = getBucket(RAW_DATA_PREFIX, hashString('1'))\n const tooManyRoutes = []\n for (let i = 0; i <= FILE_LIMIT; i++) {\n tooManyRoutes.push(\n {\n alternates: [\n { bindingId: '1', path: `/banana-${i}/p` },\n ],\n id: i,\n path: `/banana-${i}/p`,\n }\n )\n }\n await vbaseClient.saveJSON(rawBucket, 'product-0', { routes: tooManyRoutes })\n await vbaseClient.saveJSON(rawBucket, PRODUCT_ROUTES_INDEX, { index: ['product-0'] })\n\n await groupEntries(context, next)\n\n const bucket = getBucket(generationPrefix, hashString('1'))\n const { index } = await vbaseClient.getJSON<SitemapIndex>(bucket, PRODUCT_ROUTES_INDEX, true)\n const expectedIndex = ['product-0', 'product-1']\n expect(index).toStrictEqual(expectedIndex)\n\n const { routes: routes0 } = await vbaseClient.getJSON<SitemapEntry>(bucket, expectedIndex[0])\n expect(routes0.length).toEqual(FILE_LIMIT)\n\n const { routes: routes1 } = await vbaseClient.getJSON<SitemapEntry>(bucket, expectedIndex[1])\n expect(routes1.length).toEqual(1)\n })\n\n it('Next event is sent', async () => {\n const { vbase: vbaseClient } = context.clients\n\n // Saves a lot of routes\n const index = []\n const rawBucket = getBucket(RAW_DATA_PREFIX, hashString('1'))\n for (let i = 0; i <= FILE_PROCESS_LIMIT + 1; i++) {\n const file = `product-${i}`\n await vbaseClient.saveJSON(rawBucket, file, { routes: [BANANA_PRODUCT_ROUTE] })\n index.push(file)\n }\n await vbaseClient.saveJSON(rawBucket, PRODUCT_ROUTES_INDEX, { index })\n\n context.body = { from: 0, indexFile: PRODUCT_ROUTES_INDEX }\n await groupEntries(context, next)\n expect(next).toBeCalledWith()\n const { event, payload } = context.state.nextEvent\n expect(event).toEqual(GROUP_ENTRIES_EVENT)\n expect((payload as any)).toEqual({ from: FILE_PROCESS_LIMIT, indexFile: PRODUCT_ROUTES_INDEX })\n })\n\n it('Groups correctly over mutiple events', async () => {\n const { vbase: vbaseClient } = context.clients\n const { generationPrefix } = DEFAULT_CONFIG\n\n // Saves a lot of routes\n const index = []\n const rawBucket = getBucket(RAW_DATA_PREFIX, hashString('1'))\n for (let i = 0; i <= FILE_PROCESS_LIMIT + 1; i++) {\n const file = `product-${i}`\n await vbaseClient.saveJSON(rawBucket, file, { routes: [BANANA_PRODUCT_ROUTE] })\n index.push(file)\n }\n await vbaseClient.saveJSON(rawBucket, PRODUCT_ROUTES_INDEX, { index })\n\n context.body = { from: 0, indexFile: PRODUCT_ROUTES_INDEX }\n await groupEntries(context, next)\n context.body = { from: FILE_PROCESS_LIMIT , indexFile: PRODUCT_ROUTES_INDEX }\n await groupEntries(context, next)\n\n const productCompleteFile = await vbaseClient.getJSON(CONFIG_BUCKET, PRODUCT_ROUTES_INDEX)\n expect(productCompleteFile).toBe('OK')\n\n const bucket = getBucket(generationPrefix, hashString('1'))\n const { index: finalIndex } = await vbaseClient.getJSON<SitemapIndex>(bucket, PRODUCT_ROUTES_INDEX, true)\n const expectedIndex = ['product-0']\n expect(finalIndex).toStrictEqual(expectedIndex)\n })\n\n it('Should initialize', async () => {\n const { vbase: vbaseClient } = context.clients\n context.body = { from: 0, indexFile: PRODUCT_ROUTES_INDEX }\n const { generationPrefix } = DEFAULT_CONFIG\n\n const bucket = getBucket(generationPrefix, hashString('1'))\n await vbaseClient.saveJSON(bucket, PRODUCT_ROUTES_INDEX, { index: ['product-0', 'product-1'] })\n\n // Saves two product routes in different files\n const rawBucket = getBucket(RAW_DATA_PREFIX, hashString('1'))\n await vbaseClient.saveJSON(rawBucket, 'product-0', { routes: [BANANA_PRODUCT_ROUTE] })\n await vbaseClient.saveJSON(rawBucket, 'product-1', { routes: [APPLE_PRODUCT_ROUTE] })\n await vbaseClient.saveJSON(rawBucket, PRODUCT_ROUTES_INDEX, { index: ['product-0', 'product-1'] })\n\n await groupEntries(context, next)\n\n const { index } = await vbaseClient.getJSON<SitemapIndex>(bucket, PRODUCT_ROUTES_INDEX, true)\n const expectedIndex = ['product-0']\n expect(index).toStrictEqual(expectedIndex)\n })\n})\n\n```" } ]
code_store-sitemap_d0205973
[ { "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-sitemap/node/middlewares/generateMiddlewares/generateAppsRoutes.test.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {\n Apps,\n IOContext,\n Logger,\n RequestConfig,\n Tenant,\n TenantClient,\n VBase,\n VBaseSaveResponse\n} from '@vtex/api'\nimport * as TypeMoq from 'typemoq'\n\nimport { Clients } from '../../clients'\nimport { CONFIG_BUCKET, getBucket, hashString } from '../../utils'\nimport { } from './../../clients/rewriter'\nimport { generateAppsRoutes } from './generateAppsRoutes'\nimport { APPS_ROUTES_INDEX, DEFAULT_CONFIG, SitemapEntry, SitemapIndex } from './utils'\n\nconst tenantTypeMock = TypeMoq.Mock.ofInstance(TenantClient)\nconst appsTypeMock = TypeMoq.Mock.ofInstance(Apps)\nconst vbaseTypeMock = TypeMoq.Mock.ofInstance(VBase)\nconst contextMock = TypeMoq.Mock.ofType<EventContext>()\nconst ioContext = TypeMoq.Mock.ofType<IOContext>()\nconst state = TypeMoq.Mock.ofType<State>()\nconst loggerMock = TypeMoq.Mock.ofType<Logger>()\n\n\ndescribe('Test rewriter routes generation', () => {\n let context: EventContext\n\n const vbase = class VBaseMock extends vbaseTypeMock.object {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private jsonData: Record<string, any> = {}\n\n constructor() {\n super(ioContext.object)\n }\n\n public getJSON = async <T>(\n bucket: string,\n file: string,\n nullOrUndefined?: boolean | undefined\n ): Promise<T> => {\n if (!this.jsonData[bucket]?.[file] && nullOrUndefined) {\n return (null as unknown) as T\n }\n return Promise.resolve(this.jsonData[bucket][file] as T)\n }\n\n public saveJSON = async <T>(\n bucket: string,\n file: string,\n data: T\n ): Promise<VBaseSaveResponse> => {\n if (!this.jsonData[bucket]) {\n this.jsonData[bucket] = {}\n }\n this.jsonData[bucket][file] = data\n return ({ etag: 'etag' } as unknown) as VBaseSaveResponse\n }\n }\n\n // tslint:disable-next-line:max-classes-per-file\n const tenant = class TenantMock extends tenantTypeMock.object {\n constructor() {\n super(ioContext.object)\n }\n\n public info = async (_?: RequestConfig) => {\n return {\n bindings: [\n {\n id: '1',\n },\n {\n id: '2',\n },\n ],\n } as Tenant\n }\n }\n\n // tslint:disable-next-line:max-classes-per-file\n const apps = class AppsMock extends appsTypeMock.object {\n private builds: Record<string, any> = {\n ['vtex.app1@1.0.0']: {\n entries: ['/entry-1', '/entry-2'],\n },\n ['vtex.app2@1.0.0']: {\n entries: ['/entry-3'],\n },\n ['vtex.app3@1.0.0']: {\n },\n }\n constructor() {\n super(ioContext.object)\n }\n\n public getAppsMetaInfos = () => {\n return [\n { id: 'vtex.app1@1.0.0' },\n { id: 'vtex.app2@1.0.0' },\n { id: 'vtex.app3@1.0.0' },\n ] as any\n }\n\n public getAppJSON = (app: string, _: string, __?: boolean) => {\n return this.builds[app]\n }\n\n public setBuild = (app: string, data: any) => {\n this.builds[app] = data\n }\n }\n\n beforeEach(() => {\n // tslint:disable-next-line:max-classes-per-file\n const ClientsImpl = class ClientsMock extends Clients {\n get vbase() {\n return this.getOrSet('vbase', vbase)\n }\n\n get apps() {\n return this.getOrSet('apps', apps)\n\n }\n\n get tenant() {\n return this.getOrSet('tenant', tenant)\n }\n }\n context = {\n ...contextMock.object,\n body: {\n generationId: '1',\n },\n clients: new ClientsImpl({}, ioContext.object),\n state: {\n ...state.object,\n },\n vtex: {\n ...ioContext.object,\n logger: loggerMock.object,\n },\n }\n })\n\n it('Routes were saved', async () => {\n await generateAppsRoutes(context)\n const { vbase: vbaseClient } = context.clients\n const bucket = getBucket(DEFAULT_CONFIG.generationPrefix, hashString('1'))\n const { index } = await vbaseClient.getJSON<SitemapIndex>(bucket, APPS_ROUTES_INDEX, true)\n const expectedIndex = ['appsRoutes-0']\n expect(index).toStrictEqual(expectedIndex)\n const { routes: appsRoutes } = await vbaseClient.getJSON<SitemapEntry>(bucket, expectedIndex[0])\n expect(appsRoutes).toStrictEqual([\n { id: '/entry-1', path: '/entry-1' },\n { id: '/entry-2', path: '/entry-2' },\n { id: '/entry-3', path: '/entry-3' },\n ])\n\n const appsCompleteFile = await vbaseClient.getJSON(CONFIG_BUCKET, APPS_ROUTES_INDEX)\n expect(appsCompleteFile).toBe('OK')\n })\n\n it('Splits routes if too many saved', async () => {\n const { vbase: vbaseClient, } = context.clients\n const appsClient = context.clients.apps as any\n\n const tooManyRoutes = new Array(5000).fill('/entry-1')\n const appsMetaInfos = await appsClient.getAppsMetaInfos()\n appsClient.setBuild(appsMetaInfos[0].id, { entries: tooManyRoutes })\n\n await generateAppsRoutes(context)\n const bucket = getBucket(DEFAULT_CONFIG.generationPrefix, hashString('1'))\n const { index } = await vbaseClient.getJSON<SitemapIndex>(bucket, APPS_ROUTES_INDEX, true)\n const expectedIndex = ['appsRoutes-0', 'appsRoutes-1']\n expect(index).toStrictEqual(expectedIndex)\n\n const { routes: routes0} = await vbaseClient.getJSON<SitemapEntry>(bucket, expectedIndex[0])\n expect(routes0.length).toEqual(5000)\n\n const { routes: routes1 } = await vbaseClient.getJSON<SitemapEntry>(bucket, expectedIndex[1])\n expect(routes1.length).toEqual(1)\n })\n})\n\n```" } ]
code_store-sitemap_a5c58022
[ { "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-sitemap/node/middlewares/generateMiddlewares/generateProductRoutes.test.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport {\n CatalogGraphQL,\n IOContext,\n Logger,\n RequestConfig,\n RequestTracingConfig,\n Tenant,\n TenantClient,\n VBase,\n VBaseSaveResponse\n} from '@vtex/api'\nimport { Product } from '@vtex/api/lib/clients/apps/catalogGraphQL/product'\nimport * as TypeMoq from 'typemoq'\nimport { TranslateArgs } from 'vtex.messages'\n\nimport { Clients } from '../../clients'\nimport { Messages } from '../../clients/messages'\nimport { getBucket, hashString } from '../../utils'\nimport { Catalog, GetProductsAndSkuIdsReponse } from './../../clients/catalog'\nimport { GraphQLServer, ProductNotFound } from './../../clients/graphqlServer'\nimport { STORE_PRODUCT } from './../../utils'\nimport { generateProductRoutes } from './generateProductRoutes'\nimport {\n GENERATE_PRODUCT_ROUTES_EVENT,\n GROUP_ENTRIES_EVENT,\n initializeSitemap,\n PRODUCT_ROUTES_INDEX,\n RAW_DATA_PREFIX,\n SitemapEntry,\n SitemapIndex,\n} from './utils'\n\n\nconst tenantTypeMock = TypeMoq.Mock.ofInstance(TenantClient)\nconst messagesTypeMock = TypeMoq.Mock.ofInstance(Messages)\nconst graphqlServerTypeMock = TypeMoq.Mock.ofInstance(GraphQLServer)\nconst catalogTypeMock = TypeMoq.Mock.ofInstance(Catalog)\nconst catalogGraphQLTypeMock = TypeMoq.Mock.ofInstance(CatalogGraphQL)\nconst vbaseTypeMock = TypeMoq.Mock.ofInstance(VBase)\nconst contextMock = TypeMoq.Mock.ofType<EventContext>()\nconst ioContext = TypeMoq.Mock.ofType<IOContext>()\nconst state = TypeMoq.Mock.ofType<State>()\nconst loggerMock = TypeMoq.Mock.ofType<Logger>()\n\n\nlet next: any\nlet tenantInfo = {\n bindings: [\n {\n defaultLocale: 'en-US',\n extraContext: {\n portal: {\n salesChannel: '1',\n },\n },\n id: '1',\n targetProduct: STORE_PRODUCT,\n },\n {\n defaultLocale: 'pt-BR',\n extraContext: {\n portal: {\n salesChannel: '1',\n },\n },\n id: '2',\n targetProduct: STORE_PRODUCT,\n },\n ] as any,\n defaultLocale: 'en-US',\n}\n\ndescribe('Test product routes generation', () => {\n let context: EventContext\n\n const vbase = class VBaseMock extends vbaseTypeMock.object {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private jsonData: Record<string, any> = {}\n\n constructor() {\n super(ioContext.object)\n }\n\n public getJSON = async <T>(\n bucket: string,\n file: string,\n nullOrUndefined?: boolean | undefined\n ): Promise<T> => {\n if (!this.jsonData[bucket]?.[file] && nullOrUndefined) {\n return (null as unknown) as T\n }\n return Promise.resolve(this.jsonData[bucket][file] as T)\n }\n\n public saveJSON = async <T>(\n bucket: string,\n file: string,\n data: T\n ): Promise<VBaseSaveResponse> => {\n if (!this.jsonData[bucket]) {\n this.jsonData[bucket] = {}\n }\n this.jsonData[bucket][file] = data\n return Promise.resolve({}) as Promise<VBaseSaveResponse>\n }\n }\n\n // tslint:disable-next-line:max-classes-per-file\n const tenant = class TenantMock extends tenantTypeMock.object {\n constructor() {\n super(ioContext.object)\n }\n\n public info = async (_?: RequestConfig) => {\n return tenantInfo as Tenant\n }\n }\n\n // tslint:disable-next-line:max-classes-per-file\n const catalog = class CatalogMock extends catalogTypeMock.object {\n constructor() {\n super(ioContext.object)\n }\n\n public getProductsIds = async (page: number) => {\n switch (page) {\n case 2:\n return {\n items: [4, 5, 6],\n paging: { pages: 2, total: 51 },\n } as unknown as GetProductsAndSkuIdsReponse\n default:\n return {\n items: [1, 2, 3],\n paging: { pages: 2, total: 51 },\n } as unknown as GetProductsAndSkuIdsReponse\n }\n }\n }\n\n // tslint:disable-next-line:max-classes-per-file\n const catalogGraphQL = class CatalogGraphQLMock extends catalogGraphQLTypeMock.object {\n constructor() {\n super(ioContext.object)\n }\n\n public product = async (productId: string, _?: RequestTracingConfig) => {\n let product\n switch (productId) {\n case '1':\n product = {\n id: '1',\n isActive: true,\n linkId: 'banana',\n salesChannel: [{ id: '1' }],\n }\n break\n case '2':\n product = {\n id: '2',\n isActive: false,\n linkId: 'inactive-banana',\n salesChannel: [{ id: '1' }],\n }\n break\n case '3':\n product = {\n id: '3',\n isActive: true,\n linkId: 'apple',\n salesChannel: [{ id: '1' }],\n }\n break\n case '4':\n product = {\n id: '4',\n isActive: true,\n linkId: 'watermelon',\n salesChannel: [{ id: '1' }],\n }\n break\n case '5':\n product = {\n id: '5',\n isActive: true,\n linkId: 'pinnaple',\n salesChannel: [{ id: '1' }],\n }\n break\n default:\n product = undefined\n break\n }\n return {\n product: product as unknown as Product,\n }\n }\n }\n\n // tslint:disable-next-line:max-classes-per-file\n const graphqlServer = class GraphqlServerMock extends graphqlServerTypeMock.object {\n constructor() {\n super(ioContext.object)\n }\n\n public query = async (_: string, variables: any, __: any) => {\n if (variables.identifier.value === '3') {\n throw new ProductNotFound([])\n }\n return 'something-not-null' as any\n }\n }\n\n // tslint:disable-next-line:max-classes-per-file\n const messages = class MessagesMock extends messagesTypeMock.object {\n constructor() {\n super(ioContext.object)\n }\n\n public translateNoCache = async (args: TranslateArgs) => {\n return args.indexedByFrom[0].messages.map(({ content }: any) => content)\n }\n }\n\n\n\n beforeEach(() => {\n // tslint:disable-next-line:max-classes-per-file\n const ClientsImpl = class ClientsMock extends Clients {\n get vbase() {\n return this.getOrSet('vbase', vbase)\n }\n\n get catalog() {\n return this.getOrSet('catalog', catalog)\n }\n\n get catalogGraphQL() {\n return this.getOrSet('catalogGraphQL', catalogGraphQL)\n }\n\n get messages() {\n return this.getOrSet('messages', messages)\n }\n\n get graphqlServer() {\n return this.getOrSet('graphqlServer', graphqlServer)\n }\n\n get tenant() {\n return this.getOrSet('tenant', tenant)\n }\n }\n context = {\n ...contextMock.object,\n body: {\n generationId: '1',\n invalidProducts: 0,\n page: 1,\n processedProducts: 0,\n },\n clients: new ClientsImpl({}, ioContext.object),\n state: {\n ...state.object,\n },\n vtex: {\n ...ioContext.object,\n logger: loggerMock.object,\n },\n }\n next = jest.fn()\n })\n\n it('Next event is sent', async () => {\n await generateProductRoutes(context, next)\n expect(next).toBeCalled()\n const { event, payload } = context.state.nextEvent\n expect(event).toEqual(GENERATE_PRODUCT_ROUTES_EVENT)\n expect((payload as any).page).toEqual(2)\n })\n\n it('Complete event is sent', async () => {\n const thisContext = {\n ...context,\n body: {\n ...context.body,\n page: 2,\n },\n }\n await initializeSitemap(thisContext, PRODUCT_ROUTES_INDEX)\n await generateProductRoutes(thisContext, next)\n expect(next).toBeCalled()\n expect(context.state.nextEvent).toStrictEqual({\n event: GROUP_ENTRIES_EVENT,\n payload: { from: 0, generationId: '1', indexFile: 'productRoutesIndex.json' },\n })\n })\n\n it('Routes were saved', async () => {\n await generateProductRoutes(context, next)\n const { vbase: vbaseClient } = context.clients\n const bucket = getBucket(RAW_DATA_PREFIX, hashString('1'))\n const { index } = await vbaseClient.getJSON<SitemapIndex>(bucket, PRODUCT_ROUTES_INDEX, true)\n const expectedIndex = ['product-1']\n expect(index).toStrictEqual(expectedIndex)\n const { routes } = await vbaseClient.getJSON<SitemapEntry>(bucket, expectedIndex[0])\n expect(routes).toStrictEqual([\n {\n alternates: [\n { bindingId: '1', path: '/banana/p' },\n { bindingId: '2', path: '/banana/p' },\n ],\n id: '1',\n path: '/banana/p',\n },\n ])\n })\n\n it('Checks binding without SC case', async () => {\n tenantInfo = {\n bindings: [\n {\n defaultLocale: 'en-US',\n extraContext: {},\n id: '1',\n targetProduct: STORE_PRODUCT,\n },\n ],\n defaultLocale: 'en-US',\n } as Tenant\n await generateProductRoutes(context, next)\n const { vbase: vbaseClient } = context.clients\n const bucket = getBucket(RAW_DATA_PREFIX, hashString('1'))\n const { index } = await vbaseClient.getJSON<SitemapIndex>(bucket, PRODUCT_ROUTES_INDEX, true)\n const expectedIndex = ['product-1']\n expect(index).toStrictEqual(expectedIndex)\n const { routes } = await vbaseClient.getJSON<SitemapEntry>(bucket, expectedIndex[0])\n expect(routes).toStrictEqual([\n {\n alternates: [\n { bindingId: '1', path: '/banana/p' },\n ],\n id: '1',\n path: '/banana/p',\n },\n ])\n })\n})\n\n```" } ]
code_store-sitemap_28b156c9
[ { "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-sitemap/node/middlewares/generateMiddlewares/groupEntries.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { last } from 'ramda'\nimport { CONFIG_BUCKET, CONFIG_FILE, getBucket, getStoreBindings, hashString } from '../../utils'\nimport {\n cleanConfigBucket,\n completeRoutes,\n createFileName,\n currentDate,\n DEFAULT_CONFIG,\n GROUP_ENTRIES_EVENT,\n isSitemapComplete,\n RAW_DATA_PREFIX,\n SitemapEntry,\n SitemapIndex,\n splitFileName,\n uniq\n} from './utils'\n\nexport const FILE_PROCESS_LIMIT = 750\nexport const FILE_LIMIT = 5000\n\nconst reduceByEntity = (array: string[]) => array.reduce((acc, file) => {\n const entity = splitFileName(file)[0]\n if (!acc[entity]) {\n acc[entity] = []\n }\n acc[entity].push(file)\n return acc\n}, {} as Record<string, string[]>)\n\nconst groupEntityEntries = async (entity: string, files: string[], index: string[] | undefined, bucket: string, rawBucket: string, ctx: EventContext) => {\n const { clients: { vbase, vbaseWithCache }, vtex: { logger } } = ctx\n const lastFile = index && last(index)\n const lastFileData = lastFile ? await vbaseWithCache.getJSON<SitemapEntry>(bucket, lastFile) : { routes: [] as Route[] }\n let currentRoutes = lastFileData.routes\n let routesCount = currentRoutes.length\n let count = lastFile ? Number(splitFileName(lastFile)[1]) : 0\n\n const newFiles: string[] = []\n for (const file of files) {\n const { routes } = await vbase.getJSON<SitemapEntry>(rawBucket, file)\n routesCount += routes.length\n currentRoutes = [...currentRoutes, ...routes]\n if (currentRoutes.length > FILE_LIMIT) {\n const rest = currentRoutes.splice(FILE_LIMIT)\n const entry = createFileName(entity, count)\n newFiles.push(entry)\n await vbase.saveJSON<SitemapEntry>(bucket, entry, {\n lastUpdated: currentDate(),\n routes: uniq(currentRoutes),\n })\n currentRoutes = rest\n count++\n }\n }\n if (currentRoutes.length > 0) {\n const entry = createFileName(entity, count)\n newFiles.push(entry)\n await vbase.saveJSON<SitemapEntry>(bucket, entry, {\n lastUpdated: currentDate(),\n routes: uniq(currentRoutes),\n })\n }\n logger.info({\n count: routesCount,\n entity,\n messages: 'Routes grouped',\n })\n return newFiles\n}\n\nexport async function groupEntries(ctx: EventContext, next: () => Promise<void>) {\n const {\n body,\n clients: {\n tenant,\n vbase,\n vbaseWithCache,\n },\n vtex: {\n logger,\n },\n state: {\n enabledIndexFiles,\n },\n } = ctx\n const { indexFile, generationId, from }: GroupEntriesEvent = body\n\n const { generationPrefix, productionPrefix } = await vbaseWithCache.getJSON<Config>(CONFIG_BUCKET, CONFIG_FILE, true) || DEFAULT_CONFIG\n const storeBindings = await getStoreBindings(tenant)\n\n const isBindingGroupingComplete = await Promise.all(storeBindings.map(async binding => {\n const rawBucket = getBucket(RAW_DATA_PREFIX, hashString(binding.id))\n const bucket = getBucket(generationPrefix, hashString(binding.id))\n const indexData = await vbase.getJSON<SitemapIndex>(rawBucket, indexFile)\n const rawIndex = uniq(indexData.index)\n const { index: newIndex } = from === 0\n ? { index: [] as string[] }\n : await vbase.getJSON<SitemapIndex>(bucket, indexFile, true) || { index: []as string[] }\n\n if (from > rawIndex.length) {\n return true\n }\n const slicedRawIndex = rawIndex.slice(from, from + FILE_PROCESS_LIMIT)\n const filesByEntity = reduceByEntity(slicedRawIndex)\n const indexByEntity = reduceByEntity(newIndex)\n const entries = await Promise.all(\n Object.keys(filesByEntity).map(async entity =>\n groupEntityEntries(\n entity,\n filesByEntity[entity],\n indexByEntity[entity],\n bucket,\n rawBucket,\n ctx\n )\n ))\n\n const index = uniq(entries.reduce((acc, entryList) => acc.concat(entryList), newIndex))\n await vbase.saveJSON<SitemapIndex>(bucket, indexFile, {\n index,\n lastUpdated: currentDate(),\n })\n\n return from + FILE_PROCESS_LIMIT > rawIndex.length\n }))\n\n const isAllGroupingsComplete = isBindingGroupingComplete.every(Boolean)\n if (isAllGroupingsComplete) {\n await completeRoutes(indexFile, vbase)\n\n const isComplete = await isSitemapComplete(enabledIndexFiles, vbase, logger)\n if (isComplete) {\n await vbase.saveJSON<Config>(CONFIG_BUCKET, CONFIG_FILE, {\n generationPrefix: productionPrefix,\n productionPrefix: generationPrefix,\n })\n await cleanConfigBucket(enabledIndexFiles, vbase)\n logger.info({ message: `Sitemap complete`, payload: body })\n return\n }\n } else {\n ctx.state.nextEvent = {\n event: GROUP_ENTRIES_EVENT,\n payload: {\n from: from + FILE_PROCESS_LIMIT,\n generationId,\n indexFile,\n },\n }\n\n await next()\n }\n}\n\n```" } ]
code_store-sitemap_55f08f69
[ { "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-sitemap/node/middlewares/generateMiddlewares/generateRewriterRoutes.test.ts from the store-sitemap VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IOContext, Logger, RequestConfig, Tenant, TenantClient, VBase, VBaseSaveResponse } from '@vtex/api'\nimport * as TypeMoq from 'typemoq'\nimport { EntityLocator, Internal } from 'vtex.rewriter'\n\nimport { Clients } from '../../clients'\nimport { getBucket, hashString } from '../../utils'\nimport { Rewriter } from './../../clients/rewriter'\nimport { generateRewriterRoutes } from './generateRewriterRoutes'\nimport {\n GENERATE_REWRITER_ROUTES_EVENT,\n GROUP_ENTRIES_EVENT,\n initializeSitemap,\n RAW_DATA_PREFIX,\n REWRITER_ROUTES_INDEX,\n SitemapEntry,\n SitemapIndex,\n} from './utils'\n\nconst tenantTypeMock = TypeMoq.Mock.ofInstance(TenantClient)\nconst rewriterTypeMock = TypeMoq.Mock.ofInstance(Rewriter)\nconst vbaseTypeMock = TypeMoq.Mock.ofInstance(VBase)\nconst contextMock = TypeMoq.Mock.ofType<EventContext>()\nconst ioContext = TypeMoq.Mock.ofType<IOContext>()\nconst state = TypeMoq.Mock.ofType<State>()\nconst loggerMock = TypeMoq.Mock.ofType<Logger>()\n\n\nlet next: any\n\ndescribe('Test rewriter routes generation', () => {\n let context: EventContext\n\n const vbase = class VBaseMock extends vbaseTypeMock.object {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private jsonData: Record<string, any> = {}\n\n constructor() {\n super(ioContext.object)\n }\n\n public getJSON = async <T>(\n bucket: string,\n file: string,\n nullOrUndefined?: boolean | undefined\n ): Promise<T> => {\n if (!this.jsonData[bucket]?.[file] && nullOrUndefined) {\n return (null as unknown) as T\n }\n return Promise.resolve(this.jsonData[bucket][file] as T)\n }\n\n public saveJSON = async <T>(\n bucket: string,\n file: string,\n data: T\n ): Promise<VBaseSaveResponse> => {\n if (!this.jsonData[bucket]) {\n this.jsonData[bucket] = {}\n }\n this.jsonData[bucket][file] = data\n return Promise.resolve(({\n updated: true,\n } as unknown) as VBaseSaveResponse)\n }\n }\n\n // tslint:disable-next-line:max-classes-per-file\n const tenant = class TenantMock extends tenantTypeMock.object {\n constructor() {\n super(ioContext.object)\n }\n\n public info = async (_?: RequestConfig) => {\n return {\n bindings: [\n {\n id: '1',\n targetProduct: 'vtex-storefront',\n },\n {\n id: '2',\n },\n ],\n } as Tenant\n }\n }\n\n // tslint:disable-next-line:max-classes-per-file\n const rewriter = class RewriterMock extends rewriterTypeMock.object {\n constructor() {\n super(ioContext.object)\n }\n\n public routesById = async (_: EntityLocator) => {\n return []\n }\n\n public listInternals = async (_: number, cursor: Maybe<string>) => {\n switch(cursor) {\n case 'NEXT':\n return {\n next: null,\n routes: [\n {\n binding: '1',\n from: '/fruits',\n id: '1',\n type: 'department',\n },\n {\n binding: '1',\n from: '/coconut-water',\n id: '2',\n type: 'brand',\n },\n {\n binding: '2',\n from: '/coconut-water',\n id: '2',\n type: 'brand',\n },\n ] as Internal[],\n }\n default:\n return {\n next: 'NEXT',\n routes: [\n {\n binding: '1',\n from: '/fruits/citrics',\n id: '3',\n type: 'category',\n },\n {\n binding: '1',\n from: '/market',\n id: '4',\n type: 'userRoute',\n },\n {\n binding: '1',\n disableSitemapEntry: true,\n from: '/banana-routes',\n id: '5',\n type: 'user-canonical',\n },\n ] as Internal[],\n }\n }\n }\n }\n\n beforeEach(() => {\n // tslint:disable-next-line:max-classes-per-file\n const ClientsImpl = class ClientsMock extends Clients {\n get vbase() {\n return this.getOrSet('vbase', vbase)\n }\n\n get rewriter() {\n return this.getOrSet('rewriter', rewriter)\n }\n\n get tenant() {\n return this.getOrSet('tenant', tenant)\n }\n }\n context = {\n ...contextMock.object,\n body: {\n count: 0,\n generationId: '1',\n next: null,\n report: {},\n },\n clients: new ClientsImpl({}, ioContext.object),\n state: {\n ...state.object,\n },\n vtex: {\n ...ioContext.object,\n logger: loggerMock.object,\n },\n }\n next = jest.fn()\n })\n\n it('Next event is sent', async () => {\n await generateRewriterRoutes(context, next)\n expect(next).toBeCalled()\n expect(context.state.nextEvent).toStrictEqual({\n event: GENERATE_REWRITER_ROUTES_EVENT,\n payload: {\n count: 1,\n generationId: '1',\n next: 'NEXT',\n report: { category: 1, 'user-canonical': 1, userRoute: 1 },\n },\n })\n })\n\n it('Complete event is sent', async () => {\n const thisContext = {\n ...context,\n body: {\n ...context.body,\n count: 1,\n next: 'NEXT',\n report: { category: 1, userRoute: 1 },\n },\n }\n await initializeSitemap(thisContext, REWRITER_ROUTES_INDEX)\n await generateRewriterRoutes(thisContext, next)\n expect(next).toBeCalled()\n expect(context.state.nextEvent).toStrictEqual({\n event: GROUP_ENTRIES_EVENT,\n payload: { from: 0, generationId: '1', indexFile: 'rewriterRoutesIndex.json' },\n }\n )\n })\n\n it('Routes were saved', async () => {\n await generateRewriterRoutes(context, next)\n const { vbase: vbaseClient } = context.clients\n const bucket = getBucket(RAW_DATA_PREFIX, hashString('1'))\n const { index } = await vbaseClient.getJSON<SitemapIndex>(bucket, REWRITER_ROUTES_INDEX, true)\n const expectedIndex = ['category-0', 'userRoute-0']\n expect(index).toStrictEqual(expectedIndex)\n const { routes: categoryRoutes } = await vbaseClient.getJSON<SitemapEntry>(bucket, expectedIndex[0])\n expect(categoryRoutes).toStrictEqual([\n {\n alternates: [],\n id: '3',\n imagePath: undefined,\n imageTitle: undefined,\n path: '/fruits/citrics',\n },\n ])\n const { routes: userRoutes } = await vbaseClient.getJSON<SitemapEntry>(bucket, expectedIndex[1])\n expect(userRoutes).toStrictEqual( [\n {\n alternates: [],\n id: '4',\n imagePath: undefined,\n imageTitle: undefined,\n path: '/market',\n },\n ])\n })\n})\n\n```" } ]
code_events-example_bc12222c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of events-example/docs/README.md from the events-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Events Example\n\nApp in VTEX IO designed to send events using a time interval and IO's Events system.\n\n### How it works?\n\n```" } ]
code_events-example_a9f21367
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of events-example/node/service.json from the events-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"memory\": 128,\n \"ttl\": 10,\n \"timeout\": 2,\n \"minReplicas\": 2,\n \"maxReplicas\": 10,\n \"workers\": 4,\n \"events\": {\n \"example\": {\n \"sender\": \"vtex.events-example\",\n \"keys\": [\"send-event\"]\n }\n },\n \"routes\": {\n \"hcheck\": {\n \"path\": \"/_v/app/events-example/hcheck\",\n \"public\": true\n }\n }\n}\n\n```" } ]
code_events-example_c30caf10
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of events-example/node/package.json from the events-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"co-body\": \"^6.0.0\"\n },\n \"devDependencies\": {\n \"@types/co-body\": \"^0.0.3\",\n \"@types/node\": \"12.x\",\n \"@vtex/api\": \"6.44.0\",\n \"@vtex/tsconfig\": \"^0.5.6\",\n \"typescript\": \"3.9.7\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty && eslint -c .eslintrc.json --fix './**/*.ts'\"\n },\n \"version\": \"0.7.2\"\n}\n\n```" } ]
code_events-example_7086960b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of events-example/node/constants.ts from the events-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport const ENABLED_GLOBALLY = true\n\nexport const EVENT_EXAMPLE = 'send-event'\n\nexport const TIME_INTERVAL = 10\n\n```" } ]
code_events-example_4f9c400f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of events-example/node/index.ts from the events-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type {\n IOClients,\n ParamsContext,\n ServiceContext,\n RecorderState,\n} from '@vtex/api'\nimport { Service } from '@vtex/api'\n\nimport { example } from './events/example'\nimport { createSendEvent } from './routes/notify'\nimport { getCacheContext, setCacheContext } from './utils/cachedContext'\n\nconst TREE_SECONDS_MS = 3 * 1000\nconst CONCURRENCY = 10\n\ndeclare global {\n type Context = ServiceContext<IOClients, State>\n\n interface State extends RecorderState {\n code: number\n }\n}\n\nfunction sendEventWithTimer() {\n setInterval(function () {\n const context = getCacheContext()\n\n if (!context) {\n console.log('no context in memory')\n\n return\n }\n\n return createSendEvent(context)\n }, 30000)\n console.log('FIRED HERE')\n}\n\nsendEventWithTimer()\n\nexport default new Service<IOClients, State, ParamsContext>({\n clients: {\n options: {\n events: {\n exponentialTimeoutCoefficient: 2,\n exponentialBackoffCoefficient: 2,\n initialBackoffDelay: 50,\n retries: 1,\n timeout: TREE_SECONDS_MS,\n concurrency: CONCURRENCY,\n },\n },\n },\n events: {\n example,\n },\n routes: {\n hcheck: (ctx: any) => {\n setCacheContext(ctx)\n ctx.set('Cache-Control', 'no-cache')\n ctx.status = 200\n ctx.body = 'ok'\n },\n },\n})\n\n```" } ]
code_events-example_2c1b2c05
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of events-example/node/utils/randomNumber.ts from the events-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport function getRandomNumber() {\n return Math.round(Math.random() * 100)\n}\n\n```" } ]
code_events-example_7367be3a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of events-example/node/utils/cachedContext.ts from the events-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nlet context: any = null\n\nexport const getCacheContext = () => {\n return context\n}\n\nexport function setCacheContext(ctx: any) {\n context = ctx\n}\n\n```" } ]
code_events-example_53d816e0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of events-example/node/events/example.ts from the events-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { EventContext, IOClients } from '@vtex/api'\n\nexport async function example(ctx: EventContext<IOClients>) {\n console.log('RECEIVED EVENT', ctx.body)\n\n return true\n}\n\n```" } ]
code_events-example_365257ac
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of events-example/node/routes/notify.ts from the events-example VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { EVENT_EXAMPLE } from '../constants'\nimport { getRandomNumber } from '../utils/randomNumber'\n\nexport async function createSendEvent(ctx: Context) {\n await ctx.clients.events.sendEvent('', EVENT_EXAMPLE, {\n random: getRandomNumber().toString(),\n })\n ctx.status = 200\n ctx.body = 'Event sent'\n console.log('SENT EVENT')\n}\n\n// my comment\n\n```" } ]
code_product-bookmark-interfaces_0d2caa12
[ { "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 product-bookmark-interfaces/example/README.md from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Wish list app example\n\nThis is an example of how a wish list app would integrate with the store framework.\n\n## Troubleshooting\n\n## Block does not appear in the product page\n\nMake sure you have in your `blocks.json`:\n\n```diff\n \"store.product\": {\n \"blocks\": [\n // ...other blocks\n+ \"product-bookmark\",\n // ...other blocks\n ]\n }\n```\n\n## Block does not appear in shelf\n\nMake sure to add the block in the summary:\n\n```diff\n \"product-summary.shelf\": {\n \"children\": [\n // ...other blocks\n+ \"product-bookmark\",\n // ...other blocks\n ]\n }\n```\n\n```" } ]
code_product-bookmark-interfaces_4dd1db18
[ { "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 product-bookmark-interfaces/example/package.json from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"version\": \"0.0.0\",\n \"scripts\": {\n \"lint\": \"cd ./react && yarn lint\",\n \"test\": \"cd ./react && yarn test --passWithNoTests\",\n \"lint:locales\": \"intl-equalizer\",\n \"locales:fix\": \"intl-equalizer --fix\",\n \"verify\": \"yarn lint && yarn lint:locales && yarn test\"\n },\n \"dependencies\": {\n \"react-intl\": \"^3.10.0\"\n },\n \"devDependencies\": {\n \"@vtex/intl-equalizer\": \"^2.3.0\",\n \"@vtex/prettier-config\": \"^0.0.1\",\n \"husky\": \"^2.4.1\"\n },\n \"prettier\": \"@vtex/prettier-config\",\n \"husky\": {\n \"hooks\": {\n \"pre-commit\": \"yarn lint && yarn lint:locales && yarn locales:fix\",\n \"pre-push\": \"yarn verify\"\n }\n },\n \"intl-equalizer\": {\n \"referenceLocale\": \"en\",\n \"localeDirectory\": \"messages\"\n }\n}\n\n```" } ]
code_product-bookmark-interfaces_9f93bc8a
[ { "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 product-bookmark-interfaces/example/manifest.json from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"vendor\": \"vtex\",\n \"name\": \"wishlist-app-example\",\n \"version\": \"0.0.1\",\n \"title\": \"Wishlist App Example\",\n \"description\": \"Example app of a wishlist app in the platform.\",\n \"builders\": {\n \"messages\": \"1.x\",\n \"store\": \"0.x\",\n \"react\": \"3.x\"\n },\n \"dependencies\": {\n \"vtex.product-bookmark-interfaces\": \"1.x\",\n \"vtex.product-summary\": \"2.x\",\n \"vtex.product-context\": \"0.x\",\n \"vtex.store\": \"2.x\",\n \"vtex.styleguide\": \"9.x\",\n \"vtex.store-icons\": \"0.x\",\n \"vtex.css-handles\": \"0.x\"\n },\n \"settingsSchema\": {\n \"title\": \"Wishlist Example\",\n \"type\": \"object\",\n \"properties\": {\n \"storeId\": {\n \"title\": \"Store ID\",\n \"description\": \"Enter your Store ID\",\n \"type\": \"string\"\n },\n \"productBinding\": {\n \"title\": \"Product Reference\",\n \"type\": \"string\",\n \"default\": \"productId\",\n \"enum\": [\n \"productId\",\n \"refId\",\n \"skuId\",\n \"slug\"\n ]\n }\n }\n },\n \"$schema\": \"https://raw.githubusercontent.com/vtex/node-vtex-api/master/gen/manifest.schema\"\n}\n```" } ]
code_product-bookmark-interfaces_f085bcc4
[ { "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 product-bookmark-interfaces/docs/README.md from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Product Bookmark Interfaces\n\n> Interfaces for a wishlist or list app.\n\nThis app provides extensible interfaces that can be used by the `vtex.store` and a theme app. A wishlist or list app would depend on this app and extend the interfaces provided to become available in the store.\n\nYou can see an example of a wishlist app [here](/example).\n\n```" } ]
code_product-bookmark-interfaces_381e37a8
[ { "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 product-bookmark-interfaces/react/package.json from the product-bookmark-interfaces 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 \"react\": \"^16.8.3\",\n \"react-dom\": \"^16.8.3\"\n },\n \"prettier\": \"@vtex/prettier-config\",\n \"devDependencies\": {\n \"@types/graphql\": \"^14.2.0\",\n \"@types/jest\": \"^24.0.11\",\n \"@types/node\": \"^11.13.0\",\n \"@types/prop-types\": \"^15.7.0\",\n \"@types/react\": \"^16.8.10\",\n \"@vtex/prettier-config\": \"^0.0.1\",\n \"apollo-client\": \"^2.5.1\",\n \"eslint\": \"^5.16.0\",\n \"eslint-config-vtex\": \"^10.1.0\",\n \"prettier\": \"^1.19.1\",\n \"typescript\": \"3.7.3\"\n },\n \"version\": \"1.0.1\"\n}\n\n```" } ]
code_product-bookmark-interfaces_8688b20b
[ { "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 product-bookmark-interfaces/react/Noop.tsx from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FunctionComponent } from 'react'\n\nconst Noop: FunctionComponent = () => <></>\n\nexport default Noop\n\n```" } ]
code_product-bookmark-interfaces_a7fc5a7b
[ { "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 product-bookmark-interfaces/store/interfaces.json from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"product-bookmark\": {\n \"component\": \"Noop\",\n \"extensible\": \"public\"\n }\n}\n```" } ]
code_product-bookmark-interfaces_feb21400
[ { "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 product-bookmark-interfaces/example/messages/pt.json from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/wishlist.added\": \"Produto adicionado à sua lista de desejos\",\n \"store/wishlist.removed\": \"Produto removido da sua lista de desejos\"\n}\n```" } ]
code_product-bookmark-interfaces_9d1b2fe6
[ { "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 product-bookmark-interfaces/example/messages/en.json from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/wishlist.added\": \"Product added to your wishlist\",\n \"store/wishlist.removed\": \"Product removed from your wishlist\"\n}\n\n```" } ]
code_product-bookmark-interfaces_290a93f1
[ { "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 product-bookmark-interfaces/example/messages/es.json from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/wishlist.added\": \"Producto agregado a la lista de deseos\",\n \"store/wishlist.removed\": \"Producto eliminado de la lista de deseos\"\n}\n```" } ]
code_product-bookmark-interfaces_7895f987
[ { "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 product-bookmark-interfaces/example/react/ProductBookmark.tsx from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FC, MouseEvent, useState } from 'react'\nimport { defineMessages, useIntl } from 'react-intl'\nimport { IconBookmark } from 'vtex.store-icons'\nimport { withToast } from 'vtex.styleguide'\nimport { useCssHandles } from 'vtex.css-handles'\nimport useProduct from 'vtex.product-context/useProduct'\n\nconst CSS_HANDLES = ['productBookmark'] as const\n\nconst messages = defineMessages({\n added: {\n id: 'store/wishlist.added',\n defaultMessage: '',\n },\n removed: {\n id: 'store/wishlist.removed',\n defaultMessage: '',\n },\n})\n\nconst Bookmark: FC<Props> = ({ showToast }) => {\n const handles = useCssHandles(CSS_HANDLES)\n const { formatMessage } = useIntl()\n const [filled, setFill] = useState(false)\n const productContext = useProduct()\n\n const handleClick = (ev: MouseEvent) => {\n ev.stopPropagation()\n ev.preventDefault()\n setFill(!filled)\n if (productContext && productContext.product) {\n // eslint-disable-next-line no-console\n console.log('Product ' + productContext.product.productName)\n }\n showToast({\n message: filled\n ? formatMessage(messages.removed)\n : formatMessage(messages.added),\n duration: 3000,\n })\n }\n\n return (\n <div className={handles.productBookmark}>\n <button\n onClick={handleClick}\n className=\"bn pa3 pointer flex bg-action-secondary c-on-action-secondary hover-c-on-action-secondary\"\n >\n <IconBookmark\n type={filled ? 'filled' : 'outline'}\n fill=\"currentColor\"\n />\n </button>\n </div>\n )\n}\n\ninterface ShowToastParams {\n message: string\n duration?: number\n action?: { label: string; onClick: Function }\n}\n\ninterface Props {\n showToast: (params: ShowToastParams) => void\n}\n\nexport default withToast(Bookmark)\n\n```" } ]
code_product-bookmark-interfaces_e5a853d4
[ { "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 product-bookmark-interfaces/example/react/package.json from the product-bookmark-interfaces 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 \"apollo-client\": \"^2.6.8\",\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\": \"^3.1.3\",\n \"@types/graphql\": \"^14.5.0\",\n \"@types/jest\": \"^24.9.0\",\n \"@types/node\": \"^13.1.8\",\n \"@types/react\": \"^16.9.19\",\n \"@types/react-intl\": \"^3.0.0\",\n \"@vtex/test-tools\": \"^3.0.0\",\n \"@vtex/tsconfig\": \"^0.2.0\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"eslint\": \"5.x\",\n \"eslint-config-vtex-react\": \"^5.1.0\",\n \"graphql\": \"^14.5.8\",\n \"prettier\": \"^1.18.2\",\n \"prop-types\": \"^15.7.2\",\n \"typescript\": \"3.7.3\"\n }\n}\n\n```" } ]
code_product-bookmark-interfaces_85db2e4a
[ { "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 product-bookmark-interfaces/example/store/interfaces.json from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"product-bookmark.example-wishlist\": {\n \"component\": \"ProductBookmark\"\n }\n}\n\n```" } ]
code_product-bookmark-interfaces_8c9b50f6
[ { "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 product-bookmark-interfaces/example/store/plugins.json from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"product-bookmark\": \"product-bookmark.example-wishlist\"\n}\n\n```" } ]
code_product-bookmark-interfaces_c19bab3e
[ { "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 product-bookmark-interfaces/example/react/typings/storefront.d.ts from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent, ReactElement } from 'react'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n schema?: object\n }\n\n interface StorefrontComponent<P = {}, S = {}> extends Component<P, S> {\n schema: object\n }\n}\n\n```" } ]
code_product-bookmark-interfaces_cd9c740a
[ { "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 product-bookmark-interfaces/example/react/typings/vtex.product-context.d.ts from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.product-context' {\n import { Context } from 'react'\n\n interface ProductContext {\n product: any\n }\n\n export const ProductContext = Context\n}\n\ndeclare module 'vtex.product-context/useProduct'\n\n```" } ]
code_product-bookmark-interfaces_5384cd1a
[ { "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 product-bookmark-interfaces/example/react/typings/vtex.store-icons.d.ts from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.store-icons' {\n export const IconBookmark\n}\n\n```" } ]
code_product-bookmark-interfaces_84ab19f8
[ { "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 product-bookmark-interfaces/example/react/typings/css.d.ts from the product-bookmark-interfaces 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_product-bookmark-interfaces_8e23a8de
[ { "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 product-bookmark-interfaces/example/react/typings/graphql.d.ts from the product-bookmark-interfaces 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_product-bookmark-interfaces_942099fd
[ { "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 product-bookmark-interfaces/example/react/typings/vtex.product-summary.d.ts from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.product-summary' {\n import { Context } from 'react'\n\n interface ProductSummary {\n product: any\n }\n\n export const ProductSummaryContext = Context\n}\n\n```" } ]
code_product-bookmark-interfaces_de512314
[ { "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 product-bookmark-interfaces/example/react/typings/vtex.styleguide.d.ts from the product-bookmark-interfaces VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.styleguide' {\n export const withToast\n}\n\n```" } ]
code_native-types_a6386ec7
[ { "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 native-types/messages/el-GR.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Εμπορική επωνυμία\",\n \"admin/native-types.category\": \"Κατηγορία\",\n \"admin/native-types.collection\": \"Συλλογή\",\n \"admin/native-types.department\": \"Τμήμα\",\n \"admin/native-types.image\": \"Εικόνα\",\n \"admin/native-types.image.description\": \"Περιγραφή\",\n \"admin/native-types.image.desktop\": \"Επιφάνεια εργασίας\",\n \"admin/native-types.image.filename\": \"Όνομα αρχείου\",\n \"admin/native-types.image.mobile\": \"Κινητό\",\n \"admin/native-types.link\": \"Σύνδεση\",\n \"admin/native-types.link.attributeNofollow\": \"Χαρακτηριστικό nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Χαρακτηριστικό title\",\n \"admin/native-types.link.newTab\": \"Νέα καρτέλα\",\n \"admin/native-types.link.url\": \"διεύθυνση URL\",\n \"admin/native-types.richText\": \"Εμπλουτισμένο κείμενο\",\n \"admin/native-types.text\": \"Κείμενο\",\n \"admin/native-types.url\": \"διεύθυνση URL\",\n \"admin/native-types.video.description\": \"Περιγραφή\",\n \"admin/native-types.video.thumbnail\": \"μικρογραφία\",\n \"admin/native-types.video\": \"Βίντεο\",\n \"admin/native-types.video.title\": \"Τίτλος\",\n \"admin/native-types.video.url\": \"διεύθυνση URL\",\n \"store/native-types.text\": \"Θέση για το κείμενό σας\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Λειτουργεί :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_fc8d328f
[ { "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 native-types/messages/it-IT.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Brand\",\n \"admin/native-types.category\": \"Categoria\",\n \"admin/native-types.collection\": \"Collezione\",\n \"admin/native-types.department\": \"Reparto\",\n \"admin/native-types.image\": \"Immagine\",\n \"admin/native-types.image.description\": \"Descrizione\",\n \"admin/native-types.image.desktop\": \"Desktop\",\n \"admin/native-types.image.filename\": \"Nome del file\",\n \"admin/native-types.image.mobile\": \"Mobile\",\n \"admin/native-types.link\": \"Link\",\n \"admin/native-types.link.attributeNofollow\": \"Attributo nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Attributo title\",\n \"admin/native-types.link.newTab\": \"Nuova scheda\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Rich text\",\n \"admin/native-types.text\": \"Testo\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Descrizione\",\n \"admin/native-types.video.thumbnail\": \"Anteprima\",\n \"admin/native-types.video\": \"Video\",\n \"admin/native-types.video.title\": \"Titolo\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Inserisci qui il tuo testo\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://esempio.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Funziona!\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_79ad9f84
[ { "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 native-types/messages/th-TH.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"แบรนด์\",\n \"admin/native-types.category\": \"หมวดหมู่\",\n \"admin/native-types.collection\": \"คอลเลกชัน\",\n \"admin/native-types.department\": \"แผนก\",\n \"admin/native-types.image\": \"รูปภาพ\",\n \"admin/native-types.image.description\": \"คำอธิบาย\",\n \"admin/native-types.image.desktop\": \"เดสก์ท็อป\",\n \"admin/native-types.image.filename\": \"ชื่อไฟล์\",\n \"admin/native-types.image.mobile\": \"มือถือ\",\n \"admin/native-types.link\": \"ลิงก์\",\n \"admin/native-types.link.attributeNofollow\": \"แอททริบิวต์ nofollow\",\n \"admin/native-types.link.attributeTitle\": \"แอททริบิวต์ title\",\n \"admin/native-types.link.newTab\": \"แท็บใหม่\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Rich Text\",\n \"admin/native-types.text\": \"ข้อความ\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"คำอธิบาย\",\n \"admin/native-types.video.thumbnail\": \"ภาพตัวอย่างขนาดเล็ก\",\n \"admin/native-types.video\": \"วิดีโอ\",\n \"admin/native-types.video.title\": \"ชื่อหัวข้อ\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"ข้อความของคุณที่นี่\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"มันใช้การได้ :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_03699bd6
[ { "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 native-types/messages/ko-KR.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"브랜드\",\n \"admin/native-types.category\": \"카테고리\",\n \"admin/native-types.collection\": \"컬렉션\",\n \"admin/native-types.department\": \"부문\",\n \"admin/native-types.image\": \"이미지\",\n \"admin/native-types.image.description\": \"설명\",\n \"admin/native-types.image.desktop\": \"데스크톱\",\n \"admin/native-types.image.filename\": \"파일이름\",\n \"admin/native-types.image.mobile\": \"모바일\",\n \"admin/native-types.link\": \"링크\",\n \"admin/native-types.link.attributeNofollow\": \"속성 nofollow\",\n \"admin/native-types.link.attributeTitle\": \"속성 title\",\n \"admin/native-types.link.newTab\": \"새 탭\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"리치 텍스트\",\n \"admin/native-types.text\": \"텍스트\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"설명\",\n \"admin/native-types.video.thumbnail\": \"섬네일\",\n \"admin/native-types.video\": \"비디오\",\n \"admin/native-types.video.title\": \"제목\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"여기 텍스트\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"작동함 :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_d21da3b9
[ { "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 native-types/messages/nn-NO.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Merke\",\n \"admin/native-types.category\": \"Kategori\",\n \"admin/native-types.collection\": \"Samling\",\n \"admin/native-types.department\": \"Avdeling\",\n \"admin/native-types.image\": \"Bilde\",\n \"admin/native-types.image.description\": \"Beskrivelse\",\n \"admin/native-types.image.desktop\": \"Skrivebord\",\n \"admin/native-types.image.filename\": \"Filnavn\",\n \"admin/native-types.image.mobile\": \"Mobil\",\n \"admin/native-types.link\": \"Lenke\",\n \"admin/native-types.link.attributeNofollow\": \"Kjennetegn på ingen følgere\",\n \"admin/native-types.link.attributeTitle\": \"Tittel på kjennetegn\",\n \"admin/native-types.link.newTab\": \"Ny fane\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Rik tekst\",\n \"admin/native-types.text\": \"Tekst\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Beskrivelse\",\n \"admin/native-types.video.thumbnail\": \"Miniatyrbilde\",\n \"admin/native-types.video\": \"Video\",\n \"admin/native-types.video.title\": \"Tittel\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Din tekst her\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Det fungerer :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_74a7ef65
[ { "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 native-types/messages/ja-JP.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"ブランド\",\n \"admin/native-types.category\": \"カテゴリ\",\n \"admin/native-types.collection\": \"コレクション\",\n \"admin/native-types.department\": \"部門\",\n \"admin/native-types.image\": \"画像\",\n \"admin/native-types.image.description\": \"説明\",\n \"admin/native-types.image.desktop\": \"デスクトップ\",\n \"admin/native-types.image.filename\": \"ファイル名\",\n \"admin/native-types.image.mobile\": \"モバイル\",\n \"admin/native-types.link\": \"リンク\",\n \"admin/native-types.link.attributeNofollow\": \"nofollow 属性\",\n \"admin/native-types.link.attributeTitle\": \"title 属性\",\n \"admin/native-types.link.newTab\": \"新規タブ\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"リッチテキスト\",\n \"admin/native-types.text\": \"テキスト\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"説明\",\n \"admin/native-types.video.thumbnail\": \"サムネイル\",\n \"admin/native-types.video\": \"動画\",\n \"admin/native-types.video.title\": \"タイトル\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"テキストはこちらです\",\n \"store/native-types.richText\": \"ダミーテキスト…\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"有効です :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_f69b1a22
[ { "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 native-types/messages/bg-BG.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Бранд\",\n \"admin/native-types.category\": \"Категория\",\n \"admin/native-types.collection\": \"Колекция\",\n \"admin/native-types.department\": \"Отдел\",\n \"admin/native-types.image\": \"Изображение\",\n \"admin/native-types.image.description\": \"Описание\",\n \"admin/native-types.image.desktop\": \"Настолен компютър\",\n \"admin/native-types.image.filename\": \"Име на файл\",\n \"admin/native-types.image.mobile\": \"Мобилен телефон\",\n \"admin/native-types.link\": \"Връзка\",\n \"admin/native-types.link.attributeNofollow\": \"Атрибут nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Атрибут title\",\n \"admin/native-types.link.newTab\": \"Нов раздел\",\n \"admin/native-types.link.url\": \"URL адрес\",\n \"admin/native-types.richText\": \"RTF текст\",\n \"admin/native-types.text\": \"Текст\",\n \"admin/native-types.url\": \"URL адрес\",\n \"admin/native-types.video.description\": \"Описание\",\n \"admin/native-types.video.thumbnail\": \"Миниатюра\",\n \"admin/native-types.video\": \"Видео\",\n \"admin/native-types.video.title\": \"Заглавие\",\n \"admin/native-types.video.url\": \"URL адрес\",\n \"store/native-types.text\": \"Вашият текст тук\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Работи :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_2653e07d
[ { "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 native-types/messages/id-ID.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Merek\",\n \"admin/native-types.category\": \"Kategori\",\n \"admin/native-types.collection\": \"Koleksi\",\n \"admin/native-types.department\": \"Departemen\",\n \"admin/native-types.image\": \"Gambar\",\n \"admin/native-types.image.description\": \"Deskripsi\",\n \"admin/native-types.image.desktop\": \"Desktop\",\n \"admin/native-types.image.filename\": \"Nama File\",\n \"admin/native-types.image.mobile\": \"Seluler\",\n \"admin/native-types.link\": \"Tautan\",\n \"admin/native-types.link.attributeNofollow\": \"Nofollow atribut\",\n \"admin/native-types.link.attributeTitle\": \"Judul atribut\",\n \"admin/native-types.link.newTab\": \"Tab baru\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Teks Kaya\",\n \"admin/native-types.text\": \"Teks\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Deskripsi\",\n \"admin/native-types.video.thumbnail\": \"Gambar mini\",\n \"admin/native-types.video\": \"Video\",\n \"admin/native-types.video.title\": \"Judul\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Teks Anda di sini\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Berhasil :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_0b066dbc
[ { "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 native-types/messages/pt.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Marca\",\n \"admin/native-types.category\": \"Categoria\",\n \"admin/native-types.collection\": \"Coleção\",\n \"admin/native-types.department\": \"Departamento\",\n \"admin/native-types.image\": \"Imagem\",\n \"admin/native-types.image.description\": \"Descrição\",\n \"admin/native-types.image.desktop\": \"Computador\",\n \"admin/native-types.image.filename\": \"Nome do arquivo\",\n \"admin/native-types.image.mobile\": \"Dispositivos móveis\",\n \"admin/native-types.link\": \"Link\",\n \"admin/native-types.link.attributeNofollow\": \"Atributo nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Atributo title\",\n \"admin/native-types.link.newTab\": \"Nova aba\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Rich text\",\n \"admin/native-types.text\": \"Texto\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Descrição\",\n \"admin/native-types.video.thumbnail\": \"Miniatura\",\n \"admin/native-types.video\": \"Vídeo\",\n \"admin/native-types.video.title\": \"Título\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Insira seu texto aqui\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://exemplo.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Funcionou!\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_47a4f0e6
[ { "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 native-types/messages/ar-SA.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"العلامة التجارية\",\n \"admin/native-types.category\": \"القسم 2\",\n \"admin/native-types.collection\": \"المجموعة\",\n \"admin/native-types.department\": \"القسم 1\",\n \"admin/native-types.image\": \"الصورة\",\n \"admin/native-types.image.description\": \"الوصف\",\n \"admin/native-types.image.desktop\": \"المكتب\",\n \"admin/native-types.image.filename\": \"اسم الملف\",\n \"admin/native-types.image.mobile\": \"الجوال\",\n \"admin/native-types.link\": \"الرابط\",\n \"admin/native-types.link.attributeNofollow\": \"متابعة السمة\",\n \"admin/native-types.link.attributeTitle\": \"عنوان السمة\",\n \"admin/native-types.link.newTab\": \"علامة تبويب جديدة\",\n \"admin/native-types.link.url\": \"الرابط\",\n \"admin/native-types.richText\": \"محرر متطور\",\n \"admin/native-types.text\": \"النص\",\n \"admin/native-types.url\": \"الرابط\",\n \"admin/native-types.video.description\": \"الوصف\",\n \"admin/native-types.video.thumbnail\": \"الصورة المصغرة\",\n \"admin/native-types.video\": \"الفيديو\",\n \"admin/native-types.video.title\": \"العنوان\",\n \"admin/native-types.video.url\": \"الرابط\",\n \"store/native-types.text\": \"نصك هنا\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"إنه يعمل :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_b49555b1
[ { "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 native-types/messages/en.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Brand\",\n \"admin/native-types.category\": \"Category\",\n \"admin/native-types.collection\": \"Collection\",\n \"admin/native-types.department\": \"Department\",\n \"admin/native-types.image\": \"Image\",\n \"admin/native-types.image.description\": \"Description\",\n \"admin/native-types.image.desktop\": \"Desktop\",\n \"admin/native-types.image.filename\": \"File name\",\n \"admin/native-types.image.mobile\": \"Mobile\",\n \"admin/native-types.link\": \"Link\",\n \"admin/native-types.link.attributeNofollow\": \"Nofollow attribute\",\n \"admin/native-types.link.attributeTitle\": \"Title attribute\",\n \"admin/native-types.link.newTab\": \"New tab\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Rich text\",\n \"admin/native-types.text\": \"Text\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Description\",\n \"admin/native-types.video.thumbnail\": \"Thumbnail\",\n \"admin/native-types.video\": \"Video\",\n \"admin/native-types.video.title\": \"Title\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Your text here\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"It works :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_c6cf13b2
[ { "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 native-types/messages/no-NO.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Merke\",\n \"admin/native-types.category\": \"Kategori\",\n \"admin/native-types.collection\": \"Samling\",\n \"admin/native-types.department\": \"Avdeling\",\n \"admin/native-types.image\": \"Bilde\",\n \"admin/native-types.image.description\": \"Beskrivelse\",\n \"admin/native-types.image.desktop\": \"Skrivebord\",\n \"admin/native-types.image.filename\": \"Filnavn\",\n \"admin/native-types.image.mobile\": \"Mobil\",\n \"admin/native-types.link\": \"Lenke\",\n \"admin/native-types.link.attributeNofollow\": \"Kjennetegn på ingen følgere\",\n \"admin/native-types.link.attributeTitle\": \"Tittel på kjennetegn\",\n \"admin/native-types.link.newTab\": \"Ny fane\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Rik tekst\",\n \"admin/native-types.text\": \"Tekst\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Beskrivelse\",\n \"admin/native-types.video.thumbnail\": \"Miniatyrbilde\",\n \"admin/native-types.video\": \"Video\",\n \"admin/native-types.video.title\": \"Tittel\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Din tekst her\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Det fungerer :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_d8e6e373
[ { "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 native-types/messages/sv-SE.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Varumärke\",\n \"admin/native-types.category\": \"Kategori\",\n \"admin/native-types.collection\": \"Samling\",\n \"admin/native-types.department\": \"Avdelning\",\n \"admin/native-types.image\": \"Bild\",\n \"admin/native-types.image.description\": \"Beskrivning\",\n \"admin/native-types.image.desktop\": \"Skrivbord\",\n \"admin/native-types.image.filename\": \"Filnamn\",\n \"admin/native-types.image.mobile\": \"Mobil\",\n \"admin/native-types.link\": \"Koppla\",\n \"admin/native-types.link.attributeNofollow\": \"Attribut nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Attribut title\",\n \"admin/native-types.link.newTab\": \"Ny flik\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"RTF\",\n \"admin/native-types.text\": \"Text\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Beskrivning\",\n \"admin/native-types.video.thumbnail\": \"Miniatyr\",\n \"admin/native-types.video\": \"Video\",\n \"admin/native-types.video.title\": \"Rubrik\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Skriv din text här\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Det fungerar :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_5b388a9e
[ { "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 native-types/messages/ro-RO.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Marcă\",\n \"admin/native-types.category\": \"Categorie\",\n \"admin/native-types.collection\": \"Colecție\",\n \"admin/native-types.department\": \"Raion\",\n \"admin/native-types.image\": \"Imagine\",\n \"admin/native-types.image.description\": \"Descriere\",\n \"admin/native-types.image.desktop\": \"Desktop\",\n \"admin/native-types.image.filename\": \"Denumire fișier\",\n \"admin/native-types.image.mobile\": \"Mobil\",\n \"admin/native-types.link\": \"Link\",\n \"admin/native-types.link.attributeNofollow\": \"Atribut nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Titlu atribut\",\n \"admin/native-types.link.newTab\": \"Filă nouă\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Text îmbogățit\",\n \"admin/native-types.text\": \"Text\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Descriere\",\n \"admin/native-types.video.thumbnail\": \"Miniatură\",\n \"admin/native-types.video\": \"Video\",\n \"admin/native-types.video.title\": \"Titlu\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Textul tău aici\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Funcționează :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_a6a688aa
[ { "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 native-types/messages/sk-SK.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Značka\",\n \"admin/native-types.category\": \"Kategória\",\n \"admin/native-types.collection\": \"Kolekcia\",\n \"admin/native-types.department\": \"Departement\",\n \"admin/native-types.image\": \"Obrázok\",\n \"admin/native-types.image.description\": \"Popis\",\n \"admin/native-types.image.desktop\": \"Stolný počítač\",\n \"admin/native-types.image.filename\": \"Názov súboru\",\n \"admin/native-types.image.mobile\": \"Mobil\",\n \"admin/native-types.link\": \"Prepojenie\",\n \"admin/native-types.link.attributeNofollow\": \"Atribút nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Atribút title\",\n \"admin/native-types.link.newTab\": \"Nová karta\",\n \"admin/native-types.link.url\": \"URL adresa\",\n \"admin/native-types.richText\": \"Text vo formáte RTF\",\n \"admin/native-types.text\": \"Text\",\n \"admin/native-types.url\": \"URL adresa\",\n \"admin/native-types.video.description\": \"Popis\",\n \"admin/native-types.video.thumbnail\": \"Miniatúra\",\n \"admin/native-types.video\": \"Video\",\n \"admin/native-types.video.title\": \"Názov\",\n \"admin/native-types.video.url\": \"URL adresa\",\n \"store/native-types.text\": \"Sem zadajte text\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Funguje to :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_607e3c59
[ { "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 native-types/messages/uk-UA.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Бренд\",\n \"admin/native-types.category\": \"Категорія\",\n \"admin/native-types.collection\": \"Колекція\",\n \"admin/native-types.department\": \"Департамент\",\n \"admin/native-types.image\": \"Зображення\",\n \"admin/native-types.image.description\": \"Опис\",\n \"admin/native-types.image.desktop\": \"Настільний комп’ютер\",\n \"admin/native-types.image.filename\": \"Ім’я файлу\",\n \"admin/native-types.image.mobile\": \"Мобільний телефон\",\n \"admin/native-types.link\": \"Посилання\",\n \"admin/native-types.link.attributeNofollow\": \"Атрибут nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Атрибут title\",\n \"admin/native-types.link.newTab\": \"Нова вкладка\",\n \"admin/native-types.link.url\": \"Текст RTF\",\n \"admin/native-types.richText\": \"Текст RTF\",\n \"admin/native-types.text\": \"Текст\",\n \"admin/native-types.url\": \"Aдреса URL\",\n \"admin/native-types.video.description\": \"Опис\",\n \"admin/native-types.video.thumbnail\": \"Ескіз\",\n \"admin/native-types.video\": \"Відео\",\n \"admin/native-types.video.title\": \"Назва\",\n \"admin/native-types.video.url\": \"Aдреса URL\",\n \"store/native-types.text\": \"Місце для вставлення тексту\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Спрацювало! :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_ae20afb0
[ { "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 native-types/messages/pl-PL.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Marka\",\n \"admin/native-types.category\": \"Kategoria\",\n \"admin/native-types.collection\": \"Kolekcja\",\n \"admin/native-types.department\": \"Wydział\",\n \"admin/native-types.image\": \"Obraz\",\n \"admin/native-types.image.description\": \"Opis\",\n \"admin/native-types.image.desktop\": \"Komputer stacjonarny\",\n \"admin/native-types.image.filename\": \"Nazwa pliku\",\n \"admin/native-types.image.mobile\": \"Mobilne\",\n \"admin/native-types.link\": \"Połączyć\",\n \"admin/native-types.link.attributeNofollow\": \"Atrybut nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Atrybut title\",\n \"admin/native-types.link.newTab\": \"Nowa karta\",\n \"admin/native-types.link.url\": \"Adres URL\",\n \"admin/native-types.richText\": \"Tekstu sformatowanego\",\n \"admin/native-types.text\": \"Text\",\n \"admin/native-types.url\": \"Adres URL\",\n \"admin/native-types.video.description\": \"Opis\",\n \"admin/native-types.video.thumbnail\": \"Miniatura\",\n \"admin/native-types.video\": \"Wideo\",\n \"admin/native-types.video.title\": \"Tytuł\",\n \"admin/native-types.video.url\": \"Adres URL\",\n \"store/native-types.text\": \"Tutaj twój tekst\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Działa :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_880cd4cb
[ { "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 native-types/messages/da-DK.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Brand\",\n \"admin/native-types.category\": \"Kategori\",\n \"admin/native-types.collection\": \"Indsamling\",\n \"admin/native-types.department\": \"Afdeling\",\n \"admin/native-types.image\": \"Billede\",\n \"admin/native-types.image.description\": \"Beskrivelse\",\n \"admin/native-types.image.desktop\": \"Desktop\",\n \"admin/native-types.image.filename\": \"Filnavn\",\n \"admin/native-types.image.mobile\": \"Mobil\",\n \"admin/native-types.link\": \"Link\",\n \"admin/native-types.link.attributeNofollow\": \"Attribut nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Attribut title\",\n \"admin/native-types.link.newTab\": \"Ny fane\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Rig tekst\",\n \"admin/native-types.text\": \"Tekst\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Beskrivelse\",\n \"admin/native-types.video.thumbnail\": \"Miniaturebillede\",\n \"admin/native-types.video\": \"Video\",\n \"admin/native-types.video.title\": \"Titel\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Din tekst her\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://eksempel.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Det virker :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_4c4fb9e2
[ { "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 native-types/messages/context.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"admin/native-types.brand\",\n \"admin/native-types.category\": \"admin/native-types.category\",\n \"admin/native-types.collection\": \"admin/native-types.collection\",\n \"admin/native-types.department\": \"admin/native-types.department\",\n \"admin/native-types.image\": \"admin/native-types.image\",\n \"admin/native-types.image.description\": \"admin/native-types.image.description\",\n \"admin/native-types.image.desktop\": \"admin/native-types.image.desktop\",\n \"admin/native-types.image.filename\": \"admin/native-types.image.filename\",\n \"admin/native-types.image.mobile\": \"admin/native-types.image.mobile\",\n \"admin/native-types.link\": \"admin/native-types.link\",\n \"admin/native-types.link.attributeNofollow\": \"admin/native-types.link.attributeNofollow\",\n \"admin/native-types.link.attributeTitle\": \"admin/native-types.link.attributeTitle\",\n \"admin/native-types.link.newTab\": \"admin/native-types.link.newTab\",\n \"admin/native-types.link.url\": \"admin/native-types.link.url\",\n \"admin/native-types.richText\": \"admin/native-types.richText\",\n \"admin/native-types.text\": \"admin/native-types.text\",\n \"admin/native-types.url\": \"admin/native-types.url\",\n \"admin/native-types.video.description\": \"admin/native-types.video.description\",\n \"admin/native-types.video.thumbnail\": \"admin/native-types.video.thumbnail\",\n \"admin/native-types.video\": \"admin/native-types.video\",\n \"admin/native-types.video.title\": \"admin/native-types.video.title\",\n \"admin/native-types.video.url\": \"admin/native-types.video.url\",\n \"store/native-types.text\": \"Text field\",\n \"store/native-types.richText\": \"Rich text field\",\n \"store/native-types.url\": \"URL field\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"It works :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_258bd6d1
[ { "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 native-types/messages/de-DE.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Marke\",\n \"admin/native-types.category\": \"Kategorie\",\n \"admin/native-types.collection\": \"Kollektion\",\n \"admin/native-types.department\": \"Abteilung\",\n \"admin/native-types.image\": \"Bild\",\n \"admin/native-types.image.description\": \"Beschreibung\",\n \"admin/native-types.image.desktop\": \"Desktop\",\n \"admin/native-types.image.filename\": \"Dateiname\",\n \"admin/native-types.image.mobile\": \"Mobil\",\n \"admin/native-types.link\": \"Verknüpfen\",\n \"admin/native-types.link.attributeNofollow\": \"Attribut nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Attribut title\",\n \"admin/native-types.link.newTab\": \"Neues Register\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Richt-Text\",\n \"admin/native-types.text\": \"Text\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Beschreibung\",\n \"admin/native-types.video.thumbnail\": \"Miniaturansicht\",\n \"admin/native-types.video\": \"Video\",\n \"admin/native-types.video.title\": \"Titel\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Typ hier und tekst\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Es funktioniert :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_d72fa9da
[ { "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 native-types/messages/ca-ES.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Marca\",\n \"admin/native-types.category\": \"Categoria\",\n \"admin/native-types.collection\": \"Col·lecció\",\n \"admin/native-types.department\": \"Departament\",\n \"admin/native-types.image\": \"Imatge\",\n \"admin/native-types.image.description\": \"Descripció\",\n \"admin/native-types.image.desktop\": \"Ordinador d'escriptori\",\n \"admin/native-types.image.filename\": \"Nom del fitxer\",\n \"admin/native-types.image.mobile\": \"Mòbil\",\n \"admin/native-types.link\": \"Enllaç\",\n \"admin/native-types.link.attributeNofollow\": \"Atribut nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Atribut title\",\n \"admin/native-types.link.newTab\": \"Pestanya nova\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Text enriquit\",\n \"admin/native-types.text\": \"Text\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Descripció\",\n \"admin/native-types.video.thumbnail\": \"Miniatura\",\n \"admin/native-types.video\": \"Vídeo\",\n \"admin/native-types.video.title\": \"Títol\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"El vostre text aquí\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Funciona :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subjecte} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_4e259cc2
[ { "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 native-types/messages/cs-CZ.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Značka\",\n \"admin/native-types.category\": \"Kategorie\",\n \"admin/native-types.collection\": \"Kolekce\",\n \"admin/native-types.department\": \"Oddělení\",\n \"admin/native-types.image\": \"Obrázek\",\n \"admin/native-types.image.description\": \"Popis\",\n \"admin/native-types.image.desktop\": \"Počítač\",\n \"admin/native-types.image.filename\": \"Název souboru\",\n \"admin/native-types.image.mobile\": \"Mobil\",\n \"admin/native-types.link\": \"Odkaz\",\n \"admin/native-types.link.attributeNofollow\": \"Atribut nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Atribut title\",\n \"admin/native-types.link.newTab\": \"Nová záložka\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Formátovaný text\",\n \"admin/native-types.text\": \"Text\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Popis\",\n \"admin/native-types.video.thumbnail\": \"Miniatura\",\n \"admin/native-types.video\": \"Video\",\n \"admin/native-types.video.title\": \"Název\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Sem napište text\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Funguje to :-)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_e676db69
[ { "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 native-types/messages/fr-FR.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Marque\",\n \"admin/native-types.category\": \"Catégorie\",\n \"admin/native-types.collection\": \"Collection\",\n \"admin/native-types.department\": \"Département\",\n \"admin/native-types.image\": \"Image\",\n \"admin/native-types.image.description\": \"Description\",\n \"admin/native-types.image.desktop\": \"Bureau\",\n \"admin/native-types.image.filename\": \"Nom du fichier\",\n \"admin/native-types.image.mobile\": \"Mobile\",\n \"admin/native-types.link\": \"Lien\",\n \"admin/native-types.link.attributeNofollow\": \"Attribut nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Attribut title\",\n \"admin/native-types.link.newTab\": \"Nouvel onglet\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Texte enrichi\",\n \"admin/native-types.text\": \"Texte\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Description\",\n \"admin/native-types.video.thumbnail\": \"Vignette\",\n \"admin/native-types.video\": \"Vidéo\",\n \"admin/native-types.video.title\": \"Titre\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Votre texte ici\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Ça marche :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_52748183
[ { "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 native-types/messages/sl-SI.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Znamka\",\n \"admin/native-types.category\": \"Kategorija\",\n \"admin/native-types.collection\": \"Zbirka\",\n \"admin/native-types.department\": \"Oddelek\",\n \"admin/native-types.image\": \"Slika\",\n \"admin/native-types.image.description\": \"Opis\",\n \"admin/native-types.image.desktop\": \"Namizno\",\n \"admin/native-types.image.filename\": \"Ime datoteke\",\n \"admin/native-types.image.mobile\": \"Mobilno\",\n \"admin/native-types.link\": \"Povezati\",\n \"admin/native-types.link.attributeNofollow\": \"Atribut nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Atribut title\",\n \"admin/native-types.link.newTab\": \"Nov zavihek\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Obogateno besedilo\",\n \"admin/native-types.text\": \"Text\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Opis\",\n \"admin/native-types.video.thumbnail\": \"Sličica\",\n \"admin/native-types.video\": \"Video\",\n \"admin/native-types.video.title\": \"Naziv\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Tukaj vnesite besedilo\",\n \"store/native-types.richText\": \"Loren ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Deluje :)\\\"\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_70134411
[ { "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 native-types/messages/ru-RU.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Бренд\",\n \"admin/native-types.category\": \"Категория\",\n \"admin/native-types.collection\": \"Коллекция\",\n \"admin/native-types.department\": \"Oтдел\",\n \"admin/native-types.image\": \"Изображение\",\n \"admin/native-types.image.description\": \"Описание\",\n \"admin/native-types.image.desktop\": \"Настольный компьютер\",\n \"admin/native-types.image.filename\": \"Имя файла\",\n \"admin/native-types.image.mobile\": \"Мобильный телефон\",\n \"admin/native-types.link\": \"Связь\",\n \"admin/native-types.link.attributeNofollow\": \"Атрибут nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Атрибут title\",\n \"admin/native-types.link.newTab\": \"Создать вкладку\",\n \"admin/native-types.link.url\": \"URL-адрес\",\n \"admin/native-types.richText\": \"Форматированный текст\",\n \"admin/native-types.text\": \"Текст\",\n \"admin/native-types.url\": \"URL-адрес\",\n \"admin/native-types.video.description\": \"Описание\",\n \"admin/native-types.video.thumbnail\": \"Эскиз\",\n \"admin/native-types.video\": \"Видео\",\n \"admin/native-types.video.title\": \"Название\",\n \"admin/native-types.video.url\": \"URL-адрес\",\n \"store/native-types.text\": \"Текст надписи\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Сработало! :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_8ffda4b5
[ { "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 native-types/messages/nl-NL.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Merk\",\n \"admin/native-types.category\": \"Categorie\",\n \"admin/native-types.collection\": \"Collectie\",\n \"admin/native-types.department\": \"Afdeling\",\n \"admin/native-types.image\": \"Afbeelding\",\n \"admin/native-types.image.description\": \"Beschrijving\",\n \"admin/native-types.image.desktop\": \"Desktop\",\n \"admin/native-types.image.filename\": \"Bestandsnaam\",\n \"admin/native-types.image.mobile\": \"Mobiel\",\n \"admin/native-types.link\": \"Link\",\n \"admin/native-types.link.attributeNofollow\": \"Attribuut nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Attribuut title\",\n \"admin/native-types.link.newTab\": \"Nieuwe tab\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Rich tekst\",\n \"admin/native-types.text\": \"Tekst\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Beschrijving\",\n \"admin/native-types.video.thumbnail\": \"Miniatuur\",\n \"admin/native-types.video\": \"Video\",\n \"admin/native-types.video.title\": \"Titel\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Uw tekst hier\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Het werkt :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_4cdc5b88
[ { "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 native-types/messages/fi-FI.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Brändi\",\n \"admin/native-types.category\": \"Luokka\",\n \"admin/native-types.collection\": \"Kokoelma\",\n \"admin/native-types.department\": \"Osasto\",\n \"admin/native-types.image\": \"Kuva\",\n \"admin/native-types.image.description\": \"Kuvaus\",\n \"admin/native-types.image.desktop\": \"Tietokone\",\n \"admin/native-types.image.filename\": \"Tiedostonimi\",\n \"admin/native-types.image.mobile\": \"Mobiili\",\n \"admin/native-types.link\": \"Linkki\",\n \"admin/native-types.link.attributeNofollow\": \"Määrite nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Määrite title\",\n \"admin/native-types.link.newTab\": \"Uusi välilehti\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"RTF teksti\",\n \"admin/native-types.text\": \"Teksti\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Kuvaus\",\n \"admin/native-types.video.thumbnail\": \"Pikkukuva\",\n \"admin/native-types.video\": \"Videot\",\n \"admin/native-types.video.title\": \"Nimi\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Kirjoita teksti tähän\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Se toimii :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_f95e374f
[ { "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 native-types/messages/es.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/native-types.brand\": \"Marca\",\n \"admin/native-types.category\": \"Categoría\",\n \"admin/native-types.collection\": \"Colección\",\n \"admin/native-types.department\": \"Departamento\",\n \"admin/native-types.image\": \"Imagen\",\n \"admin/native-types.image.description\": \"Descripción\",\n \"admin/native-types.image.desktop\": \"Escritorio\",\n \"admin/native-types.image.filename\": \"Nombre del archivo\",\n \"admin/native-types.image.mobile\": \"Dispositivo móbil\",\n \"admin/native-types.link\": \"Link\",\n \"admin/native-types.link.attributeNofollow\": \"Atributo nofollow\",\n \"admin/native-types.link.attributeTitle\": \"Atributo title\",\n \"admin/native-types.link.newTab\": \"Nueva pestaña\",\n \"admin/native-types.link.url\": \"URL\",\n \"admin/native-types.richText\": \"Texto enriquecido\",\n \"admin/native-types.text\": \"Texto\",\n \"admin/native-types.url\": \"URL\",\n \"admin/native-types.video.description\": \"Descripción\",\n \"admin/native-types.video.thumbnail\": \"Miniatura\",\n \"admin/native-types.video\": \"Vídeo\",\n \"admin/native-types.video.title\": \"Título\",\n \"admin/native-types.video.url\": \"URL\",\n \"store/native-types.text\": \"Escribe tu texto aquí\",\n \"store/native-types.richText\": \"Lorem ipsum...\",\n \"store/native-types.url\": \"https://example.com\",\n \"admin/format-io-message.empty-string-example\": \"\",\n \"admin/format-io-message.working-static-example\": \"Funciona :)\",\n \"admin/format-io-message.working-dynamic-example\": \"{subject} {verb} {emoji}\"\n}\n\n```" } ]
code_native-types_2a7da77d
[ { "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 native-types/docs/README.md from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n📢 Use this project, contribute to it or open issues to help evolve it using Store Discussion.\n\n# Native Types\n\nThis app contains three public components that should be used to format texts according to intl rules.\n\n## Configuration\n\nAdd the `native-types` app to the app's dependencies list (in the `manifest.json`) from which you want fetch product data. For example:\n\n```json\n\"dependencies\": {\n \"vtex.native-types\": \"0.x\"\n}\n```\n\n### IOMessage\n\nComing soon :)\n\n### IOMessageWithMarkers\n\nThis component is used to render messages with interpolations and custom tags (markers). These markers are useful to wrap a part of the message with CSS handles.\n\n| Prop name | Type | Description | Default Value |\n| --- | --- | --- | --- |\n| `message` | `string` | The message that can contain values to be interpolated | `undefined` |\n| `markers` | [`string`] | The list of markers to be used during interpolation | `[]` |\n| `handleBase` | `string` | Handle that will be used along with the marker to create a span with `CSS handle` on the part wrapped by marks | `''` |\n| `values` | `Record<string, any>` | Values used in the message interpolation | `{}` |\n\n**Example:**\n```jsx\n<IOMessageWithMarkers\n message=\"<bold>Hello,</bold> {name}!\"\n markers={['bold']}\n handleBase=\"Greetings\"\n values={{ name: 'John Doe' }}\n/>\n```\n \n The following will be rendered:\n``` js\n <div>\n <span\n class=\"Greetings_bold\"\n >\n Hello,\n </span>\n John Doe!\n </div>\n```\n\n\n**🔴 WARNING:** The `markers` and `values` props of this component are both passed to `IOMessage` through `values` so it is important to notice that you **should not** use the same labels within these props.\n\n### formatIOMessage\n\nComing soon :)\n\n```" } ]
code_native-types_fd1ca46f
[ { "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 native-types/pages/contentSchemas.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"definitions\": {\n \"brand\": {\n \"format\": \"Brand\",\n \"title\": \"admin/native-types.brand\",\n \"type\": \"string\"\n },\n\n \"category\": {\n \"format\": \"Category\",\n \"title\": \"admin/native-types.category\",\n \"type\": \"string\"\n },\n\n \"collection\": {\n \"format\": \"Collection\",\n \"title\": \"admin/native-types.collection\",\n \"type\": \"string\"\n },\n\n \"department\": {\n \"format\": \"Department\",\n \"title\": \"admin/native-types.department\",\n \"type\": \"string\"\n },\n\n \"image\": {\n \"properties\": {\n \"description\": {\n \"$ref\": \"#/definitions/text\",\n \"title\": \"admin/native-types.image.description\"\n },\n \"desktop\": {\n \"$ref\": \"#/definitions/url\",\n \"format\": \"Image\",\n \"title\": \"admin/native-types.image.desktop\"\n },\n \"filename\": {\n \"title\": \"admin/native-types.image.filename\",\n \"type\": \"string\"\n },\n \"mobile\": {\n \"$ref\": \"#/definitions/url\",\n \"format\": \"Image\",\n \"title\": \"admin/native-types.image.mobile\"\n }\n },\n \"title\": \"admin/native-types.image\",\n \"type\": \"object\"\n },\n\n \"link\": {\n \"properties\": {\n \"attributeNofollow\": {\n \"default\": false,\n \"title\": \"admin/native-types.link.attributeNofollow\",\n \"type\": \"boolean\"\n },\n \"attributeTitle\": {\n \"$ref\": \"#/definitions/text\", \n \"title\": \"admin/native-types.link.attributeTitle\"\n },\n \"newTab\": {\n \"title\": \"admin/native-types.link.newTab\",\n \"type\": \"boolean\"\n },\n \"url\": {\n \"$ref\": \"#/definitions/url\",\n \"title\": \"admin/native-types.link.url\"\n }\n },\n \"title\": \"admin/native-types.link\",\n \"type\": \"object\"\n },\n\n \"richText\": {\n \"$ref\": \"#/definitions/text\",\n \"format\": \"RichText\",\n \"title\": \"admin/native-types.richText\",\n \"type\": \"string\",\n \"examples\": [\"store/native-types.richText\"]\n },\n\n \"text\": {\n \"format\": \"IOMessage\",\n \"title\": \"admin/native-types.text\",\n \"type\": \"string\",\n \"examples\": [\"store/native-types.text\"]\n },\n\n \"url\": {\n \"$ref\": \"#/definitions/text\", \n \"title\": \"admin/native-types.url\",\n \"type\": \"string\",\n \"examples\": [\"store/native-types.url\"]\n },\n\n \"video\": {\n \"properties\": {\n \"description\": {\n \"$ref\": \"#/definitions/text\",\n \"title\": \"admin/native-types.video.description\"\n },\n \"thumbnail\": {\n \"$ref\": \"#/definitions/image\",\n \"title\": \"admin/native-types.video.thumbnail\"\n },\n \"title\": {\n \"$ref\": \"#/definitions/text\" ,\n \"title\": \"admin/native-types.video.title\"\n },\n \"url\": {\n \"$ref\": \"#/definitions/url\",\n \"title\": \"admin/native-types.video.url\"\n }\n },\n \"title\": \"admin/native-types.video\",\n \"type\": \"object\"\n }\n }\n}\n\n```" } ]
code_native-types_9967891a
[ { "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 native-types/react/IOMessageWithMarkers.tsx from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useMemo, ReactElement, FC } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport IOMessage from './IOMessage'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Values = Record<string, any>\n\ninterface Props {\n message: string\n handleBase: string\n markers: string[]\n values: Values\n}\n\nconst IOMessageWithMarkers: FC<Props> = ({\n message,\n markers = [],\n handleBase = '',\n values = {},\n}) => {\n const CSS_HANDLES = useMemo(\n () => markers.map((marker) => `${handleBase}-${marker}`),\n [handleBase, markers]\n )\n\n const handles = useCssHandles(CSS_HANDLES)\n\n const markerComponents = markers.reduce((acc, marker) => {\n // for more information check https://github.com/formatjs/react-intl/blob/master/docs/Components.md#rich-text-formatting\n // eslint-disable-next-line react/display-name\n acc[marker] = (...chunks) => (\n <span key={marker} className={handles[`${handleBase}-${marker}`]}>\n {chunks}\n </span>\n )\n\n return acc\n }, {} as Record<string, (...chunks: string[]) => ReactElement>)\n\n return (\n <IOMessage\n id={message}\n values={{\n ...markerComponents,\n ...values,\n }}\n />\n )\n}\n\nexport default React.memo(IOMessageWithMarkers)\n\n```" } ]
code_native-types_e50905e0
[ { "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 native-types/react/formatIOMessage.ts from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { ReactElement } from 'react'\nimport {\n createIntl,\n createIntlCache,\n MessageDescriptor,\n IntlShape,\n} from 'react-intl'\n\ntype AdaptedMessageDescriptor = MessageDescriptor & {\n intl: IntlShape\n}\n\nexport type Values = Record<string, string | number | ReactElement>\n\nconst cache = createIntlCache()\n\nconst formatIOMessage = (\n { intl, ...messageDescriptor }: AdaptedMessageDescriptor,\n values?: Values\n) => {\n const { defaultMessage, id } = messageDescriptor\n\n if (typeof id !== 'string' || id === '') {\n return ''\n }\n\n const intlMessage = intl.messages[id]\n\n if (intlMessage) {\n return intl.formatMessage(messageDescriptor, values)\n }\n\n if (intlMessage === '') {\n return ''\n }\n\n /**\n * This enables a user to pass a translatable message which is not\n * in the current IntlContext to the function and actually have it\n * formatted by react-intl.\n */\n const newIntl = createIntl(\n {\n locale: intl.locale,\n messages: {\n [id]: id,\n },\n },\n cache\n )\n\n return newIntl.formatMessage({ defaultMessage, id }, values)\n}\n\nexport default formatIOMessage\n\n```" } ]
code_native-types_62375ea0
[ { "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 native-types/react/package.json from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test --verbose\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.3\",\n \"@types/node\": \"^12.0.0\",\n \"@types/react\": \"^16.8.16\",\n \"@vtex/test-tools\": \"^3.0.0\",\n \"@vtex/tsconfig\": \"^0.5.2\",\n \"apollo-cache-inmemory\": \"^1.5.1\",\n \"react\": \"^16.8.6\",\n \"react-dom\": \"^16.8.6\",\n \"react-intl\": \"^3.12.0\",\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.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.124.3/public/@types/vtex.render-runtime\"\n },\n \"version\": \"0.10.1\"\n}\n\n```" } ]
code_native-types_86a47170
[ { "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 native-types/react/IOMessage.tsx from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment, FC } from 'react'\nimport { useIntl, MessageDescriptor } from 'react-intl'\n\nimport formatIOMessage, { Values } from './formatIOMessage'\n\ntype IOMessageType = FC<\n MessageDescriptor & {\n values?: Values\n }\n>\n\nconst IOMessage: IOMessageType = ({\n children,\n values,\n ...messageDescriptor\n}) => {\n const intl = useIntl()\n\n const message = formatIOMessage({ intl, ...messageDescriptor }, values)\n\n if (children && typeof children === 'function') {\n return children(message === '' ? '' : message) || null\n }\n\n return message === '' ? null : <Fragment>{message}</Fragment>\n}\n\nexport default IOMessage\n\n```" } ]
code_native-types_04d29ffc
[ { "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 native-types/react/__tests__/formatIOMessage.test.ts from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { IntlShape, createIntl } from 'react-intl'\n\nimport formatIOMessage from '../formatIOMessage'\n\nconst createMockIntl = (customMessages: IntlShape['messages'] = {}) =>\n createIntl({ locale: 'en', messages: customMessages })\n\ndescribe('formatIOMessage', () => {\n it('returns id when message is undefined', () => {\n const id = 'admin/format-io-message.unmapped-id-example'\n const intl = createMockIntl()\n\n const output = formatIOMessage({ id, intl })\n\n expect(output).toBe(id)\n })\n\n it('returns formatted id when message is undefined and dynamic', () => {\n const id = '{exceedingItems, plural, =0{} one {+ # gift} other {+ # gifts}}'\n const intl = createMockIntl()\n\n const values = {\n exceedingItems: '3',\n }\n\n const output = formatIOMessage({ id, intl }, values)\n const expectedOutput = '+ 3 gifts'\n\n expect(output).toBe(expectedOutput)\n })\n\n it(\"returns '' when message is ''\", () => {\n const id = 'admin/format-io-message.empty-string-example'\n\n const messages: IntlShape['messages'] = { [id]: '' }\n const intl = createMockIntl(messages)\n\n const output = formatIOMessage({ id, intl })\n\n const expectedOutput = ''\n\n expect(output).toBe(expectedOutput)\n })\n\n it('works with static, non-empty messages', () => {\n const id = 'admin/format-io-message.working-static-example'\n\n const messages: IntlShape['messages'] = {\n [id]: 'It works :)',\n }\n\n const intl = createMockIntl(messages)\n\n const output = formatIOMessage({ id, intl })\n\n const expectedOutput = messages[id]\n\n expect(output).toBe(expectedOutput)\n })\n\n it('works with dynamic, non-empty messages', () => {\n const id = 'admin/format-io-message.working-dynamic-example'\n\n const messages: IntlShape['messages'] = {\n [id]: '{subject} {verb} {emoji}',\n }\n\n const values: Record<string, string> = {\n emoji: ':)',\n subject: 'It',\n verb: 'works',\n }\n\n const intl = createMockIntl(messages)\n const output = formatIOMessage({ id, intl }, values)\n\n const expectedOutput = Object.entries(values).reduce(\n (acc, [currKey, currValue]) => acc.replace(`{${currKey}}`, currValue),\n messages[id]\n )\n\n expect(output).toBe(expectedOutput)\n })\n\n it(\"returns '' when id is ''\", () => {\n const id = ''\n\n const intl = createMockIntl()\n\n const output = formatIOMessage({ id, intl })\n\n expect(output).toBe('')\n })\n})\n\n```" } ]
code_native-types_7e380362
[ { "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 native-types/react/__tests__/IOMessageWithMarkers.test.tsx from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\n\nimport IOMessageWithMarkers from '../IOMessageWithMarkers'\nimport { IOMessageWithMarkers as IOMessageWithMarkersType } from '../types/IOMessageWithMarkers'\n\ninterface RenderElementParams {\n message: React.ComponentProps<IOMessageWithMarkersType>['message']\n values?: React.ComponentProps<IOMessageWithMarkersType>['values']\n handleBase?: React.ComponentProps<IOMessageWithMarkersType>['handleBase']\n markers?: React.ComponentProps<IOMessageWithMarkersType>['markers']\n}\n\nconst renderIOMessageWithIntl = ({\n message,\n values = {},\n handleBase = '',\n markers = [],\n}: RenderElementParams) =>\n render(\n <IOMessageWithMarkers\n message={message}\n values={values}\n handleBase={handleBase}\n markers={markers}\n />,\n {\n locale: 'en',\n }\n )\n\ndescribe('IOMessageWithMarkers', () => {\n it('Render simple message with only the label', () => {\n const message = 'Hello world!'\n const { getByText } = renderIOMessageWithIntl({ message })\n const element = getByText(message)\n\n expect(element).toBeDefined()\n })\n\n it('Check values interpolation', () => {\n const message = '{hello} {world} {exclamation}'\n const values = {\n hello: 'Hello',\n world: 'World',\n exclamation: '!',\n }\n\n const { getByText } = renderIOMessageWithIntl({ message, values })\n const element = getByText('Hello World !')\n\n expect(element).toBeDefined()\n })\n\n it('check marker and componentName', () => {\n const message = '<bold>Hello World!</bold>'\n const markers = ['bold']\n const handleBase = 'test'\n const { getByText } = renderIOMessageWithIntl({\n message,\n markers,\n handleBase,\n })\n\n const element = getByText('Hello World!')\n\n expect(element.className).toBe('test-bold')\n })\n\n it('check message with many markers and values', () => {\n const message =\n '<bold>{a}</bold> <italic>{b}</italic> <pretty>{c}</pretty> <sale>{d}</sale>'\n\n const values = {\n a: 'A',\n b: 'B',\n c: 'C',\n d: 'D',\n }\n\n const handleBase = 'test'\n const markers = ['bold', 'italic', 'pretty', 'sale']\n const { getByText } = renderIOMessageWithIntl({\n message,\n values,\n markers,\n handleBase,\n })\n\n expect(getByText('A').className).toBe('test-bold')\n expect(getByText('B').className).toBe('test-italic')\n expect(getByText('C').className).toBe('test-pretty')\n expect(getByText('D').className).toBe('test-sale')\n })\n\n it('check that if there are values equal to markers, the component should not be rendered correctly', () => {\n const message = '<a>{a}</a> <b>{b}</b> <c>{c}</c> <d>{d}</d>'\n const values = {\n a: 'A',\n b: 'B',\n c: 'C',\n d: 'D',\n }\n\n const handleBase = 'test'\n const markers = ['a', 'b', 'c', 'd']\n const { queryByText } = renderIOMessageWithIntl({\n message,\n values,\n markers,\n handleBase,\n })\n\n expect(queryByText('A')).toBeNull()\n expect(queryByText('B')).toBeNull()\n expect(queryByText('C')).toBeNull()\n expect(queryByText('D')).toBeNull()\n })\n})\n\n```" } ]
code_native-types_7126666a
[ { "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 native-types/react/__tests__/IOMessage.test.tsx from the native-types VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\n\nimport IOMessage from '../IOMessage'\nimport { IOMessage as IOMessageType } from '../types/IOMessage'\n\ninterface RenderElementParams {\n id: React.ComponentProps<IOMessageType>['id']\n values?: React.ComponentProps<IOMessageType>['values']\n}\n\nconst renderIOMessageWithIntl = ({ id, values }: RenderElementParams) =>\n render(<IOMessage id={id} values={values} />, {\n locale: 'en',\n })\n\ninterface ParseDynamicMessageParams {\n message: string\n values: Record<string, string | number>\n}\n\nconst parseDynamicMessage = ({ message, values }: ParseDynamicMessageParams) =>\n Object.entries(values).reduce((acc, [currKey, currValue]) => {\n if (typeof currValue !== 'string') {\n return acc\n }\n\n return acc.replace(`{${currKey}}`, currValue)\n }, message)\n\ndescribe('IOMessage', () => {\n it('displays id when message is undefined', () => {\n const id = 'test/io-message.unmapped-id-example'\n\n const { getByText } = renderIOMessageWithIntl({ id })\n\n const element = getByText(id)\n\n expect(element).toBeDefined()\n })\n\n it('displays formatted id when message is undefined and id is dynamic', () => {\n const id = '{exceedingItems, plural, =0{} one {+ # gift} other {+ # gifts}}'\n const values = {\n exceedingItems: '3',\n }\n\n const { getByText } = renderIOMessageWithIntl({ id, values })\n\n const expectedOutput = '+ 3 gifts'\n const element = getByText(expectedOutput)\n\n expect(element).toBeDefined()\n })\n\n it(\"returns null when message is ''\", () => {\n /**\n * This message is defined at '/messages' so that @vtex/test-tools\n * can find it.\n * */\n const id = 'admin/format-io-message.empty-string-example'\n\n const { container } = renderIOMessageWithIntl({ id })\n\n expect(container.children).toHaveLength(0)\n })\n\n it('works with static, non-empty messages', () => {\n /**\n * This message is defined at '/messages' so that @vtex/test-tools\n * can find it.\n * */\n const id = 'admin/format-io-message.working-static-example'\n\n const { getByText } = renderIOMessageWithIntl({ id })\n\n const element = getByText('It works :)')\n\n expect(element).toBeDefined()\n })\n\n it('works with dynamic, non-empty messages', () => {\n /**\n * This message is defined at '/messages' so that @vtex/test-tools\n * can find it.\n * */\n const id = 'admin/format-io-message.working-dynamic-example'\n\n const values: Record<string, string> = {\n emoji: ':)',\n subject: 'It',\n verb: 'works',\n }\n\n const text = parseDynamicMessage({\n message: '{subject} {verb} {emoji}',\n values,\n })\n\n const { getByText } = renderIOMessageWithIntl({ id, values })\n\n const element = getByText(text)\n\n expect(element).toBeDefined()\n })\n})\n\n```" } ]
code_splunk-log-forwarder_3537f7b0
[ { "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 splunk-log-forwarder/src/routes.ts from the splunk-log-forwarder VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport Router from 'koa-router'\n\nconst router = new Router()\n\nrouter.post('/forwarder/start')\n\nexport default router\n\n```" } ]
code_splunk-log-forwarder_5f2b4647
[ { "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 splunk-log-forwarder/src/index.ts from the splunk-log-forwarder VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { config } from 'dotenv'\n\nconfig({ path: './src/.env' })\n\n// eslint-disable-next-line import/first\nimport { app, server } from './server'\n\nexport { app, server }\n\n```" } ]
code_splunk-log-forwarder_1f7e06c4
[ { "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 splunk-log-forwarder/src/server.ts from the splunk-log-forwarder VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport Koa from 'koa'\n\nimport { fetchAppToken } from './middlewares/fetch-app-token'\nimport { logsForwarder } from './middlewares/forwarder'\nimport router from './routes'\nimport { setup } from './middlewares/setup'\n\nconst app = new Koa()\nconst port = process.env.PORT ?? 8080\n\nconst middlewares = [setup, fetchAppToken, logsForwarder]\n\nmiddlewares.forEach((middleware) => app.use(middleware))\n\napp.on('error', (err: Error) => {\n console.error('Error', err)\n})\napp.use(router.routes())\n\nconst server = app.listen(port, () => {\n console.log(`App listening on the port ${port}`)\n})\n\nexport { app, server }\n\n```" } ]
code_splunk-log-forwarder_32cb6f85
[ { "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 splunk-log-forwarder/src/clients/splunk.ts from the splunk-log-forwarder VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { RawAxiosRequestHeaders } from 'axios'\nimport axios from 'axios'\n\nexport default class Splunk {\n private host: string\n private port: string\n private headers: RawAxiosRequestHeaders\n\n constructor(host: string, port: string, headers: RawAxiosRequestHeaders) {\n this.host = host\n this.port = port\n this.headers = headers\n }\n\n public async postLog(log: unknown): Promise<unknown> {\n return axios.post(\n `https://${this.host}:${this.port}/services/collector/event`,\n log,\n { headers: this.headers }\n )\n }\n}\n\n```" } ]
code_splunk-log-forwarder_9abe7280
[ { "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 splunk-log-forwarder/src/clients/logsource.ts from the splunk-log-forwarder VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nimport EventSource = require('eventsource')\n\nexport class LogSource extends EventSource {\n constructor(\n account: string,\n workspace: string,\n opts: EventSource.EventSourceInitDict\n ) {\n console.debug({ opts })\n const url = `http://infra.io.vtex.com/skidder/v1/${account}/${workspace}/logs/stream`\n\n console.debug(`connecting with ${url}`)\n super(url, opts)\n }\n}\n\n```" } ]
code_splunk-log-forwarder_4a910f41
[ { "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 splunk-log-forwarder/src/middlewares/setup.ts from the splunk-log-forwarder VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { Context, Next } from 'koa'\n\nexport const setup = async (ctx: Context, next: Next) => {\n ctx.vtex = {}\n ctx.splunk = {}\n\n ctx.vtex.account = process.env.VTEX_ACCOUNT\n ctx.vtex.workspace = process.env.VTEX_WORKSPACE\n ctx.vtex.appKey = process.env.VTEX_APP_KEY\n ctx.vtex.appToken = process.env.VTEX_APP_TOKEN\n\n ctx.splunk.host = process.env.SPLUNK_HOST\n ctx.splunk.port = process.env.SPLUNK_PORT\n ctx.splunk.token = process.env.SPLUNK_TOKEN\n\n await next()\n}\n\n```" } ]
code_splunk-log-forwarder_1ef2cf1b
[ { "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 splunk-log-forwarder/src/middlewares/fetch-app-token.ts from the splunk-log-forwarder VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { Context, Next } from 'koa'\nimport axios from 'axios'\n\nexport const fetchAppToken = async (ctx: Context, next: Next) => {\n const {\n vtex: { account, appKey, appToken },\n } = ctx\n\n const response = await axios.post(\n `https://api.vtexcommercestable.com.br/api/vtexid/apptoken/login`,\n {\n appkey: appKey,\n apptoken: appToken\n },\n {\n params: {\n an: account\n },\n }\n )\n\n ctx.vtex.VtexIdClientAutCookie = response.data.token\n\n await next()\n}\n\n```" } ]
code_splunk-log-forwarder_be8b9eed
[ { "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 splunk-log-forwarder/src/middlewares/forwarder.ts from the splunk-log-forwarder VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { Context } from 'koa'\n\nimport { LogSource } from '../clients/logsource'\nimport Splunk from '../clients/splunk'\n\ninterface Message {\n data: string\n}\n\ninterface SplunkEvent {\n event: unknown\n}\n\nconst bufferIntervalInMillis = 15 * 1000\n\nexport async function logsForwarder(ctx: Context, next: () => Promise<any>) {\n setImmediate(async () => {\n startEventSource(ctx)\n })\n\n ctx.status = 200\n ctx.set('Cache-Control', 'no-cache')\n\n await next()\n}\n\nfunction startEventSource(ctx: Context) {\n const {\n vtex: { account, workspace, VtexIdClientAutCookie },\n splunk: { host, port, token },\n } = ctx\n\n const es = new LogSource(account, workspace, {\n headers: {\n Authorization: VtexIdClientAutCookie,\n 'User-Agent': `splunk-forwarder#${host}-${port}`,\n },\n })\n\n const splunk = new Splunk(host, port, {\n 'Content-Type': 'application/json',\n Authorization: `Splunk ${token}`,\n })\n\n const buffer = new LogsBulk(splunk)\n\n es.onopen = () => {\n console.debug('connection started')\n setTimeout(async () => {\n await buffer.sendBulk()\n console.debug('Closing stream')\n es.close()\n }, bufferIntervalInMillis)\n }\n\n es.onerror = (err) => {\n console.error(`Error reading logs: ${JSON.stringify(err, null, 2)}`)\n }\n\n es.addEventListener('message', async (message: Message) => {\n console.debug({ message })\n buffer.addMessage(JSON.parse(message.data))\n })\n}\n\nclass LogsBulk {\n private messages: SplunkEvent[]\n\n constructor(private client: Splunk) {\n this.messages = []\n }\n\n public async addMessage(msg: Message) {\n console.debug('message added to buffer')\n this.messages.push(splunkEvent(msg))\n }\n\n public async sendBulk() {\n if (this.messages.length > 0) {\n console.debug(`sending bulk with ${this.messages.length} logs`)\n await this.client.postLog(this.messages)\n }\n }\n}\n\nfunction splunkEvent(msg: Message): SplunkEvent {\n return { event: msg }\n}\n\n```" } ]
code_reskyt-pixel_1dd3f9eb
[ { "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 reskyt-pixel/docs/README.md from the reskyt-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Reskyt Pixel\n\nThis pixel renders a banner with information about a downloadable app\n\n![IMG_6126](https://user-images.githubusercontent.com/50715158/125049081-7ce58700-e098-11eb-8568-debb9ccac088.jpg)\n\n### How to use it\n\n- Open the VTEX App Store and install this app on your store.\n- Now, open the app settings on your admin and fill in the Extension options.\n\n```" } ]
code_reskyt-pixel_3a79be2d
[ { "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 reskyt-pixel/react/index.tsx from the reskyt-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { canUseDOM } from 'vtex.render-runtime'\nimport { reskytHtml } from './utils/reskyt'\nimport type { PixelMessage } from './typings/events'\nimport { getMobileUserAgent } from './utils/getMobileUserAgent'\nimport { getCookies } from './utils/getCookies'\nimport { checkConfiguration } from './utils/checkConfiguration'\n\nexport function handleEvents(e: PixelMessage) {\n switch (e.data.eventName) {\n case 'vtex:pageView': {\n const mobileUserAgentLabel = getMobileUserAgent(navigator.userAgent)\n\n const hasConfig = checkConfiguration(window.__reskytSettings)\n\n if (!hasConfig) {\n console.error('Please configure Reskyt App settings')\n } else if (mobileUserAgentLabel) {\n const {\n reskytAppName,\n reskytFabName,\n reskytHtmlTitle,\n reskytDownloadLink,\n reskytAppImage,\n reskytAppImageAlt,\n reskytStorePrefix,\n reskytDownloadCTA\n } = window.__reskytSettings\n\n const appConfig = {\n htmlTitle: decodeURIComponent(reskytHtmlTitle),\n downloadLink: decodeURIComponent(reskytDownloadLink),\n appImage: decodeURIComponent(reskytAppImage),\n appImageAlt: decodeURIComponent(reskytAppImageAlt),\n appName: decodeURIComponent(reskytAppName),\n fabName: decodeURIComponent(reskytFabName),\n storePrefix: decodeURIComponent(reskytStorePrefix),\n downloadCTA: decodeURIComponent(reskytDownloadCTA)\n }\n\n const resky = reskytHtml(appConfig)\n const reskydocDOM = document\n .createRange()\n .createContextualFragment(resky)\n\n document.body.appendChild(reskydocDOM)\n const hasCookie =\n !!getCookies('is_app_install_bar') ||\n !!getCookies('reskyt-install-app')\n\n const nodeToShow = document.getElementById('href-download-app')\n const labelNode = document.getElementById('platform-app')\n\n if (!hasCookie && nodeToShow && labelNode) {\n labelNode.innerHTML = mobileUserAgentLabel\n nodeToShow.style.display = 'block'\n }\n }\n\n break\n }\n\n default: {\n break\n }\n }\n}\n\nif (canUseDOM) {\n window.addEventListener('message', handleEvents)\n}\n\n```" } ]
code_reskyt-pixel_da07ca39
[ { "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 reskyt-pixel/react/package.json from the reskyt-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.3\",\n \"@types/graphql\": \"^14.5.0\",\n \"@types/jest\": \"^25.1.5\",\n \"@types/node\": \"^13.11.0\",\n \"@types/react\": \"^16.9.31\",\n \"@types/react-intl\": \"^3.0.0\",\n \"@vtex/test-tools\": \"^3.1.0\",\n \"apollo-cache-inmemory\": \"^1.6.5\",\n \"apollo-client\": \"^2.6.8\",\n \"graphql\": \"^14.5.4\",\n \"react-intl\": \"^3.11.0\",\n \"typescript\": \"3.9.7\",\n \"vtex.pixel-interfaces\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.pixel-interfaces@1.1.1/public/_types/react\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.124.3/public/@types/vtex.render-runtime\"\n },\n \"dependencies\": {\n \"html-template-tag\": \"^3.2.0\"\n }\n}\n\n```" } ]
code_reskyt-pixel_c574b21f
[ { "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 reskyt-pixel/store/interfaces.json from the reskyt-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"pixel.reskyt-pixel\": {\n \"component\": \"index\"\n }\n}\n\n```" } ]
code_reskyt-pixel_d101e4ec
[ { "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 reskyt-pixel/public/metadata/messages/es-AR.json from the reskyt-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"\",\n \"headline\": \"\",\n \"overview\": \"\",\n \"features\": [],\n \"additionalInformation\": \"\",\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_reskyt-pixel_6d6993b4
[ { "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 reskyt-pixel/public/metadata/messages/pt-BR.json from the reskyt-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"\",\n \"headline\": \"\",\n \"overview\": \"\",\n \"features\": [],\n \"additionalInformation\": \"\",\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_reskyt-pixel_af632b22
[ { "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 reskyt-pixel/public/metadata/messages/en-US.json from the reskyt-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"\",\n \"headline\": \"\",\n \"overview\": \"\",\n \"features\": [],\n \"additionalInformation\": \"\",\n \"websiteURL\": \"https://vtex.com/\",\n \"support\": {\n \"url\": \"https://support.vtex.com/hc/requests\"\n }\n}\n\n```" } ]
code_reskyt-pixel_65fdd784
[ { "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 reskyt-pixel/react/typings/events.d.ts from the reskyt-pixel 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 | OrderPlacedTrackedData\n | PageViewData\n | ProductImpressionData\n | AddToCartData\n | RemoveToCartData\n | CartChangedData\n | HomePageInfo\n | ProductPageInfoData\n | SearchPageInfoData\n | UserData\n | CartIdData\n | PromoViewData\n | PromotionClickData\n}\n\nexport interface EventData {\n event: string\n eventName: string\n currency: string\n}\n\nexport interface PageInfoData extends EventData {\n event: 'pageInfo'\n eventName: 'vtex:pageInfo'\n accountName: string\n pageTitle: string\n pageUrl: string\n}\n\nexport interface UserData extends PageInfoData {\n eventType: 'userData'\n eventName: 'vtex:userData'\n firstName?: string\n lastName?: string\n document?: string\n id?: string\n email?: string\n phone?: string\n isAuthenticated: boolean\n}\n\nexport interface CartIdData extends PageInfoData {\n eventType: 'cartId'\n eventName: 'vtex:cartId'\n cartId: string\n}\n\nexport interface HomePageInfo extends PageInfoData {\n eventType: 'homeView'\n}\n\nexport interface ProductPageInfoData extends PageInfoData {\n eventType: 'productPageInfo'\n}\n\nexport interface SearchPageInfoData extends PageInfoData {\n eventType:\n | 'internalSiteSearchView'\n | 'categoryView'\n | 'departmentView'\n | 'emptySearchView'\n category?: CategoryMetaData\n department?: DepartmentMetaData\n search?: SearchMetaData\n}\n\ninterface CategoryMetaData {\n id: string\n name: string\n}\n\ninterface DepartmentMetaData {\n id: string\n name: string\n}\n\ninterface SearchMetaData {\n term: string\n category: CategoryMetaData\n results: number\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 AddToCartData extends EventData {\n event: 'addToCart'\n eventName: 'vtex:addToCart'\n items: CartItem[]\n}\n\nexport interface RemoveToCartData extends EventData {\n event: 'removeFromCart'\n eventName: 'vtex:removeFromCart'\n items: CartItem[]\n}\n\nexport interface CartChangedData extends EventData {\n event: 'cartChanged'\n eventName: 'vtex:cartChanged'\n items: CartItem[]\n}\n\nexport interface OrderPlacedData extends Order, EventData {\n event: 'orderPlaced'\n eventName: 'vtex:orderPlaced'\n}\n\nexport interface OrderPlacedTrackedData extends Order, EventData {\n event: 'orderPlacedTracked'\n eventName: 'vtex:orderPlacedTracked'\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: ProductSummary\n list?: string\n}\n\nexport interface ProductImpressionData extends EventData {\n event: 'productImpression'\n eventName: 'vtex:productImpression'\n impressions: Impression[]\n product?: ProductSummary // deprecated, use impressions list!\n position?: number // deprecated, use impressions list!\n list: string\n}\n\nexport interface CartData extends EventData {\n event: 'cart'\n eventName: 'vtex:cart'\n orderForm: OrderForm\n}\n\nexport interface PromoViewData extends EventData {\n event: 'promoView'\n eventName: 'vtex:promoView'\n promotions: Promotion[]\n}\n\nexport interface PromotionClickData extends EventData {\n event: 'promotionClick'\n eventName: 'vtex:promotionClick'\n promotions: Promotion[]\n}\n\ninterface Promotion {\n id?: string\n name?: string\n creative?: string\n position?: string\n}\n\ninterface CartItem {\n brand: string\n ean: string\n category: string\n detailUrl: string\n imageUrl: string\n name: string\n price: number\n productId: string\n productRefId: string\n quantity: number\n seller: string\n sellerName: string\n skuId: string\n variant: string\n}\n\nexport interface OrderForm {\n id: string\n items: CartItem[]\n}\n\nexport interface Order {\n accountName: string\n corporateName: string\n coupon: string\n currency: string\n openTextField: string\n orderGroup: string\n salesChannel: string\n visitorAddressCity: string\n visitorAddressComplement: string\n visitorAddressCountry: string\n visitorAddressNeighborhood: string\n visitorAddressNumber: string\n visitorAddressPostalCode: string\n visitorAddressState: string\n visitorAddressStreet: string\n visitorContactInfo: string[]\n visitorContactPhone: string\n visitorType: string\n transactionId: string\n transactionDate: string\n transactionAffiliation: string\n transactionTotal: number\n transactionShipping: number\n transactionSubtotal: number\n transactionDiscounts: number\n transactionTax: number\n transactionCurrency: string\n transactionPaymentType: PaymentType[]\n transactionShippingMethod: ShippingMethod[]\n transactionLatestShippingEstimate: Date\n transactionProducts: ProductOrder[]\n transactionPayment: {\n id: string\n }\n}\n\nexport interface Impression {\n product: ProductSummary\n position: number\n}\n\nexport interface PaymentType {\n group: string\n paymentSystemName: string\n installments: number\n value: number\n}\n\nexport interface ShippingMethod {\n itemId: string\n selectedSla: string\n}\n\nexport interface ProductOrder {\n id: string\n name: string\n sku: string\n skuRefId: string\n skuName: string\n productRefId: string\n ean: string\n slug: 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 priceTags: PriceTag[]\n originalPrice: number\n price: number\n sellingPrice: number\n tax: number\n quantity: number\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n components: any[]\n measurementUnit: string\n unitMultiplier: number\n}\n\nexport interface PriceTag {\n identifier: string\n isPercentual: boolean\n value: number\n}\n\nexport interface Product {\n brand: string\n brandId: string\n categories: string[]\n categoryId: string\n categoryTree: Array<{ id: string; name: string }>\n detailUrl: string\n items: Item[]\n linkText: string\n productId: string\n productName: string\n productReference: string\n selectedSku: Item\n}\n\nexport interface Item {\n itemId: string\n name: string\n ean: string\n referenceId: { Key: string; Value: string }\n imageUrl: string\n sellers: Seller[]\n}\n\nexport interface ProductSummary {\n brand: string\n brandId: string\n categories: string[]\n items: ItemSummary[]\n linkText: string\n productId: string\n productName: string\n productReference: string\n sku: ItemSummary\n}\n\ninterface ItemSummary {\n itemId: string\n ean: string\n name: string\n referenceId: { Key: string; Value: string }\n seller: Seller\n sellers: Seller[]\n}\n\nexport interface Seller {\n commertialOffer: CommertialOffer\n sellerId: string\n sellerName: string\n}\n\nexport interface CommertialOffer {\n Price: number\n ListPrice: number\n AvailableQuantity: number\n}\n\n```" } ]
code_reskyt-pixel_b51bf9c6
[ { "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 reskyt-pixel/react/typings/global.d.ts from the reskyt-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ninterface Window extends Window {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n __reskytSettings: {\n reskytAppName: string\n reskytFabName: string\n reskytHtmlTitle: string\n reskytDownloadLink: string\n reskytAppImage: string\n reskytAppImageAlt: string\n reskytStorePrefix: string\n reskytDownloadCTA: string\n }\n}\n\n```" } ]
code_reskyt-pixel_8385765c
[ { "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 reskyt-pixel/react/typings/reskytConfig.d.ts from the reskyt-pixel VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport interface ReskytSettings {\n reskytAppName: string\n reskytFabName: string\n reskytHtmlTitle: string\n reskytDownloadLink: string\n reskytAppImage: string\n reskytAppImageAlt: string\n}\n\n```" } ]