@faststore/api 3.11.3 → 3.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/directives/cacheControl.d.ts +2 -2
  3. package/dist/cjs/src/directives/cacheControl.js +6 -6
  4. package/dist/cjs/src/directives/cacheControl.js.map +1 -1
  5. package/dist/cjs/src/directives/index.d.ts +1 -1
  6. package/dist/cjs/src/index.d.ts +1 -1
  7. package/dist/cjs/src/index.js +4 -3
  8. package/dist/cjs/src/index.js.map +1 -1
  9. package/dist/cjs/src/platforms/errors.js.map +1 -1
  10. package/dist/cjs/src/platforms/vtex/clients/commerce/index.d.ts +3 -3
  11. package/dist/cjs/src/platforms/vtex/clients/commerce/index.js +2 -2
  12. package/dist/cjs/src/platforms/vtex/clients/commerce/index.js.map +1 -1
  13. package/dist/cjs/src/platforms/vtex/clients/commerce/types/Product.js.map +1 -1
  14. package/dist/cjs/src/platforms/vtex/clients/search/index.d.ts +1 -1
  15. package/dist/cjs/src/platforms/vtex/clients/search/index.js +2 -2
  16. package/dist/cjs/src/platforms/vtex/clients/search/index.js.map +1 -1
  17. package/dist/cjs/src/platforms/vtex/index.d.ts +1 -1
  18. package/dist/cjs/src/platforms/vtex/loaders/index.js +1 -1
  19. package/dist/cjs/src/platforms/vtex/loaders/index.js.map +1 -1
  20. package/dist/cjs/src/platforms/vtex/loaders/salesChannel.d.ts +4 -4
  21. package/dist/cjs/src/platforms/vtex/loaders/salesChannel.js.map +1 -1
  22. package/dist/cjs/src/platforms/vtex/loaders/simulation.js.map +1 -1
  23. package/dist/cjs/src/platforms/vtex/loaders/sku.js +1 -1
  24. package/dist/cjs/src/platforms/vtex/loaders/sku.js.map +1 -1
  25. package/dist/cjs/src/platforms/vtex/resolvers/aggregateOffer.js +1 -1
  26. package/dist/cjs/src/platforms/vtex/resolvers/aggregateOffer.js.map +1 -1
  27. package/dist/cjs/src/platforms/vtex/resolvers/facet.js.map +1 -1
  28. package/dist/cjs/src/platforms/vtex/resolvers/offer.js +1 -1
  29. package/dist/cjs/src/platforms/vtex/resolvers/offer.js.map +1 -1
  30. package/dist/cjs/src/platforms/vtex/resolvers/organization.d.ts +2 -2
  31. package/dist/cjs/src/platforms/vtex/resolvers/organization.js.map +1 -1
  32. package/dist/cjs/src/platforms/vtex/resolvers/product.d.ts +1 -1
  33. package/dist/cjs/src/platforms/vtex/resolvers/product.js +1 -1
  34. package/dist/cjs/src/platforms/vtex/resolvers/product.js.map +1 -1
  35. package/dist/cjs/src/platforms/vtex/resolvers/query.d.ts +2 -2
  36. package/dist/cjs/src/platforms/vtex/resolvers/query.js +3 -4
  37. package/dist/cjs/src/platforms/vtex/resolvers/query.js.map +1 -1
  38. package/dist/cjs/src/platforms/vtex/resolvers/searchResult.d.ts +1 -1
  39. package/dist/cjs/src/platforms/vtex/resolvers/searchResult.js +1 -1
  40. package/dist/cjs/src/platforms/vtex/resolvers/searchResult.js.map +1 -1
  41. package/dist/cjs/src/platforms/vtex/resolvers/skuVariations.js.map +1 -1
  42. package/dist/cjs/src/platforms/vtex/resolvers/validateCart.js.map +1 -1
  43. package/dist/cjs/src/platforms/vtex/resolvers/validateSession.js +2 -2
  44. package/dist/cjs/src/platforms/vtex/resolvers/validateSession.js.map +1 -1
  45. package/dist/cjs/src/platforms/vtex/utils/channel.js +1 -1
  46. package/dist/cjs/src/platforms/vtex/utils/channel.js.map +1 -1
  47. package/dist/cjs/src/platforms/vtex/utils/createNewAddress.d.ts +2 -2
  48. package/dist/cjs/src/platforms/vtex/utils/facets.js +14 -14
  49. package/dist/cjs/src/platforms/vtex/utils/facets.js.map +1 -1
  50. package/dist/cjs/src/platforms/vtex/utils/getAddressOrderForm.d.ts +2 -2
  51. package/dist/cjs/src/platforms/vtex/utils/shouldUpdateShippingData.d.ts +2 -2
  52. package/dist/cjs/src/platforms/vtex/utils/skuVariants.d.ts +1 -1
  53. package/dist/cjs/src/platforms/vtex/utils/taxes.js.map +1 -1
  54. package/dist/cjs/src/typeDefs/advertisement.graphql +22 -22
  55. package/dist/cjs/src/typeDefs/newsletter.graphql +0 -1
  56. package/dist/cjs/src/typeDefs/objectOrString.graphql +1 -1
  57. package/dist/cjs/src/typeDefs/query.graphql +0 -1
  58. package/dist/esm/package.json +1 -1
  59. package/dist/esm/src/directives/cacheControl.d.ts +2 -2
  60. package/dist/esm/src/directives/cacheControl.js +7 -7
  61. package/dist/esm/src/directives/cacheControl.js.map +1 -1
  62. package/dist/esm/src/directives/index.d.ts +1 -1
  63. package/dist/esm/src/index.d.ts +1 -1
  64. package/dist/esm/src/index.js +4 -3
  65. package/dist/esm/src/index.js.map +1 -1
  66. package/dist/esm/src/platforms/errors.js.map +1 -1
  67. package/dist/esm/src/platforms/vtex/clients/commerce/index.d.ts +3 -3
  68. package/dist/esm/src/platforms/vtex/clients/commerce/index.js +2 -2
  69. package/dist/esm/src/platforms/vtex/clients/commerce/index.js.map +1 -1
  70. package/dist/esm/src/platforms/vtex/clients/commerce/types/Product.js.map +1 -1
  71. package/dist/esm/src/platforms/vtex/clients/search/index.d.ts +1 -1
  72. package/dist/esm/src/platforms/vtex/clients/search/index.js +2 -2
  73. package/dist/esm/src/platforms/vtex/clients/search/index.js.map +1 -1
  74. package/dist/esm/src/platforms/vtex/index.d.ts +1 -1
  75. package/dist/esm/src/platforms/vtex/index.js +1 -1
  76. package/dist/esm/src/platforms/vtex/index.js.map +1 -1
  77. package/dist/esm/src/platforms/vtex/loaders/index.js +1 -1
  78. package/dist/esm/src/platforms/vtex/loaders/index.js.map +1 -1
  79. package/dist/esm/src/platforms/vtex/loaders/salesChannel.d.ts +4 -4
  80. package/dist/esm/src/platforms/vtex/loaders/salesChannel.js +1 -1
  81. package/dist/esm/src/platforms/vtex/loaders/salesChannel.js.map +1 -1
  82. package/dist/esm/src/platforms/vtex/loaders/simulation.js.map +1 -1
  83. package/dist/esm/src/platforms/vtex/loaders/sku.js +1 -1
  84. package/dist/esm/src/platforms/vtex/loaders/sku.js.map +1 -1
  85. package/dist/esm/src/platforms/vtex/resolvers/aggregateOffer.js +1 -1
  86. package/dist/esm/src/platforms/vtex/resolvers/aggregateOffer.js.map +1 -1
  87. package/dist/esm/src/platforms/vtex/resolvers/facet.js.map +1 -1
  88. package/dist/esm/src/platforms/vtex/resolvers/offer.js +1 -1
  89. package/dist/esm/src/platforms/vtex/resolvers/offer.js.map +1 -1
  90. package/dist/esm/src/platforms/vtex/resolvers/organization.d.ts +2 -2
  91. package/dist/esm/src/platforms/vtex/resolvers/organization.js.map +1 -1
  92. package/dist/esm/src/platforms/vtex/resolvers/product.d.ts +1 -1
  93. package/dist/esm/src/platforms/vtex/resolvers/product.js +1 -1
  94. package/dist/esm/src/platforms/vtex/resolvers/product.js.map +1 -1
  95. package/dist/esm/src/platforms/vtex/resolvers/query.d.ts +2 -2
  96. package/dist/esm/src/platforms/vtex/resolvers/query.js +3 -4
  97. package/dist/esm/src/platforms/vtex/resolvers/query.js.map +1 -1
  98. package/dist/esm/src/platforms/vtex/resolvers/searchResult.d.ts +1 -1
  99. package/dist/esm/src/platforms/vtex/resolvers/searchResult.js +1 -1
  100. package/dist/esm/src/platforms/vtex/resolvers/searchResult.js.map +1 -1
  101. package/dist/esm/src/platforms/vtex/resolvers/skuVariations.js.map +1 -1
  102. package/dist/esm/src/platforms/vtex/resolvers/validateCart.js.map +1 -1
  103. package/dist/esm/src/platforms/vtex/resolvers/validateSession.js +2 -2
  104. package/dist/esm/src/platforms/vtex/resolvers/validateSession.js.map +1 -1
  105. package/dist/esm/src/platforms/vtex/utils/channel.js +1 -1
  106. package/dist/esm/src/platforms/vtex/utils/channel.js.map +1 -1
  107. package/dist/esm/src/platforms/vtex/utils/createNewAddress.d.ts +2 -2
  108. package/dist/esm/src/platforms/vtex/utils/facets.js +14 -14
  109. package/dist/esm/src/platforms/vtex/utils/facets.js.map +1 -1
  110. package/dist/esm/src/platforms/vtex/utils/getAddressOrderForm.d.ts +2 -2
  111. package/dist/esm/src/platforms/vtex/utils/shouldUpdateShippingData.d.ts +2 -2
  112. package/dist/esm/src/platforms/vtex/utils/skuVariants.d.ts +1 -1
  113. package/dist/esm/src/platforms/vtex/utils/taxes.js.map +1 -1
  114. package/dist/esm/src/typeDefs/advertisement.graphql +22 -22
  115. package/dist/esm/src/typeDefs/newsletter.graphql +0 -1
  116. package/dist/esm/src/typeDefs/objectOrString.graphql +1 -1
  117. package/dist/esm/src/typeDefs/query.graphql +0 -1
  118. package/package.json +2 -2
  119. package/src/directives/cacheControl.ts +34 -36
  120. package/src/directives/index.ts +2 -2
  121. package/src/index.ts +5 -4
  122. package/src/platforms/errors.ts +4 -1
  123. package/src/platforms/vtex/clients/commerce/index.ts +13 -13
  124. package/src/platforms/vtex/clients/commerce/types/OrderForm.ts +6 -6
  125. package/src/platforms/vtex/clients/commerce/types/Product.ts +125 -128
  126. package/src/platforms/vtex/clients/commerce/types/SalesChannel.ts +20 -20
  127. package/src/platforms/vtex/clients/search/index.ts +13 -3
  128. package/src/platforms/vtex/clients/search/types/ProductSearchResult.ts +1 -1
  129. package/src/platforms/vtex/index.ts +1 -1
  130. package/src/platforms/vtex/loaders/index.ts +2 -2
  131. package/src/platforms/vtex/loaders/salesChannel.ts +7 -9
  132. package/src/platforms/vtex/loaders/simulation.ts +10 -7
  133. package/src/platforms/vtex/loaders/sku.ts +14 -9
  134. package/src/platforms/vtex/resolvers/aggregateOffer.ts +3 -3
  135. package/src/platforms/vtex/resolvers/facet.ts +9 -10
  136. package/src/platforms/vtex/resolvers/offer.ts +16 -8
  137. package/src/platforms/vtex/resolvers/organization.ts +3 -3
  138. package/src/platforms/vtex/resolvers/product.ts +5 -5
  139. package/src/platforms/vtex/resolvers/propertyValue.ts +1 -1
  140. package/src/platforms/vtex/resolvers/query.ts +13 -5
  141. package/src/platforms/vtex/resolvers/searchResult.ts +4 -4
  142. package/src/platforms/vtex/resolvers/skuVariations.ts +2 -1
  143. package/src/platforms/vtex/resolvers/validateCart.ts +7 -3
  144. package/src/platforms/vtex/resolvers/validateSession.ts +12 -13
  145. package/src/platforms/vtex/utils/channel.ts +2 -1
  146. package/src/platforms/vtex/utils/createNewAddress.ts +2 -2
  147. package/src/platforms/vtex/utils/facets.ts +21 -21
  148. package/src/platforms/vtex/utils/getAddressOrderForm.ts +2 -2
  149. package/src/platforms/vtex/utils/shouldUpdateShippingData.ts +2 -2
  150. package/src/platforms/vtex/utils/skuVariants.ts +1 -1
  151. package/src/platforms/vtex/utils/taxes.ts +1 -5
  152. package/src/typeDefs/advertisement.graphql +22 -22
  153. package/src/typeDefs/newsletter.graphql +0 -1
  154. package/src/typeDefs/objectOrString.graphql +1 -1
  155. package/src/typeDefs/query.graphql +0 -1
  156. package/src/typings/json.d.ts +2 -2
