@faststore/api 1.5.13 → 1.5.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("@graphql-tools/schema"),i=e(require("isomorphic-unfetch")),t=e(require("dataloader")),a=e(require("p-limit")),d=e(require("@sindresorhus/slugify")),r=e(require("fast-deep-equal")),l=require("graphql");const o=async(e,n)=>{const t=await i(e,n);if(t.ok)return t.json();const a=await t.text();throw new Error(a)},m={method:"POST",headers:{"content-type":"application/json"}},u=({account:e,environment:n},i)=>{const t=`http://portal.${n}.com.br/search-api/v1/${e}`,a={key:"trade-policy",value:i.storage.channel},d=({query:e="",page:n,count:i,sort:d="",selectedFacets:r=[],type:l,fuzzy:m="0"})=>{const u=new URLSearchParams({page:(n+1).toString(),count:i.toString(),query:e,sort:d,fuzzy:m}),s=(p=r,void 0===p.find(({key:e})=>e===a.key)?[...p,a]:p).map(({key:e,value:n})=>`${e}/${n}`).join("/");var p;return o(`${t}/api/split/${l}/${s}?${u.toString()}`)};return{facets:e=>d({...e,type:"attribute_search"}),products:e=>d({...e,type:"product_search"})}};class s extends Error{constructor(e){super(e),this.name="BadRequestError"}}class p extends Error{constructor(e){super(e),this.name="NotFoundError"}}const c=(e,n)=>({...e,isVariantOf:n}),k=new Set(["brand","category","department","subcategory"]),y=e=>"string"==typeof e.pageType&&k.has(e.pageType.toLowerCase()),N=e=>d(e,{separator:"-",lowercase:!0}),v=e=>"brand"===e.type,f=e=>v(e)?N(e.name.toLowerCase()):y(e)?new URL("https://"+e.url).pathname.slice(1):new URL(e.url).pathname.slice(1),g={id:({id:e})=>e.toString(),slug:e=>f(e),seo:e=>v(e)||y(e)?{title:e.title,description:e.metaTagDescription}:{title:e.Title,description:e.MetaTagDescription},type:e=>v(e)?"Brand":y(e)?e.pageType:0===e.level?"Department":"Category",meta:e=>v(e)?{selectedFacets:[{key:"brand",value:N(e.name)}]}:{selectedFacets:new URL(y(e)?"https://"+e.url:e.url).pathname.slice(1).split("/").map((e,n)=>({key:"category-"+(n+1),value:N(e)}))},breadcrumbList:async(e,n,i)=>{const{loaders:{collectionLoader:t}}=i,a=f(e).split("/").filter(e=>Boolean(e)),d=a.map((e,n)=>a.slice(0,n+1).join("/")),r=await Promise.all(d.map(e=>t.load(e)));return{itemListElement:r.map((e,n)=>({item:new URL("https://"+e.url).pathname.toLowerCase(),name:e.name,position:n+1})),numberOfItems:r.length}}},T=e=>[e.itemOffered.sku,e.seller.identifier,e.price].join("::"),S=(e,n)=>({listPrice:e.listPrice/100,price:e.sellingPrice/100,quantity:e.quantity,seller:{identifier:e.seller},itemOffered:{sku:e.id,image:[],name:e.name},index:n}),D=e=>({quantity:e.quantity,seller:e.seller.identifier,id:e.itemOffered.sku,index:e.index}),h=e=>e.reduce((e,n)=>{var i;const t=T(n);return e.set(t,null!=(i=e.get(t))?i:n),e},new Map),F={name:"image",value:"https://storecomponents.vtexassets.com/assets/faststore/images/image___117a6d3e229a96ad0e0d0876352566e2.svg"},b=(e,n)=>`${e}-${n}`,O=(e,n)=>`/${b(e,n)}/p`,I=e=>Array.isArray(e)&&e.length>0?e:null,P=e=>{const n=e.split("-").pop();if(null==n)throw new s("Error while extracting sku id from product slug");return n},C=({key:e,value:n})=>{switch(e){case"channel":return{key:"trade-policy",value:n};case"slug":return{key:"id",value:P(n)};default:return{key:e,value:n}}},V={price_desc:"price:desc",price_asc:"price:asc",orders_desc:"orders:desc",name_desc:"name:desc",name_asc:"name:asc",release_desc:"release:desc",discount_desc:"discount:desc",score_desc:""},L={product:async(e,{locator:n},i)=>{var t,a;i.storage={...i.storage,channel:null!=(t=null==(a=n.find(e=>"channel"===e.key))?void 0:a.value)?t:i.storage.channel};const{loaders:{skuLoader:d}}=i;return d.load(n.map(C))},collection:(e,{slug:n},i)=>{const{loaders:{collectionLoader:t}}=i;return t.load(n)},search:async(e,{first:n,after:i,sort:t,term:a,selectedFacets:d},r)=>{var l,o,m;r.storage={...r.storage,channel:null!=(l=null==d||null==(o=d.find(e=>"channel"===e.key))?void 0:o.value)?l:r.storage.channel};const u=i?Number(i):0;return{page:Math.ceil(u/n),count:n,query:a,sort:V[null!=t?t:"score_desc"],selectedFacets:null!=(m=null==d?void 0:d.map(C))?m:[]}},allProducts:async(e,{first:n,after:i},t)=>{const{clients:{search:a}}=t,d=i?Number(i):0,r=await a.products({page:Math.ceil(d/n),count:n}),l=r.products.map(e=>e.skus.map(n=>c(n,e))).flat().filter(e=>e.sellers.length>0);return{pageInfo:{hasNextPage:r.pagination.after.length>0,hasPreviousPage:r.pagination.before.length>0,startCursor:"0",endCursor:r.total.toString(),totalCount:r.total},edges:l.map((e,n)=>({node:e,cursor:(d+n).toString()}))}},allCollections:async(e,{first:n,after:i},t)=>{const{clients:{commerce:a}}=t,d=i?Number(i):0,[r,l]=await Promise.all([a.catalog.brand.list(),a.catalog.category.tree()]),o=[],m=(e,n)=>{o.push({...e,level:n});for(const i of e.children)m(i,n+1)};for(const e of l)m(e,0);const u=[...r.map(e=>({...e,type:"brand"})),...o].filter(e=>Boolean(g.slug(e,null,t,null)));return{pageInfo:{hasNextPage:u.length-d>n,hasPreviousPage:d>0,startCursor:"0",endCursor:(Math.min(n,u.length-d)-1).toString()},edges:u.slice(d,d+n).map((e,n)=>({node:e,cursor:(d+n).toString()}))}}},w={StoreCollection:g,StoreAggregateOffer:{highPrice:({items:e})=>{var n,i;return e.reduce((e,n)=>e>n.sellingPrice?e:n.sellingPrice,null!=(n=null==(i=e[0])?void 0:i.sellingPrice)?n:0)/100},lowPrice:({items:e})=>{var n,i;return e.reduce((e,n)=>e<n.sellingPrice?e:n.sellingPrice,null!=(n=null==(i=e[0])?void 0:i.sellingPrice)?n:0)/100},offerCount:({items:e})=>e.length,priceCurrency:()=>"",offers:({items:e,product:n})=>e.map(e=>({...e,product:n}))},StoreProduct:{productID:({id:e})=>e,name:({isVariantOf:e,name:n})=>null!=n?n:e.name,slug:({isVariantOf:{link:e},id:n})=>b(e,n),description:({isVariantOf:{description:e}})=>e,seo:({isVariantOf:{name:e,description:n}})=>({title:e,description:n}),brand:({isVariantOf:{brand:e}})=>({name:e}),breadcrumbList:({isVariantOf:{categoryTrees:e,name:n,link:i},id:t})=>({itemListElement:[...e.reverse().map(({categoryNames:e},n)=>({name:e[e.length-1],item:"/"+e.map(e=>N(e)).join("/"),position:n+1})),{name:n,item:O(i,t),position:e.length+1}],numberOfItems:e.length}),image:({isVariantOf:e,images:n})=>{var i,t;return(null!=(i=null!=(t=I(n))?t:I(e.images))?i:[F]).map(({name:e,value:n})=>({alternateName:null!=e?e:"",url:n.replace("vteximg.com.br","vtexassets.com")}))},sku:({isVariantOf:{skus:[e]}})=>e.id,gtin:({reference:e})=>null!=e?e:"",review:()=>[],aggregateRating:()=>({}),offers:async(e,n,i)=>{var t;const{loaders:{simulationLoader:a},storage:{channel:d}}=i,{id:r,policies:l}=e,o=null==(t=l.find(e=>e.id===d))?void 0:t.sellers;if(null==o)throw new Error(`Product with id ${r} has no sellers for channel ${d}.`);const m=o.map(e=>e.id),u=Array.from(new Set(m)).map(e=>({quantity:1,seller:e,id:r}));return{...await a.load(u),product:e}},isVariantOf:({isVariantOf:e})=>e,additionalProperty:({attributes:e=[]})=>e.map(e=>({name:e.key,value:e.value}))},StoreSeo:{title:({title:e})=>null!=e?e:"",description:({description:e})=>null!=e?e:"",titleTemplate:()=>"",canonical:()=>""},StoreFacet:{key:({key:e})=>e,label:({label:e})=>e,values:({values:e})=>e,type:({type:e})=>"text"===e?"BOOLEAN":"RANGE"},StoreFacetValue:{value:({key:e,from:n,to:i})=>null!=e?e:`${n}-to-${i}`,label:({label:e})=>null!=e?e:"unknown",selected:({active:e})=>e,quantity:({count:e})=>e},StoreOffer:{priceCurrency:()=>"",priceValidUntil:({priceValidUntil:e})=>null!=e?e:"",itemCondition:()=>"https://schema.org/NewCondition",availability:({availability:e})=>"available"===e?"https://schema.org/InStock":"https://schema.org/OutOfStock",seller:({seller:e})=>({identifier:e}),price:({sellingPrice:e})=>e/100,sellingPrice:({sellingPrice:e})=>e/100,listPrice:({listPrice:e})=>e/100,itemOffered:({product:e})=>e,quantity:({quantity:e})=>e},StoreAggregateRating:{ratingValue:()=>5,reviewCount:()=>0},StoreReview:{reviewRating:()=>({ratingValue:5,bestRating:5}),author:()=>({name:""})},StoreProductGroup:{hasVariant:e=>e.skus.map(n=>c(n,e)),productGroupID:({product:e})=>e,name:({name:e})=>e,additionalProperty:({textAttributes:e=[],productSpecifications:n=[]})=>{const i=new Set(n);return e.filter(e=>i.has(e.labelKey)).map(e=>({name:e.labelKey,value:e.labelValue}))}},StoreSearchResult:{products:async(e,n,i)=>{const{clients:{search:t}}=i,a=await t.products(e),d=a.products.map(e=>{const n=e.skus.find(e=>e.sellers.length>0);return n&&c(n,e)}).filter(e=>!!e);return{pageInfo:{hasNextPage:a.pagination.after.length>0,hasPreviousPage:a.pagination.before.length>0,startCursor:"0",endCursor:a.total.toString(),totalCount:a.total},edges:d.map((e,n)=>({node:e,cursor:n.toString()}))}},facets:async(e,n,i)=>{var t;const{clients:{search:a}}=i;return null!=(t=(await a.facets(e)).attributes)?t:[]}},Query:L,Mutation:{validateCart:async(e,{cart:{order:{orderNumber:n,acceptedOffer:i}}},t)=>{const{clients:{commerce:a},loaders:{skuLoader:d}}=t,l=await a.checkout.orderForm({id:n}),o=h(i),m=h(l.items.map(S)),u=Array.from(o.values()),s=Array.from(m.values()),{itemsToAdd:p,itemsToUpdate:c}=u.reduce((e,n)=>{const i=m.get(T(n));return i?e.itemsToUpdate.push({...i,quantity:n.quantity}):e.itemsToAdd.push(n),e},{itemsToAdd:[],itemsToUpdate:[]}),k=[...p,...c,...s.filter(e=>!o.has(T(e))).map(e=>({...e,quantity:0}))].map(D);if(0===k.length)return null;const y=await a.checkout.updateOrderFormItems({id:l.orderFormId,orderItems:k});return((e,n)=>{const i=({orderFormId:e,messages:n,items:i,salesChannel:t})=>({orderFormId:e,messages:n,salesChannel:t,items:i.map(({uniqueId:e,quantity:n,seller:i,sellingPrice:t,availability:a})=>({uniqueId:e,quantity:n,seller:i,sellingPrice:t,availability:a}))});return r(i(e),i(n))})(l,y)?null:{order:{orderNumber:y.orderFormId,acceptedOffer:y.items.map(e=>({...e,product:d.load([{key:"id",value:e.id}])}))},messages:y.messages.map(({text:e,status:n})=>({text:e,status:n.toUpperCase()}))}}}};var q={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreAggregateOffer"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"highPrice"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"lowPrice"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"offerCount"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"priceCurrency"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"offers"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreOffer"}}}}},directives:[]}]}],loc:{start:0,end:261}};q.loc.source={body:"type StoreAggregateOffer {\n # Highest spot price amongst all sellers\n highPrice: Float!\n # Lowest spot price amongst all sellers\n lowPrice: Float!\n # Number of sellers selling this sku\n offerCount: Int!\n priceCurrency: String!\n offers: [StoreOffer!]!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var R={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreAggregateRating"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"ratingValue"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"reviewCount"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]}],loc:{start:0,end:72}};R.loc.source={body:"type StoreAggregateRating {\n ratingValue: Float!\n reviewCount: Int!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var E={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreAuthor"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"name"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]}],loc:{start:0,end:37}};E.loc.source={body:"type StoreAuthor {\n name: String!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var j={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreBrand"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"name"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]}],loc:{start:0,end:36}};j.loc.source={body:"type StoreBrand {\n name: String!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var _={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreListItem"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"item"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"name"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"position"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreBreadcrumbList"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"itemListElement"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreListItem"}}}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"numberOfItems"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]}],loc:{start:0,end:161}};_.loc.source={body:"type StoreListItem {\n item: String!\n name: String!\n position: Int!\n}\n\ntype StoreBreadcrumbList {\n itemListElement: [StoreListItem!]!\n numberOfItems: Int!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var A={kind:"Document",definitions:[{kind:"EnumTypeDefinition",name:{kind:"Name",value:"StoreCollectionType"},directives:[],values:[{kind:"EnumValueDefinition",name:{kind:"Name",value:"Department"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"Category"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"Brand"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"Cluster"},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCollectionFacet"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"key"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"value"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCollectionMeta"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"selectedFacets"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollectionFacet"}}}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCollection"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"seo"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreSeo"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"breadcrumbList"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreBreadcrumbList"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"meta"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollectionMeta"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"id"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"slug"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"type"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollectionType"}}},directives:[]}]}],loc:{start:0,end:424}};A.loc.source={body:"enum StoreCollectionType {\n Department\n Category\n Brand\n Cluster\n}\n\ntype StoreCollectionFacet {\n key: String!\n value: String!\n}\n\ntype StoreCollectionMeta {\n selectedFacets: [StoreCollectionFacet!]!\n}\n\ntype StoreCollection {\n # Meta tag data\n seo: StoreSeo!\n # location for structured data\n breadcrumbList: StoreBreadcrumbList!\n meta: StoreCollectionMeta!\n id: ID!\n slug: String!\n type: StoreCollectionType!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var x={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreFacet"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"key"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"label"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"values"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreFacetValue"}}}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"type"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreFacetType"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreFacetValue"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"value"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"label"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"selected"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Boolean"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"quantity"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]}],loc:{start:0,end:240}};x.loc.source={body:"type StoreFacet {\n key: String!\n label: String!\n values: [StoreFacetValue!]!\n type: StoreFacetType!\n}\n\ntype StoreFacetValue {\n value: String!\n label: String!\n selected: Boolean!\n # Number of items with this facet\n quantity: Int!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var G={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreImage"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"url"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"alternateName"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreImage"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"url"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"alternateName"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]}],loc:{start:0,end:123}};G.loc.source={body:"type StoreImage {\n url: String!\n alternateName: String!\n}\n\ninput IStoreImage {\n url: String!\n alternateName: String!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var $={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"Mutation"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"validateCart"},arguments:[{kind:"InputValueDefinition",name:{kind:"Name",value:"cart"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreCart"}}},directives:[]}],type:{kind:"NamedType",name:{kind:"Name",value:"StoreCart"}},directives:[]}]}],loc:{start:0,end:148}};$.loc.source={body:"type Mutation {\n # Returns the order if anything changed with the order. Null if the order is valid\n validateCart(cart: IStoreCart!): StoreCart\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var B={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreOffer"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"listPrice"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"sellingPrice"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"priceCurrency"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"price"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"priceValidUntil"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"itemCondition"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"availability"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"seller"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreOrganization"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"itemOffered"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProduct"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"quantity"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreOffer"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"price"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"listPrice"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"seller"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreOrganization"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"itemOffered"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreProduct"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"quantity"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]}],loc:{start:0,end:419}};B.loc.source={body:"type StoreOffer {\n listPrice: Float!\n sellingPrice: Float!\n priceCurrency: String!\n # Also known as spotPrice\n price: Float!\n priceValidUntil: String!\n itemCondition: String!\n availability: String!\n seller: StoreOrganization!\n itemOffered: StoreProduct!\n quantity: Int!\n}\n\ninput IStoreOffer {\n price: Float!\n listPrice: Float!\n seller: IStoreOrganization!\n itemOffered: IStoreProduct!\n quantity: Int!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var Q={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreOrder"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"orderNumber"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"acceptedOffer"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreOffer"}}}}},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreOrder"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"orderNumber"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"acceptedOffer"},type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreOffer"}}}}},directives:[]}]}],loc:{start:0,end:154}};Q.loc.source={body:"type StoreOrder {\n orderNumber: String!\n acceptedOffer: [StoreOffer!]!\n}\n\ninput IStoreOrder {\n orderNumber: String!\n acceptedOffer: [IStoreOffer!]!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var M={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreOrganization"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"identifier"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreOrganization"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"identifier"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]}],loc:{start:0,end:101}};M.loc.source={body:"type StoreOrganization {\n identifier: String!\n}\n\ninput IStoreOrganization {\n identifier: String!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var U={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StorePageInfo"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"hasNextPage"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Boolean"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"hasPreviousPage"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Boolean"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"startCursor"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"endCursor"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"totalCount"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]}],loc:{start:0,end:197}};U.loc.source={body:"type StorePageInfo {\n hasNextPage: Boolean!\n hasPreviousPage: Boolean!\n startCursor: String!\n endCursor: String!\n # Total number of items(products/collections), not pages\n totalCount: Int!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var z={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreProduct"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"seo"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreSeo"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"breadcrumbList"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreBreadcrumbList"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"slug"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"name"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"productID"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"brand"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreBrand"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"description"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"image"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreImage"}}}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"offers"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreAggregateOffer"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"sku"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"gtin"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"review"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreReview"}}}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"aggregateRating"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreAggregateRating"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"isVariantOf"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProductGroup"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"additionalProperty"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StorePropertyValue"}}}}},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreProduct"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"sku"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"name"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"image"},type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreImage"}}}}},directives:[]}]}],loc:{start:0,end:573}};z.loc.source={body:"type StoreProduct {\n # Meta tag data\n seo: StoreSeo!\n # Location for structured data\n breadcrumbList: StoreBreadcrumbList!\n # Where to retrieve this entity\n slug: String!\n name: String!\n productID: String!\n brand: StoreBrand!\n description: String!\n image: [StoreImage!]!\n offers: StoreAggregateOffer!\n sku: String!\n gtin: String!\n review: [StoreReview!]!\n aggregateRating: StoreAggregateRating!\n isVariantOf: StoreProductGroup!\n additionalProperty: [StorePropertyValue!]!\n}\n\ninput IStoreProduct {\n sku: String!\n name: String!\n image: [IStoreImage!]!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var K={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreProductGroup"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"hasVariant"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProduct"}}}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"productGroupID"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"name"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"additionalProperty"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StorePropertyValue"}}}}},directives:[]}]}],loc:{start:0,end:145}};K.loc.source={body:"type StoreProductGroup {\n hasVariant: [StoreProduct!]!\n productGroupID: String!\n name: String!\n additionalProperty: [StorePropertyValue!]!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var W={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreProductEdge"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"node"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProduct"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"cursor"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreProductConnection"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"pageInfo"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StorePageInfo"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"edges"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProductEdge"}}}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCollectionEdge"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"node"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollection"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"cursor"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCollectionConnection"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"pageInfo"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StorePageInfo"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"edges"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollectionEdge"}}}}},directives:[]}]},{kind:"EnumTypeDefinition",name:{kind:"Name",value:"StoreSort"},directives:[],values:[{kind:"EnumValueDefinition",name:{kind:"Name",value:"price_desc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"price_asc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"orders_desc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"name_desc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"name_asc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"release_desc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"discount_desc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"score_desc"},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreSelectedFacet"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"key"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"value"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]},{kind:"EnumTypeDefinition",name:{kind:"Name",value:"StoreFacetType"},directives:[],values:[{kind:"EnumValueDefinition",name:{kind:"Name",value:"BOOLEAN"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"RANGE"},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreSearchResult"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"products"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProductConnection"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"facets"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreFacet"}}}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"Query"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"product"},arguments:[{kind:"InputValueDefinition",name:{kind:"Name",value:"locator"},type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreSelectedFacet"}}}}},directives:[]}],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProduct"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"collection"},arguments:[{kind:"InputValueDefinition",name:{kind:"Name",value:"slug"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollection"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"search"},arguments:[{kind:"InputValueDefinition",name:{kind:"Name",value:"first"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"after"},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"sort"},type:{kind:"NamedType",name:{kind:"Name",value:"StoreSort"}},defaultValue:{kind:"EnumValue",value:"score_desc"},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"term"},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},defaultValue:{kind:"StringValue",value:"",block:!1},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"selectedFacets"},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreSelectedFacet"}}}},directives:[]}],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreSearchResult"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"allProducts"},arguments:[{kind:"InputValueDefinition",name:{kind:"Name",value:"first"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"after"},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},directives:[]}],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProductConnection"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"allCollections"},arguments:[{kind:"InputValueDefinition",name:{kind:"Name",value:"first"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"after"},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},directives:[]}],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollectionConnection"}}},directives:[]}]}],loc:{start:0,end:1077}};W.loc.source={body:'type StoreProductEdge {\n node: StoreProduct!\n cursor: String!\n}\n\ntype StoreProductConnection {\n pageInfo: StorePageInfo!\n edges: [StoreProductEdge!]!\n}\n\ntype StoreCollectionEdge {\n node: StoreCollection!\n cursor: String!\n}\n\ntype StoreCollectionConnection {\n pageInfo: StorePageInfo!\n edges: [StoreCollectionEdge!]!\n}\n\nenum StoreSort {\n price_desc\n price_asc\n orders_desc\n name_desc\n name_asc\n release_desc\n discount_desc\n score_desc\n}\n\ninput IStoreSelectedFacet {\n key: String!\n value: String!\n}\n\nenum StoreFacetType {\n BOOLEAN\n RANGE\n}\n\ntype StoreSearchResult {\n products: StoreProductConnection!\n facets: [StoreFacet!]!\n}\n\ntype Query {\n product(locator: [IStoreSelectedFacet!]!): StoreProduct!\n\n collection(slug: String!): StoreCollection!\n\n search(\n first: Int!\n after: String\n sort: StoreSort = score_desc\n term: String = ""\n selectedFacets: [IStoreSelectedFacet!]\n ): StoreSearchResult!\n\n allProducts(first: Int!, after: String): StoreProductConnection!\n\n allCollections(first: Int!, after: String): StoreCollectionConnection!\n}\n',name:"GraphQL request",locationOffset:{line:1,column:1}};var H={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreReviewRating"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"ratingValue"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"bestRating"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreReview"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"reviewRating"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreReviewRating"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"author"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreAuthor"}}},directives:[]}]}],loc:{start:0,end:150}};H.loc.source={body:"type StoreReviewRating {\n ratingValue: Float!\n bestRating: Float!\n}\n\ntype StoreReview {\n reviewRating: StoreReviewRating!\n author: StoreAuthor!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var J={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreSeo"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"title"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"titleTemplate"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"description"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"canonical"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]}],loc:{start:0,end:104}};J.loc.source={body:"type StoreSeo {\n title: String!\n titleTemplate: String!\n description: String!\n canonical: String!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var X={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCartMessage"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"text"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"status"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreStatus"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCart"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"order"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreOrder"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"messages"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCartMessage"}}}}},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreCart"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"order"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreOrder"}}},directives:[]}]}],loc:{start:0,end:183}};X.loc.source={body:"type StoreCartMessage {\n text: String!\n status: StoreStatus!\n}\n\ntype StoreCart {\n order: StoreOrder!\n messages: [StoreCartMessage!]!\n}\n\ninput IStoreCart {\n order: IStoreOrder!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var Y={kind:"Document",definitions:[{kind:"EnumTypeDefinition",name:{kind:"Name",value:"StoreStatus"},directives:[],values:[{kind:"EnumValueDefinition",name:{kind:"Name",value:"INFO"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"WARNING"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"ERROR"},directives:[]}]}],loc:{start:0,end:46}};Y.loc.source={body:"enum StoreStatus {\n INFO\n WARNING\n ERROR\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var Z={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StorePropertyValue"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"value"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"name"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]}],loc:{start:0,end:61}};Z.loc.source={body:"type StorePropertyValue {\n value: String!\n name: String!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};const ee=[W,$,j,_,A,x,G,U,z,J,B,R,H,E,K,M,q,Q,X,Y,Z].map(l.print).join("\n"),ne={vtex:{getResolvers:e=>w,getContextFactory:e=>n=>(n.storage={channel:e.channel},n.clients=((e,n)=>({search:u(e,n),commerce:(({account:e,environment:n},i)=>{const t=`http://${e}.${n}.com.br`;return{catalog:{brand:{list:()=>o(t+"/api/catalog_system/pub/brand/list")},category:{tree:(e=3)=>o(`${t}/api/catalog_system/pub/category/tree/${e}`)},portal:{pagetype:e=>o(`${t}/api/catalog_system/pub/portal/pagetype/${e}`)}},checkout:{simulation:(e,{salesChannel:n}={salesChannel:i.storage.channel})=>{const a=new URLSearchParams({sc:n});return o(`${t}/api/checkout/pub/orderForms/simulation?${a.toString()}`,{...m,body:JSON.stringify(e)})},orderForm:({id:e,refreshOutdatedData:n=!0,salesChannel:a=i.storage.channel})=>{const d=new URLSearchParams({refreshOutdatedData:n.toString(),sc:a});return o(`${t}/api/checkout/pub/orderForm/${e}?${d.toString()}`,m)},updateOrderFormItems:({id:e,orderItems:n,allowOutdatedData:a="paymentData",salesChannel:d=i.storage.channel})=>{const r=new URLSearchParams({allowOutdatedData:a,sc:d});return o(`${t}/api/checkout/pub/orderForm/${e}/items?${r}`,{...m,body:JSON.stringify({orderItems:n}),method:"PATCH"})}}}})(e,n)}))(e,n),n.loaders=((e,{clients:n})=>({skuLoader:((e,n)=>new t(async e=>{const i=e.map(e=>{const n=e.find(({key:e})=>"id"===e);if(!n)throw new s("Error while loading SKU. Needs to pass an id to selected facets");return n.value}),{products:t}=await n.search.products({query:"sku:"+i.join(";"),page:0,count:i.length}),a=t.reduce((e,n)=>{for(const i of n.skus)e[i.id]=c(i,n);return e},{}),d=i.map(e=>a[e]),r=d.filter(e=>!e);if(r.length>0)throw new Error("Search API did not return the following skus: "+r.join(","));return d},{maxBatchSize:99}))(0,n),simulationLoader:((e,n)=>new t(async e=>{const i=[...e.flat()],t=await n.commerce.checkout.simulation({items:i}),a=t.items.reduce((e,n)=>{const i=n.requestIndex;return"number"==typeof i&&i<e.length&&(e[i]=n),e},Array(i.length).fill(null)),d=e.reduce((e,n)=>[...e,n.length+e[e.length-1]],[0]);return e.map((e,n)=>({...t,items:a.slice(d[n],d[n+1]).filter(e=>Boolean(e))}))},{maxBatchSize:20}))(0,n),collectionLoader:((e,n)=>{const i=a(20);return new t(async e=>Promise.all(e.map(e=>i(async()=>{const i=await n.commerce.catalog.portal.pagetype(e);if(y(i))return i;throw new p(`Catalog returned ${i.pageType} for slug: ${e}. This usually happens when there is more than one category with the same name in the same category tree level.`)}))),{batch:!1})})(0,n)}))(0,n),n)}},ie=()=>ee,te=e=>ne[e.platform].getResolvers(e);exports.getContextFactory=e=>ne[e.platform].getContextFactory(e),exports.getResolvers=te,exports.getSchema=async e=>n.makeExecutableSchema({resolvers:te(e),typeDefs:ie()}),exports.getTypeDefs=ie;
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("@graphql-tools/schema"),i=e(require("isomorphic-unfetch")),t=e(require("dataloader")),a=e(require("p-limit")),d=e(require("@sindresorhus/slugify")),r=e(require("fast-deep-equal")),l=require("graphql");const o=async(e,n)=>{const t=await i(e,n);if(t.ok)return t.json();const a=await t.text();throw new Error(a)},m={method:"POST",headers:{"content-type":"application/json"}},u=({account:e,environment:n},i)=>{const t=`http://portal.${n}.com.br/search-api/v1/${e}`,a={key:"trade-policy",value:i.storage.channel},d=({query:e="",page:n,count:i,sort:d="",selectedFacets:r=[],type:l,fuzzy:m="0"})=>{const u=new URLSearchParams({page:(n+1).toString(),count:i.toString(),query:e,sort:d,fuzzy:m}),s=(p=r,void 0===p.find(({key:e})=>e===a.key)?[...p,a]:p).map(({key:e,value:n})=>`${e}/${n}`).join("/");var p;return o(`${t}/api/split/${l}/${s}?${u.toString()}`)};return{facets:e=>d({...e,type:"attribute_search"}),products:e=>d({...e,type:"product_search"})}};class s extends Error{constructor(e){super(e),this.name="BadRequestError"}}class p extends Error{constructor(e){super(e),this.name="NotFoundError"}}const c=(e,n)=>({...e,isVariantOf:n}),k=new Set(["brand","category","department","subcategory"]),y=e=>"string"==typeof e.pageType&&k.has(e.pageType.toLowerCase()),N=e=>d(e,{separator:"-",lowercase:!0}),v=e=>"brand"===e.type,f=e=>v(e)?N(e.name.toLowerCase()):y(e)?new URL("https://"+e.url).pathname.slice(1):new URL(e.url).pathname.slice(1),g={id:({id:e})=>e.toString(),slug:e=>f(e),seo:e=>v(e)||y(e)?{title:e.title,description:e.metaTagDescription}:{title:e.Title,description:e.MetaTagDescription},type:e=>v(e)?"Brand":y(e)?e.pageType:0===e.level?"Department":"Category",meta:e=>v(e)?{selectedFacets:[{key:"brand",value:N(e.name)}]}:{selectedFacets:new URL(y(e)?"https://"+e.url:e.url).pathname.slice(1).split("/").map((e,n)=>({key:"category-"+(n+1),value:N(e)}))},breadcrumbList:async(e,n,i)=>{const{loaders:{collectionLoader:t}}=i,a=f(e).split("/").filter(e=>Boolean(e)),d=a.map((e,n)=>a.slice(0,n+1).join("/")),r=await Promise.all(d.map(e=>t.load(e)));return{itemListElement:r.map((e,n)=>({item:new URL("https://"+e.url).pathname.toLowerCase(),name:e.name,position:n+1})),numberOfItems:r.length}}},T=e=>[e.itemOffered.sku,e.seller.identifier,e.price].join("::"),S=(e,n)=>({listPrice:e.listPrice/100,price:e.sellingPrice/100,quantity:e.quantity,seller:{identifier:e.seller},itemOffered:{sku:e.id,image:[],name:e.name},index:n}),D=e=>({quantity:e.quantity,seller:e.seller.identifier,id:e.itemOffered.sku,index:e.index}),h=e=>e.reduce((e,n)=>{var i;const t=T(n);return e.set(t,null!=(i=e.get(t))?i:n),e},new Map),F={name:"image",value:"https://storecomponents.vtexassets.com/assets/faststore/images/image___117a6d3e229a96ad0e0d0876352566e2.svg"},b=(e,n)=>`${e}-${n}`,O=(e,n)=>`/${b(e,n)}/p`,I=e=>Array.isArray(e)&&e.length>0?e:null,P=e=>{const n=e.split("-").pop();if(null==n)throw new s("Error while extracting sku id from product slug");return n},C=({key:e,value:n})=>{switch(e){case"channel":return{key:"trade-policy",value:n};case"slug":return{key:"id",value:P(n)};default:return{key:e,value:n}}},V={price_desc:"price:desc",price_asc:"price:asc",orders_desc:"orders:desc",name_desc:"name:desc",name_asc:"name:asc",release_desc:"release:desc",discount_desc:"discount:desc",score_desc:""},L={product:async(e,{locator:n},i)=>{var t,a;i.storage={...i.storage,channel:null!=(t=null==(a=n.find(e=>"channel"===e.key))?void 0:a.value)?t:i.storage.channel};const{loaders:{skuLoader:d}}=i;return d.load(n.map(C))},collection:(e,{slug:n},i)=>{const{loaders:{collectionLoader:t}}=i;return t.load(n)},search:async(e,{first:n,after:i,sort:t,term:a,selectedFacets:d},r)=>{var l,o,m;r.storage={...r.storage,channel:null!=(l=null==d||null==(o=d.find(e=>"channel"===e.key))?void 0:o.value)?l:r.storage.channel};const u=i?Number(i):0;return{page:Math.ceil(u/n),count:n,query:a,sort:V[null!=t?t:"score_desc"],selectedFacets:null!=(m=null==d?void 0:d.map(C))?m:[]}},allProducts:async(e,{first:n,after:i},t)=>{const{clients:{search:a}}=t,d=i?Number(i):0,r=await a.products({page:Math.ceil(d/n),count:n}),l=r.products.map(e=>e.skus.map(n=>c(n,e))).flat().filter(e=>e.sellers.length>0);return{pageInfo:{hasNextPage:r.pagination.after.length>0,hasPreviousPage:r.pagination.before.length>0,startCursor:"0",endCursor:r.total.toString(),totalCount:r.total},edges:l.map((e,n)=>({node:e,cursor:(d+n).toString()}))}},allCollections:async(e,{first:n,after:i},t)=>{const{clients:{commerce:a}}=t,d=i?Number(i):0,[r,l]=await Promise.all([a.catalog.brand.list(),a.catalog.category.tree()]),o=[],m=(e,n)=>{o.push({...e,level:n});for(const i of e.children)m(i,n+1)};for(const e of l)m(e,0);const u=[...r.filter(e=>e.isActive).map(e=>({...e,type:"brand"})),...o].filter(e=>Boolean(g.slug(e,null,t,null)));return{pageInfo:{hasNextPage:u.length-d>n,hasPreviousPage:d>0,startCursor:"0",endCursor:(Math.min(n,u.length-d)-1).toString()},edges:u.slice(d,d+n).map((e,n)=>({node:e,cursor:(d+n).toString()}))}}},w={StoreCollection:g,StoreAggregateOffer:{highPrice:({items:e})=>{var n,i;return e.reduce((e,n)=>e>n.sellingPrice?e:n.sellingPrice,null!=(n=null==(i=e[0])?void 0:i.sellingPrice)?n:0)/100},lowPrice:({items:e})=>{var n,i;return e.reduce((e,n)=>e<n.sellingPrice?e:n.sellingPrice,null!=(n=null==(i=e[0])?void 0:i.sellingPrice)?n:0)/100},offerCount:({items:e})=>e.length,priceCurrency:()=>"",offers:({items:e,product:n})=>e.map(e=>({...e,product:n}))},StoreProduct:{productID:({id:e})=>e,name:({isVariantOf:e,name:n})=>null!=n?n:e.name,slug:({isVariantOf:{link:e},id:n})=>b(e,n),description:({isVariantOf:{description:e}})=>e,seo:({isVariantOf:{name:e,description:n}})=>({title:e,description:n}),brand:({isVariantOf:{brand:e}})=>({name:e}),breadcrumbList:({isVariantOf:{categoryTrees:e,name:n,link:i},id:t})=>({itemListElement:[...e.reverse().map(({categoryNames:e},n)=>({name:e[e.length-1],item:"/"+e.map(e=>N(e)).join("/"),position:n+1})),{name:n,item:O(i,t),position:e.length+1}],numberOfItems:e.length}),image:({isVariantOf:e,images:n})=>{var i,t;return(null!=(i=null!=(t=I(n))?t:I(e.images))?i:[F]).map(({name:e,value:n})=>({alternateName:null!=e?e:"",url:n.replace("vteximg.com.br","vtexassets.com")}))},sku:({id:e})=>e,gtin:({reference:e})=>null!=e?e:"",review:()=>[],aggregateRating:()=>({}),offers:async(e,n,i)=>{var t;const{loaders:{simulationLoader:a},storage:{channel:d}}=i,{id:r,policies:l}=e,o=null==(t=l.find(e=>e.id===d))?void 0:t.sellers;if(null==o)throw new Error(`Product with id ${r} has no sellers for channel ${d}.`);const m=o.map(e=>e.id),u=Array.from(new Set(m)).map(e=>({quantity:1,seller:e,id:r}));return{...await a.load(u),product:e}},isVariantOf:({isVariantOf:e})=>e,additionalProperty:({attributes:e=[]})=>e.map(e=>({name:e.key,value:e.value}))},StoreSeo:{title:({title:e})=>null!=e?e:"",description:({description:e})=>null!=e?e:"",titleTemplate:()=>"",canonical:()=>""},StoreFacet:{key:({key:e})=>e,label:({label:e})=>e,values:({values:e})=>e,type:({type:e})=>"text"===e?"BOOLEAN":"RANGE"},StoreFacetValue:{value:({key:e,from:n,to:i})=>null!=e?e:`${n}-to-${i}`,label:({label:e})=>null!=e?e:"unknown",selected:({active:e})=>e,quantity:({count:e})=>e},StoreOffer:{priceCurrency:()=>"",priceValidUntil:({priceValidUntil:e})=>null!=e?e:"",itemCondition:()=>"https://schema.org/NewCondition",availability:({availability:e})=>"available"===e?"https://schema.org/InStock":"https://schema.org/OutOfStock",seller:({seller:e})=>({identifier:e}),price:({sellingPrice:e})=>e/100,sellingPrice:({sellingPrice:e})=>e/100,listPrice:({listPrice:e})=>e/100,itemOffered:({product:e})=>e,quantity:({quantity:e})=>e},StoreAggregateRating:{ratingValue:()=>5,reviewCount:()=>0},StoreReview:{reviewRating:()=>({ratingValue:5,bestRating:5}),author:()=>({name:""})},StoreProductGroup:{hasVariant:e=>e.skus.map(n=>c(n,e)),productGroupID:({product:e})=>e,name:({name:e})=>e,additionalProperty:({textAttributes:e=[],productSpecifications:n=[]})=>{const i=new Set(n);return e.filter(e=>i.has(e.labelKey)).map(e=>({name:e.labelKey,value:e.labelValue}))}},StoreSearchResult:{products:async(e,n,i)=>{const{clients:{search:t}}=i,a=await t.products(e),d=a.products.map(e=>{const n=e.skus.find(e=>e.sellers.length>0);return n&&c(n,e)}).filter(e=>!!e);return{pageInfo:{hasNextPage:a.pagination.after.length>0,hasPreviousPage:a.pagination.before.length>0,startCursor:"0",endCursor:a.total.toString(),totalCount:a.total},edges:d.map((e,n)=>({node:e,cursor:n.toString()}))}},facets:async(e,n,i)=>{var t;const{clients:{search:a}}=i;return null!=(t=(await a.facets(e)).attributes)?t:[]}},Query:L,Mutation:{validateCart:async(e,{cart:{order:{orderNumber:n,acceptedOffer:i}}},t)=>{const{clients:{commerce:a},loaders:{skuLoader:d}}=t,l=await a.checkout.orderForm({id:n}),o=h(i),m=h(l.items.map(S)),u=Array.from(o.values()),s=Array.from(m.values()),{itemsToAdd:p,itemsToUpdate:c}=u.reduce((e,n)=>{const i=m.get(T(n));return i?e.itemsToUpdate.push({...i,quantity:n.quantity}):e.itemsToAdd.push(n),e},{itemsToAdd:[],itemsToUpdate:[]}),k=[...p,...c,...s.filter(e=>!o.has(T(e))).map(e=>({...e,quantity:0}))].map(D);if(0===k.length)return null;const y=await a.checkout.updateOrderFormItems({id:l.orderFormId,orderItems:k});return((e,n)=>{const i=({orderFormId:e,messages:n,items:i,salesChannel:t})=>({orderFormId:e,messages:n,salesChannel:t,items:i.map(({uniqueId:e,quantity:n,seller:i,sellingPrice:t,availability:a})=>({uniqueId:e,quantity:n,seller:i,sellingPrice:t,availability:a}))});return r(i(e),i(n))})(l,y)?null:{order:{orderNumber:y.orderFormId,acceptedOffer:y.items.map(e=>({...e,product:d.load([{key:"id",value:e.id}])}))},messages:y.messages.map(({text:e,status:n})=>({text:e,status:n.toUpperCase()}))}}}};var q={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreAggregateOffer"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"highPrice"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"lowPrice"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"offerCount"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"priceCurrency"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"offers"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreOffer"}}}}},directives:[]}]}],loc:{start:0,end:261}};q.loc.source={body:"type StoreAggregateOffer {\n # Highest spot price amongst all sellers\n highPrice: Float!\n # Lowest spot price amongst all sellers\n lowPrice: Float!\n # Number of sellers selling this sku\n offerCount: Int!\n priceCurrency: String!\n offers: [StoreOffer!]!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var R={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreAggregateRating"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"ratingValue"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"reviewCount"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]}],loc:{start:0,end:72}};R.loc.source={body:"type StoreAggregateRating {\n ratingValue: Float!\n reviewCount: Int!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var E={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreAuthor"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"name"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]}],loc:{start:0,end:37}};E.loc.source={body:"type StoreAuthor {\n name: String!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var j={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreBrand"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"name"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]}],loc:{start:0,end:36}};j.loc.source={body:"type StoreBrand {\n name: String!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var _={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreListItem"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"item"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"name"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"position"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreBreadcrumbList"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"itemListElement"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreListItem"}}}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"numberOfItems"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]}],loc:{start:0,end:161}};_.loc.source={body:"type StoreListItem {\n item: String!\n name: String!\n position: Int!\n}\n\ntype StoreBreadcrumbList {\n itemListElement: [StoreListItem!]!\n numberOfItems: Int!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var A={kind:"Document",definitions:[{kind:"EnumTypeDefinition",name:{kind:"Name",value:"StoreCollectionType"},directives:[],values:[{kind:"EnumValueDefinition",name:{kind:"Name",value:"Department"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"Category"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"Brand"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"Cluster"},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCollectionFacet"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"key"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"value"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCollectionMeta"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"selectedFacets"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollectionFacet"}}}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCollection"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"seo"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreSeo"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"breadcrumbList"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreBreadcrumbList"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"meta"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollectionMeta"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"id"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"slug"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"type"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollectionType"}}},directives:[]}]}],loc:{start:0,end:424}};A.loc.source={body:"enum StoreCollectionType {\n Department\n Category\n Brand\n Cluster\n}\n\ntype StoreCollectionFacet {\n key: String!\n value: String!\n}\n\ntype StoreCollectionMeta {\n selectedFacets: [StoreCollectionFacet!]!\n}\n\ntype StoreCollection {\n # Meta tag data\n seo: StoreSeo!\n # location for structured data\n breadcrumbList: StoreBreadcrumbList!\n meta: StoreCollectionMeta!\n id: ID!\n slug: String!\n type: StoreCollectionType!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var x={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreFacet"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"key"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"label"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"values"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreFacetValue"}}}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"type"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreFacetType"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreFacetValue"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"value"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"label"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"selected"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Boolean"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"quantity"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]}],loc:{start:0,end:240}};x.loc.source={body:"type StoreFacet {\n key: String!\n label: String!\n values: [StoreFacetValue!]!\n type: StoreFacetType!\n}\n\ntype StoreFacetValue {\n value: String!\n label: String!\n selected: Boolean!\n # Number of items with this facet\n quantity: Int!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var G={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreImage"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"url"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"alternateName"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreImage"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"url"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"alternateName"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]}],loc:{start:0,end:123}};G.loc.source={body:"type StoreImage {\n url: String!\n alternateName: String!\n}\n\ninput IStoreImage {\n url: String!\n alternateName: String!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var $={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"Mutation"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"validateCart"},arguments:[{kind:"InputValueDefinition",name:{kind:"Name",value:"cart"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreCart"}}},directives:[]}],type:{kind:"NamedType",name:{kind:"Name",value:"StoreCart"}},directives:[]}]}],loc:{start:0,end:148}};$.loc.source={body:"type Mutation {\n # Returns the order if anything changed with the order. Null if the order is valid\n validateCart(cart: IStoreCart!): StoreCart\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var B={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreOffer"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"listPrice"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"sellingPrice"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"priceCurrency"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"price"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"priceValidUntil"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"itemCondition"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"availability"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"seller"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreOrganization"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"itemOffered"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProduct"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"quantity"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreOffer"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"price"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"listPrice"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"seller"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreOrganization"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"itemOffered"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreProduct"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"quantity"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]}],loc:{start:0,end:419}};B.loc.source={body:"type StoreOffer {\n listPrice: Float!\n sellingPrice: Float!\n priceCurrency: String!\n # Also known as spotPrice\n price: Float!\n priceValidUntil: String!\n itemCondition: String!\n availability: String!\n seller: StoreOrganization!\n itemOffered: StoreProduct!\n quantity: Int!\n}\n\ninput IStoreOffer {\n price: Float!\n listPrice: Float!\n seller: IStoreOrganization!\n itemOffered: IStoreProduct!\n quantity: Int!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var Q={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreOrder"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"orderNumber"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"acceptedOffer"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreOffer"}}}}},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreOrder"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"orderNumber"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"acceptedOffer"},type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreOffer"}}}}},directives:[]}]}],loc:{start:0,end:154}};Q.loc.source={body:"type StoreOrder {\n orderNumber: String!\n acceptedOffer: [StoreOffer!]!\n}\n\ninput IStoreOrder {\n orderNumber: String!\n acceptedOffer: [IStoreOffer!]!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var M={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreOrganization"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"identifier"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreOrganization"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"identifier"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]}],loc:{start:0,end:101}};M.loc.source={body:"type StoreOrganization {\n identifier: String!\n}\n\ninput IStoreOrganization {\n identifier: String!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var U={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StorePageInfo"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"hasNextPage"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Boolean"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"hasPreviousPage"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Boolean"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"startCursor"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"endCursor"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"totalCount"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]}]}],loc:{start:0,end:197}};U.loc.source={body:"type StorePageInfo {\n hasNextPage: Boolean!\n hasPreviousPage: Boolean!\n startCursor: String!\n endCursor: String!\n # Total number of items(products/collections), not pages\n totalCount: Int!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var z={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreProduct"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"seo"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreSeo"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"breadcrumbList"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreBreadcrumbList"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"slug"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"name"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"productID"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"brand"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreBrand"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"description"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"image"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreImage"}}}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"offers"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreAggregateOffer"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"sku"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"gtin"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"review"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreReview"}}}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"aggregateRating"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreAggregateRating"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"isVariantOf"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProductGroup"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"additionalProperty"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StorePropertyValue"}}}}},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreProduct"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"sku"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"name"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"image"},type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreImage"}}}}},directives:[]}]}],loc:{start:0,end:573}};z.loc.source={body:"type StoreProduct {\n # Meta tag data\n seo: StoreSeo!\n # Location for structured data\n breadcrumbList: StoreBreadcrumbList!\n # Where to retrieve this entity\n slug: String!\n name: String!\n productID: String!\n brand: StoreBrand!\n description: String!\n image: [StoreImage!]!\n offers: StoreAggregateOffer!\n sku: String!\n gtin: String!\n review: [StoreReview!]!\n aggregateRating: StoreAggregateRating!\n isVariantOf: StoreProductGroup!\n additionalProperty: [StorePropertyValue!]!\n}\n\ninput IStoreProduct {\n sku: String!\n name: String!\n image: [IStoreImage!]!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var K={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreProductGroup"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"hasVariant"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProduct"}}}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"productGroupID"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"name"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"additionalProperty"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StorePropertyValue"}}}}},directives:[]}]}],loc:{start:0,end:145}};K.loc.source={body:"type StoreProductGroup {\n hasVariant: [StoreProduct!]!\n productGroupID: String!\n name: String!\n additionalProperty: [StorePropertyValue!]!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var W={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreProductEdge"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"node"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProduct"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"cursor"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreProductConnection"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"pageInfo"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StorePageInfo"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"edges"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProductEdge"}}}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCollectionEdge"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"node"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollection"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"cursor"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCollectionConnection"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"pageInfo"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StorePageInfo"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"edges"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollectionEdge"}}}}},directives:[]}]},{kind:"EnumTypeDefinition",name:{kind:"Name",value:"StoreSort"},directives:[],values:[{kind:"EnumValueDefinition",name:{kind:"Name",value:"price_desc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"price_asc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"orders_desc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"name_desc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"name_asc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"release_desc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"discount_desc"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"score_desc"},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreSelectedFacet"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"key"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"value"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]},{kind:"EnumTypeDefinition",name:{kind:"Name",value:"StoreFacetType"},directives:[],values:[{kind:"EnumValueDefinition",name:{kind:"Name",value:"BOOLEAN"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"RANGE"},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreSearchResult"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"products"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProductConnection"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"facets"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreFacet"}}}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"Query"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"product"},arguments:[{kind:"InputValueDefinition",name:{kind:"Name",value:"locator"},type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreSelectedFacet"}}}}},directives:[]}],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProduct"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"collection"},arguments:[{kind:"InputValueDefinition",name:{kind:"Name",value:"slug"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollection"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"search"},arguments:[{kind:"InputValueDefinition",name:{kind:"Name",value:"first"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"after"},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"sort"},type:{kind:"NamedType",name:{kind:"Name",value:"StoreSort"}},defaultValue:{kind:"EnumValue",value:"score_desc"},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"term"},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},defaultValue:{kind:"StringValue",value:"",block:!1},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"selectedFacets"},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreSelectedFacet"}}}},directives:[]}],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreSearchResult"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"allProducts"},arguments:[{kind:"InputValueDefinition",name:{kind:"Name",value:"first"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"after"},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},directives:[]}],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreProductConnection"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"allCollections"},arguments:[{kind:"InputValueDefinition",name:{kind:"Name",value:"first"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},directives:[]},{kind:"InputValueDefinition",name:{kind:"Name",value:"after"},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},directives:[]}],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCollectionConnection"}}},directives:[]}]}],loc:{start:0,end:1077}};W.loc.source={body:'type StoreProductEdge {\n node: StoreProduct!\n cursor: String!\n}\n\ntype StoreProductConnection {\n pageInfo: StorePageInfo!\n edges: [StoreProductEdge!]!\n}\n\ntype StoreCollectionEdge {\n node: StoreCollection!\n cursor: String!\n}\n\ntype StoreCollectionConnection {\n pageInfo: StorePageInfo!\n edges: [StoreCollectionEdge!]!\n}\n\nenum StoreSort {\n price_desc\n price_asc\n orders_desc\n name_desc\n name_asc\n release_desc\n discount_desc\n score_desc\n}\n\ninput IStoreSelectedFacet {\n key: String!\n value: String!\n}\n\nenum StoreFacetType {\n BOOLEAN\n RANGE\n}\n\ntype StoreSearchResult {\n products: StoreProductConnection!\n facets: [StoreFacet!]!\n}\n\ntype Query {\n product(locator: [IStoreSelectedFacet!]!): StoreProduct!\n\n collection(slug: String!): StoreCollection!\n\n search(\n first: Int!\n after: String\n sort: StoreSort = score_desc\n term: String = ""\n selectedFacets: [IStoreSelectedFacet!]\n ): StoreSearchResult!\n\n allProducts(first: Int!, after: String): StoreProductConnection!\n\n allCollections(first: Int!, after: String): StoreCollectionConnection!\n}\n',name:"GraphQL request",locationOffset:{line:1,column:1}};var H={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreReviewRating"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"ratingValue"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"bestRating"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Float"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreReview"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"reviewRating"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreReviewRating"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"author"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreAuthor"}}},directives:[]}]}],loc:{start:0,end:150}};H.loc.source={body:"type StoreReviewRating {\n ratingValue: Float!\n bestRating: Float!\n}\n\ntype StoreReview {\n reviewRating: StoreReviewRating!\n author: StoreAuthor!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var J={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreSeo"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"title"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"titleTemplate"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"description"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"canonical"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]}],loc:{start:0,end:104}};J.loc.source={body:"type StoreSeo {\n title: String!\n titleTemplate: String!\n description: String!\n canonical: String!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var X={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCartMessage"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"text"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"status"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreStatus"}}},directives:[]}]},{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StoreCart"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"order"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreOrder"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"messages"},arguments:[],type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"StoreCartMessage"}}}}},directives:[]}]},{kind:"InputObjectTypeDefinition",name:{kind:"Name",value:"IStoreCart"},directives:[],fields:[{kind:"InputValueDefinition",name:{kind:"Name",value:"order"},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"IStoreOrder"}}},directives:[]}]}],loc:{start:0,end:183}};X.loc.source={body:"type StoreCartMessage {\n text: String!\n status: StoreStatus!\n}\n\ntype StoreCart {\n order: StoreOrder!\n messages: [StoreCartMessage!]!\n}\n\ninput IStoreCart {\n order: IStoreOrder!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var Y={kind:"Document",definitions:[{kind:"EnumTypeDefinition",name:{kind:"Name",value:"StoreStatus"},directives:[],values:[{kind:"EnumValueDefinition",name:{kind:"Name",value:"INFO"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"WARNING"},directives:[]},{kind:"EnumValueDefinition",name:{kind:"Name",value:"ERROR"},directives:[]}]}],loc:{start:0,end:46}};Y.loc.source={body:"enum StoreStatus {\n INFO\n WARNING\n ERROR\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};var Z={kind:"Document",definitions:[{kind:"ObjectTypeDefinition",name:{kind:"Name",value:"StorePropertyValue"},interfaces:[],directives:[],fields:[{kind:"FieldDefinition",name:{kind:"Name",value:"value"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]},{kind:"FieldDefinition",name:{kind:"Name",value:"name"},arguments:[],type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}]}],loc:{start:0,end:61}};Z.loc.source={body:"type StorePropertyValue {\n value: String!\n name: String!\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};const ee=[W,$,j,_,A,x,G,U,z,J,B,R,H,E,K,M,q,Q,X,Y,Z].map(l.print).join("\n"),ne={vtex:{getResolvers:e=>w,getContextFactory:e=>n=>(n.storage={channel:e.channel},n.clients=((e,n)=>({search:u(e,n),commerce:(({account:e,environment:n},i)=>{const t=`http://${e}.${n}.com.br`;return{catalog:{brand:{list:()=>o(t+"/api/catalog_system/pub/brand/list")},category:{tree:(e=3)=>o(`${t}/api/catalog_system/pub/category/tree/${e}`)},portal:{pagetype:e=>o(`${t}/api/catalog_system/pub/portal/pagetype/${e}`)}},checkout:{simulation:(e,{salesChannel:n}={salesChannel:i.storage.channel})=>{const a=new URLSearchParams({sc:n});return o(`${t}/api/checkout/pub/orderForms/simulation?${a.toString()}`,{...m,body:JSON.stringify(e)})},orderForm:({id:e,refreshOutdatedData:n=!0,salesChannel:a=i.storage.channel})=>{const d=new URLSearchParams({refreshOutdatedData:n.toString(),sc:a});return o(`${t}/api/checkout/pub/orderForm/${e}?${d.toString()}`,m)},updateOrderFormItems:({id:e,orderItems:n,allowOutdatedData:a="paymentData",salesChannel:d=i.storage.channel})=>{const r=new URLSearchParams({allowOutdatedData:a,sc:d});return o(`${t}/api/checkout/pub/orderForm/${e}/items?${r}`,{...m,body:JSON.stringify({orderItems:n}),method:"PATCH"})}}}})(e,n)}))(e,n),n.loaders=((e,{clients:n})=>({skuLoader:((e,n)=>new t(async e=>{const i=e.map(e=>{const n=e.find(({key:e})=>"id"===e);if(!n)throw new s("Error while loading SKU. Needs to pass an id to selected facets");return n.value}),{products:t}=await n.search.products({query:"sku:"+i.join(";"),page:0,count:i.length}),a=t.reduce((e,n)=>{for(const i of n.skus)e[i.id]=c(i,n);return e},{}),d=i.map(e=>a[e]),r=d.filter(e=>!e);if(r.length>0)throw new Error("Search API did not return the following skus: "+r.join(","));return d},{maxBatchSize:99}))(0,n),simulationLoader:((e,n)=>new t(async e=>{const i=[...e.flat()],t=await n.commerce.checkout.simulation({items:i}),a=t.items.reduce((e,n)=>{const i=n.requestIndex;return"number"==typeof i&&i<e.length&&(e[i]=n),e},Array(i.length).fill(null)),d=e.reduce((e,n)=>[...e,n.length+e[e.length-1]],[0]);return e.map((e,n)=>({...t,items:a.slice(d[n],d[n+1]).filter(e=>Boolean(e))}))},{maxBatchSize:20}))(0,n),collectionLoader:((e,n)=>{const i=a(20);return new t(async e=>Promise.all(e.map(e=>i(async()=>{const i=await n.commerce.catalog.portal.pagetype(e);if(y(i))return i;throw new p(`Catalog returned ${i.pageType} for slug: ${e}. This usually happens when there is more than one category with the same name in the same category tree level.`)}))),{batch:!1})})(0,n)}))(0,n),n)}},ie=()=>ee,te=e=>ne[e.platform].getResolvers(e);exports.getContextFactory=e=>ne[e.platform].getContextFactory(e),exports.getResolvers=te,exports.getSchema=async e=>n.makeExecutableSchema({resolvers:te(e),typeDefs:ie()}),exports.getTypeDefs=ie;
2
2
  //# sourceMappingURL=api.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.cjs.production.min.js","sources":["../src/platforms/vtex/clients/fetch.ts","../src/platforms/vtex/clients/commerce/index.ts","../src/platforms/vtex/clients/search/index.ts","../src/platforms/vtex/utils/errors.ts","../src/platforms/vtex/utils/enhanceSku.ts","../src/platforms/vtex/loaders/collection.ts","../src/platforms/vtex/utils/slugify.ts","../src/platforms/vtex/resolvers/collection.ts","../src/platforms/vtex/resolvers/validateCart.ts","../src/platforms/vtex/resolvers/product.ts","../src/platforms/vtex/utils/facets.ts","../src/platforms/vtex/utils/sort.ts","../src/platforms/vtex/resolvers/query.ts","../src/platforms/vtex/index.ts","../src/platforms/vtex/resolvers/aggregateOffer.ts","../src/platforms/vtex/resolvers/seo.ts","../src/platforms/vtex/resolvers/facet.ts","../src/platforms/vtex/resolvers/facetValue.ts","../src/platforms/vtex/resolvers/offer.ts","../src/platforms/vtex/resolvers/aggregateRating.ts","../src/platforms/vtex/resolvers/review.ts","../src/platforms/vtex/resolvers/productGroup.ts","../src/platforms/vtex/resolvers/searchResult.ts","../src/platforms/vtex/resolvers/mutation.ts","../src/typeDefs/index.ts","../src/index.ts","../src/platforms/vtex/clients/index.ts","../src/platforms/vtex/loaders/index.ts","../src/platforms/vtex/loaders/sku.ts","../src/platforms/vtex/loaders/simulation.ts"],"sourcesContent":["import fetch from 'isomorphic-unfetch'\n\nexport const fetchAPI = async (info: RequestInfo, init?: RequestInit) => {\n const response = await fetch(info, init)\n\n if (response.ok) {\n return response.json()\n }\n\n const text = await response.text()\n\n throw new Error(text)\n}\n","import type { Context, Options } from '../../index'\nimport { fetchAPI } from '../fetch'\nimport type { Brand } from './types/Brand'\nimport type { CategoryTree } from './types/CategoryTree'\nimport type { OrderForm, OrderFormInputItem } from './types/OrderForm'\nimport type { PortalPagetype } from './types/Portal'\nimport type {\n Simulation,\n SimulationArgs,\n SimulationOptions,\n} from './types/Simulation'\n\nconst BASE_INIT = {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n },\n}\n\nexport const VtexCommerce = (\n { account, environment }: Options,\n ctx: Context\n) => {\n const base = `http://${account}.${environment}.com.br`\n\n return {\n catalog: {\n brand: {\n list: (): Promise<Brand[]> =>\n fetchAPI(`${base}/api/catalog_system/pub/brand/list`),\n },\n category: {\n tree: (depth = 3): Promise<CategoryTree[]> =>\n fetchAPI(`${base}/api/catalog_system/pub/category/tree/${depth}`),\n },\n portal: {\n pagetype: (slug: string): Promise<PortalPagetype> =>\n fetchAPI(`${base}/api/catalog_system/pub/portal/pagetype/${slug}`),\n },\n },\n checkout: {\n simulation: (\n args: SimulationArgs,\n { salesChannel }: SimulationOptions = {\n salesChannel: ctx.storage.channel,\n }\n ): Promise<Simulation> => {\n const params = new URLSearchParams({\n sc: salesChannel,\n })\n\n return fetchAPI(\n `${base}/api/checkout/pub/orderForms/simulation?${params.toString()}`,\n {\n ...BASE_INIT,\n body: JSON.stringify(args),\n }\n )\n },\n orderForm: ({\n id,\n refreshOutdatedData = true,\n salesChannel = ctx.storage.channel,\n }: {\n id: string\n refreshOutdatedData?: boolean\n salesChannel?: string\n }): Promise<OrderForm> => {\n const params = new URLSearchParams({\n refreshOutdatedData: refreshOutdatedData.toString(),\n sc: salesChannel,\n })\n\n return fetchAPI(\n `${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`,\n BASE_INIT\n )\n },\n updateOrderFormItems: ({\n id,\n orderItems,\n allowOutdatedData = 'paymentData',\n salesChannel = ctx.storage.channel,\n }: {\n id: string\n orderItems: OrderFormInputItem[]\n allowOutdatedData?: 'paymentData'\n salesChannel?: string\n }): Promise<OrderForm> => {\n const params = new URLSearchParams({\n allowOutdatedData,\n sc: salesChannel,\n })\n\n return fetchAPI(\n `${base}/api/checkout/pub/orderForm/${id}/items?${params}`,\n {\n ...BASE_INIT,\n body: JSON.stringify({ orderItems }),\n method: 'PATCH',\n }\n )\n },\n },\n }\n}\n","import type { Context, Options } from '../../index'\nimport { fetchAPI } from '../fetch'\nimport type { SelectedFacet } from '../../utils/facets'\nimport type { ProductSearchResult } from './types/ProductSearchResult'\nimport type { AttributeSearchResult } from './types/AttributeSearchResult'\n\nexport type Sort =\n | 'price:desc'\n | 'price:asc'\n | 'orders:desc'\n | 'name:desc'\n | 'name:asc'\n | 'release:desc'\n | 'discount:desc'\n | ''\n\nexport interface SearchArgs {\n query?: string\n page: number\n count: number\n type: 'product_search' | 'attribute_search'\n sort?: Sort\n selectedFacets?: SelectedFacet[]\n fuzzy?: '0' | '1'\n}\n\nexport interface ProductLocator {\n field: 'id' | 'slug'\n value: string\n}\n\nexport const IntelligentSearch = (\n { account, environment }: Options,\n ctx: Context\n) => {\n const base = `http://portal.${environment}.com.br/search-api/v1/${account}`\n const policyFacet = { key: 'trade-policy', value: ctx.storage.channel }\n\n const addDefaultFacets = (facets: SelectedFacet[]) => {\n const facet = facets.find(({ key }) => key === policyFacet.key)\n\n if (facet === undefined) {\n return [...facets, policyFacet]\n }\n\n return facets\n }\n\n const search = <T>({\n query = '',\n page,\n count,\n sort = '',\n selectedFacets = [],\n type,\n fuzzy = '0',\n }: SearchArgs): Promise<T> => {\n const params = new URLSearchParams({\n page: (page + 1).toString(),\n count: count.toString(),\n query,\n sort,\n fuzzy,\n })\n\n const pathname = addDefaultFacets(selectedFacets)\n .map(({ key, value }) => `${key}/${value}`)\n .join('/')\n\n return fetchAPI(\n `${base}/api/split/${type}/${pathname}?${params.toString()}`\n )\n }\n\n const products = (args: Omit<SearchArgs, 'type'>) =>\n search<ProductSearchResult>({ ...args, type: 'product_search' })\n\n const facets = (args: Omit<SearchArgs, 'type'>) =>\n search<AttributeSearchResult>({ ...args, type: 'attribute_search' })\n\n return {\n facets,\n products,\n }\n}\n","export class BadRequestError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'BadRequestError'\n }\n}\n\nexport class NotFoundError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'NotFoundError'\n }\n}\n","import type { Product, Sku } from '../clients/search/types/ProductSearchResult'\n\nexport type EnhancedSku = Sku & { isVariantOf: Product }\n\nexport const enhanceSku = (sku: Sku, product: Product): EnhancedSku => ({\n ...sku,\n isVariantOf: product,\n})\n","import DataLoader from 'dataloader'\nimport pLimit from 'p-limit'\n\nimport { NotFoundError } from '../utils/errors'\nimport type { CollectionPageType } from '../clients/commerce/types/Portal'\nimport type { Options } from '..'\nimport type { Clients } from '../clients'\n\n// Limits concurrent requests to 20 so that they don't timeout\nconst CONCURRENT_REQUESTS_MAX = 20\n\nconst collectionPageTypes = new Set([\n 'brand',\n 'category',\n 'department',\n 'subcategory',\n] as const)\n\nexport const isCollectionPageType = (x: any): x is CollectionPageType =>\n typeof x.pageType === 'string' &&\n collectionPageTypes.has(x.pageType.toLowerCase())\n\nexport const getCollectionLoader = (_: Options, clients: Clients) => {\n const limit = pLimit(CONCURRENT_REQUESTS_MAX)\n\n const loader = async (\n slugs: readonly string[]\n ): Promise<CollectionPageType[]> => {\n return Promise.all(\n slugs.map((slug: string) =>\n limit(async () => {\n const page = await clients.commerce.catalog.portal.pagetype(slug)\n\n if (isCollectionPageType(page)) {\n return page\n }\n\n throw new NotFoundError(\n `Catalog returned ${page.pageType} for slug: ${slug}. This usually happens when there is more than one category with the same name in the same category tree level.`\n )\n })\n )\n )\n }\n\n return new DataLoader<string, CollectionPageType>(loader, {\n // DataLoader is being used to cache requests, not to batch them\n batch: false,\n })\n}\n","import rawSlugify from '@sindresorhus/slugify'\n\nexport const slugify = (path: string) =>\n rawSlugify(path, { separator: '-', lowercase: true })\n","import { isCollectionPageType } from '../loaders/collection'\nimport { slugify as baseSlugify } from '../utils/slugify'\nimport type { Resolver } from '..'\nimport type { Brand } from '../clients/commerce/types/Brand'\nimport type { CategoryTree } from '../clients/commerce/types/CategoryTree'\nimport type { CollectionPageType } from '../clients/commerce/types/Portal'\n\ntype Root = Brand | (CategoryTree & { level: number }) | CollectionPageType\n\nconst isBrand = (x: any): x is Brand => x.type === 'brand'\n\nconst slugify = (root: Root) => {\n if (isBrand(root)) {\n return baseSlugify(root.name.toLowerCase())\n }\n\n if (isCollectionPageType(root)) {\n return new URL(`https://${root.url}`).pathname.slice(1)\n }\n\n return new URL(root.url).pathname.slice(1)\n}\n\nexport const StoreCollection: Record<string, Resolver<Root>> = {\n id: ({ id }) => id.toString(),\n slug: (root) => slugify(root),\n seo: (root) =>\n isBrand(root) || isCollectionPageType(root)\n ? {\n title: root.title,\n description: root.metaTagDescription,\n }\n : {\n title: root.Title,\n description: root.MetaTagDescription,\n },\n type: (root) =>\n isBrand(root)\n ? 'Brand'\n : isCollectionPageType(root)\n ? root.pageType\n : root.level === 0\n ? 'Department'\n : 'Category',\n meta: (root) =>\n isBrand(root)\n ? {\n selectedFacets: [{ key: 'brand', value: baseSlugify(root.name) }],\n }\n : {\n selectedFacets: new URL(\n isCollectionPageType(root) ? `https://${root.url}` : root.url\n ).pathname\n .slice(1)\n .split('/')\n .map((segment, index) => ({\n key: `category-${index + 1}`,\n value: baseSlugify(segment),\n })),\n },\n breadcrumbList: async (root, _, ctx) => {\n const {\n loaders: { collectionLoader },\n } = ctx\n\n const slug = slugify(root)\n\n /**\n * Split slug into segments so we fetch all data for\n * the breadcrumb. For instance, if we get `/foo/bar`\n * we need all metadata for both `/foo` and `/bar` and\n * thus we need to fetch pageType for `/foo` and `/bar`\n */\n const segments = slug.split('/').filter((segment) => Boolean(segment))\n const slugs = segments.map((__, index) =>\n segments.slice(0, index + 1).join('/')\n )\n\n const collections = await Promise.all(\n slugs.map((s) => collectionLoader.load(s))\n )\n\n return {\n itemListElement: collections.map((collection, index) => ({\n item: new URL(`https://${collection.url}`).pathname.toLowerCase(),\n name: collection.name,\n position: index + 1,\n })),\n numberOfItems: collections.length,\n }\n },\n}\n","import deepEquals from 'fast-deep-equal'\n\nimport type { IStoreCart, IStoreOffer } from '../../../__generated__/schema'\nimport type {\n OrderForm,\n OrderFormItem,\n OrderFormInputItem,\n} from '../clients/commerce/types/OrderForm'\nimport type { Context } from '..'\n\ntype Indexed<T> = T & { index?: number }\n\nconst getId = (item: IStoreOffer) =>\n [item.itemOffered.sku, item.seller.identifier, item.price].join('::')\n\nconst orderFormItemToOffer = (\n item: OrderFormItem,\n index?: number\n): Indexed<IStoreOffer> => ({\n listPrice: item.listPrice / 100,\n price: item.sellingPrice / 100,\n quantity: item.quantity,\n seller: { identifier: item.seller },\n itemOffered: {\n sku: item.id,\n image: [],\n name: item.name,\n },\n index,\n})\n\nconst offerToOrderItemInput = (\n offer: Indexed<IStoreOffer>\n): OrderFormInputItem => ({\n quantity: offer.quantity,\n seller: offer.seller.identifier,\n id: offer.itemOffered.sku,\n index: offer.index,\n})\n\nconst groupById = (offers: IStoreOffer[]): Map<string, IStoreOffer> =>\n offers.reduce((acc, item) => {\n const id = getId(item)\n\n acc.set(id, acc.get(id) ?? item)\n\n return acc\n }, new Map<string, IStoreOffer>())\n\nconst equals = (of1: OrderForm, of2: OrderForm) => {\n const pick = ({ orderFormId, messages, items, salesChannel }: OrderForm) => ({\n orderFormId,\n messages,\n salesChannel,\n items: items.map(\n ({ uniqueId, quantity, seller, sellingPrice, availability }) => ({\n uniqueId,\n quantity,\n seller,\n sellingPrice,\n availability,\n })\n ),\n })\n\n return deepEquals(pick(of1), pick(of2))\n}\n\n/**\n * This resolver implements the optimistic cart behavior. The main idea in here\n * is that we receive a cart from the UI (as query params) and we validate it with\n * the commerce platform. If the cart is valid, we return null, if the cart is\n * invalid according to the commerce platform, we return the new cart the UI should use\n * instead\n *\n * The algoritm is something like:\n * 1. Fetch orderForm from VTEX\n * 2. Compute delta changes between the orderForm and the UI's cart\n * 3. Update the orderForm in VTEX platform accordingly\n * 4. If any chages were made, send to the UI the new cart. Null otherwise\n */\nexport const validateCart = async (\n _: unknown,\n {\n cart: {\n order: { orderNumber, acceptedOffer },\n },\n }: { cart: IStoreCart },\n ctx: Context\n) => {\n const {\n clients: { commerce },\n loaders: { skuLoader },\n } = ctx\n\n // Step1: Get OrderForm from VTEX Commerce\n const orderForm = await commerce.checkout.orderForm({\n id: orderNumber,\n })\n\n // Step2: Process items from both browser and checkout so they have the same shape\n const browserItemsById = groupById(acceptedOffer)\n const originItemsById = groupById(orderForm.items.map(orderFormItemToOffer))\n const browserItems = Array.from(browserItemsById.values()) // items on the user's browser\n const originItems = Array.from(originItemsById.values()) // items on the VTEX platform backend\n\n // Step3: Compute delta changes\n const { itemsToAdd, itemsToUpdate } = browserItems.reduce(\n (acc, item) => {\n const maybeOriginItem = originItemsById.get(getId(item))\n\n if (!maybeOriginItem) {\n acc.itemsToAdd.push(item)\n } else {\n acc.itemsToUpdate.push({\n ...maybeOriginItem,\n quantity: item.quantity,\n })\n }\n\n return acc\n },\n {\n itemsToAdd: [] as IStoreOffer[],\n itemsToUpdate: [] as IStoreOffer[],\n }\n )\n\n const itemsToDelete = originItems\n .filter((item) => !browserItemsById.has(getId(item)))\n .map((item) => ({ ...item, quantity: 0 }))\n\n const changes = [...itemsToAdd, ...itemsToUpdate, ...itemsToDelete].map(\n offerToOrderItemInput\n )\n\n if (changes.length === 0) {\n return null\n }\n\n // Step4: Apply delta changes to order form\n const updatedOrderForm = await commerce.checkout.updateOrderFormItems({\n id: orderForm.orderFormId,\n orderItems: changes,\n })\n\n // Step5: If no changes detected before/after updating orderForm, the order is validated\n if (equals(orderForm, updatedOrderForm)) {\n return null\n }\n\n // Step6: There were changes, convert orderForm to StoreOrder\n return {\n order: {\n orderNumber: updatedOrderForm.orderFormId,\n acceptedOffer: updatedOrderForm.items.map((item) => ({\n ...item,\n product: skuLoader.load([{ key: 'id', value: item.id }]), // TODO: add channel\n })),\n },\n messages: updatedOrderForm.messages.map(({ text, status }) => ({\n text,\n status: status.toUpperCase(),\n })),\n }\n}\n","import type { Resolver } from '..'\nimport type { EnhancedSku } from '../utils/enhanceSku'\nimport { slugify } from '../utils/slugify'\n\ntype Root = EnhancedSku\n\nconst DEFAULT_IMAGE = {\n name: 'image',\n value:\n 'https://storecomponents.vtexassets.com/assets/faststore/images/image___117a6d3e229a96ad0e0d0876352566e2.svg',\n}\n\nconst getSlug = (link: string, id: string) => `${link}-${id}`\nconst getPath = (link: string, id: string) => `/${getSlug(link, id)}/p`\nconst nonEmptyArray = <T>(array: T[] | null | undefined) =>\n Array.isArray(array) && array.length > 0 ? array : null\n\nexport const StoreProduct: Record<string, Resolver<Root>> = {\n productID: ({ id }) => id,\n name: ({ isVariantOf, name }) => name ?? isVariantOf.name,\n slug: ({ isVariantOf: { link }, id }) => getSlug(link, id),\n description: ({ isVariantOf: { description } }) => description,\n seo: ({ isVariantOf: { name, description } }) => ({\n title: name,\n description,\n }),\n brand: ({ isVariantOf: { brand } }) => ({ name: brand }),\n breadcrumbList: ({ isVariantOf: { categoryTrees, name, link }, id }) => ({\n itemListElement: [\n ...categoryTrees.reverse().map(({ categoryNames }, index) => ({\n name: categoryNames[categoryNames.length - 1],\n item: `/${categoryNames\n .map((categoryName) => slugify(categoryName))\n .join('/')}`,\n position: index + 1,\n })),\n {\n name,\n item: getPath(link, id),\n position: categoryTrees.length + 1,\n },\n ],\n numberOfItems: categoryTrees.length,\n }),\n image: ({ isVariantOf, images }) =>\n (\n nonEmptyArray(images) ??\n nonEmptyArray(isVariantOf.images) ?? [DEFAULT_IMAGE]\n ).map(({ name, value }) => ({\n alternateName: name ?? '',\n url: value.replace('vteximg.com.br', 'vtexassets.com'),\n })),\n sku: ({\n isVariantOf: {\n skus: [sku],\n },\n }) => sku.id,\n gtin: ({ reference }) => reference ?? '',\n review: () => [],\n aggregateRating: () => ({}),\n offers: async (product, _, ctx) => {\n const {\n loaders: { simulationLoader },\n storage: { channel },\n } = ctx\n\n const { id, policies } = product\n const sellers = policies.find((policy) => policy.id === channel)?.sellers\n\n if (sellers == null) {\n // This error will likely happen when you forget to forward the channel somewhere in your code.\n // Make sure all queries that lead to a product are forwarding the channel in context corectly\n throw new Error(\n `Product with id ${id} has no sellers for channel ${channel}.`\n )\n }\n\n // Unique seller ids\n const sellerIds = sellers.map((seller) => seller.id)\n const items = Array.from(new Set(sellerIds)).map((seller) => ({\n quantity: 1,\n seller,\n id,\n }))\n\n const simulation = await simulationLoader.load(items)\n\n return { ...simulation, product }\n },\n isVariantOf: ({ isVariantOf }) => isVariantOf,\n additionalProperty: ({ attributes = [] }) =>\n attributes.map((attribute) => ({\n name: attribute.key,\n value: attribute.value,\n })),\n}\n","import { BadRequestError } from './errors'\n\nexport interface SelectedFacet {\n key: string\n value: string\n}\n\nconst getIdFromSlug = (slug: string) => {\n const id = slug.split('-').pop()\n\n if (id == null) {\n throw new BadRequestError('Error while extracting sku id from product slug')\n }\n\n return id\n}\n\n/**\n * Transform facets from the store to VTEX platform facets.\n * For instance, the channel in Store becames trade-policy in VTEX's realm\n * */\nexport const transformSelectedFacet = ({ key, value }: SelectedFacet) => {\n switch (key) {\n case 'channel':\n return { key: 'trade-policy', value }\n\n case 'slug':\n return { key: 'id', value: getIdFromSlug(value) }\n\n default:\n return { key, value }\n }\n}\n","export const SORT_MAP = {\n price_desc: 'price:desc',\n price_asc: 'price:asc',\n orders_desc: 'orders:desc',\n name_desc: 'name:desc',\n name_asc: 'name:asc',\n release_desc: 'release:desc',\n discount_desc: 'discount:desc',\n score_desc: '',\n} as const\n","import { enhanceSku } from '../utils/enhanceSku'\nimport { transformSelectedFacet } from '../utils/facets'\nimport { SORT_MAP } from '../utils/sort'\nimport { StoreCollection } from './collection'\nimport type {\n QueryProductArgs,\n QueryAllCollectionsArgs,\n QueryAllProductsArgs,\n QuerySearchArgs,\n QueryCollectionArgs,\n} from '../../../__generated__/schema'\nimport type { CategoryTree } from '../clients/commerce/types/CategoryTree'\nimport type { Context } from '../index'\n\nexport const Query = {\n product: async (_: unknown, { locator }: QueryProductArgs, ctx: Context) => {\n // Insert channel in context for later usage\n ctx.storage = {\n ...ctx.storage,\n channel:\n locator.find((facet) => facet.key === 'channel')?.value ??\n ctx.storage.channel,\n }\n\n const {\n loaders: { skuLoader },\n } = ctx\n\n return skuLoader.load(locator.map(transformSelectedFacet))\n },\n collection: (_: unknown, { slug }: QueryCollectionArgs, ctx: Context) => {\n const {\n loaders: { collectionLoader },\n } = ctx\n\n return collectionLoader.load(slug)\n },\n search: async (\n _: unknown,\n { first, after: maybeAfter, sort, term, selectedFacets }: QuerySearchArgs,\n ctx: Context\n ) => {\n // Insert channel in context for later usage\n ctx.storage = {\n ...ctx.storage,\n channel:\n selectedFacets?.find((facet) => facet.key === 'channel')?.value ??\n ctx.storage.channel,\n }\n\n const after = maybeAfter ? Number(maybeAfter) : 0\n const searchArgs = {\n page: Math.ceil(after / first),\n count: first,\n query: term,\n sort: SORT_MAP[sort ?? 'score_desc'],\n selectedFacets: selectedFacets?.map(transformSelectedFacet) ?? [],\n }\n\n return searchArgs\n },\n allProducts: async (\n _: unknown,\n { first, after: maybeAfter }: QueryAllProductsArgs,\n ctx: Context\n ) => {\n const {\n clients: { search },\n } = ctx\n\n const after = maybeAfter ? Number(maybeAfter) : 0\n const products = await search.products({\n page: Math.ceil(after / first),\n count: first,\n })\n\n const skus = products.products\n .map((product) => product.skus.map((sku) => enhanceSku(sku, product)))\n .flat()\n .filter((sku) => sku.sellers.length > 0)\n\n return {\n pageInfo: {\n hasNextPage: products.pagination.after.length > 0,\n hasPreviousPage: products.pagination.before.length > 0,\n startCursor: '0',\n endCursor: products.total.toString(),\n totalCount: products.total,\n },\n // after + index is bigger than after+first itself because of the array flat() above\n edges: skus.map((sku, index) => ({\n node: sku,\n cursor: (after + index).toString(),\n })),\n }\n },\n allCollections: async (\n _: unknown,\n { first, after: maybeAfter }: QueryAllCollectionsArgs,\n ctx: Context\n ) => {\n const {\n clients: { commerce },\n } = ctx\n\n const after = maybeAfter ? Number(maybeAfter) : 0\n\n const [brands, tree] = await Promise.all([\n commerce.catalog.brand.list(),\n commerce.catalog.category.tree(),\n ])\n\n const categories: Array<CategoryTree & { level: number }> = []\n const dfs = (node: CategoryTree, level: number) => {\n categories.push({ ...node, level })\n\n for (const child of node.children) {\n dfs(child, level + 1)\n }\n }\n\n for (const node of tree) {\n dfs(node, 0)\n }\n\n const collections = [\n ...brands.map((x) => ({ ...x, type: 'brand' })),\n ...categories,\n ]\n\n const validCollections = collections\n // Nullable slugs may cause one route to override the other\n .filter((node) => Boolean(StoreCollection.slug(node, null, ctx, null)))\n\n return {\n pageInfo: {\n hasNextPage: validCollections.length - after > first,\n hasPreviousPage: after > 0,\n startCursor: '0',\n endCursor: (\n Math.min(first, validCollections.length - after) - 1\n ).toString(),\n },\n edges: validCollections\n .slice(after, after + first)\n .map((node, index) => ({\n node,\n cursor: (after + index).toString(),\n })),\n }\n },\n}\n","import { getClients } from './clients'\nimport { getLoaders } from './loaders'\nimport { StoreAggregateOffer } from './resolvers/aggregateOffer'\nimport { StoreAggregateRating } from './resolvers/aggregateRating'\nimport { StoreCollection } from './resolvers/collection'\nimport { StoreFacet } from './resolvers/facet'\nimport { StoreFacetValue } from './resolvers/facetValue'\nimport { Mutation } from './resolvers/mutation'\nimport { StoreOffer } from './resolvers/offer'\nimport { StoreProduct } from './resolvers/product'\nimport { StoreProductGroup } from './resolvers/productGroup'\nimport { Query } from './resolvers/query'\nimport { StoreReview } from './resolvers/review'\nimport { StoreSearchResult } from './resolvers/searchResult'\nimport { StoreSeo } from './resolvers/seo'\nimport type { Loaders } from './loaders'\nimport type { Clients } from './clients'\n\nexport interface Options {\n platform: 'vtex'\n account: string\n environment: 'vtexcommercestable' | 'vtexcommercebeta'\n // Default sales channel to use for fetching products\n channel: string\n}\n\nexport interface Context {\n clients: Clients\n loaders: Loaders\n /**\n * @description Storage updated at each request.\n *\n * Use this datastructure to store and share small values in the context.\n * Use it with caution since dependecy injection leads to a more complex code\n * */\n storage: {\n channel: string\n }\n}\n\nexport type Resolver<R = unknown, A = unknown> = (\n root: R,\n args: A,\n ctx: Context,\n info: any\n) => any\n\nconst Resolvers = {\n StoreCollection,\n StoreAggregateOffer,\n StoreProduct,\n StoreSeo,\n StoreFacet,\n StoreFacetValue,\n StoreOffer,\n StoreAggregateRating,\n StoreReview,\n StoreProductGroup,\n StoreSearchResult,\n Query,\n Mutation,\n}\n\nexport const getContextFactory = (options: Options) => (ctx: any) => {\n ctx.storage = {\n channel: options.channel,\n }\n ctx.clients = getClients(options, ctx)\n ctx.loaders = getLoaders(options, ctx)\n\n return ctx\n}\n\nexport const getResolvers = (_: Options) => Resolvers\n","import type { EnhancedSku } from '../utils/enhanceSku'\nimport type { Simulation } from '../clients/commerce/types/Simulation'\n\ntype Resolvers = (root: Simulation & { product: EnhancedSku }) => unknown\n\nexport const StoreAggregateOffer: Record<string, Resolvers> = {\n highPrice: ({ items }) =>\n items.reduce(\n (acc, curr) => (acc > curr.sellingPrice ? acc : curr.sellingPrice),\n items[0]?.sellingPrice ?? 0\n ) / 1e2,\n lowPrice: ({ items }) =>\n items.reduce(\n (acc, curr) => (acc < curr.sellingPrice ? acc : curr.sellingPrice),\n items[0]?.sellingPrice ?? 0\n ) / 1e2,\n offerCount: ({ items }) => items.length,\n priceCurrency: () => '',\n offers: ({ items, product }) => items.map((item) => ({ ...item, product })),\n}\n","import type { Resolver } from '..'\n\ntype Root = { title?: string; description?: string }\n\nexport const StoreSeo: Record<string, Resolver<Root>> = {\n title: ({ title }) => title ?? '',\n description: ({ description }) => description ?? '',\n titleTemplate: () => '',\n canonical: () => '',\n}\n","import type { Resolver } from '..'\nimport type { Attribute } from '../clients/search/types/AttributeSearchResult'\n\ntype Root = Attribute\n\nexport const StoreFacet: Record<string, Resolver<Root>> = {\n key: ({ key }) => key,\n label: ({ label }) => label,\n values: ({ values }) => values,\n type: ({ type }) => (type === 'text' ? 'BOOLEAN' : 'RANGE'),\n}\n","import type { Resolver } from '..'\nimport type { Value } from '../clients/search/types/AttributeSearchResult'\n\ntype Root = Value\n\nexport const StoreFacetValue: Record<string, Resolver<Root>> = {\n value: ({ key, from, to }) => key ?? `${from}-to-${to}`,\n label: ({ label }) => label ?? 'unknown',\n selected: ({ active }) => active,\n quantity: ({ count }) => count,\n}\n","import type { EnhancedSku } from '../utils/enhanceSku'\nimport type { Resolver } from '..'\nimport type { Item } from '../clients/commerce/types/Simulation'\nimport type { OrderFormItem } from '../clients/commerce/types/OrderForm'\n\ntype Root =\n | (Item & { product: EnhancedSku }) // when querying search/product\n | (OrderFormItem & { product: Promise<EnhancedSku> }) // when querying order\n\nexport const StoreOffer: Record<string, Resolver<Root>> = {\n priceCurrency: () => '',\n priceValidUntil: ({ priceValidUntil }) => priceValidUntil ?? '',\n itemCondition: () => 'https://schema.org/NewCondition',\n availability: ({ availability }) =>\n availability === 'available'\n ? 'https://schema.org/InStock'\n : 'https://schema.org/OutOfStock',\n seller: ({ seller }) => ({\n identifier: seller,\n }),\n price: ({ sellingPrice }) => sellingPrice / 1e2, // TODO add spot price calculation\n sellingPrice: ({ sellingPrice }) => sellingPrice / 1e2,\n listPrice: ({ listPrice }) => listPrice / 1e2,\n itemOffered: ({ product }) => product,\n quantity: ({ quantity }) => quantity,\n}\n","import type { Resolver } from '..'\n\n// TODO: Add a review system integration\nexport const StoreAggregateRating: Record<string, Resolver> = {\n ratingValue: () => 5,\n reviewCount: () => 0,\n}\n","import type { Resolver } from '..'\n\nexport const StoreReview: Record<string, Resolver> = {\n reviewRating: () => ({\n ratingValue: 5,\n bestRating: 5,\n }),\n author: () => ({\n name: '',\n }),\n}\n","import { enhanceSku } from '../utils/enhanceSku'\nimport type { Product } from '../clients/search/types/ProductSearchResult'\nimport type { Resolver } from '..'\n\nexport const StoreProductGroup: Record<string, Resolver<Product>> = {\n hasVariant: (root) => root.skus.map((sku) => enhanceSku(sku, root)),\n productGroupID: ({ product }) => product,\n name: ({ name }) => name,\n additionalProperty: ({ textAttributes = [], productSpecifications = [] }) => {\n const specs = new Set(productSpecifications)\n\n return textAttributes\n .filter((attribute) => specs.has(attribute.labelKey))\n .map((attribute) => ({\n name: attribute.labelKey,\n value: attribute.labelValue,\n }))\n },\n}\n","import { enhanceSku } from '../utils/enhanceSku'\nimport type { Resolver } from '..'\nimport type { SearchArgs } from '../clients/search'\n\ntype Root = Omit<SearchArgs, 'type'>\n\nexport const StoreSearchResult: Record<string, Resolver<Root>> = {\n products: async (searchArgs, _, ctx) => {\n const {\n clients: { search },\n } = ctx\n\n const products = await search.products(searchArgs)\n\n const skus = products.products\n .map((product) => {\n const maybeSku = product.skus.find((x) => x.sellers.length > 0)\n\n return maybeSku && enhanceSku(maybeSku, product)\n })\n .filter((sku) => !!sku)\n\n return {\n pageInfo: {\n hasNextPage: products.pagination.after.length > 0,\n hasPreviousPage: products.pagination.before.length > 0,\n startCursor: '0',\n endCursor: products.total.toString(),\n totalCount: products.total,\n },\n edges: skus.map((sku, index) => ({\n node: sku,\n cursor: index.toString(),\n })),\n }\n },\n facets: async (searchArgs, _, ctx) => {\n const {\n clients: { search: is },\n } = ctx\n\n const facets = await is.facets(searchArgs)\n\n return facets.attributes ?? []\n },\n}\n","import { validateCart } from './validateCart'\n\nexport const Mutation = {\n validateCart,\n}\n","import { print } from 'graphql'\n\nimport AggregateOffer from './aggregateOffer.graphql'\nimport AggregateRating from './aggregateRating.graphql'\nimport Author from './author.graphql'\nimport Brand from './brand.graphql'\nimport Breadcrumb from './breadcrumb.graphql'\nimport Collection from './collection.graphql'\nimport Facet from './facet.graphql'\nimport Image from './image.graphql'\nimport Mutation from './mutation.graphql'\nimport Offer from './offer.graphql'\nimport Order from './order.graphql'\nimport Organization from './organization.graphql'\nimport PageInfo from './pageInfo.graphql'\nimport Product from './product.graphql'\nimport ProductGroup from './productGroup.graphql'\nimport Query from './query.graphql'\nimport Review from './review.graphql'\nimport Seo from './seo.graphql'\nimport Cart from './cart.graphql'\nimport Status from './status.graphql'\nimport PropertyValue from './propertyValue.graphql'\n\nexport const typeDefs = [\n Query,\n Mutation,\n Brand,\n Breadcrumb,\n Collection,\n Facet,\n Image,\n PageInfo,\n Product,\n Seo,\n Offer,\n AggregateRating,\n Review,\n Author,\n ProductGroup,\n Organization,\n AggregateOffer,\n Order,\n Cart,\n Status,\n PropertyValue,\n]\n .map(print)\n .join('\\n')\n","import { makeExecutableSchema } from '@graphql-tools/schema'\n\nimport {\n getContextFactory as getContextFactoryVTEX,\n getResolvers as getResolversVTEX,\n} from './platforms/vtex'\nimport { typeDefs } from './typeDefs'\nimport type { Options as OptionsVTEX } from './platforms/vtex'\n\nexport * from './__generated__/schema'\n\nexport type Options = OptionsVTEX\n\nconst platforms = {\n vtex: {\n getResolvers: getResolversVTEX,\n getContextFactory: getContextFactoryVTEX,\n },\n}\n\nexport const getTypeDefs = () => typeDefs\n\nexport const getResolvers = (options: Options) =>\n platforms[options.platform].getResolvers(options)\n\nexport const getContextFactory = (options: Options) =>\n platforms[options.platform].getContextFactory(options)\n\nexport const getSchema = async (options: Options) =>\n makeExecutableSchema({\n resolvers: getResolvers(options),\n typeDefs: getTypeDefs(),\n })\n","import { VtexCommerce } from './commerce'\nimport { IntelligentSearch } from './search'\nimport type { Context, Options } from '..'\n\nexport type Clients = ReturnType<typeof getClients>\n\nexport const getClients = (options: Options, ctx: Context) => {\n const search = IntelligentSearch(options, ctx)\n const commerce = VtexCommerce(options, ctx)\n\n return {\n search,\n commerce,\n }\n}\n","import { getSimulationLoader } from './simulation'\nimport { getSkuLoader } from './sku'\nimport { getCollectionLoader } from './collection'\nimport type { Context, Options } from '..'\n\nexport type Loaders = ReturnType<typeof getLoaders>\n\nexport const getLoaders = (options: Options, { clients }: Context) => {\n const skuLoader = getSkuLoader(options, clients)\n const simulationLoader = getSimulationLoader(options, clients)\n const collectionLoader = getCollectionLoader(options, clients)\n\n return {\n skuLoader,\n simulationLoader,\n collectionLoader,\n }\n}\n","import DataLoader from 'dataloader'\n\nimport { BadRequestError } from '../utils/errors'\nimport { enhanceSku } from '../utils/enhanceSku'\nimport type { EnhancedSku } from '../utils/enhanceSku'\nimport type { Options } from '..'\nimport type { Clients } from '../clients'\nimport type { SelectedFacet } from '../utils/facets'\n\nexport const getSkuLoader = (_: Options, clients: Clients) => {\n const loader = async (facetsList: readonly SelectedFacet[][]) => {\n const skuIds = facetsList.map((facets) => {\n const maybeFacet = facets.find(({ key }) => key === 'id')\n\n if (!maybeFacet) {\n throw new BadRequestError(\n 'Error while loading SKU. Needs to pass an id to selected facets'\n )\n }\n\n return maybeFacet.value\n })\n\n const { products } = await clients.search.products({\n query: `sku:${skuIds.join(';')}`,\n page: 0,\n count: skuIds.length,\n })\n\n const skuBySkuId = products.reduce((acc, product) => {\n for (const sku of product.skus) {\n acc[sku.id] = enhanceSku(sku, product)\n }\n\n return acc\n }, {} as Record<string, EnhancedSku>)\n\n const skus = skuIds.map((skuId) => skuBySkuId[skuId])\n const missingSkus = skus.filter((sku) => !sku)\n\n if (missingSkus.length > 0) {\n throw new Error(\n `Search API did not return the following skus: ${missingSkus.join(',')}`\n )\n }\n\n return skus\n }\n\n return new DataLoader<SelectedFacet[], EnhancedSku>(loader, {\n maxBatchSize: 99, // Max allowed batch size of Search API\n })\n}\n","import DataLoader from 'dataloader'\n\nimport type {\n PayloadItem,\n Simulation,\n} from '../clients/commerce/types/Simulation'\nimport type { Options } from '..'\nimport type { Clients } from '../clients'\n\nexport const getSimulationLoader = (_: Options, clients: Clients) => {\n const loader = async (allItems: readonly PayloadItem[][]) => {\n const items = [...allItems.flat()]\n const simulation = await clients.commerce.checkout.simulation({\n items,\n })\n\n // Sort and filter simulation since Checkout API may return\n // items that we didn't ask for\n const simulated = simulation.items.reduce((acc, item) => {\n const index = item.requestIndex\n\n if (typeof index === 'number' && index < acc.length) {\n acc[index] = item\n }\n\n return acc\n }, Array(items.length).fill(null) as Simulation['items'])\n\n const itemsIndices = allItems.reduce(\n (acc, curr) => [...acc, curr.length + acc[acc.length - 1]],\n [0]\n )\n\n return allItems.map((__, index) => ({\n ...simulation,\n items: simulated\n .slice(itemsIndices[index], itemsIndices[index + 1])\n .filter((item) => Boolean(item)),\n }))\n }\n\n return new DataLoader<PayloadItem[], Simulation>(loader, {\n maxBatchSize: 20,\n })\n}\n"],"names":["fetchAPI","async","info","init","response","fetch","ok","json","text","Error","BASE_INIT","method","headers","IntelligentSearch","account","environment","ctx","base","policyFacet","key","value","storage","channel","search","query","page","count","sort","selectedFacets","type","fuzzy","params","URLSearchParams","toString","pathname","facets","undefined","find","map","join","args","products","BadRequestError","constructor","message","name","NotFoundError","enhanceSku","sku","product","isVariantOf","collectionPageTypes","Set","isCollectionPageType","x","pageType","has","toLowerCase","slugify","path","rawSlugify","separator","lowercase","isBrand","root","baseSlugify","URL","url","slice","StoreCollection","id","slug","seo","title","description","metaTagDescription","Title","MetaTagDescription","level","meta","split","segment","index","breadcrumbList","_","loaders","collectionLoader","segments","filter","Boolean","slugs","__","collections","Promise","all","s","load","itemListElement","collection","item","position","numberOfItems","length","getId","itemOffered","seller","identifier","price","orderFormItemToOffer","listPrice","sellingPrice","quantity","image","offerToOrderItemInput","offer","groupById","offers","reduce","acc","set","get","Map","DEFAULT_IMAGE","getSlug","link","getPath","nonEmptyArray","array","Array","isArray","getIdFromSlug","pop","transformSelectedFacet","SORT_MAP","price_desc","price_asc","orders_desc","name_desc","name_asc","release_desc","discount_desc","score_desc","Query","locator","facet","_locator$find","skuLoader","first","after","maybeAfter","term","_selectedFacets$find","Number","Math","ceil","allProducts","clients","skus","flat","sellers","pageInfo","hasNextPage","pagination","hasPreviousPage","before","startCursor","endCursor","total","totalCount","edges","node","cursor","allCollections","commerce","brands","tree","catalog","brand","list","category","categories","dfs","push","child","children","validCollections","min","Resolvers","StoreAggregateOffer","highPrice","items","curr","_items$","lowPrice","_items$2","offerCount","priceCurrency","StoreProduct","productID","categoryTrees","reverse","categoryNames","categoryName","images","alternateName","replace","gtin","reference","review","aggregateRating","simulationLoader","policies","policy","_policies$find","sellerIds","from","additionalProperty","attributes","attribute","StoreSeo","titleTemplate","canonical","StoreFacet","label","values","StoreFacetValue","to","selected","active","StoreOffer","priceValidUntil","itemCondition","availability","StoreAggregateRating","ratingValue","reviewCount","StoreReview","reviewRating","bestRating","author","StoreProductGroup","hasVariant","productGroupID","textAttributes","productSpecifications","specs","labelKey","labelValue","StoreSearchResult","searchArgs","maybeSku","is","Mutation","validateCart","cart","order","orderNumber","acceptedOffer","orderForm","checkout","browserItemsById","originItemsById","browserItems","originItems","itemsToAdd","itemsToUpdate","maybeOriginItem","changes","updatedOrderForm","updateOrderFormItems","orderFormId","orderItems","of1","of2","pick","messages","salesChannel","uniqueId","deepEquals","equals","status","toUpperCase","typeDefs","Brand","Breadcrumb","Collection","Facet","Image","PageInfo","Product","Seo","Offer","AggregateRating","Review","Author","ProductGroup","Organization","AggregateOffer","Order","Cart","Status","PropertyValue","print","platforms","vtex","getResolvers","getContextFactory","options","depth","portal","pagetype","simulation","sc","body","JSON","stringify","refreshOutdatedData","allowOutdatedData","VtexCommerce","getClients","DataLoader","skuIds","facetsList","maybeFacet","skuBySkuId","skuId","missingSkus","maxBatchSize","getSkuLoader","allItems","simulated","requestIndex","fill","itemsIndices","getSimulationLoader","limit","pLimit","batch","getCollectionLoader","getLoaders","getTypeDefs","platform","makeExecutableSchema","resolvers"],"mappings":"kWAEO,MAAMA,EAAWC,MAAOC,EAAmBC,WAC1CC,QAAiBC,EAAMH,EAAMC,MAE/BC,EAASE,UACJF,EAASG,aAGZC,QAAaJ,EAASI,aAEtB,IAAIC,MAAMD,ICCZE,EAAY,CAChBC,OAAQ,OACRC,QAAS,gBACS,qBCgBPC,EAAoB,EAC7BC,QAAAA,EAASC,YAAAA,GACXC,WAEMC,mBAAwBF,0BAAoCD,IAC5DI,EAAc,CAAEC,IAAK,eAAgBC,MAAOJ,EAAIK,QAAQC,SAYxDC,EAAS,EACbC,MAAAA,EAAQ,GACRC,KAAAA,EACAC,MAAAA,EACAC,KAAAA,EAAO,GACPC,eAAAA,EAAiB,GACjBC,K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QAGH,IAAIqB,sBACYrB,EAAK8B,sBAAsBgB,wHAOC,CAExD0Q,OAAO,KsBrCgBC,CAAoB/B,EAASvJ,Kd0DxCuL,CAAWhC,EAASnS,GAE3BA,KYlDIoU,GAAc,IAAM1D,GAEpBuB,GAAgBE,GAC3BJ,GAAUI,EAAQkC,UAAUpC,aAAaE,6BAETA,GAChCJ,GAAUI,EAAQkC,UAAUnC,kBAAkBC,6CAEvBlT,MAAAA,GACvBqV,uBAAqB,CACnBC,UAAWtC,GAAaE,GACxBzB,SAAU0D"}
1
+ {"version":3,"file":"api.cjs.production.min.js","sources":["../src/platforms/vtex/clients/fetch.ts","../src/platforms/vtex/clients/commerce/index.ts","../src/platforms/vtex/clients/search/index.ts","../src/platforms/vtex/utils/errors.ts","../src/platforms/vtex/utils/enhanceSku.ts","../src/platforms/vtex/loaders/collection.ts","../src/platforms/vtex/utils/slugify.ts","../src/platforms/vtex/resolvers/collection.ts","../src/platforms/vtex/resolvers/validateCart.ts","../src/platforms/vtex/resolvers/product.ts","../src/platforms/vtex/utils/facets.ts","../src/platforms/vtex/utils/sort.ts","../src/platforms/vtex/resolvers/query.ts","../src/platforms/vtex/index.ts","../src/platforms/vtex/resolvers/aggregateOffer.ts","../src/platforms/vtex/resolvers/seo.ts","../src/platforms/vtex/resolvers/facet.ts","../src/platforms/vtex/resolvers/facetValue.ts","../src/platforms/vtex/resolvers/offer.ts","../src/platforms/vtex/resolvers/aggregateRating.ts","../src/platforms/vtex/resolvers/review.ts","../src/platforms/vtex/resolvers/productGroup.ts","../src/platforms/vtex/resolvers/searchResult.ts","../src/platforms/vtex/resolvers/mutation.ts","../src/typeDefs/index.ts","../src/index.ts","../src/platforms/vtex/clients/index.ts","../src/platforms/vtex/loaders/index.ts","../src/platforms/vtex/loaders/sku.ts","../src/platforms/vtex/loaders/simulation.ts"],"sourcesContent":["import fetch from 'isomorphic-unfetch'\n\nexport const fetchAPI = async (info: RequestInfo, init?: RequestInit) => {\n const response = await fetch(info, init)\n\n if (response.ok) {\n return response.json()\n }\n\n const text = await response.text()\n\n throw new Error(text)\n}\n","import type { Context, Options } from '../../index'\nimport { fetchAPI } from '../fetch'\nimport type { Brand } from './types/Brand'\nimport type { CategoryTree } from './types/CategoryTree'\nimport type { OrderForm, OrderFormInputItem } from './types/OrderForm'\nimport type { PortalPagetype } from './types/Portal'\nimport type {\n Simulation,\n SimulationArgs,\n SimulationOptions,\n} from './types/Simulation'\n\nconst BASE_INIT = {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n },\n}\n\nexport const VtexCommerce = (\n { account, environment }: Options,\n ctx: Context\n) => {\n const base = `http://${account}.${environment}.com.br`\n\n return {\n catalog: {\n brand: {\n list: (): Promise<Brand[]> =>\n fetchAPI(`${base}/api/catalog_system/pub/brand/list`),\n },\n category: {\n tree: (depth = 3): Promise<CategoryTree[]> =>\n fetchAPI(`${base}/api/catalog_system/pub/category/tree/${depth}`),\n },\n portal: {\n pagetype: (slug: string): Promise<PortalPagetype> =>\n fetchAPI(`${base}/api/catalog_system/pub/portal/pagetype/${slug}`),\n },\n },\n checkout: {\n simulation: (\n args: SimulationArgs,\n { salesChannel }: SimulationOptions = {\n salesChannel: ctx.storage.channel,\n }\n ): Promise<Simulation> => {\n const params = new URLSearchParams({\n sc: salesChannel,\n })\n\n return fetchAPI(\n `${base}/api/checkout/pub/orderForms/simulation?${params.toString()}`,\n {\n ...BASE_INIT,\n body: JSON.stringify(args),\n }\n )\n },\n orderForm: ({\n id,\n refreshOutdatedData = true,\n salesChannel = ctx.storage.channel,\n }: {\n id: string\n refreshOutdatedData?: boolean\n salesChannel?: string\n }): Promise<OrderForm> => {\n const params = new URLSearchParams({\n refreshOutdatedData: refreshOutdatedData.toString(),\n sc: salesChannel,\n })\n\n return fetchAPI(\n `${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`,\n BASE_INIT\n )\n },\n updateOrderFormItems: ({\n id,\n orderItems,\n allowOutdatedData = 'paymentData',\n salesChannel = ctx.storage.channel,\n }: {\n id: string\n orderItems: OrderFormInputItem[]\n allowOutdatedData?: 'paymentData'\n salesChannel?: string\n }): Promise<OrderForm> => {\n const params = new URLSearchParams({\n allowOutdatedData,\n sc: salesChannel,\n })\n\n return fetchAPI(\n `${base}/api/checkout/pub/orderForm/${id}/items?${params}`,\n {\n ...BASE_INIT,\n body: JSON.stringify({ orderItems }),\n method: 'PATCH',\n }\n )\n },\n },\n }\n}\n","import type { Context, Options } from '../../index'\nimport { fetchAPI } from '../fetch'\nimport type { SelectedFacet } from '../../utils/facets'\nimport type { ProductSearchResult } from './types/ProductSearchResult'\nimport type { AttributeSearchResult } from './types/AttributeSearchResult'\n\nexport type Sort =\n | 'price:desc'\n | 'price:asc'\n | 'orders:desc'\n | 'name:desc'\n | 'name:asc'\n | 'release:desc'\n | 'discount:desc'\n | ''\n\nexport interface SearchArgs {\n query?: string\n page: number\n count: number\n type: 'product_search' | 'attribute_search'\n sort?: Sort\n selectedFacets?: SelectedFacet[]\n fuzzy?: '0' | '1'\n}\n\nexport interface ProductLocator {\n field: 'id' | 'slug'\n value: string\n}\n\nexport const IntelligentSearch = (\n { account, environment }: Options,\n ctx: Context\n) => {\n const base = `http://portal.${environment}.com.br/search-api/v1/${account}`\n const policyFacet = { key: 'trade-policy', value: ctx.storage.channel }\n\n const addDefaultFacets = (facets: SelectedFacet[]) => {\n const facet = facets.find(({ key }) => key === policyFacet.key)\n\n if (facet === undefined) {\n return [...facets, policyFacet]\n }\n\n return facets\n }\n\n const search = <T>({\n query = '',\n page,\n count,\n sort = '',\n selectedFacets = [],\n type,\n fuzzy = '0',\n }: SearchArgs): Promise<T> => {\n const params = new URLSearchParams({\n page: (page + 1).toString(),\n count: count.toString(),\n query,\n sort,\n fuzzy,\n })\n\n const pathname = addDefaultFacets(selectedFacets)\n .map(({ key, value }) => `${key}/${value}`)\n .join('/')\n\n return fetchAPI(\n `${base}/api/split/${type}/${pathname}?${params.toString()}`\n )\n }\n\n const products = (args: Omit<SearchArgs, 'type'>) =>\n search<ProductSearchResult>({ ...args, type: 'product_search' })\n\n const facets = (args: Omit<SearchArgs, 'type'>) =>\n search<AttributeSearchResult>({ ...args, type: 'attribute_search' })\n\n return {\n facets,\n products,\n }\n}\n","export class BadRequestError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'BadRequestError'\n }\n}\n\nexport class NotFoundError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'NotFoundError'\n }\n}\n","import type { Product, Sku } from '../clients/search/types/ProductSearchResult'\n\nexport type EnhancedSku = Sku & { isVariantOf: Product }\n\nexport const enhanceSku = (sku: Sku, product: Product): EnhancedSku => ({\n ...sku,\n isVariantOf: product,\n})\n","import DataLoader from 'dataloader'\nimport pLimit from 'p-limit'\n\nimport { NotFoundError } from '../utils/errors'\nimport type { CollectionPageType } from '../clients/commerce/types/Portal'\nimport type { Options } from '..'\nimport type { Clients } from '../clients'\n\n// Limits concurrent requests to 20 so that they don't timeout\nconst CONCURRENT_REQUESTS_MAX = 20\n\nconst collectionPageTypes = new Set([\n 'brand',\n 'category',\n 'department',\n 'subcategory',\n] as const)\n\nexport const isCollectionPageType = (x: any): x is CollectionPageType =>\n typeof x.pageType === 'string' &&\n collectionPageTypes.has(x.pageType.toLowerCase())\n\nexport const getCollectionLoader = (_: Options, clients: Clients) => {\n const limit = pLimit(CONCURRENT_REQUESTS_MAX)\n\n const loader = async (\n slugs: readonly string[]\n ): Promise<CollectionPageType[]> => {\n return Promise.all(\n slugs.map((slug: string) =>\n limit(async () => {\n const page = await clients.commerce.catalog.portal.pagetype(slug)\n\n if (isCollectionPageType(page)) {\n return page\n }\n\n throw new NotFoundError(\n `Catalog returned ${page.pageType} for slug: ${slug}. This usually happens when there is more than one category with the same name in the same category tree level.`\n )\n })\n )\n )\n }\n\n return new DataLoader<string, CollectionPageType>(loader, {\n // DataLoader is being used to cache requests, not to batch them\n batch: false,\n })\n}\n","import rawSlugify from '@sindresorhus/slugify'\n\nexport const slugify = (path: string) =>\n rawSlugify(path, { separator: '-', lowercase: true })\n","import { isCollectionPageType } from '../loaders/collection'\nimport { slugify as baseSlugify } from '../utils/slugify'\nimport type { Resolver } from '..'\nimport type { Brand } from '../clients/commerce/types/Brand'\nimport type { CategoryTree } from '../clients/commerce/types/CategoryTree'\nimport type { CollectionPageType } from '../clients/commerce/types/Portal'\n\ntype Root = Brand | (CategoryTree & { level: number }) | CollectionPageType\n\nconst isBrand = (x: any): x is Brand => x.type === 'brand'\n\nconst slugify = (root: Root) => {\n if (isBrand(root)) {\n return baseSlugify(root.name.toLowerCase())\n }\n\n if (isCollectionPageType(root)) {\n return new URL(`https://${root.url}`).pathname.slice(1)\n }\n\n return new URL(root.url).pathname.slice(1)\n}\n\nexport const StoreCollection: Record<string, Resolver<Root>> = {\n id: ({ id }) => id.toString(),\n slug: (root) => slugify(root),\n seo: (root) =>\n isBrand(root) || isCollectionPageType(root)\n ? {\n title: root.title,\n description: root.metaTagDescription,\n }\n : {\n title: root.Title,\n description: root.MetaTagDescription,\n },\n type: (root) =>\n isBrand(root)\n ? 'Brand'\n : isCollectionPageType(root)\n ? root.pageType\n : root.level === 0\n ? 'Department'\n : 'Category',\n meta: (root) =>\n isBrand(root)\n ? {\n selectedFacets: [{ key: 'brand', value: baseSlugify(root.name) }],\n }\n : {\n selectedFacets: new URL(\n isCollectionPageType(root) ? `https://${root.url}` : root.url\n ).pathname\n .slice(1)\n .split('/')\n .map((segment, index) => ({\n key: `category-${index + 1}`,\n value: baseSlugify(segment),\n })),\n },\n breadcrumbList: async (root, _, ctx) => {\n const {\n loaders: { collectionLoader },\n } = ctx\n\n const slug = slugify(root)\n\n /**\n * Split slug into segments so we fetch all data for\n * the breadcrumb. For instance, if we get `/foo/bar`\n * we need all metadata for both `/foo` and `/bar` and\n * thus we need to fetch pageType for `/foo` and `/bar`\n */\n const segments = slug.split('/').filter((segment) => Boolean(segment))\n const slugs = segments.map((__, index) =>\n segments.slice(0, index + 1).join('/')\n )\n\n const collections = await Promise.all(\n slugs.map((s) => collectionLoader.load(s))\n )\n\n return {\n itemListElement: collections.map((collection, index) => ({\n item: new URL(`https://${collection.url}`).pathname.toLowerCase(),\n name: collection.name,\n position: index + 1,\n })),\n numberOfItems: collections.length,\n }\n },\n}\n","import deepEquals from 'fast-deep-equal'\n\nimport type { IStoreCart, IStoreOffer } from '../../../__generated__/schema'\nimport type {\n OrderForm,\n OrderFormItem,\n OrderFormInputItem,\n} from '../clients/commerce/types/OrderForm'\nimport type { Context } from '..'\n\ntype Indexed<T> = T & { index?: number }\n\nconst getId = (item: IStoreOffer) =>\n [item.itemOffered.sku, item.seller.identifier, item.price].join('::')\n\nconst orderFormItemToOffer = (\n item: OrderFormItem,\n index?: number\n): Indexed<IStoreOffer> => ({\n listPrice: item.listPrice / 100,\n price: item.sellingPrice / 100,\n quantity: item.quantity,\n seller: { identifier: item.seller },\n itemOffered: {\n sku: item.id,\n image: [],\n name: item.name,\n },\n index,\n})\n\nconst offerToOrderItemInput = (\n offer: Indexed<IStoreOffer>\n): OrderFormInputItem => ({\n quantity: offer.quantity,\n seller: offer.seller.identifier,\n id: offer.itemOffered.sku,\n index: offer.index,\n})\n\nconst groupById = (offers: IStoreOffer[]): Map<string, IStoreOffer> =>\n offers.reduce((acc, item) => {\n const id = getId(item)\n\n acc.set(id, acc.get(id) ?? item)\n\n return acc\n }, new Map<string, IStoreOffer>())\n\nconst equals = (of1: OrderForm, of2: OrderForm) => {\n const pick = ({ orderFormId, messages, items, salesChannel }: OrderForm) => ({\n orderFormId,\n messages,\n salesChannel,\n items: items.map(\n ({ uniqueId, quantity, seller, sellingPrice, availability }) => ({\n uniqueId,\n quantity,\n seller,\n sellingPrice,\n availability,\n })\n ),\n })\n\n return deepEquals(pick(of1), pick(of2))\n}\n\n/**\n * This resolver implements the optimistic cart behavior. The main idea in here\n * is that we receive a cart from the UI (as query params) and we validate it with\n * the commerce platform. If the cart is valid, we return null, if the cart is\n * invalid according to the commerce platform, we return the new cart the UI should use\n * instead\n *\n * The algoritm is something like:\n * 1. Fetch orderForm from VTEX\n * 2. Compute delta changes between the orderForm and the UI's cart\n * 3. Update the orderForm in VTEX platform accordingly\n * 4. If any chages were made, send to the UI the new cart. Null otherwise\n */\nexport const validateCart = async (\n _: unknown,\n {\n cart: {\n order: { orderNumber, acceptedOffer },\n },\n }: { cart: IStoreCart },\n ctx: Context\n) => {\n const {\n clients: { commerce },\n loaders: { skuLoader },\n } = ctx\n\n // Step1: Get OrderForm from VTEX Commerce\n const orderForm = await commerce.checkout.orderForm({\n id: orderNumber,\n })\n\n // Step2: Process items from both browser and checkout so they have the same shape\n const browserItemsById = groupById(acceptedOffer)\n const originItemsById = groupById(orderForm.items.map(orderFormItemToOffer))\n const browserItems = Array.from(browserItemsById.values()) // items on the user's browser\n const originItems = Array.from(originItemsById.values()) // items on the VTEX platform backend\n\n // Step3: Compute delta changes\n const { itemsToAdd, itemsToUpdate } = browserItems.reduce(\n (acc, item) => {\n const maybeOriginItem = originItemsById.get(getId(item))\n\n if (!maybeOriginItem) {\n acc.itemsToAdd.push(item)\n } else {\n acc.itemsToUpdate.push({\n ...maybeOriginItem,\n quantity: item.quantity,\n })\n }\n\n return acc\n },\n {\n itemsToAdd: [] as IStoreOffer[],\n itemsToUpdate: [] as IStoreOffer[],\n }\n )\n\n const itemsToDelete = originItems\n .filter((item) => !browserItemsById.has(getId(item)))\n .map((item) => ({ ...item, quantity: 0 }))\n\n const changes = [...itemsToAdd, ...itemsToUpdate, ...itemsToDelete].map(\n offerToOrderItemInput\n )\n\n if (changes.length === 0) {\n return null\n }\n\n // Step4: Apply delta changes to order form\n const updatedOrderForm = await commerce.checkout.updateOrderFormItems({\n id: orderForm.orderFormId,\n orderItems: changes,\n })\n\n // Step5: If no changes detected before/after updating orderForm, the order is validated\n if (equals(orderForm, updatedOrderForm)) {\n return null\n }\n\n // Step6: There were changes, convert orderForm to StoreOrder\n return {\n order: {\n orderNumber: updatedOrderForm.orderFormId,\n acceptedOffer: updatedOrderForm.items.map((item) => ({\n ...item,\n product: skuLoader.load([{ key: 'id', value: item.id }]), // TODO: add channel\n })),\n },\n messages: updatedOrderForm.messages.map(({ text, status }) => ({\n text,\n status: status.toUpperCase(),\n })),\n }\n}\n","import type { Resolver } from '..'\nimport type { EnhancedSku } from '../utils/enhanceSku'\nimport { slugify } from '../utils/slugify'\n\ntype Root = EnhancedSku\n\nconst DEFAULT_IMAGE = {\n name: 'image',\n value:\n 'https://storecomponents.vtexassets.com/assets/faststore/images/image___117a6d3e229a96ad0e0d0876352566e2.svg',\n}\n\nconst getSlug = (link: string, id: string) => `${link}-${id}`\nconst getPath = (link: string, id: string) => `/${getSlug(link, id)}/p`\nconst nonEmptyArray = <T>(array: T[] | null | undefined) =>\n Array.isArray(array) && array.length > 0 ? array : null\n\nexport const StoreProduct: Record<string, Resolver<Root>> = {\n productID: ({ id }) => id,\n name: ({ isVariantOf, name }) => name ?? isVariantOf.name,\n slug: ({ isVariantOf: { link }, id }) => getSlug(link, id),\n description: ({ isVariantOf: { description } }) => description,\n seo: ({ isVariantOf: { name, description } }) => ({\n title: name,\n description,\n }),\n brand: ({ isVariantOf: { brand } }) => ({ name: brand }),\n breadcrumbList: ({ isVariantOf: { categoryTrees, name, link }, id }) => ({\n itemListElement: [\n ...categoryTrees.reverse().map(({ categoryNames }, index) => ({\n name: categoryNames[categoryNames.length - 1],\n item: `/${categoryNames\n .map((categoryName) => slugify(categoryName))\n .join('/')}`,\n position: index + 1,\n })),\n {\n name,\n item: getPath(link, id),\n position: categoryTrees.length + 1,\n },\n ],\n numberOfItems: categoryTrees.length,\n }),\n image: ({ isVariantOf, images }) =>\n (\n nonEmptyArray(images) ??\n nonEmptyArray(isVariantOf.images) ?? [DEFAULT_IMAGE]\n ).map(({ name, value }) => ({\n alternateName: name ?? '',\n url: value.replace('vteximg.com.br', 'vtexassets.com'),\n })),\n sku: ({ id }) => id,\n gtin: ({ reference }) => reference ?? '',\n review: () => [],\n aggregateRating: () => ({}),\n offers: async (product, _, ctx) => {\n const {\n loaders: { simulationLoader },\n storage: { channel },\n } = ctx\n\n const { id, policies } = product\n const sellers = policies.find((policy) => policy.id === channel)?.sellers\n\n if (sellers == null) {\n // This error will likely happen when you forget to forward the channel somewhere in your code.\n // Make sure all queries that lead to a product are forwarding the channel in context corectly\n throw new Error(\n `Product with id ${id} has no sellers for channel ${channel}.`\n )\n }\n\n // Unique seller ids\n const sellerIds = sellers.map((seller) => seller.id)\n const items = Array.from(new Set(sellerIds)).map((seller) => ({\n quantity: 1,\n seller,\n id,\n }))\n\n const simulation = await simulationLoader.load(items)\n\n return { ...simulation, product }\n },\n isVariantOf: ({ isVariantOf }) => isVariantOf,\n additionalProperty: ({ attributes = [] }) =>\n attributes.map((attribute) => ({\n name: attribute.key,\n value: attribute.value,\n })),\n}\n","import { BadRequestError } from './errors'\n\nexport interface SelectedFacet {\n key: string\n value: string\n}\n\nconst getIdFromSlug = (slug: string) => {\n const id = slug.split('-').pop()\n\n if (id == null) {\n throw new BadRequestError('Error while extracting sku id from product slug')\n }\n\n return id\n}\n\n/**\n * Transform facets from the store to VTEX platform facets.\n * For instance, the channel in Store becames trade-policy in VTEX's realm\n * */\nexport const transformSelectedFacet = ({ key, value }: SelectedFacet) => {\n switch (key) {\n case 'channel':\n return { key: 'trade-policy', value }\n\n case 'slug':\n return { key: 'id', value: getIdFromSlug(value) }\n\n default:\n return { key, value }\n }\n}\n","export const SORT_MAP = {\n price_desc: 'price:desc',\n price_asc: 'price:asc',\n orders_desc: 'orders:desc',\n name_desc: 'name:desc',\n name_asc: 'name:asc',\n release_desc: 'release:desc',\n discount_desc: 'discount:desc',\n score_desc: '',\n} as const\n","import { enhanceSku } from '../utils/enhanceSku'\nimport { transformSelectedFacet } from '../utils/facets'\nimport { SORT_MAP } from '../utils/sort'\nimport { StoreCollection } from './collection'\nimport type {\n QueryProductArgs,\n QueryAllCollectionsArgs,\n QueryAllProductsArgs,\n QuerySearchArgs,\n QueryCollectionArgs,\n} from '../../../__generated__/schema'\nimport type { CategoryTree } from '../clients/commerce/types/CategoryTree'\nimport type { Context } from '../index'\n\nexport const Query = {\n product: async (_: unknown, { locator }: QueryProductArgs, ctx: Context) => {\n // Insert channel in context for later usage\n ctx.storage = {\n ...ctx.storage,\n channel:\n locator.find((facet) => facet.key === 'channel')?.value ??\n ctx.storage.channel,\n }\n\n const {\n loaders: { skuLoader },\n } = ctx\n\n return skuLoader.load(locator.map(transformSelectedFacet))\n },\n collection: (_: unknown, { slug }: QueryCollectionArgs, ctx: Context) => {\n const {\n loaders: { collectionLoader },\n } = ctx\n\n return collectionLoader.load(slug)\n },\n search: async (\n _: unknown,\n { first, after: maybeAfter, sort, term, selectedFacets }: QuerySearchArgs,\n ctx: Context\n ) => {\n // Insert channel in context for later usage\n ctx.storage = {\n ...ctx.storage,\n channel:\n selectedFacets?.find((facet) => facet.key === 'channel')?.value ??\n ctx.storage.channel,\n }\n\n const after = maybeAfter ? Number(maybeAfter) : 0\n const searchArgs = {\n page: Math.ceil(after / first),\n count: first,\n query: term,\n sort: SORT_MAP[sort ?? 'score_desc'],\n selectedFacets: selectedFacets?.map(transformSelectedFacet) ?? [],\n }\n\n return searchArgs\n },\n allProducts: async (\n _: unknown,\n { first, after: maybeAfter }: QueryAllProductsArgs,\n ctx: Context\n ) => {\n const {\n clients: { search },\n } = ctx\n\n const after = maybeAfter ? Number(maybeAfter) : 0\n const products = await search.products({\n page: Math.ceil(after / first),\n count: first,\n })\n\n const skus = products.products\n .map((product) => product.skus.map((sku) => enhanceSku(sku, product)))\n .flat()\n .filter((sku) => sku.sellers.length > 0)\n\n return {\n pageInfo: {\n hasNextPage: products.pagination.after.length > 0,\n hasPreviousPage: products.pagination.before.length > 0,\n startCursor: '0',\n endCursor: products.total.toString(),\n totalCount: products.total,\n },\n // after + index is bigger than after+first itself because of the array flat() above\n edges: skus.map((sku, index) => ({\n node: sku,\n cursor: (after + index).toString(),\n })),\n }\n },\n allCollections: async (\n _: unknown,\n { first, after: maybeAfter }: QueryAllCollectionsArgs,\n ctx: Context\n ) => {\n const {\n clients: { commerce },\n } = ctx\n\n const after = maybeAfter ? Number(maybeAfter) : 0\n\n const [brands, tree] = await Promise.all([\n commerce.catalog.brand.list(),\n commerce.catalog.category.tree(),\n ])\n\n const categories: Array<CategoryTree & { level: number }> = []\n const dfs = (node: CategoryTree, level: number) => {\n categories.push({ ...node, level })\n\n for (const child of node.children) {\n dfs(child, level + 1)\n }\n }\n\n for (const node of tree) {\n dfs(node, 0)\n }\n\n const collections = [\n ...brands\n .filter((brand) => brand.isActive)\n .map((x) => ({ ...x, type: 'brand' })),\n ...categories,\n ]\n\n const validCollections = collections\n // Nullable slugs may cause one route to override the other\n .filter((node) => Boolean(StoreCollection.slug(node, null, ctx, null)))\n\n return {\n pageInfo: {\n hasNextPage: validCollections.length - after > first,\n hasPreviousPage: after > 0,\n startCursor: '0',\n endCursor: (\n Math.min(first, validCollections.length - after) - 1\n ).toString(),\n },\n edges: validCollections\n .slice(after, after + first)\n .map((node, index) => ({\n node,\n cursor: (after + index).toString(),\n })),\n }\n },\n}\n","import { getClients } from './clients'\nimport { getLoaders } from './loaders'\nimport { StoreAggregateOffer } from './resolvers/aggregateOffer'\nimport { StoreAggregateRating } from './resolvers/aggregateRating'\nimport { StoreCollection } from './resolvers/collection'\nimport { StoreFacet } from './resolvers/facet'\nimport { StoreFacetValue } from './resolvers/facetValue'\nimport { Mutation } from './resolvers/mutation'\nimport { StoreOffer } from './resolvers/offer'\nimport { StoreProduct } from './resolvers/product'\nimport { StoreProductGroup } from './resolvers/productGroup'\nimport { Query } from './resolvers/query'\nimport { StoreReview } from './resolvers/review'\nimport { StoreSearchResult } from './resolvers/searchResult'\nimport { StoreSeo } from './resolvers/seo'\nimport type { Loaders } from './loaders'\nimport type { Clients } from './clients'\n\nexport interface Options {\n platform: 'vtex'\n account: string\n environment: 'vtexcommercestable' | 'vtexcommercebeta'\n // Default sales channel to use for fetching products\n channel: string\n}\n\nexport interface Context {\n clients: Clients\n loaders: Loaders\n /**\n * @description Storage updated at each request.\n *\n * Use this datastructure to store and share small values in the context.\n * Use it with caution since dependecy injection leads to a more complex code\n * */\n storage: {\n channel: string\n }\n}\n\nexport type Resolver<R = unknown, A = unknown> = (\n root: R,\n args: A,\n ctx: Context,\n info: any\n) => any\n\nconst Resolvers = {\n StoreCollection,\n StoreAggregateOffer,\n StoreProduct,\n StoreSeo,\n StoreFacet,\n StoreFacetValue,\n StoreOffer,\n StoreAggregateRating,\n StoreReview,\n StoreProductGroup,\n StoreSearchResult,\n Query,\n Mutation,\n}\n\nexport const getContextFactory = (options: Options) => (ctx: any) => {\n ctx.storage = {\n channel: options.channel,\n }\n ctx.clients = getClients(options, ctx)\n ctx.loaders = getLoaders(options, ctx)\n\n return ctx\n}\n\nexport const getResolvers = (_: Options) => Resolvers\n","import type { EnhancedSku } from '../utils/enhanceSku'\nimport type { Simulation } from '../clients/commerce/types/Simulation'\n\ntype Resolvers = (root: Simulation & { product: EnhancedSku }) => unknown\n\nexport const StoreAggregateOffer: Record<string, Resolvers> = {\n highPrice: ({ items }) =>\n items.reduce(\n (acc, curr) => (acc > curr.sellingPrice ? acc : curr.sellingPrice),\n items[0]?.sellingPrice ?? 0\n ) / 1e2,\n lowPrice: ({ items }) =>\n items.reduce(\n (acc, curr) => (acc < curr.sellingPrice ? acc : curr.sellingPrice),\n items[0]?.sellingPrice ?? 0\n ) / 1e2,\n offerCount: ({ items }) => items.length,\n priceCurrency: () => '',\n offers: ({ items, product }) => items.map((item) => ({ ...item, product })),\n}\n","import type { Resolver } from '..'\n\ntype Root = { title?: string; description?: string }\n\nexport const StoreSeo: Record<string, Resolver<Root>> = {\n title: ({ title }) => title ?? '',\n description: ({ description }) => description ?? '',\n titleTemplate: () => '',\n canonical: () => '',\n}\n","import type { Resolver } from '..'\nimport type { Attribute } from '../clients/search/types/AttributeSearchResult'\n\ntype Root = Attribute\n\nexport const StoreFacet: Record<string, Resolver<Root>> = {\n key: ({ key }) => key,\n label: ({ label }) => label,\n values: ({ values }) => values,\n type: ({ type }) => (type === 'text' ? 'BOOLEAN' : 'RANGE'),\n}\n","import type { Resolver } from '..'\nimport type { Value } from '../clients/search/types/AttributeSearchResult'\n\ntype Root = Value\n\nexport const StoreFacetValue: Record<string, Resolver<Root>> = {\n value: ({ key, from, to }) => key ?? `${from}-to-${to}`,\n label: ({ label }) => label ?? 'unknown',\n selected: ({ active }) => active,\n quantity: ({ count }) => count,\n}\n","import type { EnhancedSku } from '../utils/enhanceSku'\nimport type { Resolver } from '..'\nimport type { Item } from '../clients/commerce/types/Simulation'\nimport type { OrderFormItem } from '../clients/commerce/types/OrderForm'\n\ntype Root =\n | (Item & { product: EnhancedSku }) // when querying search/product\n | (OrderFormItem & { product: Promise<EnhancedSku> }) // when querying order\n\nexport const StoreOffer: Record<string, Resolver<Root>> = {\n priceCurrency: () => '',\n priceValidUntil: ({ priceValidUntil }) => priceValidUntil ?? '',\n itemCondition: () => 'https://schema.org/NewCondition',\n availability: ({ availability }) =>\n availability === 'available'\n ? 'https://schema.org/InStock'\n : 'https://schema.org/OutOfStock',\n seller: ({ seller }) => ({\n identifier: seller,\n }),\n price: ({ sellingPrice }) => sellingPrice / 1e2, // TODO add spot price calculation\n sellingPrice: ({ sellingPrice }) => sellingPrice / 1e2,\n listPrice: ({ listPrice }) => listPrice / 1e2,\n itemOffered: ({ product }) => product,\n quantity: ({ quantity }) => quantity,\n}\n","import type { Resolver } from '..'\n\n// TODO: Add a review system integration\nexport const StoreAggregateRating: Record<string, Resolver> = {\n ratingValue: () => 5,\n reviewCount: () => 0,\n}\n","import type { Resolver } from '..'\n\nexport const StoreReview: Record<string, Resolver> = {\n reviewRating: () => ({\n ratingValue: 5,\n bestRating: 5,\n }),\n author: () => ({\n name: '',\n }),\n}\n","import { enhanceSku } from '../utils/enhanceSku'\nimport type { Product } from '../clients/search/types/ProductSearchResult'\nimport type { Resolver } from '..'\n\nexport const StoreProductGroup: Record<string, Resolver<Product>> = {\n hasVariant: (root) => root.skus.map((sku) => enhanceSku(sku, root)),\n productGroupID: ({ product }) => product,\n name: ({ name }) => name,\n additionalProperty: ({ textAttributes = [], productSpecifications = [] }) => {\n const specs = new Set(productSpecifications)\n\n return textAttributes\n .filter((attribute) => specs.has(attribute.labelKey))\n .map((attribute) => ({\n name: attribute.labelKey,\n value: attribute.labelValue,\n }))\n },\n}\n","import { enhanceSku } from '../utils/enhanceSku'\nimport type { Resolver } from '..'\nimport type { SearchArgs } from '../clients/search'\n\ntype Root = Omit<SearchArgs, 'type'>\n\nexport const StoreSearchResult: Record<string, Resolver<Root>> = {\n products: async (searchArgs, _, ctx) => {\n const {\n clients: { search },\n } = ctx\n\n const products = await search.products(searchArgs)\n\n const skus = products.products\n .map((product) => {\n const maybeSku = product.skus.find((x) => x.sellers.length > 0)\n\n return maybeSku && enhanceSku(maybeSku, product)\n })\n .filter((sku) => !!sku)\n\n return {\n pageInfo: {\n hasNextPage: products.pagination.after.length > 0,\n hasPreviousPage: products.pagination.before.length > 0,\n startCursor: '0',\n endCursor: products.total.toString(),\n totalCount: products.total,\n },\n edges: skus.map((sku, index) => ({\n node: sku,\n cursor: index.toString(),\n })),\n }\n },\n facets: async (searchArgs, _, ctx) => {\n const {\n clients: { search: is },\n } = ctx\n\n const facets = await is.facets(searchArgs)\n\n return facets.attributes ?? []\n },\n}\n","import { validateCart } from './validateCart'\n\nexport const Mutation = {\n validateCart,\n}\n","import { print } from 'graphql'\n\nimport AggregateOffer from './aggregateOffer.graphql'\nimport AggregateRating from './aggregateRating.graphql'\nimport Author from './author.graphql'\nimport Brand from './brand.graphql'\nimport Breadcrumb from './breadcrumb.graphql'\nimport Collection from './collection.graphql'\nimport Facet from './facet.graphql'\nimport Image from './image.graphql'\nimport Mutation from './mutation.graphql'\nimport Offer from './offer.graphql'\nimport Order from './order.graphql'\nimport Organization from './organization.graphql'\nimport PageInfo from './pageInfo.graphql'\nimport Product from './product.graphql'\nimport ProductGroup from './productGroup.graphql'\nimport Query from './query.graphql'\nimport Review from './review.graphql'\nimport Seo from './seo.graphql'\nimport Cart from './cart.graphql'\nimport Status from './status.graphql'\nimport PropertyValue from './propertyValue.graphql'\n\nexport const typeDefs = [\n Query,\n Mutation,\n Brand,\n Breadcrumb,\n Collection,\n Facet,\n Image,\n PageInfo,\n Product,\n Seo,\n Offer,\n AggregateRating,\n Review,\n Author,\n ProductGroup,\n Organization,\n AggregateOffer,\n Order,\n Cart,\n Status,\n PropertyValue,\n]\n .map(print)\n .join('\\n')\n","import { makeExecutableSchema } from '@graphql-tools/schema'\n\nimport {\n getContextFactory as getContextFactoryVTEX,\n getResolvers as getResolversVTEX,\n} from './platforms/vtex'\nimport { typeDefs } from './typeDefs'\nimport type { Options as OptionsVTEX } from './platforms/vtex'\n\nexport * from './__generated__/schema'\n\nexport type Options = OptionsVTEX\n\nconst platforms = {\n vtex: {\n getResolvers: getResolversVTEX,\n getContextFactory: getContextFactoryVTEX,\n },\n}\n\nexport const getTypeDefs = () => typeDefs\n\nexport const getResolvers = (options: Options) =>\n platforms[options.platform].getResolvers(options)\n\nexport const getContextFactory = (options: Options) =>\n platforms[options.platform].getContextFactory(options)\n\nexport const getSchema = async (options: Options) =>\n makeExecutableSchema({\n resolvers: getResolvers(options),\n typeDefs: getTypeDefs(),\n })\n","import { VtexCommerce } from './commerce'\nimport { IntelligentSearch } from './search'\nimport type { Context, Options } from '..'\n\nexport type Clients = ReturnType<typeof getClients>\n\nexport const getClients = (options: Options, ctx: Context) => {\n const search = IntelligentSearch(options, ctx)\n const commerce = VtexCommerce(options, ctx)\n\n return {\n search,\n commerce,\n }\n}\n","import { getSimulationLoader } from './simulation'\nimport { getSkuLoader } from './sku'\nimport { getCollectionLoader } from './collection'\nimport type { Context, Options } from '..'\n\nexport type Loaders = ReturnType<typeof getLoaders>\n\nexport const getLoaders = (options: Options, { clients }: Context) => {\n const skuLoader = getSkuLoader(options, clients)\n const simulationLoader = getSimulationLoader(options, clients)\n const collectionLoader = getCollectionLoader(options, clients)\n\n return {\n skuLoader,\n simulationLoader,\n collectionLoader,\n }\n}\n","import DataLoader from 'dataloader'\n\nimport { BadRequestError } from '../utils/errors'\nimport { enhanceSku } from '../utils/enhanceSku'\nimport type { EnhancedSku } from '../utils/enhanceSku'\nimport type { Options } from '..'\nimport type { Clients } from '../clients'\nimport type { SelectedFacet } from '../utils/facets'\n\nexport const getSkuLoader = (_: Options, clients: Clients) => {\n const loader = async (facetsList: readonly SelectedFacet[][]) => {\n const skuIds = facetsList.map((facets) => {\n const maybeFacet = facets.find(({ key }) => key === 'id')\n\n if (!maybeFacet) {\n throw new BadRequestError(\n 'Error while loading SKU. Needs to pass an id to selected facets'\n )\n }\n\n return maybeFacet.value\n })\n\n const { products } = await clients.search.products({\n query: `sku:${skuIds.join(';')}`,\n page: 0,\n count: skuIds.length,\n })\n\n const skuBySkuId = products.reduce((acc, product) => {\n for (const sku of product.skus) {\n acc[sku.id] = enhanceSku(sku, product)\n }\n\n return acc\n }, {} as Record<string, EnhancedSku>)\n\n const skus = skuIds.map((skuId) => skuBySkuId[skuId])\n const missingSkus = skus.filter((sku) => !sku)\n\n if (missingSkus.length > 0) {\n throw new Error(\n `Search API did not return the following skus: ${missingSkus.join(',')}`\n )\n }\n\n return skus\n }\n\n return new DataLoader<SelectedFacet[], EnhancedSku>(loader, {\n maxBatchSize: 99, // Max allowed batch size of Search API\n })\n}\n","import DataLoader from 'dataloader'\n\nimport type {\n PayloadItem,\n Simulation,\n} from '../clients/commerce/types/Simulation'\nimport type { Options } from '..'\nimport type { Clients } from '../clients'\n\nexport const getSimulationLoader = (_: Options, clients: Clients) => {\n const loader = async (allItems: readonly PayloadItem[][]) => {\n const items = [...allItems.flat()]\n const simulation = await clients.commerce.checkout.simulation({\n items,\n })\n\n // Sort and filter simulation since Checkout API may return\n // items that we didn't ask for\n const simulated = simulation.items.reduce((acc, item) => {\n const index = item.requestIndex\n\n if (typeof index === 'number' && index < acc.length) {\n acc[index] = item\n }\n\n return acc\n }, Array(items.length).fill(null) as Simulation['items'])\n\n const itemsIndices = allItems.reduce(\n (acc, curr) => [...acc, curr.length + acc[acc.length - 1]],\n [0]\n )\n\n return allItems.map((__, index) => ({\n ...simulation,\n items: simulated\n .slice(itemsIndices[index], itemsIndices[index + 1])\n .filter((item) => Boolean(item)),\n }))\n }\n\n return new DataLoader<PayloadItem[], Simulation>(loader, {\n maxBatchSize: 20,\n })\n}\n"],"names":["fetchAPI","async","info","init","response","fetch","ok","json","text","Error","BASE_INIT","method","headers","IntelligentSearch","account","environment","ctx","base","policyFacet","key","value","storage","channel","search","query","page","count","sort","selectedFacets","type","fuzzy","params","URLSearchParams","toString","pathname","facets","undefined","find","map","join","args","products","BadRequestError","constructor","message","name","NotFoundError","enhanceSku","sku","product","isVariantOf","collectionPageTypes","Set","isCollectionPageType","x","pageType","has","toLowerCase","slugify","path","rawSlugify","separator","lowercase","isBrand","root","baseSlugify","URL","url","slice","StoreCollection","id","slug","seo","title","description","metaTagDescription","Title","MetaTagDescription","level","meta","split","segment","index","breadcrumbList","_","loaders","collectionLoader","segments","filter","Boolean","slugs","__","collections","Promise","all","s","load","itemListElement","collection","item","position","numberOfItems","length","getId","itemOffered","seller","identifier","price","orderFormItemToOffer","listPrice","sellingPrice","quantity","image","offerToOrderItemInput","offer","groupById","offers","reduce","acc","set","get","Map","DEFAULT_IMAGE","getSlug","link","getPath","nonEmptyArray","array","Array","isArray","getIdFromSlug","pop","transformSelectedFacet","SORT_MAP","price_desc","price_asc","orders_desc","name_desc","name_asc","release_desc","discount_desc","score_desc","Query","locator","facet","_locator$find","skuLoader","first","after","maybeAfter","term","_selectedFacets$find","Number","Math","ceil","allProducts","clients","skus","flat","sellers","pageInfo","hasNextPage","pagination","hasPreviousPage","before","startCursor","endCursor","total","totalCount","edges","node","cursor","allCollections","commerce","brands","tree","catalog","brand","list","category","categories","dfs","push","child","children","validCollections","isActive","min","Resolvers","StoreAggregateOffer","highPrice","items","curr","_items$","lowPrice","_items$2","offerCount","priceCurrency","StoreProduct","productID","categoryTrees","reverse","categoryNames","categoryName","images","alternateName","replace","gtin","reference","review","aggregateRating","simulationLoader","policies","policy","_policies$find","sellerIds","from","additionalProperty","attributes","attribute","StoreSeo","titleTemplate","canonical","StoreFacet","label","values","StoreFacetValue","to","selected","active","StoreOffer","priceValidUntil","itemCondition","availability","StoreAggregateRating","ratingValue","reviewCount","StoreReview","reviewRating","bestRating","author","StoreProductGroup","hasVariant","productGroupID","textAttributes","productSpecifications","specs","labelKey","labelValue","StoreSearchResult","searchArgs","maybeSku","is","Mutation","validateCart","cart","order","orderNumber","acceptedOffer","orderForm","checkout","browserItemsById","originItemsById","browserItems","originItems","itemsToAdd","itemsToUpdate","maybeOriginItem","changes","updatedOrderForm","updateOrderFormItems","orderFormId","orderItems","of1","of2","pick","messages","salesChannel","uniqueId","deepEquals","equals","status","toUpperCase","typeDefs","Brand","Breadcrumb","Collection","Facet","Image","PageInfo","Product","Seo","Offer","AggregateRating","Review","Author","ProductGroup","Organization","AggregateOffer","Order","Cart","Status","PropertyValue","print","platforms","vtex","getResolvers","getContextFactory","options","depth","portal","pagetype","simulation","sc","body","JSON","stringify","refreshOutdatedData","allowOutdatedData","VtexCommerce","getClients","DataLoader","skuIds","facetsList","maybeFacet","skuBySkuId","skuId","missingSkus","maxBatchSize","getSkuLoader","allItems","simulated","requestIndex","fill","itemsIndices","getSimulationLoader","limit","pLimit","batch","getCollectionLoader","getLoaders","getTypeDefs","platform","makeExecutableSchema","resolvers"],"mappings":"kWAEO,MAAMA,EAAWC,MAAOC,EAAmBC,WAC1CC,QAAiBC,EAAMH,EAAMC,MAE/BC,EAASE,UACJF,EAASG,aAGZC,QAAaJ,EAASI,aAEtB,IAAIC,MAAMD,ICCZE,EAAY,CAChBC,OAAQ,OACRC,QAAS,gBACS,qBCgBPC,EAAoB,EAC7BC,QAAAA,EAASC,YAAAA,GACXC,WAEMC,mBAAwBF,0BAAoCD,IAC5DI,EAAc,CAAEC,IAAK,eAAgBC,MAAOJ,EAAIK,QAAQC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