@@ -9,7 +9,7 @@ import { StoreCollection } from './resolvers/collection'
9
9
  import {
10
10
  StoreFacet,
11
11
  StoreFacetBoolean,
12
- StoreFacetRange
12
+ StoreFacetRange,
13
13
  } from './resolvers/facet'
14
14
  import { StoreFacetValueBoolean } from './resolvers/faceValue'
15
15
  import { Mutation } from './resolvers/mutation'
@@ -1,4 +1,4 @@
1
- import { getSalesChannelLoader } from './salesChannel';
1
+ import { getSalesChannelLoader } from './salesChannel'
2
2
  import { getSimulationLoader } from './simulation'
3
3
  import { getSkuLoader } from './sku'
4
4
  import { getCollectionLoader } from './collection'
@@ -16,6 +16,6 @@ export const getLoaders = (options: Options, { clients }: Context) => {
16
16
  skuLoader,
17
17
  simulationLoader,
18
18
  collectionLoader,
19
- salesChannelLoader
19
+ salesChannelLoader,
20
20
  }
21
21
  }
@@ -1,15 +1,13 @@
1
- import DataLoader from "dataloader";
1
+ import DataLoader from 'dataloader'
2
2
 
3
- import { Options } from "..";
4
- import { Clients } from "../clients";
3
+ import type { Options } from '..'
4
+ import type { Clients } from '../clients'
5
5
 
6
- import type { SalesChannel } from "./../clients/commerce/types/SalesChannel";
6
+ import type { SalesChannel } from './../clients/commerce/types/SalesChannel'
7
7
 
8
8
  export const getSalesChannelLoader = (_: Options, clients: Clients) => {
9
9
  const loader = async (channels: readonly string[]) =>
10
- Promise.all(
11
- channels.map((sc) => clients.commerce.catalog.salesChannel(sc)),
12
- );
10
+ Promise.all(channels.map((sc) => clients.commerce.catalog.salesChannel(sc)))
13
11
 
14
- return new DataLoader<string, SalesChannel>(loader);
15
- };
12
+ return new DataLoader<string, SalesChannel>(loader)
13
+ }
@@ -29,15 +29,18 @@ export const getSimulationLoader = (_: Options, clients: Clients) => {
29
29
 
30
30
  // Sort and filter simulation since Checkout API may return
31
31
  // items that we didn't ask for
32
- const simulated = simulation.items.reduce((acc, item) => {
33
- const index = item.requestIndex
32
+ const simulated = simulation.items.reduce(
33
+ (acc, item) => {
34
+ const index = item.requestIndex
34
35
 
35
- if (typeof index === 'number' && index < acc.length) {
36
- acc[index] = item
37
- }
36
+ if (typeof index === 'number' && index < acc.length) {
37
+ acc[index] = item
38
+ }
38
39
 
39
- return acc
40
- }, Array(items.length).fill(null) as Simulation['items'])
40
+ return acc
41
+ },
42
+ Array(items.length).fill(null) as Simulation['items']
43
+ )
41
44
 
42
45
  const itemsIndices = allItems.reduce(
43
46
  (acc, curr) => [...acc, curr.length + acc[acc.length - 1]],
@@ -8,23 +8,28 @@ import type { Clients } from '../clients'
8
8
 
9
9
  export const getSkuLoader = (_: Options, clients: Clients) => {
10
10
  const loader = async (keys: readonly string[]) => {
11
- const skuIds = keys.map((key) => key.split('-')[0]);
12
- const showInvisibleItems = keys.some((key) => key.split('-')[1] === 'invisibleItems')
11
+ const skuIds = keys.map((key) => key.split('-')[0])
12
+ const showInvisibleItems = keys.some(
13
+ (key) => key.split('-')[1] === 'invisibleItems'
14
+ )
13
15
 
14
16
  const { products } = await clients.search.products({
15
17
  query: `sku:${skuIds.join(';')}`,
16
18
  page: 0,
17
19
  count: skuIds.length,
18
- showInvisibleItems
20
+ showInvisibleItems,
19
21
  })
20
22
 
21
- const skuBySkuId = products.reduce((acc, product) => {
22
- for (const sku of product.items) {
23
- acc[sku.itemId] = enhanceSku(sku, product)
24
- }
23
+ const skuBySkuId = products.reduce(
24
+ (acc, product) => {
25
+ for (const sku of product.items) {
26
+ acc[sku.itemId] = enhanceSku(sku, product)
27
+ }
25
28
 
26
- return acc
27
- }, {} as Record<string, EnhancedSku>)
29
+ return acc
30
+ },
31
+ {} as Record<string, EnhancedSku>
32
+ )
28
33
 
29
34
  const skus = skuIds.map((skuId) => skuBySkuId[skuId])
30
35
  const missingSkus = skuIds.filter((skuId) => !skuBySkuId[skuId])
@@ -45,12 +45,12 @@ export const StoreAggregateOffer: Record<string, Resolver<Root>> & {
45
45
  priceCurrency: async (_, __, ctx) => {
46
46
  const {
47
47
  loaders: { salesChannelLoader },
48
- storage: { channel }
48
+ storage: { channel },
49
49
  } = ctx
50
50
 
51
- const sc = await salesChannelLoader.load(channel.salesChannel);
51
+ const sc = await salesChannelLoader.load(channel.salesChannel)
52
52
 
53
- return sc.CurrencyCode ?? '';
53
+ return sc.CurrencyCode ?? ''
54
54
  },
55
55
  offers: (offers) => offers,
56
56
  }
@@ -10,18 +10,17 @@ import type { Resolver } from '..'
10
10
  export type Root = Facet
11
11
 
12
12
  export const StoreFacet: Record<string, Resolver<Root>> = {
13
- __resolveType: ({ type, values }) =>
14
- {
15
- if (type !== 'TEXT') {
16
- return 'StoreFacetRange'
17
- }
13
+ __resolveType: ({ type, values }) => {
14
+ if (type !== 'TEXT') {
15
+ return 'StoreFacetRange'
16
+ }
18
17
 
19
- if (values.every((value) => (value as FacetValueRange).range)) {
20
- return 'StoreFacetRange'
21
- }
18
+ if (values.every((value) => (value as FacetValueRange).range)) {
19
+ return 'StoreFacetRange'
20
+ }
22
21
 
23
- return 'StoreFacetBoolean'
24
- },
22
+ return 'StoreFacetBoolean'
23
+ },
25
24
  }
26
25
 
27
26
  export const StoreFacetBoolean: Record<
@@ -26,14 +26,14 @@ const isOrderFormItem = (item: Root): item is OrderFormProduct =>
26
26
 
27
27
  export const StoreOffer: Record<string, Resolver<Root>> = {
28
28
  priceCurrency: async (_, __, ctx) => {
29
- const {
30
- loaders: { salesChannelLoader },
31
- storage: { channel }
29
+ const {
30
+ loaders: { salesChannelLoader },
31
+ storage: { channel },
32
32
  } = ctx
33
33
 
34
- const sc = await salesChannelLoader.load(channel.salesChannel);
35
-
36
- return sc.CurrencyCode ?? '';
34
+ const sc = await salesChannelLoader.load(channel.salesChannel)
35
+
36
+ return sc.CurrencyCode ?? ''
37
37
  },
38
38
  priceValidUntil: (root) => {
39
39
  if (isSearchItem(root)) {
@@ -90,7 +90,11 @@ export const StoreOffer: Record<string, Resolver<Root>> = {
90
90
  }
91
91
 
92
92
  if (isOrderFormItem(root)) {
93
- return withTax(root.sellingPrice / 1e2, root.tax / 1e2, root.unitMultiplier)
93
+ return withTax(
94
+ root.sellingPrice / 1e2,
95
+ root.tax / 1e2,
96
+ root.unitMultiplier
97
+ )
94
98
  }
95
99
 
96
100
  return null
@@ -119,7 +123,11 @@ export const StoreOffer: Record<string, Resolver<Root>> = {
119
123
  },
120
124
  listPriceWithTaxes: (root) => {
121
125
  if (isSearchItem(root)) {
122
- return withTax(root.ListPrice ?? 0, root?.Tax, root.product.unitMultiplier)
126
+ return withTax(
127
+ root.ListPrice ?? 0,
128
+ root?.Tax,
129
+ root.product.unitMultiplier
130
+ )
123
131
  }
124
132
 
125
133
  if (isOrderFormItem(root)) {
@@ -1,9 +1,9 @@
1
1
  import type { Resolver } from '..'
2
- import { PromiseType } from '../../../typings'
3
- import { StoreOffer } from './offer'
2
+ import type { PromiseType } from '../../../typings'
3
+ import type { StoreOffer } from './offer'
4
4
 
5
5
  export type Root = PromiseType<ReturnType<typeof StoreOffer.seller>>
6
6
 
7
- export const StoreOrganization: Record<string, Resolver<Root>> = {
7
+ export const StoreOrganization: Record<string, Resolver<Root>> = {
8
8
  identifier: () => '',
9
9
  }
@@ -12,7 +12,7 @@ import {
12
12
  VALUE_REFERENCES,
13
13
  } from '../utils/propertyValue'
14
14
  import type { Attachment } from '../clients/commerce/types/OrderForm'
15
- import { StoreImage, StoreProductImageArgs } from '../../..'
15
+ import type { StoreImage, StoreProductImageArgs } from '../../..'
16
16
 
17
17
  type QueryProduct = PromiseType<ReturnType<typeof Query.product>>
18
18
 
@@ -54,7 +54,7 @@ export const StoreProduct: Record<string, Resolver<Root>> & {
54
54
  canonical: canonicalFromProduct(isVariantOf),
55
55
  }),
56
56
  brand: ({ isVariantOf: { brand } }) => ({ name: brand }),
57
- unitMultiplier: ({unitMultiplier}) => unitMultiplier,
57
+ unitMultiplier: ({ unitMultiplier }) => unitMultiplier,
58
58
  breadcrumbList: ({
59
59
  isVariantOf: { categories, productName, linkText },
60
60
  itemId,
@@ -90,13 +90,13 @@ export const StoreProduct: Record<string, Resolver<Root>> & {
90
90
  })
91
91
  )
92
92
 
93
- if(typeof args !== 'object') {
94
- return resolvedImages;
93
+ if (typeof args !== 'object') {
94
+ return resolvedImages
95
95
  }
96
96
 
97
97
  let { context, limit } = args as StoreProductImageArgs
98
98
 
99
- const shouldFilter = context !== "generic"
99
+ const shouldFilter = context !== 'generic'
100
100
 
101
101
  // Normalize count to undefined as we want any negative value to always return the full list of images
102
102
  limit = limit || -1
@@ -1,5 +1,5 @@
1
1
  import type { Resolver } from '..'
2
- import type { StorePropertyValue as StorePropertyValueType } from '../../../__generated__/schema'
2
+ import type { StorePropertyValue as StorePropertyValueType } from '../../../__generated__/schema'
3
3
  import { getPropertyId } from '../utils/propertyValue'
4
4
 
5
5
  export type Root = StorePropertyValueType
@@ -25,7 +25,7 @@ import type {
25
25
  import type { CategoryTree } from '../clients/commerce/types/CategoryTree'
26
26
  import type { Context } from '../index'
27
27
  import { isValidSkuId, pickBestSku } from '../utils/sku'
28
- import { SearchArgs } from '../clients/search'
28
+ import type { SearchArgs } from '../clients/search'
29
29
 
30
30
  export const Query = {
31
31
  product: async (_: unknown, { locator }: QueryProductArgs, ctx: Context) => {
@@ -112,7 +112,14 @@ export const Query = {
112
112
  },
113
113
  search: async (
114
114
  _: unknown,
115
- { first, after: maybeAfter, sort, term, selectedFacets, sponsoredCount }: QuerySearchArgs,
115
+ {
116
+ first,
117
+ after: maybeAfter,
118
+ sort,
119
+ term,
120
+ selectedFacets,
121
+ sponsoredCount,
122
+ }: QuerySearchArgs,
116
123
  ctx: Context
117
124
  ) => {
118
125
  // Insert channel in context for later usage
@@ -160,7 +167,7 @@ export const Query = {
160
167
  query: query ?? undefined,
161
168
  sort: SORT_MAP[sort ?? 'score_desc'],
162
169
  selectedFacets: selectedFacets?.flatMap(transformSelectedFacet) ?? [],
163
- sponsoredCount: sponsoredCount ?? undefined
170
+ sponsoredCount: sponsoredCount ?? undefined,
164
171
  }
165
172
 
166
173
  const productSearchPromise = ctx.clients.search.products(searchArgs)
@@ -183,8 +190,9 @@ export const Query = {
183
190
  })
184
191
 
185
192
  const skus = products.products
186
- .map((product) => product.items.map((sku) => enhanceSku(sku, product)))
187
- .flat()
193
+ .flatMap((product) =>
194
+ product.items.map((sku) => enhanceSku(sku, product))
195
+ )
188
196
  .filter((sku) => sku.sellers.length > 0)
189
197
 
190
198
  return {
@@ -2,7 +2,7 @@ import { enhanceSku } from '../utils/enhanceSku'
2
2
  import type { Resolver } from '..'
3
3
  import type { SearchArgs } from '../clients/search'
4
4
  import type { Facet } from '../clients/search/types/FacetSearchResult'
5
- import { ProductSearchResult } from '../clients/search/types/ProductSearchResult'
5
+ import type { ProductSearchResult } from '../clients/search/types/ProductSearchResult'
6
6
  import { pickBestSku } from '../utils/sku'
7
7
 
8
8
  export type Root = {
@@ -14,8 +14,8 @@ const isRootFacet = (facet: Facet, isDepartment: boolean, isBrand: boolean) =>
14
14
  isDepartment
15
15
  ? facet.key === 'category-1'
16
16
  : isBrand
17
- ? facet.key === 'brand'
18
- : false
17
+ ? facet.key === 'brand'
18
+ : false
19
19
 
20
20
  export const StoreSearchResult: Record<string, Resolver<Root>> = {
21
21
  suggestions: async (root, _, ctx) => {
@@ -123,7 +123,7 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
123
123
  return {
124
124
  isTermMisspelled: productSearchResult.correction?.misspelled ?? false,
125
125
  logicalOperator: productSearchResult.operator,
126
- fuzzy: productSearchResult.fuzzy
126
+ fuzzy: productSearchResult.fuzzy,
127
127
  }
128
128
  },
129
129
  }
@@ -27,7 +27,8 @@ export const SkuVariants: Record<string, Resolver<Root>> = {
27
27
  ),
28
28
 
29
29
  availableVariations: (root, args) => {
30
- const dominantVariantName = (args as SlugsMapArgs).dominantVariantName ?? root.variations[0]?.name
30
+ const dominantVariantName =
31
+ (args as SlugsMapArgs).dominantVariantName ?? root.variations[0]?.name
31
32
  const activeVariations = getActiveSkuVariations(root.variations)
32
33
 
33
34
  const activeDominantVariationValue = activeVariations[dominantVariantName]
@@ -25,7 +25,7 @@ import type {
25
25
  } from '../clients/commerce/types/OrderForm'
26
26
  import { shouldUpdateShippingData } from '../utils/shouldUpdateShippingData'
27
27
  import { getAddressOrderForm } from '../utils/getAddressOrderForm'
28
- import { SelectedAddress } from '../clients/commerce/types/ShippingData'
28
+ import type { SelectedAddress } from '../clients/commerce/types/ShippingData'
29
29
  import { createNewAddress } from '../utils/createNewAddress'
30
30
 
31
31
  type Indexed<T> = T & { index?: number }
@@ -333,8 +333,12 @@ export const validateCart = async (
333
333
  { cart: { order }, session }: MutationValidateCartArgs,
334
334
  ctx: Context
335
335
  ) => {
336
- const orderFormIdFromCookie = getCookieCheckoutOrderNumber(ctx.headers.cookie, 'checkout.vtex.com')
337
- const orderNumber = orderFormIdFromCookie !== '' ? orderFormIdFromCookie : order?.orderNumber
336
+ const orderFormIdFromCookie = getCookieCheckoutOrderNumber(
337
+ ctx.headers.cookie,
338
+ 'checkout.vtex.com'
339
+ )
340
+ const orderNumber =
341
+ orderFormIdFromCookie !== '' ? orderFormIdFromCookie : order?.orderNumber
338
342
 
339
343
  const { acceptedOffer, shouldSplitItem } = order
340
344
  const {
@@ -12,7 +12,6 @@ export const validateSession = async (
12
12
  { session: oldSession, search }: MutationValidateSessionArgs,
13
13
  { clients }: Context
14
14
  ): Promise<StoreSession | null> => {
15
-
16
15
  const channel = ChannelMarshal.parse(oldSession.channel ?? '')
17
16
  const postalCode = String(oldSession.postalCode ?? '')
18
17
  const geoCoordinates = oldSession.geoCoordinates ?? null
@@ -27,11 +26,11 @@ export const validateSession = async (
27
26
  const [regionData, sessionData] = await Promise.all([
28
27
  postalCode || geoCoordinates
29
28
  ? clients.commerce.checkout.region({
30
- postalCode,
31
- geoCoordinates,
32
- country,
33
- salesChannel,
34
- })
29
+ postalCode,
30
+ geoCoordinates,
31
+ country,
32
+ salesChannel,
33
+ })
35
34
  : Promise.resolve(null),
36
35
  clients.commerce.session(params.toString()).catch(() => null),
37
36
  ])
@@ -54,18 +53,18 @@ export const validateSession = async (
54
53
  salesChannel: store?.channel?.value ?? channel.salesChannel,
55
54
  regionId: region?.id ?? channel.regionId,
56
55
  seller: seller?.id,
57
- hasOnlyDefaultSalesChannel: !store?.channel?.value
56
+ hasOnlyDefaultSalesChannel: !store?.channel?.value,
58
57
  }),
59
58
  b2b: {
60
- customerId: authentication?.customerId?.value ?? ''
59
+ customerId: authentication?.customerId?.value ?? '',
61
60
  },
62
61
  person: profile?.id
63
62
  ? {
64
- id: profile.id?.value ?? '',
65
- email: profile.email?.value ?? '',
66
- givenName: profile.firstName?.value ?? '',
67
- familyName: profile.lastName?.value ?? '',
68
- }
63
+ id: profile.id?.value ?? '',
64
+ email: profile.email?.value ?? '',
65
+ givenName: profile.firstName?.value ?? '',
66
+ familyName: profile.lastName?.value ?? '',
67
+ }
69
68
  : null,
70
69
  }
71
70
 
@@ -14,7 +14,8 @@ export default class ChannelMarshal {
14
14
  seller: parsedChannel.seller ?? '',
15
15
  regionId: parsedChannel.regionId ?? '',
16
16
  salesChannel: parsedChannel.salesChannel ?? '',
17
- hasOnlyDefaultSalesChannel: parsedChannel.hasOnlyDefaultSalesChannel ?? true
17
+ hasOnlyDefaultSalesChannel:
18
+ parsedChannel.hasOnlyDefaultSalesChannel ?? true,
18
19
  }
19
20
  } catch (error) {
20
21
  console.error(error)
@@ -1,5 +1,5 @@
1
- import { IStoreSession } from '../../../__generated__/schema'
2
- import { SelectedAddress } from '../clients/commerce/types/ShippingData'
1
+ import type { IStoreSession } from '../../../__generated__/schema'
2
+ import type { SelectedAddress } from '../clients/commerce/types/ShippingData'
3
3
 
4
4
  export const createNewAddress = (session: IStoreSession) => {
5
5
  const postalCode = session.postalCode
@@ -12,12 +12,12 @@ export interface CrossSellingFacet {
12
12
  }
13
13
 
14
14
  export const FACET_CROSS_SELLING_MAP = {
15
- buy: "whoboughtalsobought",
16
- view: "whosawalsosaw",
17
- similars: "similars",
18
- viewAndBought: "whosawalsobought",
19
- accessories: "accessories",
20
- suggestions: "suggestions",
15
+ buy: 'whoboughtalsobought',
16
+ view: 'whosawalsosaw',
17
+ similars: 'similars',
18
+ viewAndBought: 'whosawalsobought',
19
+ accessories: 'accessories',
20
+ suggestions: 'suggestions',
21
21
  } as const
22
22
 
23
23
  export type FuzzyFacet = {
@@ -39,15 +39,15 @@ export const transformSelectedFacet = ({ key, value }: SelectedFacet) => {
39
39
  case 'price': {
40
40
  return { key, value: value.replace('-to-', ':') }
41
41
  }
42
-
43
- case 'channel':
44
- case 'locale':
45
- case "buy":
46
- case "view":
47
- case "similars":
48
- case "viewAndBought":
49
- case "accessories":
50
- case "suggestions": {
42
+
43
+ case 'channel':
44
+ case 'locale':
45
+ case 'buy':
46
+ case 'view':
47
+ case 'similars':
48
+ case 'viewAndBought':
49
+ case 'accessories':
50
+ case 'suggestions': {
51
51
  return [] // remove this facet from search
52
52
  }
53
53
 
@@ -70,17 +70,17 @@ export const parseRange = (range: string): [number, number] | null => {
70
70
  return splitted as [number, number]
71
71
  }
72
72
 
73
- export const isCrossSelling = (
74
- x: string,
75
- ): x is CrossSellingFacet['key'] =>
76
- typeof (FACET_CROSS_SELLING_MAP as Record<string, string>)[x] === "string"
73
+ export const isCrossSelling = (x: string): x is CrossSellingFacet['key'] =>
74
+ typeof (FACET_CROSS_SELLING_MAP as Record<string, string>)[x] === 'string'
77
75
 
78
76
  export const findCrossSelling = (facets?: Maybe<SelectedFacet[]>) => {
79
- const filtered = facets?.filter((x): x is CrossSellingFacet => isCrossSelling(x.key))
77
+ const filtered = facets?.filter((x): x is CrossSellingFacet =>
78
+ isCrossSelling(x.key)
79
+ )
80
80
 
81
81
  if (Array.isArray(filtered) && filtered.length > 1) {
82
82
  throw new BadRequestError(
83
- `You passed ${filtered.length} cross selling facets but only one is allowed. Please leave one of the following facet: ${filtered.map(x => x.key).join(',')}`
83
+ `You passed ${filtered.length} cross selling facets but only one is allowed. Please leave one of the following facet: ${filtered.map((x) => x.key).join(',')}`
84
84
  )
85
85
  }
86
86
 
@@ -1,5 +1,5 @@
1
- import { IStoreSession } from '../../../__generated__/schema'
2
- import { OrderForm } from '../clients/commerce/types/OrderForm'
1
+ import type { IStoreSession } from '../../../__generated__/schema'
2
+ import type { OrderForm } from '../clients/commerce/types/OrderForm'
3
3
 
4
4
  export const getAddressOrderForm = (
5
5
  orderForm: OrderForm,
@@ -1,8 +1,8 @@
1
- import {
1
+ import type {
2
2
  IStoreGeoCoordinates,
3
3
  IStoreSession,
4
4
  } from '../../../__generated__/schema'
5
- import {
5
+ import type {
6
6
  CheckoutAddress,
7
7
  OrderForm,
8
8
  LogisticsInfo,
@@ -1,4 +1,4 @@
1
- import { StoreProduct as StoreProductType } from '../../..'
1
+ import type { StoreProduct as StoreProductType } from '../../..'
2
2
  import type { Product, Item } from '../clients/search/types/ProductSearchResult'
3
3
 
4
4
  export type SkuVariants = StoreProductType[]
@@ -1,8 +1,4 @@
1
- export const withTax = (
2
- price: number,
3
- tax: number = 0,
4
- unitMultiplier: number = 1
5
- ) => {
1
+ export const withTax = (price: number, tax = 0, unitMultiplier = 1) => {
6
2
  const unitTax = tax / unitMultiplier
7
3
 
8
4
  return Math.round((price + unitTax) * 100) / 100
@@ -1,25 +1,25 @@
1
1
  """
2
2
  Advertisement information about a specific product in a campaign
3
3
  """
4
- type Advertisement {
5
- """
6
- Advertiser ID of the product.
7
- """
8
- adId: String!
9
- """
10
- Campaign ID.
11
- """
12
- campaignId: String!
13
- """
14
- Cost of the action, usually Cost Per Click.
15
- """
16
- actionCost: Float!
17
- """
18
- Advertiser Request ID.
19
- """
20
- adRequestId: String!
21
- """
22
- Advertiser Response ID.
23
- """
24
- adResponseId: String!
25
- }
4
+ type Advertisement {
5
+ """
6
+ Advertiser ID of the product.
7
+ """
8
+ adId: String!
9
+ """
10
+ Campaign ID.
11
+ """
12
+ campaignId: String!
13
+ """
14
+ Cost of the action, usually Cost Per Click.
15
+ """
16
+ actionCost: Float!
17
+ """
18
+ Advertiser Request ID.
19
+ """
20
+ adRequestId: String!
21
+ """
22
+ Advertiser Response ID.
23
+ """
24
+ adResponseId: String!
25
+ }
@@ -1,7 +1,6 @@
1
1
  """
2
2
  Newsletter information.
3
3
  """
4
-
5
4
  type PersonNewsletter {
6
5
  """
7
6
  Person's ID in the newsletter list.
@@ -1 +1 @@
1
- scalar ObjectOrString
1
+ scalar ObjectOrString
@@ -316,7 +316,6 @@ type Query {
316
316
  selectedFacets: [IStoreSelectedFacet!]
317
317
  ): StoreRedirect
318
318
 
319
-
320
319
  """
321
320
  Returns a list of sellers available for a specific localization.
322
321
  """
@@ -1,4 +1,4 @@
1
1
  declare module '*.json' {
2
- const value: any;
3
- export default value;
2
+ const value: any
3
+ export default value
4
4
  }