@faststore/core 2.2.70 → 2.2.71

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 (139) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +62 -52
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/config.json +3 -3
  5. package/.next/cache/eslint/.cache_1gneedd +1 -1
  6. package/.next/cache/next-server.js.nft.json +1 -1
  7. package/.next/cache/webpack/client-production/0.pack +0 -0
  8. package/.next/cache/webpack/client-production/index.pack +0 -0
  9. package/.next/cache/webpack/server-production/0.pack +0 -0
  10. package/.next/cache/webpack/server-production/index.pack +0 -0
  11. package/.next/next-server.js.nft.json +1 -1
  12. package/.next/prerender-manifest.json +1 -1
  13. package/.next/react-loadable-manifest.json +4 -4
  14. package/.next/routes-manifest.json +1 -1
  15. package/.next/server/chunks/117.js +427 -0
  16. package/.next/server/chunks/184.js +61 -0
  17. package/.next/server/chunks/350.js +2846 -35
  18. package/.next/server/chunks/585.js +22 -0
  19. package/.next/server/chunks/632.js +514 -0
  20. package/.next/server/chunks/661.js +1451 -0
  21. package/.next/server/chunks/693.js +58 -0
  22. package/.next/server/chunks/719.js +84 -0
  23. package/.next/server/chunks/74.js +569 -6467
  24. package/.next/server/chunks/779.js +58 -0
  25. package/.next/server/chunks/854.js +72 -0
  26. package/.next/server/chunks/863.js +22 -0
  27. package/.next/server/chunks/{520.js → 898.js} +250 -30
  28. package/.next/server/chunks/903.js +1926 -0
  29. package/.next/server/middleware-build-manifest.js +1 -1
  30. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  31. package/.next/server/pages/404.js +0 -21
  32. package/.next/server/pages/404.js.nft.json +1 -1
  33. package/.next/server/pages/500.js +0 -21
  34. package/.next/server/pages/500.js.nft.json +1 -1
  35. package/.next/server/pages/[...slug].js +9 -9
  36. package/.next/server/pages/[...slug].js.nft.json +1 -1
  37. package/.next/server/pages/[slug]/p.js +1373 -33
  38. package/.next/server/pages/[slug]/p.js.nft.json +1 -1
  39. package/.next/server/pages/_app.js.nft.json +1 -1
  40. package/.next/server/pages/_error.js.nft.json +1 -1
  41. package/.next/server/pages/account.js +0 -21
  42. package/.next/server/pages/account.js.nft.json +1 -1
  43. package/.next/server/pages/api/graphql.js.nft.json +1 -1
  44. package/.next/server/pages/checkout.js +0 -21
  45. package/.next/server/pages/checkout.js.nft.json +1 -1
  46. package/.next/server/pages/en-US/404.html +2 -2
  47. package/.next/server/pages/en-US/500.html +2 -2
  48. package/.next/server/pages/en-US/account.html +2 -2
  49. package/.next/server/pages/en-US/checkout.html +2 -2
  50. package/.next/server/pages/en-US/login.html +2 -2
  51. package/.next/server/pages/en-US/s.html +2 -2
  52. package/.next/server/pages/en-US.html +2 -2
  53. package/.next/server/pages/index.js +5 -5
  54. package/.next/server/pages/index.js.nft.json +1 -1
  55. package/.next/server/pages/login.js +0 -21
  56. package/.next/server/pages/login.js.nft.json +1 -1
  57. package/.next/server/pages/s.js +4 -58
  58. package/.next/server/pages/s.js.nft.json +1 -1
  59. package/.next/static/IDskqcKTB7kE5quFZAhgJ/_buildManifest.js +1 -0
  60. package/.next/static/chunks/223-cb77217cce52d45c.js +1 -0
  61. package/.next/static/chunks/251.11f5198fc8bef3a4.js +1 -0
  62. package/.next/static/chunks/397-0d3aada1012cd78b.js +1 -0
  63. package/.next/static/chunks/585.6561778b7763b79e.js +1 -0
  64. package/.next/static/chunks/675-479a97aecebead97.js +1 -0
  65. package/.next/static/chunks/800.5d92de2974baf641.js +1 -0
  66. package/.next/static/chunks/881-57643fb90f59e576.js +1 -0
  67. package/.next/static/chunks/988.afda042dd9ba11d1.js +1 -0
  68. package/.next/static/chunks/pages/404-e106cb9a78182f5f.js +1 -0
  69. package/.next/static/chunks/pages/500-d28aa4a8ce88bddd.js +1 -0
  70. package/.next/static/chunks/pages/[...slug]-cf872b9e9befd47c.js +1 -0
  71. package/.next/static/chunks/pages/[slug]/p-4a75b11857b82b5c.js +1 -0
  72. package/.next/static/chunks/pages/{account-3741291b1e89c2e7.js → account-bf9c88a9cac80d8a.js} +1 -1
  73. package/.next/static/chunks/pages/{checkout-95066de007bdbbdb.js → checkout-6ca76c1e88a28ac4.js} +1 -1
  74. package/.next/static/chunks/pages/index-629ba146ae5f0ecf.js +1 -0
  75. package/.next/static/chunks/pages/login-d2af0de13ea75848.js +1 -0
  76. package/.next/static/chunks/pages/s-d729254b91430d1c.js +1 -0
  77. package/.next/static/chunks/webpack-54ce04ec11860b0b.js +1 -0
  78. package/.next/static/css/021de9c7b050d301.css +1 -0
  79. package/.next/static/css/510895065f32ed2f.css +1 -0
  80. package/.next/static/css/7e897ebb936fac09.css +1 -0
  81. package/.next/static/css/938781cdc945862e.css +1 -0
  82. package/.next/static/css/9558da13053ac066.css +1 -0
  83. package/.next/static/css/def381bf7c69fa2e.css +1 -0
  84. package/.next/trace +82 -82
  85. package/.turbo/turbo-build.log +19 -19
  86. package/.turbo/turbo-test.log +11 -11
  87. package/index.ts +13 -0
  88. package/package.json +2 -2
  89. package/src/components/sections/Alert/Alert.tsx +11 -3
  90. package/src/components/sections/Alert/OverriddenDefaultAlert.ts +7 -4
  91. package/src/components/sections/BannerText/BannerText.tsx +10 -2
  92. package/src/components/sections/BannerText/OverriddenDefaultBannerText.ts +7 -4
  93. package/src/components/sections/Breadcrumb/Breadcrumb.tsx +9 -3
  94. package/src/components/sections/Breadcrumb/OverriddenDefaultBreadcrumb.ts +7 -4
  95. package/src/components/sections/CrossSellingShelf/CrossSellingShelf.tsx +8 -2
  96. package/src/components/sections/CrossSellingShelf/OverriddenDefaultCrossSellingShelf.ts +2 -1
  97. package/src/components/sections/EmptyState/Overrides.tsx +2 -2
  98. package/src/components/sections/Hero/Hero.tsx +11 -3
  99. package/src/components/sections/Hero/OverriddenDefaultHero.ts +7 -4
  100. package/src/components/sections/Navbar/Navbar.tsx +10 -2
  101. package/src/components/sections/Navbar/OverriddenDefaultNavbar.ts +6 -4
  102. package/src/components/sections/Newsletter/Newsletter.tsx +10 -2
  103. package/src/components/sections/Newsletter/OverriddenDefaultNewsletter.ts +6 -4
  104. package/src/components/sections/ProductDetails/OverriddenDefaultProductDetails.ts +7 -4
  105. package/src/components/sections/ProductDetails/ProductDetails.tsx +16 -8
  106. package/src/components/sections/ProductGallery/OverriddenDefaultProductGallery.ts +6 -4
  107. package/src/components/sections/ProductGallery/ProductGallery.tsx +13 -5
  108. package/src/components/sections/ProductShelf/OverriddenDefaultProductShelf.ts +7 -4
  109. package/src/components/sections/ProductShelf/ProductShelf.tsx +12 -2
  110. package/src/components/sections/RegionBar/OverriddenDefaultRegionBar.ts +6 -4
  111. package/src/components/sections/RegionBar/RegionBar.tsx +11 -5
  112. package/src/sdk/overrides/getOverriddenSection.tsx +45 -44
  113. package/src/sdk/overrides/overrides.ts +2 -2
  114. package/src/typings/overrides.ts +265 -187
  115. package/src/typings/overridesDefinition.ts +20 -6
  116. package/.next/server/chunks/445.js +0 -167
  117. package/.next/server/chunks/829.js +0 -2938
  118. package/.next/server/chunks/934.js +0 -125
  119. package/.next/static/9t0jxL0Q7hZ_ItlxJLOtn/_buildManifest.js +0 -1
  120. package/.next/static/chunks/251.65e0bb7a2f58b3db.js +0 -1
  121. package/.next/static/chunks/464-bc1301cb64b71518.js +0 -1
  122. package/.next/static/chunks/557-4f8a963d7e07e582.js +0 -1
  123. package/.next/static/chunks/585.ee7478bead8853ae.js +0 -1
  124. package/.next/static/chunks/800.8f4f91b39aa47346.js +0 -1
  125. package/.next/static/chunks/988.a57dac6501fb5184.js +0 -1
  126. package/.next/static/chunks/pages/404-8aa1a5d5e6a66a9a.js +0 -1
  127. package/.next/static/chunks/pages/500-36ea8ba52ee65fe2.js +0 -1
  128. package/.next/static/chunks/pages/[...slug]-29c2c581a7246de4.js +0 -1
  129. package/.next/static/chunks/pages/[slug]/p-d4a3fd33abda8f62.js +0 -1
  130. package/.next/static/chunks/pages/index-bbd90798e45dc0ff.js +0 -1
  131. package/.next/static/chunks/pages/login-f0d8dfab2f856c25.js +0 -1
  132. package/.next/static/chunks/pages/s-e9b663c3e4f84b0a.js +0 -1
  133. package/.next/static/chunks/webpack-776cfd646b505dc5.js +0 -1
  134. package/.next/static/css/0c844be3b8585e70.css +0 -1
  135. package/.next/static/css/557d58510041152c.css +0 -1
  136. package/.next/static/css/a6bcc59f42b42f36.css +0 -1
  137. package/.next/static/css/ecdecb8d639a8311.css +0 -1
  138. package/src/sdk/overrides/sections.tsx +0 -58
  139. /package/.next/static/{9t0jxL0Q7hZ_ItlxJLOtn → IDskqcKTB7kE5quFZAhgJ}/_ssgManifest.js +0 -0
@@ -1,2938 +0,0 @@
1
- "use strict";
2
- exports.id = 829;
3
- exports.ids = [829];
4
- exports.modules = {
5
-
6
- /***/ 8608:
7
- /***/ ((module, __webpack_exports__, __webpack_require__) => {
8
-
9
- __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
10
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11
- /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
12
- /* harmony export */ });
13
- /* unused harmony export stringify */
14
- /* harmony import */ var _graphql_tools_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8722);
15
- var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_graphql_tools_utils__WEBPACK_IMPORTED_MODULE_0__]);
16
- _graphql_tools_utils__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
17
-
18
- const NAME = "cacheControl";
19
- const stringify = ({ scope = "private", sMaxAge = 0, staleWhileRevalidate = 0 }) => `${scope}, s-maxage=${sMaxAge}, stale-while-revalidate=${staleWhileRevalidate}`;
20
- const min = (a, b) => {
21
- if (typeof a === "number" && typeof b === "number") {
22
- return a > b ? b : a;
23
- }
24
- if (typeof a === "number") {
25
- return a;
26
- }
27
- return b;
28
- };
29
- const minScope = (a, b) => {
30
- if (typeof a === "string" && typeof b === "string") {
31
- return a === "public" && b === "public" ? "public" : "private";
32
- }
33
- return a || b;
34
- };
35
- const directive = {
36
- typeDefs: `directive @cacheControl(sMaxAge: Int, staleWhileRevalidate: Int, scope: String) on FIELD_DEFINITION`,
37
- transformer: (schema) => (0,_graphql_tools_utils__WEBPACK_IMPORTED_MODULE_0__.mapSchema)(schema, {
38
- [_graphql_tools_utils__WEBPACK_IMPORTED_MODULE_0__.MapperKind.OBJECT_FIELD]: (fieldConfig) => {
39
- const cacheControl = (0,_graphql_tools_utils__WEBPACK_IMPORTED_MODULE_0__.getDirective)(schema, fieldConfig, NAME)?.[0];
40
- if (cacheControl) {
41
- const { sMaxAge, staleWhileRevalidate, scope } = cacheControl;
42
- const resolver = fieldConfig.resolve;
43
- fieldConfig.resolve = (obj, args, ctx, info) => {
44
- ctx.cacheControl = {
45
- sMaxAge: min(ctx.cacheControl?.sMaxAge, sMaxAge),
46
- staleWhileRevalidate: min(ctx.cacheControl?.staleWhileRevalidate, staleWhileRevalidate),
47
- scope: minScope(ctx.cacheControl?.scope, scope),
48
- };
49
- return resolver?.(obj, args, ctx, info);
50
- };
51
- }
52
- return fieldConfig;
53
- },
54
- }),
55
- };
56
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (directive);
57
- //# sourceMappingURL=cacheControl.js.map
58
- __webpack_async_result__();
59
- } catch(e) { __webpack_async_result__(e); } });
60
-
61
- /***/ }),
62
-
63
- /***/ 7397:
64
- /***/ ((module, __webpack_exports__, __webpack_require__) => {
65
-
66
- __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
67
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
68
- /* harmony export */ "E9": () => (/* binding */ getContextFactory),
69
- /* harmony export */ "T9": () => (/* reexport safe */ _platforms_errors__WEBPACK_IMPORTED_MODULE_3__.T9),
70
- /* harmony export */ "XD": () => (/* reexport safe */ _platforms_errors__WEBPACK_IMPORTED_MODULE_3__.XD),
71
- /* harmony export */ "yd": () => (/* binding */ getResolvers)
72
- /* harmony export */ });
73
- /* unused harmony exports getTypeDefs, getSchema */
74
- /* harmony import */ var _platforms_vtex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7805);
75
- /* harmony import */ var _typeDefs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3999);
76
- /* harmony import */ var _directives_cacheControl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8608);
77
- /* harmony import */ var _platforms_errors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(782);
78
- /* harmony import */ var _telemetry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(941);
79
- var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_typeDefs__WEBPACK_IMPORTED_MODULE_1__, _directives_cacheControl__WEBPACK_IMPORTED_MODULE_2__]);
80
- ([_typeDefs__WEBPACK_IMPORTED_MODULE_1__, _directives_cacheControl__WEBPACK_IMPORTED_MODULE_2__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
- const platforms = {
90
- vtex: {
91
- getResolvers: _platforms_vtex__WEBPACK_IMPORTED_MODULE_0__/* .getResolvers */ .y,
92
- getContextFactory: _platforms_vtex__WEBPACK_IMPORTED_MODULE_0__/* .getContextFactory */ .E,
93
- },
94
- };
95
- const directives = [
96
- _directives_cacheControl__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z
97
- ];
98
- const getTypeDefs = () => [typeDefs, ...directives.map(d => d.typeDefs)];
99
- const getResolvers = (options) => platforms[options.platform].getResolvers(options);
100
- const getContextFactory = (options) => platforms[options.platform].getContextFactory(options);
101
- const getSchema = async (options) => {
102
- const schema = makeExecutableSchema({
103
- resolvers: getResolvers(options),
104
- typeDefs: getTypeDefs(),
105
- });
106
- return directives.reduce((s, d) => d.transformer(s), schema);
107
- };
108
-
109
- //# sourceMappingURL=index.js.map
110
- __webpack_async_result__();
111
- } catch(e) { __webpack_async_result__(e); } });
112
-
113
- /***/ }),
114
-
115
- /***/ 782:
116
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
117
-
118
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
119
- /* harmony export */ "T9": () => (/* binding */ isFastStoreError),
120
- /* harmony export */ "XD": () => (/* binding */ isNotFoundError),
121
- /* harmony export */ "dR": () => (/* binding */ NotFoundError),
122
- /* harmony export */ "oY": () => (/* binding */ BadRequestError)
123
- /* harmony export */ });
124
- /* unused harmony export isBadRequestError */
125
- class FastStoreError extends Error {
126
- extensions;
127
- constructor(extensions, message) {
128
- super(message);
129
- this.extensions = extensions;
130
- this.name = 'FastStoreError';
131
- }
132
- }
133
- class BadRequestError extends FastStoreError {
134
- constructor(message) {
135
- super({ status: 400, type: 'BadRequestError' }, message);
136
- }
137
- }
138
- class NotFoundError extends FastStoreError {
139
- constructor(message) {
140
- super({ status: 404, type: 'NotFoundError' }, message);
141
- }
142
- }
143
- const isFastStoreError = (error) => error?.name === 'FastStoreError';
144
- const isNotFoundError = (error) => error?.extensions?.type === 'NotFoundError';
145
- const isBadRequestError = (error) => error?.extensions?.type === 'BadRequestError';
146
- //# sourceMappingURL=errors.js.map
147
-
148
- /***/ }),
149
-
150
- /***/ 7805:
151
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
152
-
153
-
154
- // EXPORTS
155
- __webpack_require__.d(__webpack_exports__, {
156
- "E": () => (/* binding */ getContextFactory),
157
- "y": () => (/* binding */ getResolvers)
158
- });
159
-
160
- // EXTERNAL MODULE: external "isomorphic-unfetch"
161
- var external_isomorphic_unfetch_ = __webpack_require__(7881);
162
- var external_isomorphic_unfetch_default = /*#__PURE__*/__webpack_require__.n(external_isomorphic_unfetch_);
163
- // EXTERNAL MODULE: ../api/dist/esm/package.json
164
- var esm_package = __webpack_require__(2828);
165
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/clients/fetch.js
166
-
167
-
168
- const USER_AGENT = `${esm_package/* name */.u2}@${esm_package/* version */.i8}`;
169
- const fetchAPI = async (info, init, options) => {
170
- const response = await external_isomorphic_unfetch_default()(info, {
171
- ...init,
172
- headers: {
173
- ...(init?.headers ?? {}),
174
- 'User-Agent': USER_AGENT,
175
- },
176
- });
177
- if (response.ok) {
178
- if (options?.storeCookies) {
179
- options.storeCookies(response.headers);
180
- }
181
- return response.status !== 204 ? response.json() : undefined;
182
- }
183
- console.error(info, init, response);
184
- const text = await response.text();
185
- throw new Error(text);
186
- };
187
- //# sourceMappingURL=fetch.js.map
188
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/cookies.js
189
- const MATCH_FIRST_SET_COOKIE_KEY_VALUE = /^([^=]+)=([^;]*)/;
190
- /**
191
- * This function updates the ctx.storage.cookies, that is used in each request.
192
- *
193
- * ctx.storage.cookies is a Map<string[1], Record<string, string>[2]> where,
194
- * [1] cookie key
195
- * [2] {
196
- * value: cookie value,
197
- * setCookie: setCookie used in browser response
198
- * }
199
- */
200
- const updatesContextStorageCookies = (ctx, setCookieValue) => {
201
- const matchCookie = setCookieValue.match(MATCH_FIRST_SET_COOKIE_KEY_VALUE);
202
- if (matchCookie) {
203
- const cookieKey = matchCookie[1];
204
- const cookieValue = matchCookie[2];
205
- ctx.storage.cookies.set(cookieKey, {
206
- value: cookieValue,
207
- setCookie: setCookieValue,
208
- });
209
- }
210
- };
211
- const setCookie = (ctx, headers) => {
212
- headers
213
- .getSetCookie()
214
- .forEach((setCookieValue) => updatesContextStorageCookies(ctx, setCookieValue));
215
- };
216
- const getStoreCookie = (ctx) => (headers) => setCookie(ctx, headers);
217
- /**
218
- * This function returns a modified copy of the original cookie header (ctx.headers.cookie from the first request)
219
- * with the cookie values that comes in each request (ctx.storage.cookies).
220
- * If there is no cookies in storage, the ctx.headers?.cookie is used
221
- *
222
- * ctx.storage.cookies is a Map<string[1], Record<string, string>[2]> where,
223
- * [1] cookie key
224
- * [2] {
225
- * value: cookie value,
226
- * setCookie: setCookie used in browser response
227
- * }
228
- */
229
- const getUpdatedCookie = (ctx) => {
230
- if (!ctx.headers?.cookie) {
231
- return null;
232
- }
233
- const contextStorageCookies = Array.from(ctx.storage.cookies.entries());
234
- if (contextStorageCookies.length === 0) {
235
- return ctx.headers.cookie;
236
- }
237
- return contextStorageCookies.reduce((existingCookies, [storageCookieKey, { value: storageCookieValue }]) => updatesCookieValueByKey(existingCookies, storageCookieKey, storageCookieValue), ctx.headers.cookie);
238
- };
239
- const getWithCookie = (ctx) => function withCookie(headers) {
240
- const updatedCookie = getUpdatedCookie(ctx);
241
- if (!updatedCookie) {
242
- return headers;
243
- }
244
- return {
245
- ...headers,
246
- cookie: updatedCookie,
247
- };
248
- };
249
- /**
250
- * This function updates the cookie value based on its key
251
- *
252
- * const existingCookies = 'key=value1; key2=; key3=value3';
253
- * const storageCookieKey = 'key2';
254
- * const storageCookieValue = 'value2'
255
- *
256
- * updatesCookieValueByKey(existingCookies, storageCookieKey, storageCookieValue) returns 'key=value1; key2=value2; key3=value3';
257
- */
258
- const updatesCookieValueByKey = (existingCookies, storageCookieKey, storageCookieValue) => {
259
- const MATCH_COOKIE_KEY_VALUE = new RegExp(`(${storageCookieKey})=([^;]*)`);
260
- const cookieParts = existingCookies.match(MATCH_COOKIE_KEY_VALUE);
261
- // replaces original cookie with the one coming from storage
262
- if (cookieParts) {
263
- return existingCookies.replace(cookieParts[0], `${cookieParts[1]}=${storageCookieValue}`);
264
- }
265
- // add new storage cookie to the original list of cookies
266
- return `${existingCookies};${storageCookieKey}=${storageCookieValue}`;
267
- };
268
- //# sourceMappingURL=cookies.js.map
269
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/clients/commerce/index.js
270
-
271
-
272
- const BASE_INIT = {
273
- method: 'POST',
274
- headers: {
275
- 'content-type': 'application/json',
276
- },
277
- };
278
- const VtexCommerce = ({ account, environment, incrementAddress }, ctx) => {
279
- const base = `https://${account}.${environment}.com.br`;
280
- const storeCookies = getStoreCookie(ctx);
281
- const withCookie = getWithCookie(ctx);
282
- // replacing www. only for testing while www.vtexfaststore.com is configured with www
283
- const forwardedHost = (new Headers(ctx.headers).get('x-forwarded-host') ??
284
- ctx.headers?.host ??
285
- '').replace('www.', '');
286
- return {
287
- catalog: {
288
- salesChannel: (sc) => fetchAPI(`${base}/api/catalog_system/pub/saleschannel/${sc}`, undefined, { storeCookies }),
289
- brand: {
290
- list: () => fetchAPI(`${base}/api/catalog_system/pub/brand/list`, undefined, {
291
- storeCookies,
292
- }),
293
- },
294
- category: {
295
- tree: (depth = 3) => fetchAPI(`${base}/api/catalog_system/pub/category/tree/${depth}`, undefined, { storeCookies }),
296
- },
297
- portal: {
298
- pagetype: (slug) => fetchAPI(`${base}/api/catalog_system/pub/portal/pagetype/${slug}`, undefined, { storeCookies }),
299
- },
300
- products: {
301
- crossselling: ({ type, productId, groupByProduct = true, }) => {
302
- const params = new URLSearchParams({
303
- sc: ctx.storage.channel.salesChannel,
304
- groupByProduct: groupByProduct.toString(),
305
- });
306
- return fetchAPI(`${base}/api/catalog_system/pub/products/crossselling/${type}/${productId}?${params}`, undefined, { storeCookies });
307
- },
308
- },
309
- },
310
- checkout: {
311
- simulation: (args, { salesChannel } = ctx.storage.channel) => {
312
- const params = new URLSearchParams({
313
- sc: salesChannel,
314
- });
315
- const headers = withCookie({
316
- 'content-type': 'application/json',
317
- 'X-FORWARDED-HOST': forwardedHost,
318
- });
319
- return fetchAPI(`${base}/api/checkout/pub/orderForms/simulation?${params.toString()}`, {
320
- ...BASE_INIT,
321
- headers,
322
- body: JSON.stringify(args),
323
- }, { storeCookies });
324
- },
325
- shippingData: ({ id, index, deliveryMode, selectedAddresses, }, setDeliveryWindow) => {
326
- const deliveryWindow = setDeliveryWindow
327
- ? {
328
- startDateUtc: deliveryMode?.deliveryWindow?.startDate,
329
- endDateUtc: deliveryMode?.deliveryWindow?.endDate,
330
- }
331
- : null;
332
- const mappedBody = {
333
- logisticsInfo: Array.from({ length: index }, (_, itemIndex) => ({
334
- itemIndex,
335
- selectedDeliveryChannel: deliveryMode?.deliveryChannel || null,
336
- selectedSla: deliveryMode?.deliveryMethod || null,
337
- deliveryWindow: deliveryWindow,
338
- })),
339
- selectedAddresses: selectedAddresses,
340
- clearAddressIfPostalCodeNotFound: incrementAddress,
341
- };
342
- const headers = withCookie({
343
- 'content-type': 'application/json',
344
- 'X-FORWARDED-HOST': forwardedHost,
345
- });
346
- return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}/attachments/shippingData`, {
347
- ...BASE_INIT,
348
- headers,
349
- body: JSON.stringify(mappedBody),
350
- }, { storeCookies });
351
- },
352
- orderForm: ({ id, refreshOutdatedData = true, channel = ctx.storage.channel, }) => {
353
- const { salesChannel } = channel;
354
- const params = new URLSearchParams({
355
- refreshOutdatedData: refreshOutdatedData.toString(),
356
- sc: salesChannel,
357
- });
358
- const headers = withCookie({
359
- 'content-type': 'application/json',
360
- 'X-FORWARDED-HOST': forwardedHost,
361
- });
362
- return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`, {
363
- ...BASE_INIT,
364
- headers,
365
- }, { storeCookies });
366
- },
367
- clearOrderFormMessages: ({ id }) => {
368
- const headers = withCookie({
369
- 'content-type': 'application/json',
370
- 'X-FORWARDED-HOST': forwardedHost,
371
- });
372
- return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}/messages/clear`, {
373
- ...BASE_INIT,
374
- headers,
375
- body: '{}',
376
- });
377
- },
378
- updateOrderFormItems: ({ id, orderItems, allowOutdatedData = 'paymentData', salesChannel = ctx.storage.channel.salesChannel, shouldSplitItem = true, }) => {
379
- const params = new URLSearchParams({
380
- allowOutdatedData,
381
- sc: salesChannel,
382
- });
383
- const headers = withCookie({
384
- 'content-type': 'application/json',
385
- 'X-FORWARDED-HOST': forwardedHost,
386
- });
387
- return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}/items?${params}`, {
388
- headers,
389
- body: JSON.stringify({
390
- orderItems,
391
- noSplitItem: !shouldSplitItem,
392
- }),
393
- method: 'PATCH',
394
- }, { storeCookies });
395
- },
396
- setCustomData: ({ id, appId, key, value, }) => {
397
- const headers = withCookie({
398
- 'content-type': 'application/json',
399
- 'X-FORWARDED-HOST': forwardedHost,
400
- });
401
- return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}/customData/${appId}/${key}`, {
402
- headers,
403
- body: JSON.stringify({ value }),
404
- method: 'PUT',
405
- });
406
- },
407
- region: async ({ postalCode, geoCoordinates, country, salesChannel, }) => {
408
- const params = new URLSearchParams({
409
- country: country,
410
- sc: salesChannel ?? '',
411
- });
412
- postalCode
413
- ? params.append('postalCode', postalCode)
414
- : params.append('geoCoordinates', `${geoCoordinates?.longitude};${geoCoordinates?.latitude}`);
415
- const url = `${base}/api/checkout/pub/regions/?${params.toString()}`;
416
- const headers = withCookie({
417
- 'content-type': 'application/json',
418
- 'X-FORWARDED-HOST': forwardedHost,
419
- });
420
- return fetchAPI(url, {
421
- headers,
422
- }, { storeCookies });
423
- },
424
- address: async ({ postalCode, country, }) => {
425
- const headers = withCookie({
426
- 'content-type': 'application/json',
427
- 'X-FORWARDED-HOST': forwardedHost,
428
- });
429
- return fetchAPI(`${base}/api/checkout/pub/postal-code/${country}/${postalCode}`, {
430
- headers,
431
- }, { storeCookies });
432
- },
433
- },
434
- session: (search) => {
435
- const params = new URLSearchParams(search);
436
- params.set('items', 'profile.id,profile.email,profile.firstName,profile.lastName,store.channel,store.countryCode,store.cultureInfo,store.currencyCode,store.currencySymbol');
437
- const headers = withCookie({
438
- 'content-type': 'application/json',
439
- });
440
- return fetchAPI(`${base}/api/sessions?${params.toString()}`, {
441
- method: 'POST',
442
- headers,
443
- body: '{}',
444
- }, { storeCookies });
445
- },
446
- subscribeToNewsletter: (data) => {
447
- return fetchAPI(`${base}/api/dataentities/NL/documents/`, {
448
- ...BASE_INIT,
449
- body: JSON.stringify({ ...data, isNewsletterOptIn: true }),
450
- method: 'PATCH',
451
- }, { storeCookies });
452
- },
453
- };
454
- };
455
- //# sourceMappingURL=index.js.map
456
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/clients/search/index.js
457
-
458
-
459
- const POLICY_KEY = 'trade-policy';
460
- const REGION_KEY = 'region-id';
461
- const CHANNEL_KEYS = new Set([POLICY_KEY, REGION_KEY]);
462
- const isFacetBoolean = (facet) => facet.type === 'TEXT';
463
- const IntelligentSearch = ({ account, environment, hideUnavailableItems }, ctx) => {
464
- const base = `https://${account}.${environment}.com.br/api/io`;
465
- const storeCookies = getStoreCookie(ctx);
466
- const getPolicyFacet = () => {
467
- const { salesChannel } = ctx.storage.channel;
468
- if (!salesChannel) {
469
- return null;
470
- }
471
- return {
472
- key: POLICY_KEY,
473
- value: salesChannel,
474
- };
475
- };
476
- const getRegionFacet = () => {
477
- const { regionId, seller } = ctx.storage.channel;
478
- const sellerRegionId = seller
479
- ? Buffer.from(`SW#${seller}`).toString('base64')
480
- : null;
481
- const facet = sellerRegionId ?? regionId;
482
- if (!facet) {
483
- return null;
484
- }
485
- return {
486
- key: REGION_KEY,
487
- value: facet,
488
- };
489
- };
490
- const addDefaultFacets = (facets) => {
491
- const withDefaultFacets = facets.filter(({ key }) => !CHANNEL_KEYS.has(key));
492
- const policyFacet = facets.find(({ key }) => key === POLICY_KEY) ?? getPolicyFacet();
493
- const regionFacet = facets.find(({ key }) => key === REGION_KEY) ?? getRegionFacet();
494
- if (policyFacet !== null) {
495
- withDefaultFacets.push(policyFacet);
496
- }
497
- if (regionFacet !== null) {
498
- withDefaultFacets.push(regionFacet);
499
- }
500
- return withDefaultFacets;
501
- };
502
- const search = ({ query = '', page, count, sort = '', selectedFacets = [], type, fuzzy = 'auto', }) => {
503
- const params = new URLSearchParams({
504
- page: (page + 1).toString(),
505
- count: count.toString(),
506
- query,
507
- sort,
508
- fuzzy,
509
- locale: ctx.storage.locale,
510
- });
511
- if (hideUnavailableItems !== undefined) {
512
- params.append('hideUnavailableItems', hideUnavailableItems.toString());
513
- }
514
- const pathname = addDefaultFacets(selectedFacets)
515
- .map(({ key, value }) => `${key}/${value}`)
516
- .join('/');
517
- return fetchAPI(`${base}/_v/api/intelligent-search/${type}/${pathname}?${params.toString()}`, undefined, { storeCookies });
518
- };
519
- const products = (args) => search({ ...args, type: 'product_search' });
520
- const suggestedTerms = (args) => {
521
- const params = new URLSearchParams({
522
- query: args.query?.toString() ?? '',
523
- locale: ctx.storage.locale,
524
- });
525
- return fetchAPI(`${base}/_v/api/intelligent-search/search_suggestions?${params.toString()}`, undefined, { storeCookies });
526
- };
527
- const topSearches = () => {
528
- const params = new URLSearchParams({
529
- locale: ctx.storage.locale,
530
- });
531
- return fetchAPI(`${base}/_v/api/intelligent-search/top_searches?${params.toString()}`, undefined, { storeCookies });
532
- };
533
- const facets = (args) => search({ ...args, type: 'facets' });
534
- return {
535
- facets,
536
- products,
537
- suggestedTerms,
538
- topSearches,
539
- };
540
- };
541
- //# sourceMappingURL=index.js.map
542
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/clients/index.js
543
-
544
-
545
- const getClients = (options, ctx) => {
546
- const search = IntelligentSearch(options, ctx);
547
- const commerce = VtexCommerce(options, ctx);
548
- return {
549
- search,
550
- commerce,
551
- };
552
- };
553
- //# sourceMappingURL=index.js.map
554
- // EXTERNAL MODULE: ../api/node_modules/dataloader/index.js
555
- var dataloader = __webpack_require__(3404);
556
- var dataloader_default = /*#__PURE__*/__webpack_require__.n(dataloader);
557
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/loaders/salesChannel.js
558
-
559
- const getSalesChannelLoader = (_, clients) => {
560
- const loader = async (channels) => Promise.all(channels.map((sc) => clients.commerce.catalog.salesChannel(sc)));
561
- return new (dataloader_default())(loader);
562
- };
563
- //# sourceMappingURL=salesChannel.js.map
564
- // EXTERNAL MODULE: external "p-limit"
565
- var external_p_limit_ = __webpack_require__(5471);
566
- var external_p_limit_default = /*#__PURE__*/__webpack_require__.n(external_p_limit_);
567
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/loaders/simulation.js
568
-
569
-
570
- // Limits concurrent requests to the API per request cycle
571
- const CONCURRENT_REQUESTS_MAX = 1;
572
- const getSimulationLoader = (_, clients) => {
573
- const limit = external_p_limit_default()(CONCURRENT_REQUESTS_MAX);
574
- const loader = async (simulationArgs) => {
575
- const allItems = simulationArgs.reduce((acc, { items }) => {
576
- return [...acc, items];
577
- }, []);
578
- const items = [...allItems.flat()];
579
- const simulation = await clients.commerce.checkout.simulation({
580
- country: simulationArgs[0].country,
581
- postalCode: simulationArgs[0].postalCode,
582
- items,
583
- });
584
- // Sort and filter simulation since Checkout API may return
585
- // items that we didn't ask for
586
- const simulated = simulation.items.reduce((acc, item) => {
587
- const index = item.requestIndex;
588
- if (typeof index === 'number' && index < acc.length) {
589
- acc[index] = item;
590
- }
591
- return acc;
592
- }, Array(items.length).fill(null));
593
- const itemsIndices = allItems.reduce((acc, curr) => [...acc, curr.length + acc[acc.length - 1]], [0]);
594
- return allItems.map((__, index) => ({
595
- ...simulation,
596
- items: simulated
597
- .slice(itemsIndices[index], itemsIndices[index + 1])
598
- .filter((item) => Boolean(item)),
599
- }));
600
- };
601
- const limited = async (allItems) => limit(loader, allItems);
602
- return new (dataloader_default())(limited, {
603
- maxBatchSize: 50,
604
- });
605
- };
606
- //# sourceMappingURL=simulation.js.map
607
- // EXTERNAL MODULE: external "sanitize-html"
608
- var external_sanitize_html_ = __webpack_require__(6109);
609
- var external_sanitize_html_default = /*#__PURE__*/__webpack_require__.n(external_sanitize_html_);
610
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/sanitizeHtml.js
611
-
612
- /**
613
- * For now, we're using sanitize-html's default set
614
- * of allowed tags and attributes, which don't even include img elements
615
- *
616
- * It is known many client depends on pontentially vulnerable tags, such as script tags
617
- * We chose to be restrictive at first, and document those restrictions later.
618
- *
619
- * When expanding the set of allowed tags and attributes, please consider performance, privacy and security.
620
- *
621
- * This possibily breaks compatibility with Portal and Store Framework,
622
- * which both allows an enormous amount of tags and attributes
623
- *
624
- * This was a thoughtful decision that can be reviewed in the future given
625
- * research was made to back up those changes.
626
- */
627
- const sanitizeHtml = (dirty, options) => external_sanitize_html_default()(dirty, options);
628
- //# sourceMappingURL=sanitizeHtml.js.map
629
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/enhanceSku.js
630
-
631
- function sanitizeProduct(product) {
632
- return {
633
- ...product,
634
- description: product.description
635
- ? sanitizeHtml(product.description)
636
- : product.description,
637
- };
638
- }
639
- const enhanceSku = (item, product) => ({
640
- ...item,
641
- isVariantOf: sanitizeProduct(product),
642
- });
643
- //# sourceMappingURL=enhanceSku.js.map
644
- // EXTERNAL MODULE: ../api/dist/esm/src/platforms/errors.js
645
- var errors = __webpack_require__(782);
646
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/loaders/sku.js
647
-
648
-
649
-
650
- const getSkuLoader = (_, clients) => {
651
- const loader = async (skuIds) => {
652
- const { products } = await clients.search.products({
653
- query: `sku:${skuIds.join(';')}`,
654
- page: 0,
655
- count: skuIds.length,
656
- });
657
- const skuBySkuId = products.reduce((acc, product) => {
658
- for (const sku of product.items) {
659
- acc[sku.itemId] = enhanceSku(sku, product);
660
- }
661
- return acc;
662
- }, {});
663
- const skus = skuIds.map((skuId) => skuBySkuId[skuId]);
664
- const missingSkus = skuIds.filter((skuId) => !skuBySkuId[skuId]);
665
- if (missingSkus.length > 0) {
666
- throw new errors/* NotFoundError */.dR(`Search API did not found the following skus: ${missingSkus.join(',')}`);
667
- }
668
- return skus;
669
- };
670
- return new (dataloader_default())(loader, {
671
- maxBatchSize: 99, // Max allowed batch size of Search API
672
- });
673
- };
674
- //# sourceMappingURL=sku.js.map
675
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/loaders/collection.js
676
-
677
-
678
-
679
- // Limits concurrent requests to 20 so that they don't timeout
680
- const collection_CONCURRENT_REQUESTS_MAX = 20;
681
- const collectionPageTypes = new Set([
682
- 'brand',
683
- 'category',
684
- 'department',
685
- 'subcategory',
686
- 'collection',
687
- 'cluster',
688
- ]);
689
- const isCollectionPageType = (x) => typeof x.pageType === 'string' &&
690
- collectionPageTypes.has(x.pageType.toLowerCase());
691
- const getCollectionLoader = (_, clients) => {
692
- const limit = external_p_limit_default()(collection_CONCURRENT_REQUESTS_MAX);
693
- const loader = async (slugs) => {
694
- return Promise.all(slugs.map((slug) => limit(async () => {
695
- const page = await clients.commerce.catalog.portal.pagetype(slug);
696
- if (isCollectionPageType(page)) {
697
- return page;
698
- }
699
- throw new errors/* NotFoundError */.dR(`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.`);
700
- })));
701
- };
702
- return new (dataloader_default())(loader, {
703
- // DataLoader is being used to cache requests, not to batch them
704
- batch: false,
705
- });
706
- };
707
- //# sourceMappingURL=collection.js.map
708
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/loaders/index.js
709
-
710
-
711
-
712
-
713
- const getLoaders = (options, { clients }) => {
714
- const skuLoader = getSkuLoader(options, clients);
715
- const simulationLoader = getSimulationLoader(options, clients);
716
- const collectionLoader = getCollectionLoader(options, clients);
717
- const salesChannelLoader = getSalesChannelLoader(options, clients);
718
- return {
719
- skuLoader,
720
- simulationLoader,
721
- collectionLoader,
722
- salesChannelLoader
723
- };
724
- };
725
- //# sourceMappingURL=index.js.map
726
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/productStock.js
727
- const inStock = (offer) => offer.AvailableQuantity > 0;
728
- const price = (offer) => offer.spotPrice ?? 0;
729
- const sellingPrice = (offer) => offer.Price ?? 0;
730
- const availability = (available) => available ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock';
731
- // Smallest Available Spot Price First
732
- const bestOfferFirst = (a, b) => {
733
- if (inStock(a) && !inStock(b)) {
734
- return -1;
735
- }
736
- if (!inStock(a) && inStock(b)) {
737
- return 1;
738
- }
739
- return price(a) - price(b);
740
- };
741
- const inStockOrderFormItem = (itemAvailability) => itemAvailability === 'available';
742
- //# sourceMappingURL=productStock.js.map
743
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/aggregateOffer.js
744
-
745
- const StoreAggregateOffer = {
746
- highPrice: (offers) => {
747
- const availableOffers = offers.filter(inStock);
748
- const highOffer = availableOffers[availableOffers.length - 1];
749
- return highOffer != null ? price(highOffer) : 0;
750
- },
751
- lowPrice: (offers) => {
752
- const [lowOffer] = offers.filter(inStock);
753
- return lowOffer ? price(lowOffer) : 0;
754
- },
755
- offerCount: (offers) => offers.length,
756
- priceCurrency: async (_, __, ctx) => {
757
- const { loaders: { salesChannelLoader }, storage: { channel } } = ctx;
758
- const sc = await salesChannelLoader.load(channel.salesChannel);
759
- return sc.CurrencyCode ?? '';
760
- },
761
- offers: (offers) => offers,
762
- };
763
- //# sourceMappingURL=aggregateOffer.js.map
764
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/aggregateRating.js
765
- // TODO: Add a review system integration
766
- const StoreAggregateRating = {
767
- ratingValue: () => 5,
768
- reviewCount: () => 0,
769
- };
770
- //# sourceMappingURL=aggregateRating.js.map
771
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/slugify.js
772
- /**
773
- * VTEX catalog slugify function
774
- *
775
- * Copied from:
776
- * https://github.com/vtex/rewriter/blob/1ce2010783e0586cab42534ce2fb7a983d8a3a84/node/clients/catalog.ts#L72
777
- *
778
- * Sometimes, we need to slugify strings for creating urls. An example is the
779
- * brand urls, where we create them from the brand's name.
780
- * This slugify function should match exactly what VTEX catalog generates. Any mismatch
781
- * will lead to broken links.
782
- * Hopefully, we had this function implemented on VTEX IO and we've been using it for
783
- * years now. However, looking at the code, I think we can save lots of computing. I'm
784
- * in a hurry for doing these tests now, so I'll leave a small TODO.
785
- *
786
- * TODO: Research for better ways of computing this slugify function. Things I'd try are:
787
- * - Join those 3 regexs for special characters into a single one.
788
- * - Replace the regexp of `removeDiacritics` function with a Map. We can make the complexity
789
- * of this function be O(n) with n=string.length
790
- *
791
- */
792
- const from = 'ÁÄÂÀÃÅČÇĆĎÉĚËÈÊẼĔȆÍÌÎÏŇÑÓÖÒÔÕØŘŔŠŤÚŮÜÙÛÝŸŽáäâàãåčçćďéěëèêẽĕȇíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđ߯a';
793
- const to = 'AAAAAACCCDEEEEEEEEIIIINNOOOOOORRSTUUUUUYYZaaaaaacccdeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa';
794
- const removeDiacritics = (str) => {
795
- let newStr = str.slice(0);
796
- for (let i = 0; i < from.length; i++) {
797
- newStr = newStr.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
798
- }
799
- return newStr;
800
- };
801
- const slugifySpecialCharacters = (str) => {
802
- return str.replace(/[·/_,:]/, '-');
803
- };
804
- function slugify(str) {
805
- const noCommas = str.replace(/,/g, '');
806
- const replaced = noCommas.replace(/[*+~.()'"!:@&\[\]`/ %$#?{}|><=_^]/g, '-');
807
- const slugified = slugifySpecialCharacters(removeDiacritics(replaced));
808
- return slugified.toLowerCase();
809
- }
810
- //# sourceMappingURL=slugify.js.map
811
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/collection.js
812
-
813
-
814
- const isBrand = (x) => x.type === 'brand' ||
815
- (isCollectionPageType(x) && x.pageType.toLowerCase() === 'brand');
816
- const isCollection = (x) => isCollectionPageType(x) && x.pageType.toLowerCase() === 'collection';
817
- const slugifyRoot = (root) => {
818
- if (isBrand(root) || isCollection(root)) {
819
- return slugify(root.name);
820
- }
821
- if (isCollectionPageType(root)) {
822
- return new URL(`https://${root.url}`).pathname.slice(1).toLowerCase();
823
- }
824
- return new URL(root.url).pathname.slice(1).toLowerCase();
825
- };
826
- const StoreCollection = {
827
- id: ({ id }) => id.toString(),
828
- slug: (root) => slugifyRoot(root),
829
- seo: (root) => isBrand(root) || isCollectionPageType(root)
830
- ? {
831
- title: root.title,
832
- description: root.metaTagDescription,
833
- }
834
- : {
835
- title: root.Title,
836
- description: root.MetaTagDescription,
837
- },
838
- type: (root) => isBrand(root)
839
- ? 'Brand'
840
- : isCollectionPageType(root)
841
- ? root.pageType
842
- : root.level === 0
843
- ? 'Department'
844
- : 'Category',
845
- meta: (root) => {
846
- const slug = slugifyRoot(root);
847
- return isBrand(root)
848
- ? {
849
- selectedFacets: [{ key: 'brand', value: slug }],
850
- }
851
- : isCollection(root)
852
- ? {
853
- selectedFacets: [{ key: 'productclusterids', value: root.id }],
854
- }
855
- : {
856
- selectedFacets: slug.split('/').map((segment, index) => ({
857
- key: `category-${index + 1}`,
858
- value: segment,
859
- })),
860
- };
861
- },
862
- breadcrumbList: async (root, _, ctx) => {
863
- const { loaders: { collectionLoader }, } = ctx;
864
- const slug = slugifyRoot(root);
865
- /**
866
- * Split slug into segments so we fetch all data for
867
- * the breadcrumb. For instance, if we get `/foo/bar`
868
- * we need all metadata for both `/foo` and `/bar` and
869
- * thus we need to fetch pageType for `/foo` and `/bar`
870
- */
871
- const segments = slug.split('/').filter((segment) => Boolean(segment));
872
- const slugs = segments.map((__, index) => segments.slice(0, index + 1).join('/'));
873
- const collections = await Promise.all(slugs.map(async (s) => {
874
- const collection = await collectionLoader.load(s);
875
- return { slug: s, ...collection };
876
- }));
877
- return {
878
- itemListElement: collections.map((collection, index) => ({
879
- item: isCollection(collection)
880
- ? `/${collection.slug}`
881
- : new URL(`https://${collection.url}`).pathname.toLowerCase(),
882
- name: collection.name,
883
- position: index + 1,
884
- })),
885
- numberOfItems: collections.length,
886
- };
887
- },
888
- };
889
- //# sourceMappingURL=collection.js.map
890
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/facets.js
891
-
892
- const FACET_CROSS_SELLING_MAP = {
893
- buy: "whoboughtalsobought",
894
- view: "whosawalsosaw",
895
- similars: "similars",
896
- viewAndBought: "whosawalsobought",
897
- accessories: "accessories",
898
- suggestions: "suggestions",
899
- };
900
- /**
901
- * Transform facets from the store to VTEX platform facets.
902
- * For instance, the channel in Store becomes trade-policy and regionId in VTEX's realm
903
- * */
904
- const transformSelectedFacet = ({ key, value }) => {
905
- switch (key) {
906
- case 'price': {
907
- return { key, value: value.replace('-to-', ':') };
908
- }
909
- case 'channel':
910
- case 'locale':
911
- case "buy":
912
- case "view":
913
- case "similars":
914
- case "viewAndBought":
915
- case "accessories":
916
- case "suggestions": {
917
- return []; // remove this facet from search
918
- }
919
- default:
920
- return { key, value };
921
- }
922
- };
923
- const parseRange = (range) => {
924
- const splitted = range.split(':').map(Number);
925
- if (splitted.length !== 2 ||
926
- Number.isNaN(splitted[0]) ||
927
- Number.isNaN(splitted[1])) {
928
- return null;
929
- }
930
- return splitted;
931
- };
932
- const isCrossSelling = (x) => typeof FACET_CROSS_SELLING_MAP[x] === "string";
933
- const findCrossSelling = (facets) => {
934
- const filtered = facets?.filter((x) => isCrossSelling(x.key));
935
- if (Array.isArray(filtered) && filtered.length > 1) {
936
- throw new errors/* BadRequestError */.oY(`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(',')}`);
937
- }
938
- return filtered?.[0] ?? null;
939
- };
940
- const findSlug = (facets) => facets?.find((x) => x.key === 'slug')?.value ?? null;
941
- const findSkuId = (facets) => facets?.find((x) => x.key === 'id')?.value ?? null;
942
- const findLocale = (facets) => facets?.find((x) => x.key === 'locale')?.value ?? null;
943
- const findChannel = (facets) => facets?.find((facet) => facet.key === 'channel')?.value ?? null;
944
- //# sourceMappingURL=facets.js.map
945
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/orderStatistics.js
946
- /**
947
- * More info at: https://en.wikipedia.org/wiki/Order_statistic
948
- */
949
- // O(n) search to find the max of an array
950
- const min = (array, cmp) => {
951
- let best = 0;
952
- for (let curr = 1; curr < array.length; curr++) {
953
- if (cmp(array[best], array[curr]) > 0) {
954
- best = curr;
955
- }
956
- }
957
- return array[best];
958
- };
959
- //# sourceMappingURL=orderStatistics.js.map
960
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/facet.js
961
-
962
-
963
- const StoreFacet = {
964
- __resolveType: ({ type }) => type === 'TEXT' ? 'StoreFacetBoolean' : 'StoreFacetRange',
965
- };
966
- const StoreFacetBoolean = {
967
- key: ({ key }) => key,
968
- label: ({ name }) => name,
969
- values: ({ values }) => values.sort((a, b) => a.name.localeCompare(b.name)),
970
- };
971
- const StoreFacetRange = {
972
- key: ({ key }) => key,
973
- label: ({ name }) => name,
974
- min: ({ values, key }, _, { storage: { searchArgs } }) => {
975
- /**
976
- * Fetch the selected range the user queried.
977
- *
978
- * This is necessary because, differently from boolean facets, Search API does
979
- * not return the selected values, making us have to implement it in here
980
- */
981
- const selectedRange = parseRange(searchArgs?.selectedFacets?.find((facet) => facet.key === key)?.value ??
982
- '');
983
- const facet = min(values, (a, b) => a.range.from - b.range.from);
984
- const globalMin = facet?.range.from ?? 0;
985
- return {
986
- selected: selectedRange?.[0] ?? globalMin,
987
- absolute: globalMin,
988
- };
989
- },
990
- max: ({ values, key }, _, { storage: { searchArgs } }) => {
991
- /**
992
- * Fetch the selected range the user queried.
993
- *
994
- * This is necessary because, differently from boolean facets, Search API does
995
- * not return the selected values, making us have to implement it in here
996
- */
997
- const selectedRange = parseRange(searchArgs?.selectedFacets?.find((facet) => facet.key === key)?.value ??
998
- '');
999
- const facet = min(values, (a, b) => b.range.to - a.range.to);
1000
- const globalMax = facet?.range.to ?? 0;
1001
- return {
1002
- selected: selectedRange?.[1] ?? globalMax,
1003
- absolute: globalMax,
1004
- };
1005
- },
1006
- };
1007
- //# sourceMappingURL=facet.js.map
1008
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/faceValue.js
1009
- const StoreFacetValueBoolean = {
1010
- value: ({ value }) => value,
1011
- label: ({ name }) => name || 'unknown',
1012
- selected: ({ selected }) => selected,
1013
- quantity: ({ quantity }) => quantity,
1014
- };
1015
- //# sourceMappingURL=faceValue.js.map
1016
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/subscribeToNewsletter.js
1017
- const subscribeToNewsletter = async (_, { data }, { clients: { commerce } }) => {
1018
- const response = await commerce.subscribeToNewsletter(data);
1019
- return { id: response?.Id };
1020
- };
1021
- //# sourceMappingURL=subscribeToNewsletter.js.map
1022
- // EXTERNAL MODULE: external "fast-deep-equal"
1023
- var external_fast_deep_equal_ = __webpack_require__(2404);
1024
- var external_fast_deep_equal_default = /*#__PURE__*/__webpack_require__.n(external_fast_deep_equal_);
1025
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/channel.js
1026
- class ChannelMarshal {
1027
- static parse(channelString) {
1028
- try {
1029
- const parsedChannel = JSON.parse(channelString);
1030
- return {
1031
- seller: parsedChannel.seller ?? '',
1032
- regionId: parsedChannel.regionId ?? '',
1033
- salesChannel: parsedChannel.salesChannel ?? '',
1034
- };
1035
- }
1036
- catch (error) {
1037
- console.error(error);
1038
- throw new Error('Malformed channel string');
1039
- }
1040
- }
1041
- static stringify(channel) {
1042
- return JSON.stringify(channel);
1043
- }
1044
- }
1045
- //# sourceMappingURL=channel.js.map
1046
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/contex.js
1047
-
1048
- const mutateChannelContext = (ctx, channelString) => {
1049
- ctx.storage.channel = ChannelMarshal.parse(channelString);
1050
- };
1051
- const mutateLocaleContext = (ctx, locale) => {
1052
- ctx.storage.locale = locale;
1053
- };
1054
- //# sourceMappingURL=contex.js.map
1055
- // EXTERNAL MODULE: external "crypto"
1056
- var external_crypto_ = __webpack_require__(6113);
1057
- var external_crypto_default = /*#__PURE__*/__webpack_require__.n(external_crypto_);
1058
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/md5.js
1059
-
1060
- const md5 = (payload) => external_crypto_default().createHash('md5').update(payload).digest('hex');
1061
- //# sourceMappingURL=md5.js.map
1062
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/propertyValue.js
1063
-
1064
- const VALUE_REFERENCES = {
1065
- attachment: 'ATTACHMENT',
1066
- specification: 'SPECIFICATION',
1067
- };
1068
- function attachmentToPropertyValue(attachment) {
1069
- return {
1070
- name: attachment.name,
1071
- value: attachment.content,
1072
- valueReference: VALUE_REFERENCES.attachment,
1073
- };
1074
- }
1075
- function getPropertyId(item) {
1076
- return md5(`${item.name}:${JSON.stringify(item.value)}:${item.valueReference}`);
1077
- }
1078
- //# sourceMappingURL=propertyValue.js.map
1079
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/shouldUpdateShippingData.js
1080
- const shouldUpdateShippingData = (orderForm, session) => {
1081
- if (!hasSessionPostalCodeOrGeoCoordinates(session)) {
1082
- return { updateShipping: false, addressChanged: false };
1083
- }
1084
- if (!hasItems(orderForm)) {
1085
- return { updateShipping: false, addressChanged: false };
1086
- }
1087
- const [selectedAddress] = orderForm?.shippingData?.selectedAddresses ?? [];
1088
- if (checkPostalCode(selectedAddress, session.postalCode) ||
1089
- checkGeoCoordinates(selectedAddress, session.geoCoordinates) ||
1090
- checkAddressType(selectedAddress, session.addressType)) {
1091
- return { updateShipping: true, addressChanged: true };
1092
- }
1093
- // The logisticsInfo will always exist if there´s at least one item inside the cart
1094
- const { logisticsInfo } = orderForm.shippingData;
1095
- if (shouldUpdateDeliveryInfo(logisticsInfo, session)) {
1096
- return { updateShipping: true, addressChanged: false };
1097
- }
1098
- return { updateShipping: false, addressChanged: false };
1099
- };
1100
- // Validate if theres any postal Code or GeoCoordinates set at the session
1101
- const hasSessionPostalCodeOrGeoCoordinates = (session) => {
1102
- return (!!session.postalCode ||
1103
- (session.geoCoordinates?.latitude && session.geoCoordinates?.longitude));
1104
- };
1105
- // Validate if theres a difference between the session postal code and orderForm postal code
1106
- const checkPostalCode = (address, postalCode) => {
1107
- return typeof postalCode === 'string' && address?.postalCode !== postalCode;
1108
- };
1109
- // Validate if theres a difference between the session geoCoords and orderForm geoCoords
1110
- const checkGeoCoordinates = (address, geoCoordinates) => {
1111
- return (typeof geoCoordinates?.latitude === 'number' &&
1112
- typeof geoCoordinates?.longitude === 'number' &&
1113
- (address?.geoCoordinates[0] !== geoCoordinates?.longitude ||
1114
- address?.geoCoordinates[1] !== geoCoordinates?.latitude));
1115
- };
1116
- const checkAddressType = (address, addressType) => {
1117
- return typeof addressType === 'string' && address?.addressType !== addressType;
1118
- };
1119
- // Validate if theres any item inside the orderForm
1120
- const hasItems = (orderForm) => {
1121
- return orderForm.items.length !== 0;
1122
- };
1123
- const shouldUpdateDeliveryInfo = (logisticsInfo, session) => {
1124
- const deliveryChannel = session?.deliveryMode?.deliveryChannel;
1125
- const deliveryMethod = session?.deliveryMode?.deliveryMethod;
1126
- const { startDate, endDate } = session?.deliveryMode?.deliveryWindow || {};
1127
- return logisticsInfo.some(({ selectedDeliveryChannel, selectedSla, slas }) => {
1128
- const checkDeliveryChannel = deliveryChannel && selectedDeliveryChannel !== deliveryChannel;
1129
- const checkDeliveryMethod = deliveryMethod && selectedSla !== deliveryMethod;
1130
- return slas?.some((sla) => {
1131
- if ((checkDeliveryChannel && sla.deliveryChannel === deliveryChannel) ||
1132
- (checkDeliveryMethod && sla.id === deliveryMethod)) {
1133
- return true;
1134
- }
1135
- return (startDate &&
1136
- endDate &&
1137
- sla.deliveryChannel === deliveryChannel &&
1138
- sla.id === deliveryMethod &&
1139
- (!sla?.deliveryWindow ||
1140
- sla?.deliveryWindow?.startDateUtc !== startDate ||
1141
- sla?.deliveryWindow?.endDateUtc !== endDate) &&
1142
- sla.availableDeliveryWindows?.some((window) => window?.startDateUtc === startDate &&
1143
- window?.endDateUtc === endDate));
1144
- });
1145
- });
1146
- };
1147
- //# sourceMappingURL=shouldUpdateShippingData.js.map
1148
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/getAddressOrderForm.js
1149
- const getAddressOrderForm = (orderForm, session, addressChanged) => {
1150
- const postalCode = session.postalCode;
1151
- const geoCoordinates = session.geoCoordinates;
1152
- const availableAddresses = orderForm?.shippingData?.availableAddresses ?? [];
1153
- const selectedAddresses = orderForm?.shippingData?.selectedAddresses ?? [];
1154
- // Validate if no change for the address was made and the deliveryMode has changed we can return the address from the orderForm
1155
- if (!addressChanged && selectedAddresses.length > 0) {
1156
- return [selectedAddresses[0]];
1157
- }
1158
- // Validate if the address from the session already exists at the availableAddresses from the OrderForm to avoid duplication
1159
- if (addressChanged && availableAddresses.length > 0) {
1160
- for (const address of availableAddresses) {
1161
- if (postalCode && geoCoordinates) {
1162
- const addressMatcher = address.postalCode === postalCode ||
1163
- (address.geoCoordinates[0] === geoCoordinates.longitude &&
1164
- address.geoCoordinates[1] === geoCoordinates.latitude);
1165
- if (addressMatcher) {
1166
- return [address];
1167
- }
1168
- }
1169
- if (postalCode && !geoCoordinates) {
1170
- const addressMatcher = address.postalCode === postalCode;
1171
- if (addressMatcher) {
1172
- return [address];
1173
- }
1174
- }
1175
- if (geoCoordinates && !postalCode) {
1176
- const addressMatcher = address.geoCoordinates[0] === geoCoordinates.longitude &&
1177
- address.geoCoordinates[1] === geoCoordinates.latitude;
1178
- if (addressMatcher) {
1179
- return [address];
1180
- }
1181
- }
1182
- }
1183
- }
1184
- return null;
1185
- };
1186
- //# sourceMappingURL=getAddressOrderForm.js.map
1187
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/createNewAddress.js
1188
- const createNewAddress = (session) => {
1189
- const postalCode = session.postalCode;
1190
- const geoCoordinates = session.geoCoordinates;
1191
- // If the address from the session has changed and it do not exist we will create the new one
1192
- const addressSession = {
1193
- addressType: session.addressType || null,
1194
- postalCode: postalCode || null,
1195
- city: null,
1196
- state: null,
1197
- country: session.country || null,
1198
- street: null,
1199
- number: null,
1200
- neighborhood: null,
1201
- complement: null,
1202
- reference: null,
1203
- geoCoordinates: [],
1204
- };
1205
- if (geoCoordinates) {
1206
- const latitude = typeof geoCoordinates === 'object' && 'latitude' in geoCoordinates
1207
- ? geoCoordinates.latitude
1208
- : null;
1209
- const longitude = typeof geoCoordinates === 'object' && 'longitude' in geoCoordinates
1210
- ? geoCoordinates.longitude
1211
- : null;
1212
- addressSession.geoCoordinates =
1213
- latitude !== null && longitude !== null ? [longitude, latitude] : [];
1214
- }
1215
- return [addressSession];
1216
- };
1217
- //# sourceMappingURL=createNewAddress.js.map
1218
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/validateCart.js
1219
-
1220
-
1221
-
1222
-
1223
-
1224
-
1225
-
1226
- const isAttachment = (value) => value.valueReference === VALUE_REFERENCES.attachment;
1227
- const getId = (item) => [
1228
- item.itemOffered.sku,
1229
- item.seller.identifier,
1230
- item.price < 0.01 ? 'Gift' : undefined,
1231
- item.itemOffered.additionalProperty
1232
- ?.filter(isAttachment)
1233
- .map(getPropertyId)
1234
- .join('-'),
1235
- ]
1236
- .filter(Boolean)
1237
- .join('::');
1238
- const orderFormItemToOffer = (item, index) => ({
1239
- listPrice: item.listPrice / 100,
1240
- price: item.sellingPrice / 100,
1241
- quantity: item.quantity,
1242
- seller: { identifier: item.seller },
1243
- itemOffered: {
1244
- sku: item.id,
1245
- image: [],
1246
- name: item.name,
1247
- additionalProperty: item.attachments.map(attachmentToPropertyValue),
1248
- },
1249
- index,
1250
- });
1251
- const offerToOrderItemInput = (offer) => ({
1252
- quantity: offer.quantity,
1253
- seller: offer.seller.identifier,
1254
- id: offer.itemOffered.sku,
1255
- index: offer.index,
1256
- attachments: (offer.itemOffered.additionalProperty?.filter(isAttachment) ?? []).map((attachment) => ({
1257
- name: attachment.name,
1258
- content: attachment.value,
1259
- })),
1260
- });
1261
- const groupById = (offers) => offers.reduce((acc, item) => {
1262
- const id = getId(item);
1263
- if (!acc.has(id)) {
1264
- acc.set(id, []);
1265
- }
1266
- acc.get(id)?.push(item);
1267
- return acc;
1268
- }, new Map());
1269
- const equals = (storeOrder, orderForm) => {
1270
- const pick = (item, index) => ({
1271
- ...item,
1272
- itemOffered: {
1273
- sku: item.itemOffered.sku,
1274
- },
1275
- index,
1276
- });
1277
- const orderFormItems = orderForm.items.map(orderFormItemToOffer).map(pick);
1278
- const storeOrderItems = storeOrder.acceptedOffer.map(pick);
1279
- const isSameOrder = storeOrder.orderNumber === orderForm.orderFormId;
1280
- const orderItemsAreSync = external_fast_deep_equal_default()(orderFormItems, storeOrderItems);
1281
- return isSameOrder && orderItemsAreSync;
1282
- };
1283
- const joinItems = (form) => {
1284
- const itemsById = form.items.reduce((acc, item) => {
1285
- const id = getId(orderFormItemToOffer(item));
1286
- if (!acc[id]) {
1287
- acc[id] = [];
1288
- }
1289
- acc[id].push(item);
1290
- return acc;
1291
- }, {});
1292
- return {
1293
- ...form,
1294
- items: Object.values(itemsById).map((items) => {
1295
- const [item] = items;
1296
- const quantity = items.reduce((acc, i) => acc + i.quantity, 0);
1297
- const totalPrice = items.reduce((acc, i) => acc +
1298
- (i?.priceDefinition?.total ??
1299
- (i?.quantity ?? 0) * (i?.sellingPrice ?? 0)), 0);
1300
- return {
1301
- ...item,
1302
- quantity,
1303
- sellingPrice: totalPrice / quantity,
1304
- };
1305
- }),
1306
- };
1307
- };
1308
- const orderFormToCart = async (form, skuLoader) => {
1309
- return {
1310
- order: {
1311
- orderNumber: form.orderFormId,
1312
- acceptedOffer: form.items.map(async (item) => ({
1313
- ...item,
1314
- product: await skuLoader.load(item.id),
1315
- })),
1316
- },
1317
- messages: form.messages.map(({ text, status }) => ({
1318
- text,
1319
- status: status.toUpperCase(),
1320
- })),
1321
- };
1322
- };
1323
- const getOrderFormEtag = ({ items }) => md5(JSON.stringify(items));
1324
- const setOrderFormEtag = async (form, commerce) => {
1325
- try {
1326
- const orderForm = await commerce.checkout.setCustomData({
1327
- id: form.orderFormId,
1328
- appId: 'faststore',
1329
- key: 'cartEtag',
1330
- value: getOrderFormEtag(form),
1331
- });
1332
- return orderForm;
1333
- }
1334
- catch (err) {
1335
- console.error('Error while setting custom data to orderForm.\n Make sure to add the following custom app to the orderForm: \n{"fields":["cartEtag"],"id":"faststore","major":1}.\n More info at: https://developers.vtex.com/vtex-rest-api/docs/customizable-fields-with-checkout-api');
1336
- throw err;
1337
- }
1338
- };
1339
- /**
1340
- * Checks if cartEtag stored on customData is up to date
1341
- * @description If cartEtag is not up to date, this means that
1342
- * another system changed the cart, like Checkout UI or Order Placed
1343
- */
1344
- const isOrderFormStale = (form) => {
1345
- const faststoreData = form.customData?.customApps.find((app) => app.id === 'faststore');
1346
- const oldEtag = faststoreData?.fields?.cartEtag;
1347
- if (oldEtag == null) {
1348
- return true;
1349
- }
1350
- const newEtag = getOrderFormEtag(form);
1351
- return newEtag !== oldEtag;
1352
- };
1353
- // Returns the regionalized orderForm
1354
- const getOrderForm = async (id, { clients: { commerce } }) => {
1355
- return commerce.checkout.orderForm({
1356
- id,
1357
- });
1358
- };
1359
- const clearOrderFormMessages = async (id, { clients: { commerce } }) => {
1360
- return commerce.checkout.clearOrderFormMessages({
1361
- id,
1362
- });
1363
- };
1364
- const updateOrderFormShippingData = async (orderForm, session, { clients: { commerce } }) => {
1365
- // Stores that are not yet providing the session while validating the cart
1366
- // should not be able to update the shipping data
1367
- //
1368
- // This was causing errors while validating regionalizated carts
1369
- // because the following code was trying to change the shippingData to an undefined address/session
1370
- if (!session) {
1371
- return orderForm;
1372
- }
1373
- const { updateShipping, addressChanged } = shouldUpdateShippingData(orderForm, session);
1374
- if (updateShipping) {
1375
- // Check if the orderForm address matches the one from the session
1376
- const oldAddress = getAddressOrderForm(orderForm, session, addressChanged);
1377
- const address = oldAddress ? oldAddress : createNewAddress(session);
1378
- const selectedAddresses = address;
1379
- const hasDeliveryWindow = session.deliveryMode?.deliveryWindow
1380
- ? true
1381
- : false;
1382
- if (hasDeliveryWindow) {
1383
- // if you have a Delivery Window you have to first get the delivery window to set the desired after
1384
- await commerce.checkout.shippingData({
1385
- id: orderForm.orderFormId,
1386
- index: orderForm.items.length,
1387
- deliveryMode: session.deliveryMode,
1388
- selectedAddresses: selectedAddresses,
1389
- }, false);
1390
- }
1391
- return commerce.checkout.shippingData({
1392
- id: orderForm.orderFormId,
1393
- index: orderForm.items.length,
1394
- deliveryMode: session.deliveryMode,
1395
- selectedAddresses: selectedAddresses,
1396
- }, true);
1397
- }
1398
- return orderForm;
1399
- };
1400
- /**
1401
- * This resolver implements the optimistic cart behavior. The main idea in here
1402
- * is that we receive a cart from the UI (as query params) and we validate it with
1403
- * the commerce platform. If the cart is valid, we return null, if the cart is
1404
- * invalid according to the commerce platform, we return the new cart the UI should use
1405
- * instead.
1406
- *
1407
- * The algorithm is something like:
1408
- * 1. Fetch orderForm from VTEX
1409
- * 2. Compute delta changes between the orderForm and the UI's cart
1410
- * 3. Update the orderForm in VTEX platform accordingly
1411
- * 4. If any changes were made, send to the UI the new cart. Null otherwise
1412
- */
1413
- const validateCart = async (_, { cart: { order }, session }, ctx) => {
1414
- const { orderNumber, acceptedOffer, shouldSplitItem } = order;
1415
- const { clients: { commerce }, loaders: { skuLoader }, } = ctx;
1416
- const channel = session?.channel;
1417
- const locale = session?.locale;
1418
- if (channel) {
1419
- mutateChannelContext(ctx, channel);
1420
- }
1421
- if (locale) {
1422
- mutateLocaleContext(ctx, locale);
1423
- }
1424
- // Step1: Get OrderForm from VTEX Commerce
1425
- const orderForm = await getOrderForm(orderNumber, ctx);
1426
- // Clear messages so it doesn't keep populating toasts on a loop
1427
- // In the next validateCart mutation it will only have messages if a new message is created on orderForm
1428
- if (orderForm.messages.length !== 0) {
1429
- await clearOrderFormMessages(orderNumber, ctx);
1430
- }
1431
- // Step1.5: Check if another system changed the orderForm with this orderNumber
1432
- // If so, this means the user interacted with this cart elsewhere and expects
1433
- // to see this new cart state instead of what's stored on the user's browser.
1434
- const isStale = isOrderFormStale(orderForm);
1435
- if (isStale && orderNumber) {
1436
- const newOrderForm = await setOrderFormEtag(orderForm, commerce).then(joinItems);
1437
- return orderFormToCart(newOrderForm, skuLoader);
1438
- }
1439
- // Step2: Process items from both browser and checkout so they have the same shape
1440
- const browserItemsById = groupById(acceptedOffer);
1441
- const originItemsById = groupById(orderForm.items.map(orderFormItemToOffer));
1442
- const originItems = Array.from(originItemsById.entries()); // items on the VTEX platform backend
1443
- const browserItems = Array.from(browserItemsById.entries()); // items on the user's browser
1444
- // Step3: Compute delta changes
1445
- const { itemsToAdd, itemsToUpdate } = browserItems.reduce((acc, [id, items]) => {
1446
- const maybeOriginItem = originItemsById.get(id);
1447
- // Adding new items to cart
1448
- if (!maybeOriginItem) {
1449
- items.forEach((item) => acc.itemsToAdd.push(item));
1450
- return acc;
1451
- }
1452
- // Update existing items
1453
- const [head, ...tail] = maybeOriginItem;
1454
- const totalQuantity = items.reduce((acc, curr) => acc + curr.quantity, 0);
1455
- // set total quantity to first item
1456
- acc.itemsToUpdate.push({
1457
- ...head,
1458
- quantity: totalQuantity,
1459
- });
1460
- // Remove all the rest
1461
- tail.forEach((item) => acc.itemsToUpdate.push({ ...item, quantity: 0 }));
1462
- return acc;
1463
- }, {
1464
- itemsToAdd: [],
1465
- itemsToUpdate: [],
1466
- });
1467
- const itemsToDelete = originItems
1468
- .filter(([id]) => !browserItemsById.has(id))
1469
- .flatMap(([, items]) => items.map((item) => ({ ...item, quantity: 0 })));
1470
- const changes = [...itemsToAdd, ...itemsToUpdate, ...itemsToDelete].map(offerToOrderItemInput);
1471
- if (changes.length === 0) {
1472
- return null;
1473
- }
1474
- // Step4: Apply delta changes to order form
1475
- const updatedOrderForm = await commerce.checkout
1476
- // update orderForm items
1477
- .updateOrderFormItems({
1478
- id: orderForm.orderFormId,
1479
- orderItems: changes,
1480
- shouldSplitItem,
1481
- })
1482
- // update orderForm shippingData
1483
- .then((form) => updateOrderFormShippingData(form, session, ctx))
1484
- // update orderForm etag so we know last time we touched this orderForm
1485
- .then((form) => setOrderFormEtag(form, commerce))
1486
- .then(joinItems);
1487
- const equalMessages = external_fast_deep_equal_default()(orderForm.messages, updatedOrderForm.messages);
1488
- // Step5: If no changes detected before/after updating orderForm, the order is validated
1489
- if (equals(order, updatedOrderForm) && equalMessages) {
1490
- return null;
1491
- }
1492
- // Step6: There were changes, convert orderForm to StoreCart
1493
- return orderFormToCart(updatedOrderForm, skuLoader);
1494
- };
1495
- //# sourceMappingURL=validateCart.js.map
1496
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/validateSession.js
1497
-
1498
-
1499
- const validateSession = async (_, { session: oldSession, search }, { clients }) => {
1500
- const channel = ChannelMarshal.parse(oldSession.channel ?? '');
1501
- const postalCode = String(oldSession.postalCode ?? '').replace(/\D/g, '');
1502
- const geoCoordinates = oldSession.geoCoordinates ?? null;
1503
- const country = oldSession.country ?? '';
1504
- const params = new URLSearchParams(search);
1505
- const salesChannel = params.get('sc') ?? channel.salesChannel;
1506
- params.set('sc', salesChannel);
1507
- const [regionData, sessionData] = await Promise.all([
1508
- postalCode || geoCoordinates
1509
- ? clients.commerce.checkout.region({
1510
- postalCode,
1511
- geoCoordinates,
1512
- country,
1513
- salesChannel,
1514
- })
1515
- : Promise.resolve(null),
1516
- clients.commerce.session(params.toString()).catch(() => null),
1517
- ]);
1518
- const profile = sessionData?.namespaces.profile ?? null;
1519
- const store = sessionData?.namespaces.store ?? null;
1520
- const region = regionData?.[0];
1521
- // Set seller only if it's inside a region
1522
- const seller = region?.sellers.find((seller) => channel.seller === seller.id);
1523
- const newSession = {
1524
- ...oldSession,
1525
- currency: {
1526
- code: store?.currencyCode.value ?? oldSession.currency.code,
1527
- symbol: store?.currencySymbol.value ?? oldSession.currency.symbol,
1528
- },
1529
- country: store?.countryCode.value ?? oldSession.country,
1530
- channel: ChannelMarshal.stringify({
1531
- salesChannel: store?.channel?.value ?? channel.salesChannel,
1532
- regionId: region?.id ?? channel.regionId,
1533
- seller: seller?.id,
1534
- }),
1535
- person: profile?.id
1536
- ? {
1537
- id: profile.id?.value ?? '',
1538
- email: profile.email?.value ?? '',
1539
- givenName: profile.firstName?.value ?? '',
1540
- familyName: profile.lastName?.value ?? '',
1541
- }
1542
- : null,
1543
- };
1544
- if (external_fast_deep_equal_default()(oldSession, newSession)) {
1545
- return null;
1546
- }
1547
- return newSession;
1548
- };
1549
- //# sourceMappingURL=validateSession.js.map
1550
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/mutation.js
1551
-
1552
-
1553
-
1554
- const Mutation = {
1555
- validateCart: validateCart,
1556
- validateSession: validateSession,
1557
- subscribeToNewsletter: subscribeToNewsletter,
1558
- };
1559
- //# sourceMappingURL=mutation.js.map
1560
- // EXTERNAL MODULE: external "graphql"
1561
- var external_graphql_ = __webpack_require__(7343);
1562
- // EXTERNAL MODULE: external "graphql/language"
1563
- var language_ = __webpack_require__(6548);
1564
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/objectOrString.js
1565
-
1566
-
1567
- const ObjectOrString = new external_graphql_.GraphQLScalarType({
1568
- name: 'ObjectOrString',
1569
- description: 'A string or the string representation of an object (a stringified object).',
1570
- parseValue: toObjectOrString,
1571
- serialize: stringify,
1572
- parseLiteral(ast) {
1573
- if (ast.kind === language_.Kind.STRING) {
1574
- return getValueAsObjectOrString(ast.value);
1575
- }
1576
- return null;
1577
- },
1578
- });
1579
- function toObjectOrString(value) {
1580
- if (typeof value === 'string') {
1581
- return getValueAsObjectOrString(value);
1582
- }
1583
- return null;
1584
- }
1585
- function getValueAsObjectOrString(value) {
1586
- try {
1587
- return JSON.parse(value);
1588
- }
1589
- catch (e) {
1590
- return value;
1591
- }
1592
- }
1593
- function stringify(value) {
1594
- if (typeof value === 'object') {
1595
- return JSON.stringify(value);
1596
- }
1597
- if (typeof value === 'string') {
1598
- return value;
1599
- }
1600
- return null;
1601
- }
1602
- //# sourceMappingURL=objectOrString.js.map
1603
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/offer.js
1604
-
1605
- const isSearchItem = (item) => 'Price' in item && 'seller' in item && 'product' in item;
1606
- const isOrderFormItem = (item) => 'skuName' in item;
1607
- const StoreOffer = {
1608
- priceCurrency: async (_, __, ctx) => {
1609
- const { loaders: { salesChannelLoader }, storage: { channel } } = ctx;
1610
- const sc = await salesChannelLoader.load(channel.salesChannel);
1611
- return sc.CurrencyCode ?? '';
1612
- },
1613
- priceValidUntil: (root) => {
1614
- if (isSearchItem(root)) {
1615
- return root.PriceValidUntil ?? '';
1616
- }
1617
- if (isOrderFormItem(root)) {
1618
- return root.priceValidUntil ?? '';
1619
- }
1620
- return null;
1621
- },
1622
- itemCondition: () => 'https://schema.org/NewCondition',
1623
- availability: async (root) => {
1624
- if (isSearchItem(root)) {
1625
- return availability(inStock(root));
1626
- }
1627
- if (isOrderFormItem(root)) {
1628
- return availability(inStockOrderFormItem(root.availability));
1629
- }
1630
- return null;
1631
- },
1632
- seller: (root, _, ctx) => {
1633
- if (isSearchItem(root)) {
1634
- return {
1635
- identifier: ctx.storage.channel?.seller || root.seller.sellerId || '',
1636
- };
1637
- }
1638
- if (isOrderFormItem(root)) {
1639
- return {
1640
- identifier: root.seller,
1641
- };
1642
- }
1643
- return null;
1644
- },
1645
- price: (root) => {
1646
- if (isSearchItem(root)) {
1647
- return price(root);
1648
- }
1649
- if (isOrderFormItem(root)) {
1650
- return root.sellingPrice / 1e2;
1651
- }
1652
- return null;
1653
- },
1654
- sellingPrice: (root) => {
1655
- if (isSearchItem(root)) {
1656
- return sellingPrice(root);
1657
- }
1658
- if (isOrderFormItem(root)) {
1659
- return root.sellingPrice / 1e2;
1660
- }
1661
- return null;
1662
- },
1663
- listPrice: (root) => {
1664
- if (isSearchItem(root)) {
1665
- return root.ListPrice ?? 0;
1666
- }
1667
- if (isOrderFormItem(root)) {
1668
- return root.listPrice / 1e2;
1669
- }
1670
- return null;
1671
- },
1672
- itemOffered: (root) => {
1673
- if (isSearchItem(root)) {
1674
- return root.product;
1675
- }
1676
- if (isOrderFormItem(root)) {
1677
- return {
1678
- ...root.product,
1679
- attachmentsValues: root.attachments,
1680
- };
1681
- }
1682
- return null;
1683
- },
1684
- quantity: (root) => {
1685
- if (isSearchItem(root)) {
1686
- return root.AvailableQuantity ?? 0;
1687
- }
1688
- if (isOrderFormItem(root)) {
1689
- return root.quantity;
1690
- }
1691
- return null;
1692
- },
1693
- };
1694
- //# sourceMappingURL=offer.js.map
1695
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/canonical.js
1696
- const canonicalFromProduct = ({ linkText }) => `/${linkText}/p`;
1697
- //# sourceMappingURL=canonical.js.map
1698
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/enhanceCommercialOffer.js
1699
- const enhanceCommercialOffer = ({ offer, seller, product, }) => ({
1700
- ...offer,
1701
- product,
1702
- seller,
1703
- });
1704
- //# sourceMappingURL=enhanceCommercialOffer.js.map
1705
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/product.js
1706
-
1707
-
1708
-
1709
-
1710
-
1711
- const DEFAULT_IMAGE = {
1712
- imageText: 'image',
1713
- imageUrl: 'https://storecomponents.vtexassets.com/assets/faststore/images/image___117a6d3e229a96ad0e0d0876352566e2.svg',
1714
- };
1715
- const getSlug = (link, id) => `${link}-${id}`;
1716
- const getPath = (link, id) => `/${getSlug(link, id)}/p`;
1717
- const nonEmptyArray = (array) => Array.isArray(array) && array.length > 0 ? array : null;
1718
- const StoreProduct = {
1719
- productID: ({ itemId }) => itemId,
1720
- name: ({ isVariantOf, name }) => name ?? isVariantOf.productName,
1721
- slug: ({ isVariantOf: { linkText }, itemId }) => getSlug(linkText, itemId),
1722
- description: ({ isVariantOf: { description } }) => description,
1723
- seo: ({ isVariantOf }) => ({
1724
- title: isVariantOf.productName,
1725
- description: isVariantOf.description,
1726
- canonical: canonicalFromProduct(isVariantOf),
1727
- }),
1728
- brand: ({ isVariantOf: { brand } }) => ({ name: brand }),
1729
- breadcrumbList: ({ isVariantOf: { categories, productName, linkText }, itemId, }) => {
1730
- return {
1731
- itemListElement: [
1732
- ...categories.reverse().map((categoryPath, index) => {
1733
- const splitted = categoryPath.split('/');
1734
- const name = splitted[splitted.length - 2];
1735
- const item = splitted.map(slugify).join('/');
1736
- return {
1737
- name,
1738
- item,
1739
- position: index + 1,
1740
- };
1741
- }),
1742
- {
1743
- name: productName,
1744
- item: getPath(linkText, itemId),
1745
- position: categories.length + 1,
1746
- },
1747
- ],
1748
- numberOfItems: categories.length,
1749
- };
1750
- },
1751
- image: ({ images }) => (nonEmptyArray(images) ?? [DEFAULT_IMAGE]).map(({ imageUrl, imageText }) => ({
1752
- alternateName: imageText ?? '',
1753
- url: imageUrl.replace('vteximg.com.br', 'vtexassets.com'),
1754
- })),
1755
- sku: ({ itemId }) => itemId,
1756
- gtin: ({ referenceId }) => referenceId[0]?.Value ?? '',
1757
- review: () => [],
1758
- aggregateRating: () => ({}),
1759
- offers: (root) => root.sellers
1760
- .map((seller) => enhanceCommercialOffer({
1761
- offer: seller.commertialOffer,
1762
- seller,
1763
- product: root,
1764
- }))
1765
- .sort(bestOfferFirst),
1766
- isVariantOf: (root) => root,
1767
- additionalProperty: ({
1768
- // Search uses the name variations for specifications
1769
- variations: specifications = [], attachmentsValues = [], }) => {
1770
- const propertyValueSpecifications = specifications.flatMap(({ name, values }) => values.map((value) => ({
1771
- name,
1772
- value,
1773
- valueReference: VALUE_REFERENCES.specification,
1774
- })));
1775
- const propertyValueAttachments = attachmentsValues.map(attachmentToPropertyValue);
1776
- return [...propertyValueSpecifications, ...propertyValueAttachments];
1777
- },
1778
- releaseDate: ({ isVariantOf: { releaseDate } }) => releaseDate ?? ''
1779
- };
1780
- //# sourceMappingURL=product.js.map
1781
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/productGroup.js
1782
-
1783
-
1784
- const BLOCKED_SPECIFICATIONS = new Set(['allSpecifications']);
1785
- const StoreProductGroup = {
1786
- hasVariant: (root) => root.isVariantOf.items.map((item) => enhanceSku(item, root.isVariantOf)),
1787
- productGroupID: ({ isVariantOf }) => isVariantOf.productId,
1788
- name: (root) => root.isVariantOf.productName,
1789
- skuVariants: (root) => root,
1790
- additionalProperty: ({ isVariantOf: { specificationGroups } }) => specificationGroups
1791
- // Filter sku specifications so we don't mix them with product specs.
1792
- .filter((specificationGroup) => !BLOCKED_SPECIFICATIONS.has(specificationGroup.name))
1793
- // Transform specs back into product specs.
1794
- .flatMap(({ specifications }) => specifications.flatMap(({ name, values }) => values.map((value) => ({
1795
- name,
1796
- value,
1797
- valueReference: VALUE_REFERENCES.specification,
1798
- })))),
1799
- };
1800
- //# sourceMappingURL=productGroup.js.map
1801
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/propertyValue.js
1802
-
1803
- const StorePropertyValue = {
1804
- propertyID: (root) => getPropertyId(root),
1805
- name: ({ name }) => name,
1806
- value: ({ value }) => value,
1807
- valueReference: ({ valueReference }) => valueReference,
1808
- };
1809
- //# sourceMappingURL=propertyValue.js.map
1810
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/sort.js
1811
- const SORT_MAP = {
1812
- price_desc: 'price:desc',
1813
- price_asc: 'price:asc',
1814
- orders_desc: 'orders:desc',
1815
- name_desc: 'name:desc',
1816
- name_asc: 'name:asc',
1817
- release_desc: 'release:desc',
1818
- discount_desc: 'discount:desc',
1819
- score_desc: '',
1820
- };
1821
- //# sourceMappingURL=sort.js.map
1822
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/sku.js
1823
-
1824
-
1825
- /**
1826
- * This function implements Portal heuristics for returning the best sku for a product.
1827
- *
1828
- * The best sku is the one with the best (cheapest available) offer
1829
- * */
1830
- const pickBestSku = (skus) => {
1831
- const offersBySku = skus.flatMap((sku) => sku.sellers.map((seller) => ({
1832
- offer: seller.commertialOffer,
1833
- sku,
1834
- })));
1835
- const best = min(offersBySku, ({ offer: o1 }, { offer: o2 }) => bestOfferFirst(o1, o2));
1836
- return best ? best.sku : skus[0];
1837
- };
1838
- const isValidSkuId = (skuId) => skuId !== '' && !Number.isNaN(Number(skuId));
1839
- //# sourceMappingURL=sku.js.map
1840
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/query.js
1841
-
1842
-
1843
-
1844
-
1845
-
1846
-
1847
-
1848
-
1849
- const Query = {
1850
- product: async (_, { locator }, ctx) => {
1851
- // Insert channel in context for later usage
1852
- const channel = findChannel(locator);
1853
- const locale = findLocale(locator);
1854
- const id = findSkuId(locator);
1855
- const slug = findSlug(locator);
1856
- if (channel) {
1857
- mutateChannelContext(ctx, channel);
1858
- }
1859
- if (locale) {
1860
- mutateLocaleContext(ctx, locale);
1861
- }
1862
- const { loaders: { skuLoader }, clients: { commerce, search }, } = ctx;
1863
- try {
1864
- const skuId = id ?? slug?.split('-').pop() ?? '';
1865
- if (!isValidSkuId(skuId)) {
1866
- throw new Error('Invalid SkuId');
1867
- }
1868
- const sku = await skuLoader.load(skuId);
1869
- /**
1870
- * Here be dragons 🦄🦄🦄
1871
- *
1872
- * In some cases, the slug has a valid skuId for a different
1873
- * product. This condition makes sure that the fetched sku
1874
- * is the one we actually asked for
1875
- * */
1876
- if (slug &&
1877
- sku.isVariantOf.linkText &&
1878
- !slug.startsWith(sku.isVariantOf.linkText)) {
1879
- throw new Error(`Slug was set but the fetched sku does not satisfy the slug condition. slug: ${slug}, linkText: ${sku.isVariantOf.linkText}`);
1880
- }
1881
- return sku;
1882
- }
1883
- catch (err) {
1884
- if (slug == null) {
1885
- throw new errors/* BadRequestError */.oY('Missing slug or id');
1886
- }
1887
- const route = await commerce.catalog.portal.pagetype(`${slug}/p`);
1888
- if (route.pageType !== 'Product' || !route.id) {
1889
- throw new errors/* NotFoundError */.dR(`No product found for slug ${slug}`);
1890
- }
1891
- const { products: [product], } = await search.products({
1892
- page: 0,
1893
- count: 1,
1894
- query: `product:${route.id}`,
1895
- });
1896
- if (!product) {
1897
- throw new errors/* NotFoundError */.dR(`No product found for id ${route.id}`);
1898
- }
1899
- const sku = pickBestSku(product.items);
1900
- return enhanceSku(sku, product);
1901
- }
1902
- },
1903
- collection: (_, { slug }, ctx) => {
1904
- const { loaders: { collectionLoader }, } = ctx;
1905
- return collectionLoader.load(slug);
1906
- },
1907
- search: async (_, { first, after: maybeAfter, sort, term, selectedFacets }, ctx) => {
1908
- // Insert channel in context for later usage
1909
- const channel = findChannel(selectedFacets);
1910
- const locale = findLocale(selectedFacets);
1911
- const crossSelling = findCrossSelling(selectedFacets);
1912
- if (channel) {
1913
- mutateChannelContext(ctx, channel);
1914
- }
1915
- if (locale) {
1916
- mutateLocaleContext(ctx, locale);
1917
- }
1918
- let query = term;
1919
- /**
1920
- * In case we are using crossSelling, we need to modify the search
1921
- * we will be performing on our search engine. The idea in here
1922
- * is to use the cross selling API for fetching the productIds our
1923
- * search will return for us.
1924
- * Doing this two request workflow makes it possible to have cross
1925
- * selling with Search features, like pagination, internationalization
1926
- * etc
1927
- */
1928
- if (crossSelling) {
1929
- const products = await ctx.clients.commerce.catalog.products.crossselling({
1930
- type: FACET_CROSS_SELLING_MAP[crossSelling.key],
1931
- productId: crossSelling.value,
1932
- });
1933
- query = `product:${products
1934
- .map((x) => x.productId)
1935
- .slice(0, first)
1936
- .join(';')}`;
1937
- }
1938
- const after = maybeAfter ? Number(maybeAfter) : 0;
1939
- const searchArgs = {
1940
- page: Math.ceil(after / first),
1941
- count: first,
1942
- query: query ?? undefined,
1943
- sort: SORT_MAP[sort ?? 'score_desc'],
1944
- selectedFacets: selectedFacets?.flatMap(transformSelectedFacet) ?? [],
1945
- };
1946
- const productSearchPromise = ctx.clients.search.products(searchArgs);
1947
- return { searchArgs, productSearchPromise };
1948
- },
1949
- allProducts: async (_, { first, after: maybeAfter }, ctx) => {
1950
- const { clients: { search }, } = ctx;
1951
- const after = maybeAfter ? Number(maybeAfter) : 0;
1952
- const products = await search.products({
1953
- page: Math.ceil(after / first),
1954
- count: first,
1955
- });
1956
- const skus = products.products
1957
- .map((product) => product.items.map((sku) => enhanceSku(sku, product)))
1958
- .flat()
1959
- .filter((sku) => sku.sellers.length > 0);
1960
- return {
1961
- pageInfo: {
1962
- hasNextPage: products.pagination.after.length > 0,
1963
- hasPreviousPage: products.pagination.before.length > 0,
1964
- startCursor: '0',
1965
- endCursor: products.recordsFiltered.toString(),
1966
- totalCount: products.recordsFiltered,
1967
- },
1968
- // after + index is bigger than after+first itself because of the array flat() above
1969
- edges: skus.map((sku, index) => ({
1970
- node: sku,
1971
- cursor: (after + index).toString(),
1972
- })),
1973
- };
1974
- },
1975
- allCollections: async (_, { first, after: maybeAfter }, ctx) => {
1976
- const { clients: { commerce }, } = ctx;
1977
- const after = maybeAfter ? Number(maybeAfter) : 0;
1978
- const [brands, tree] = await Promise.all([
1979
- commerce.catalog.brand.list(),
1980
- commerce.catalog.category.tree(),
1981
- ]);
1982
- const categories = [];
1983
- const dfs = (node, level) => {
1984
- categories.push({ ...node, level });
1985
- for (const child of node.children) {
1986
- dfs(child, level + 1);
1987
- }
1988
- };
1989
- for (const node of tree) {
1990
- dfs(node, 0);
1991
- }
1992
- const collections = [
1993
- ...brands
1994
- .filter((brand) => brand.isActive)
1995
- .map((x) => ({ ...x, type: 'brand' })),
1996
- ...categories,
1997
- ];
1998
- const validCollections = collections
1999
- // Nullable slugs may cause one route to override the other
2000
- .filter((node) => Boolean(StoreCollection.slug(node, null, ctx, null)));
2001
- return {
2002
- pageInfo: {
2003
- hasNextPage: validCollections.length - after > first,
2004
- hasPreviousPage: after > 0,
2005
- startCursor: '0',
2006
- endCursor: (Math.min(first, validCollections.length - after) - 1).toString(),
2007
- totalCount: validCollections.length,
2008
- },
2009
- edges: validCollections
2010
- .slice(after, after + first)
2011
- .map((node, index) => ({
2012
- node,
2013
- cursor: (after + index).toString(),
2014
- })),
2015
- };
2016
- },
2017
- shipping: async (_, { country, items, postalCode }, ctx) => {
2018
- const { loaders: { simulationLoader }, clients: { commerce }, } = ctx;
2019
- const [simulation, address] = await Promise.all([
2020
- simulationLoader.load({ country, items, postalCode }),
2021
- commerce.checkout.address({ postalCode, country }),
2022
- ]);
2023
- return {
2024
- ...simulation,
2025
- address,
2026
- };
2027
- },
2028
- redirect: async (_, { term, selectedFacets }, ctx) => {
2029
- // Currently the search redirection can be done through a search term or filter (facet) so we limit the redirect query to always have one of these values otherwise we do not execute it.
2030
- // https://help.vtex.com/en/tracks/vtex-intelligent-search--19wrbB7nEQcmwzDPl1l4Cb/4Gd2wLQFbCwTsh8RUDwSoL?&utm_source=autocomplete
2031
- if (!term && (!selectedFacets || !selectedFacets.length)) {
2032
- return null;
2033
- }
2034
- const { redirect } = await ctx.clients.search.products({
2035
- page: 1,
2036
- count: 1,
2037
- query: term ?? undefined,
2038
- selectedFacets: selectedFacets?.flatMap(transformSelectedFacet) ?? [],
2039
- });
2040
- return {
2041
- url: redirect,
2042
- };
2043
- },
2044
- sellers: async (_, { postalCode, geoCoordinates, country, salesChannel }, ctx) => {
2045
- const { clients: { commerce }, } = ctx;
2046
- const regionData = await commerce.checkout.region({
2047
- postalCode,
2048
- geoCoordinates,
2049
- country,
2050
- salesChannel,
2051
- });
2052
- const region = regionData?.[0];
2053
- const { id, sellers } = region;
2054
- return {
2055
- id,
2056
- sellers,
2057
- };
2058
- },
2059
- };
2060
- //# sourceMappingURL=query.js.map
2061
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/review.js
2062
- const StoreReview = {
2063
- reviewRating: () => ({
2064
- ratingValue: 5,
2065
- bestRating: 5,
2066
- }),
2067
- author: () => ({
2068
- name: '',
2069
- }),
2070
- };
2071
- //# sourceMappingURL=review.js.map
2072
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/searchResult.js
2073
-
2074
-
2075
- const isRootFacet = (facet, isDepartment, isBrand) => isDepartment
2076
- ? facet.key === 'category-1'
2077
- : isBrand
2078
- ? facet.key === 'brand'
2079
- : false;
2080
- const StoreSearchResult = {
2081
- suggestions: async (root, _, ctx) => {
2082
- const { clients: { search }, } = ctx;
2083
- const { searchArgs } = root;
2084
- // If there's no search query, suggest the most popular searches.
2085
- if (!searchArgs.query) {
2086
- const topSearches = await search.topSearches();
2087
- return {
2088
- terms: topSearches.searches.map((item) => ({
2089
- value: item.term,
2090
- count: item.count,
2091
- })),
2092
- products: [],
2093
- };
2094
- }
2095
- const { productSearchPromise } = root;
2096
- const [terms, productSearchResult] = await Promise.all([
2097
- search.suggestedTerms(searchArgs),
2098
- productSearchPromise,
2099
- ]);
2100
- const skus = productSearchResult.products
2101
- .map((product) => {
2102
- // What determines the presentation of the SKU is the price order
2103
- // https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
2104
- const maybeSku = pickBestSku(product.items);
2105
- return maybeSku && enhanceSku(maybeSku, product);
2106
- })
2107
- .filter((sku) => !!sku);
2108
- const { searches } = terms;
2109
- return {
2110
- terms: searches.map((item) => ({ value: item.term, count: item.count })),
2111
- products: skus,
2112
- };
2113
- },
2114
- products: async ({ productSearchPromise }) => {
2115
- const productSearchResult = await productSearchPromise;
2116
- const skus = productSearchResult.products
2117
- .map((product) => {
2118
- // What determines the presentation of the SKU is the price order
2119
- // https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
2120
- const maybeSku = pickBestSku(product.items);
2121
- return maybeSku && enhanceSku(maybeSku, product);
2122
- })
2123
- .filter((sku) => !!sku);
2124
- return {
2125
- pageInfo: {
2126
- hasNextPage: productSearchResult.pagination.after.length > 0,
2127
- hasPreviousPage: productSearchResult.pagination.before.length > 0,
2128
- startCursor: '0',
2129
- endCursor: productSearchResult.recordsFiltered.toString(),
2130
- totalCount: productSearchResult.recordsFiltered,
2131
- },
2132
- edges: skus.map((sku, index) => ({
2133
- node: sku,
2134
- cursor: index.toString(),
2135
- })),
2136
- };
2137
- },
2138
- facets: async ({ searchArgs }, _, ctx) => {
2139
- const { clients: { search: is }, } = ctx;
2140
- ctx.storage.searchArgs = searchArgs;
2141
- const { facets = [] } = await is.facets(searchArgs);
2142
- const isCollectionPage = !searchArgs.query;
2143
- const isDepartment = searchArgs.selectedFacets?.length
2144
- ? searchArgs.selectedFacets[0].key === 'category-1'
2145
- : false;
2146
- const isBrand = searchArgs.selectedFacets?.length
2147
- ? searchArgs.selectedFacets[0].key === 'brand'
2148
- : false;
2149
- const filteredFacets = facets
2150
- // Remove root facet on category and brand pages
2151
- // TODO: Hide category filters for category pages. E.g. /office/desks
2152
- .filter((facet) => !isCollectionPage || !isRootFacet(facet, isDepartment, isBrand));
2153
- return filteredFacets;
2154
- },
2155
- metadata: async ({ searchArgs, productSearchPromise }) => {
2156
- if (!searchArgs.query) {
2157
- return null;
2158
- }
2159
- const productSearchResult = await productSearchPromise;
2160
- return {
2161
- isTermMisspelled: productSearchResult.correction?.misspelled ?? false,
2162
- logicalOperator: productSearchResult.operator,
2163
- };
2164
- },
2165
- };
2166
- //# sourceMappingURL=searchResult.js.map
2167
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/seo.js
2168
- const StoreSeo = {
2169
- title: ({ title }) => title ?? '',
2170
- description: ({ description }) => description ?? '',
2171
- canonical: ({ canonical }) => canonical ?? '',
2172
- titleTemplate: () => '',
2173
- };
2174
- //# sourceMappingURL=seo.js.map
2175
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/shippingSLA.js
2176
- const units = ['bd', 'd', 'h', 'm'];
2177
- const isUnit = (x) => units.includes(x);
2178
- const localizedEstimates = {
2179
- bd: {
2180
- 0: 'Today',
2181
- 1: 'In 1 business day',
2182
- other: `Up to # business days`,
2183
- },
2184
- d: {
2185
- 0: 'Today',
2186
- 1: 'In 1 day',
2187
- other: 'Up to # days',
2188
- },
2189
- h: {
2190
- 0: 'Now',
2191
- 1: 'In 1 hour',
2192
- other: 'Up to # hours',
2193
- },
2194
- m: {
2195
- 0: 'Now',
2196
- 1: 'In 1 minute',
2197
- other: 'Up to # minutes',
2198
- },
2199
- };
2200
- /**
2201
- * Transforms estimate (e.g 3bd) into friendly format (e.g Up to 3 business days)
2202
- * based on https://github.com/vtex-apps/shipping-estimate-translator/blob/13e17055d6353dd3f3f4c31bae77ab049002809b/messages/en.json
2203
- */
2204
- const getLocalizedEstimates = (estimate) => {
2205
- const [amount, unit] = [estimate.split(/\D+/)[0], estimate.split(/[0-9]+/)[1]];
2206
- const isAmountNumber = amount !== '' && !Number.isNaN(Number(amount));
2207
- const isUnitValid = isUnit(unit);
2208
- if (!isAmountNumber || !isUnitValid) {
2209
- return '';
2210
- }
2211
- const amountKey = Number(amount) < 2 ? Number(amount) : 'other';
2212
- return localizedEstimates[unit][amountKey].replace('#', amount) ?? '';
2213
- };
2214
- const ShippingSLA = {
2215
- carrier: (root) => root?.friendlyName ?? root?.name ?? '',
2216
- price: (root) => (root?.price ? root.price / 100 : root?.price),
2217
- localizedEstimates: (root) => root?.shippingEstimate ? getLocalizedEstimates(root.shippingEstimate) : '',
2218
- };
2219
- //# sourceMappingURL=shippingSLA.js.map
2220
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/utils/skuVariants.js
2221
- function findSkuVariantImage(availableImages) {
2222
- return (availableImages.find((imageProperties) => imageProperties.imageLabel === 'skuvariation') ?? availableImages[0]);
2223
- }
2224
- function createSlugsMap(variants, dominantVariantName, baseSlug) {
2225
- /**
2226
- * Maps property value combinations to their respective SKU's slug. Enables
2227
- * us to retrieve the slug for the SKU that matches the currently selected
2228
- * variations in O(1) time.
2229
- *
2230
- * Example: `'Color-Red-Size-40': 'classic-shoes-37'`
2231
- */
2232
- const slugsMap = {};
2233
- variants.forEach((variant) => {
2234
- const skuSpecificationProperties = variant.variations;
2235
- if (skuSpecificationProperties.length === 0) {
2236
- return;
2237
- }
2238
- // Make sure that the 'name-value' pair for the dominant variation
2239
- // is always the first one.
2240
- const dominantNameValue = `${dominantVariantName}-${skuSpecificationProperties.find((variationDetails) => variationDetails.name === dominantVariantName)?.values[0] ?? ''}`;
2241
- const skuVariantKey = skuSpecificationProperties.reduce((acc, property) => {
2242
- const shouldIgnore = property.name === dominantVariantName;
2243
- if (shouldIgnore) {
2244
- return acc;
2245
- }
2246
- return acc + `-${property.name}-${property.values[0]}`;
2247
- }, dominantNameValue);
2248
- slugsMap[skuVariantKey] = `${baseSlug}-${variant.itemId}`;
2249
- });
2250
- return slugsMap;
2251
- }
2252
- function getActiveSkuVariations(variations) {
2253
- const activeVariations = {};
2254
- variations.forEach((variation) => {
2255
- activeVariations[variation.name] = variation.values[0];
2256
- });
2257
- return activeVariations;
2258
- }
2259
- function getVariantsByName(skuSpecifications) {
2260
- const variants = {};
2261
- skuSpecifications?.forEach((specification) => {
2262
- variants[specification.field.originalName ?? specification.field.name] =
2263
- specification.values.map((value) => value.originalName ?? value.name);
2264
- });
2265
- return variants;
2266
- }
2267
- function compare(a, b) {
2268
- // Values are always represented as Strings, so we need to handle numbers
2269
- // in this special case.
2270
- if (!Number.isNaN(Number(a) - Number(b))) {
2271
- return Number(a) - Number(b);
2272
- }
2273
- if (a < b) {
2274
- return -1;
2275
- }
2276
- if (a > b) {
2277
- return 1;
2278
- }
2279
- return 0;
2280
- }
2281
- function sortVariants(variantsByName) {
2282
- const sortedVariants = variantsByName;
2283
- for (const variantProperty in variantsByName) {
2284
- variantsByName[variantProperty].sort((a, b) => compare(a.value, b.value));
2285
- }
2286
- return sortedVariants;
2287
- }
2288
- function getFormattedVariations(variants, dominantVariantName, dominantVariantValue) {
2289
- /**
2290
- * SKU options already formatted and indexed by their property name.
2291
- *
2292
- * Ex: {
2293
- * `Size`: [
2294
- * { label: '42', value: '42' },
2295
- * { label: '41', value: '41' },
2296
- * { label: '39', value: '39' },
2297
- * ]
2298
- * }
2299
- */
2300
- const variantsByName = {};
2301
- const previouslySeenPropertyValues = new Set();
2302
- variants.forEach((variant) => {
2303
- if (variant.variations.length === 0) {
2304
- return;
2305
- }
2306
- const variantImageToUse = findSkuVariantImage(variant.images);
2307
- const dominantVariantEntry = variant.variations.find((variation) => variation.name === dominantVariantName);
2308
- const matchesDominantVariant = dominantVariantEntry?.values[0] === dominantVariantValue;
2309
- if (!matchesDominantVariant) {
2310
- const nameValueIdentifier = `${dominantVariantName}-${dominantVariantEntry?.values[0]}`;
2311
- if (!dominantVariantEntry ||
2312
- previouslySeenPropertyValues.has(nameValueIdentifier)) {
2313
- return;
2314
- }
2315
- previouslySeenPropertyValues.add(nameValueIdentifier);
2316
- const formattedVariant = {
2317
- src: variantImageToUse.imageUrl,
2318
- alt: variantImageToUse.imageLabel ?? '',
2319
- label: `${dominantVariantName}: ${dominantVariantEntry.values[0]}`,
2320
- value: dominantVariantEntry.values[0],
2321
- };
2322
- if (variantsByName[dominantVariantEntry.name]) {
2323
- variantsByName[dominantVariantEntry.name].push(formattedVariant);
2324
- }
2325
- else {
2326
- variantsByName[dominantVariantEntry.name] = [formattedVariant];
2327
- }
2328
- return;
2329
- }
2330
- variant.variations.forEach((variationProperty) => {
2331
- const nameValueIdentifier = `${variationProperty.name}-${variationProperty.values[0]}`;
2332
- if (previouslySeenPropertyValues.has(nameValueIdentifier)) {
2333
- return;
2334
- }
2335
- previouslySeenPropertyValues.add(nameValueIdentifier);
2336
- const formattedVariant = {
2337
- src: variantImageToUse.imageUrl,
2338
- alt: variantImageToUse.imageLabel ?? '',
2339
- label: `${variationProperty.name}: ${variationProperty.values[0]}`,
2340
- value: variationProperty.values[0],
2341
- };
2342
- if (variantsByName[variationProperty.name]) {
2343
- variantsByName[variationProperty.name].push(formattedVariant);
2344
- }
2345
- else {
2346
- variantsByName[variationProperty.name] = [formattedVariant];
2347
- }
2348
- });
2349
- });
2350
- return sortVariants(variantsByName);
2351
- }
2352
- //# sourceMappingURL=skuVariants.js.map
2353
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/resolvers/skuVariations.js
2354
-
2355
- const SkuVariants = {
2356
- activeVariations: (root) => getActiveSkuVariations(root.variations),
2357
- allVariantsByName: (root) => getVariantsByName(root.isVariantOf.skuSpecifications),
2358
- slugsMap: (root, args) => createSlugsMap(root.isVariantOf.items, args.dominantVariantName ?? root.variations[0]?.name, root.isVariantOf.linkText),
2359
- availableVariations: (root, args) => {
2360
- const dominantVariantName = args.dominantVariantName ?? root.variations[0]?.name;
2361
- const activeVariations = getActiveSkuVariations(root.variations);
2362
- const activeDominantVariationValue = activeVariations[dominantVariantName];
2363
- const filteredFormattedVariations = getFormattedVariations(root.isVariantOf.items, dominantVariantName, activeDominantVariationValue);
2364
- return filteredFormattedVariations;
2365
- },
2366
- };
2367
- //# sourceMappingURL=skuVariations.js.map
2368
- ;// CONCATENATED MODULE: ../api/dist/esm/src/platforms/vtex/index.js
2369
-
2370
-
2371
-
2372
-
2373
-
2374
-
2375
-
2376
-
2377
-
2378
-
2379
-
2380
-
2381
-
2382
-
2383
-
2384
-
2385
-
2386
-
2387
-
2388
-
2389
- const Resolvers = {
2390
- StoreCollection: StoreCollection,
2391
- StoreAggregateOffer: StoreAggregateOffer,
2392
- StoreProduct: StoreProduct,
2393
- StoreSeo: StoreSeo,
2394
- StoreFacet: StoreFacet,
2395
- StoreFacetBoolean: StoreFacetBoolean,
2396
- StoreFacetRange: StoreFacetRange,
2397
- StoreFacetValueBoolean: StoreFacetValueBoolean,
2398
- StoreOffer: StoreOffer,
2399
- StoreAggregateRating: StoreAggregateRating,
2400
- StoreReview: StoreReview,
2401
- StoreProductGroup: StoreProductGroup,
2402
- StoreSearchResult: StoreSearchResult,
2403
- StorePropertyValue: StorePropertyValue,
2404
- SkuVariants: SkuVariants,
2405
- ShippingSLA: ShippingSLA,
2406
- ObjectOrString: ObjectOrString,
2407
- Query: Query,
2408
- Mutation: Mutation,
2409
- };
2410
- const getContextFactory = (options) => (ctx) => {
2411
- ctx.storage = {
2412
- channel: ChannelMarshal.parse(options.channel),
2413
- flags: options.flags ?? {},
2414
- locale: options.locale,
2415
- cookies: new Map(),
2416
- };
2417
- ctx.clients = getClients(options, ctx);
2418
- ctx.loaders = getLoaders(options, ctx);
2419
- return ctx;
2420
- };
2421
- const getResolvers = (_) => Resolvers;
2422
- //# sourceMappingURL=index.js.map
2423
-
2424
- /***/ }),
2425
-
2426
- /***/ 941:
2427
- /***/ ((__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) => {
2428
-
2429
-
2430
- // UNUSED EXPORTS: getTelemetry
2431
-
2432
- // EXTERNAL MODULE: external "@opentelemetry/sdk-trace-base"
2433
- var sdk_trace_base_ = __webpack_require__(1283);
2434
- // EXTERNAL MODULE: external "@opentelemetry/resources"
2435
- var resources_ = __webpack_require__(4161);
2436
- // EXTERNAL MODULE: external "@opentelemetry/exporter-trace-otlp-grpc"
2437
- var exporter_trace_otlp_grpc_ = __webpack_require__(5196);
2438
- // EXTERNAL MODULE: external "@opentelemetry/sdk-logs"
2439
- var sdk_logs_ = __webpack_require__(2793);
2440
- // EXTERNAL MODULE: external "@opentelemetry/exporter-logs-otlp-grpc"
2441
- var exporter_logs_otlp_grpc_ = __webpack_require__(6969);
2442
- // EXTERNAL MODULE: external "@opentelemetry/api"
2443
- var api_ = __webpack_require__(4691);
2444
- // EXTERNAL MODULE: external "@opentelemetry/api-logs"
2445
- var api_logs_ = __webpack_require__(8973);
2446
- // EXTERNAL MODULE: external "graphql"
2447
- var external_graphql_ = __webpack_require__(7343);
2448
- ;// CONCATENATED MODULE: ../api/dist/esm/src/telemetry/useFaststoreTelemetry.js
2449
-
2450
-
2451
-
2452
-
2453
-
2454
-
2455
- var AttributeName;
2456
- (function (AttributeName) {
2457
- AttributeName["EXECUTION_ERROR"] = "graphql.error";
2458
- AttributeName["EXECUTION_RESULT"] = "graphql.result";
2459
- AttributeName["RESOLVER_EXECUTION_ERROR"] = "graphql.resolver.error";
2460
- AttributeName["RESOLVER_EXCEPTION"] = "graphql.resolver.exception";
2461
- AttributeName["RESOLVER_FIELD_NAME"] = "graphql.resolver.fieldName";
2462
- AttributeName["RESOLVER_TYPE_NAME"] = "graphql.resolver.typeName";
2463
- AttributeName["RESOLVER_RESULT_TYPE"] = "graphql.resolver.resultType";
2464
- AttributeName["RESOLVER_ARGS"] = "graphql.resolver.args";
2465
- AttributeName["EXECUTION_OPERATION_NAME"] = "graphql.operation.name";
2466
- AttributeName["EXECUTION_OPERATION_TYPE"] = "graphql.operation.type";
2467
- AttributeName["EXECUTION_OPERATION_DOCUMENT"] = "graphql.document";
2468
- AttributeName["EXECUTION_VARIABLES"] = "graphql.variables";
2469
- })(AttributeName || (AttributeName = {}));
2470
- const tracingSpanSymbol = Symbol('OPEN_TELEMETRY_GRAPHQL');
2471
- function getResolverSpanKey(path) {
2472
- const nodes = [];
2473
- // If the first node (after reversed, it will be the last one) is an integer, that is, identifies a list,
2474
- // we don't want to include it in the key. Note that this will only happen when analysing .prev paths in
2475
- // a list of elements. We just want to remove the initial node that is a integer, not all of them.
2476
- //
2477
- // Nodes with keys 6bc73341b2a183fc::product::image::0::url would not be able to find
2478
- // parents with key 6bc73341b2a183fc::product::image because of the "0" list index -
2479
- // it would search for 6bc73341b2a183fc::product::image::0
2480
- let currentPath = nodes.length === 0 && Number.isInteger(path.key) ? path.prev : path;
2481
- while (currentPath) {
2482
- nodes.push(currentPath.key);
2483
- currentPath = currentPath.prev;
2484
- }
2485
- return [...nodes].reverse().join('.');
2486
- }
2487
- const useFaststoreTelemetry_getFaststoreTelemetryPlugin = (tracingProvider, loggerProvider, serviceName, experimentalSendLogs) => {
2488
- return function useFaststoreTelemetry() {
2489
- const tracer = tracingProvider.getTracer(serviceName);
2490
- const logger = loggerProvider.getLogger(serviceName);
2491
- const resolverContextsByRootSpans = {};
2492
- return {
2493
- onPluginInit({ addPlugin }) {
2494
- addPlugin(
2495
- // eslint-disable-next-line
2496
- useOnResolve(({ info, context }) => {
2497
- if (context &&
2498
- typeof context === 'object' &&
2499
- context[tracingSpanSymbol]) {
2500
- tracer.getActiveSpanProcessor();
2501
- const rootContextSpanId = context[tracingSpanSymbol].spanContext().spanId;
2502
- const { fieldName, returnType, parentType, path } = info;
2503
- const previousResolverSpanKey = path.prev && getResolverSpanKey(path.prev);
2504
- let ctx = null;
2505
- if (previousResolverSpanKey &&
2506
- resolverContextsByRootSpans[rootContextSpanId][previousResolverSpanKey]) {
2507
- ctx =
2508
- resolverContextsByRootSpans[rootContextSpanId][previousResolverSpanKey];
2509
- }
2510
- else {
2511
- ctx = openTelTrace.setSpan(openTelContext.active(), context[tracingSpanSymbol]);
2512
- resolverContextsByRootSpans[rootContextSpanId] =
2513
- resolverContextsByRootSpans[rootContextSpanId] ?? {};
2514
- }
2515
- const resolverIndexInList = Number.isInteger(path.prev?.key)
2516
- ? `[${path.prev?.key}]`
2517
- : '';
2518
- const resolverSpan = tracer.startSpan(`${parentType.toString()}.${fieldName}${resolverIndexInList}`, {
2519
- attributes: {
2520
- [AttributeName.RESOLVER_FIELD_NAME]: fieldName,
2521
- [AttributeName.RESOLVER_TYPE_NAME]: parentType.toString(),
2522
- [AttributeName.RESOLVER_RESULT_TYPE]: returnType.toString(),
2523
- 'meta.span.path': getResolverSpanKey(path),
2524
- },
2525
- }, ctx);
2526
- const resolverCtx = openTelTrace.setSpan(ctx, resolverSpan);
2527
- resolverContextsByRootSpans[rootContextSpanId][getResolverSpanKey(path)] = resolverCtx;
2528
- return ({ result }) => {
2529
- if (result instanceof Error) {
2530
- resolverSpan.setAttributes({
2531
- error: true,
2532
- 'exception.category': AttributeName.RESOLVER_EXECUTION_ERROR,
2533
- 'exception.message': result.message,
2534
- 'exception.type': result.name,
2535
- });
2536
- resolverSpan.recordException(result);
2537
- }
2538
- resolverSpan.end();
2539
- };
2540
- }
2541
- return () => { };
2542
- }));
2543
- },
2544
- onExecute({ args, extendContext }) {
2545
- const operationType = args.document.definitions
2546
- .filter((def) => def.kind === Kind.OPERATION_DEFINITION)
2547
- .map((def) => def.operation)?.[0];
2548
- // Span name according to Semantic Conventions
2549
- // https://github.com/open-telemetry/semantic-conventions
2550
- let spanName = 'GraphQL Operation';
2551
- if (operationType && args.operationName) {
2552
- spanName = `${operationType} ${args.operationName}`;
2553
- }
2554
- else if (operationType && !args.operationName) {
2555
- spanName = operationType;
2556
- }
2557
- const executionSpan = tracer.startSpan(spanName, {
2558
- kind: SpanKind.SERVER,
2559
- attributes: {
2560
- [AttributeName.EXECUTION_OPERATION_NAME]: args.operationName ?? undefined,
2561
- [AttributeName.EXECUTION_OPERATION_TYPE]: operationType ?? undefined,
2562
- [AttributeName.EXECUTION_OPERATION_DOCUMENT]: print(args.document),
2563
- },
2564
- });
2565
- const executeContext = openTelContext.active();
2566
- const resultCbs = {
2567
- onExecuteDone({ result }) {
2568
- if (isAsyncIterable(result)) {
2569
- executionSpan.end();
2570
- // eslint-disable-next-line no-console
2571
- console.warn(`Plugin "newrelic" encountered a AsyncIterator which is not supported yet, so tracing data is not available for the operation.`);
2572
- return;
2573
- }
2574
- const logRecord = {
2575
- context: executeContext,
2576
- attributes: {
2577
- 'service.name': 'faststore-api',
2578
- 'service.version': '1.12.38',
2579
- 'service.name_and_version': 'faststore-api@1.12.38',
2580
- 'vtex.search_index': 'faststore_beta_api',
2581
- [AttributeName.EXECUTION_OPERATION_NAME]: args.operationName ?? undefined,
2582
- [AttributeName.EXECUTION_OPERATION_DOCUMENT]: print(args.document),
2583
- [AttributeName.EXECUTION_VARIABLES]: JSON.stringify(args.variableValues ?? {}),
2584
- },
2585
- };
2586
- if (typeof result.data !== 'undefined' &&
2587
- !(result.errors && result.errors.length > 0)) {
2588
- logRecord.severityNumber = SeverityNumber.INFO;
2589
- logRecord.severityText = 'Info';
2590
- logRecord.attributes[AttributeName.EXECUTION_RESULT] =
2591
- JSON.stringify(result);
2592
- }
2593
- if (result.errors && result.errors.length > 0) {
2594
- logRecord.severityNumber = SeverityNumber.ERROR;
2595
- logRecord.severityText = 'Error';
2596
- logRecord.attributes[AttributeName.EXECUTION_ERROR] =
2597
- JSON.stringify(result.errors);
2598
- executionSpan.setAttributes({
2599
- error: true,
2600
- 'exception.category': AttributeName.EXECUTION_ERROR,
2601
- 'exception.message': JSON.stringify(result.errors),
2602
- });
2603
- }
2604
- if (experimentalSendLogs) {
2605
- logger.emit(logRecord);
2606
- }
2607
- executionSpan.end();
2608
- },
2609
- };
2610
- extendContext({
2611
- [tracingSpanSymbol]: executionSpan,
2612
- });
2613
- return resultCbs;
2614
- },
2615
- };
2616
- };
2617
- };
2618
- //# sourceMappingURL=useFaststoreTelemetry.js.map
2619
- // EXTERNAL MODULE: ../api/dist/esm/package.json
2620
- var esm_package = __webpack_require__(2828);
2621
- ;// CONCATENATED MODULE: ../api/dist/esm/src/telemetry/index.js
2622
-
2623
-
2624
-
2625
-
2626
-
2627
-
2628
-
2629
- const FASTSTORE_API_VERSION = esm_package/* version */.i8;
2630
- // TODO: These urls are hardcoded for now, but they should be configurable via ENV variables
2631
- // They are only acessible from within the VTEX network, so they are not a security risk
2632
- const TRACE_COLLECTOR_URL = 'opentelemetry-collector.vtex.systems';
2633
- const TRACE_COLLECTOR_URL_DEV = 'opentelemetry-collector-beta.vtex.systems';
2634
- const LOG_COLLECTOR_URL = 'opentelemetry-collector.vtex.systems';
2635
- function getTelemetry(APIOptions, telemetryOptions) {
2636
- const honeycombCollectorOptions = {
2637
- url: telemetryOptions?.mode === 'dev'
2638
- ? TRACE_COLLECTOR_URL_DEV
2639
- : TRACE_COLLECTOR_URL,
2640
- };
2641
- const openSearchCollectorOptions = {
2642
- url: LOG_COLLECTOR_URL,
2643
- };
2644
- // Create a new tracer provider
2645
- const tracerProvider = new BasicTracerProvider({
2646
- resource: new Resource({
2647
- 'service.name': 'faststore-api',
2648
- 'service.version': FASTSTORE_API_VERSION,
2649
- 'service.name_and_version': `faststore-api@${FASTSTORE_API_VERSION}`,
2650
- platform: APIOptions.platform,
2651
- [`${APIOptions.platform}.account`]: APIOptions.account,
2652
- [`${APIOptions.platform}.environment`]: APIOptions.environment,
2653
- // TODO: include the following properties in the logs
2654
- // [`${APIOptions.platform}.options.hideUnavailableItems`]:
2655
- // APIOptions.hideUnavailableItems,
2656
- // [`${APIOptions.platform}.flags.enableOrderFormSync`]:
2657
- // APIOptions.flags?.enableOrderFormSync,
2658
- // channel: APIOptions.channel,
2659
- locale: APIOptions.locale,
2660
- }),
2661
- });
2662
- const loggerProvider = new LoggerProvider();
2663
- // Create trace exporter
2664
- const honeycombExporter = new OTLPTraceExporter(honeycombCollectorOptions);
2665
- // Create log exporter
2666
- const openSearchExporter = new OTLPLogsExporter(openSearchCollectorOptions);
2667
- // Set up a span processor to export spans to Honeycomb
2668
- const honeyCombSpanProcessor = new SimpleSpanProcessor(honeycombExporter);
2669
- // Set up a log record processor to export spans to OpenSearch
2670
- const openSearchLogProcessor = new SimpleLogRecordProcessor(openSearchExporter);
2671
- // Register the span processor with the tracer provider
2672
- tracerProvider.addSpanProcessor(honeyCombSpanProcessor);
2673
- // Register the log record processor with the log provider
2674
- loggerProvider.addLogRecordProcessor(openSearchLogProcessor);
2675
- if (telemetryOptions?.mode === 'verbose' ||
2676
- telemetryOptions?.mode === 'dev') {
2677
- // Set up a console exporter for verbose mode
2678
- const consoleExporter = new ConsoleSpanExporter();
2679
- const verboseTraceProcessor = new SimpleSpanProcessor(consoleExporter);
2680
- // Set up processors for verbose mode
2681
- const consoleLogExporter = new ConsoleLogRecordExporter();
2682
- const veboseLogRecordExporter = new SimpleLogRecordProcessor(consoleLogExporter);
2683
- tracerProvider.addSpanProcessor(verboseTraceProcessor);
2684
- loggerProvider.addLogRecordProcessor(veboseLogRecordExporter);
2685
- }
2686
- const useFaststoreTelemetry = getFaststoreTelemetryPlugin(
2687
- // The @opentelemetry/sdk-trace-base was renamed from @opentelemetry/tracing but the
2688
- // envelop plugin doesn't support this change yet. This causes the class type to be incompatible,
2689
- // even if they are the same. https://github.com/n1ru4l/envelop/issues/1610
2690
- tracerProvider, loggerProvider, 'faststore-api', telemetryOptions?.experimentalSendLogs ?? false);
2691
- return { useFaststoreTelemetry };
2692
- }
2693
- //# sourceMappingURL=index.js.map
2694
-
2695
- /***/ }),
2696
-
2697
- /***/ 3999:
2698
- /***/ ((module, __webpack_exports__, __webpack_require__) => {
2699
-
2700
- __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
2701
- /* unused harmony export typeDefs */
2702
- /* harmony import */ var graphql__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7343);
2703
- /* harmony import */ var graphql__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(graphql__WEBPACK_IMPORTED_MODULE_0__);
2704
- /* harmony import */ var _graphql_tools_load_files__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5774);
2705
- var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_graphql_tools_load_files__WEBPACK_IMPORTED_MODULE_1__]);
2706
- _graphql_tools_load_files__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
2707
-
2708
-
2709
- // Empty string ('') is interpreted as the current dir. Referencing it as './' won't work.
2710
- const typeDefs = (0,_graphql_tools_load_files__WEBPACK_IMPORTED_MODULE_1__.loadFilesSync)('', { extensions: ['.graphql'] })
2711
- .map(graphql__WEBPACK_IMPORTED_MODULE_0__.print)
2712
- .join('\n');
2713
- //# sourceMappingURL=index.js.map
2714
- __webpack_async_result__();
2715
- } catch(e) { __webpack_async_result__(e); } });
2716
-
2717
- /***/ }),
2718
-
2719
- /***/ 194:
2720
- /***/ ((module, __webpack_exports__, __webpack_require__) => {
2721
-
2722
- __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
2723
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2724
- /* harmony export */ "j": () => (/* binding */ OverriddenDefaultBreadcrumb)
2725
- /* harmony export */ });
2726
- /* harmony import */ var src_customizations_src_components_overrides_Breadcrumb__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3661);
2727
- /* harmony import */ var src_sdk_overrides_getOverriddenSection__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8788);
2728
- var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([src_sdk_overrides_getOverriddenSection__WEBPACK_IMPORTED_MODULE_0__]);
2729
- src_sdk_overrides_getOverriddenSection__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
2730
-
2731
-
2732
-
2733
- /**
2734
- * This component exists to support overrides 1.0
2735
- *
2736
- * This allows users to override the default Breadcrumb section present in the Headless CMS
2737
- */
2738
- const OverriddenDefaultBreadcrumb = (0,src_sdk_overrides_getOverriddenSection__WEBPACK_IMPORTED_MODULE_0__/* .getOverriddenSection */ .v)(src_customizations_src_components_overrides_Breadcrumb__WEBPACK_IMPORTED_MODULE_1__/* .override */ .K);
2739
- __webpack_async_result__();
2740
- } catch(e) { __webpack_async_result__(e); } });
2741
-
2742
- /***/ }),
2743
-
2744
- /***/ 3661:
2745
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2746
-
2747
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2748
- /* harmony export */ "K": () => (/* binding */ override)
2749
- /* harmony export */ });
2750
- // This is an example of how it can be used on the starter.
2751
- const SECTION = 'Breadcrumb';
2752
- const override = {
2753
- section: SECTION
2754
- };
2755
-
2756
-
2757
- /***/ }),
2758
-
2759
- /***/ 9297:
2760
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2761
-
2762
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2763
- /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
2764
- /* harmony export */ });
2765
- const resolvers = {};
2766
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (resolvers);
2767
-
2768
- /***/ }),
2769
-
2770
- /***/ 8299:
2771
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2772
-
2773
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2774
- /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
2775
- /* harmony export */ });
2776
- const resolvers = {};
2777
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (resolvers);
2778
-
2779
- /***/ }),
2780
-
2781
- /***/ 9685:
2782
- /***/ ((module, __webpack_exports__, __webpack_require__) => {
2783
-
2784
- __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
2785
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2786
- /* harmony export */ "h": () => (/* binding */ execute)
2787
- /* harmony export */ });
2788
- /* unused harmony export getEnvelop */
2789
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1423);
2790
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
2791
- /* harmony import */ var _envelop_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9664);
2792
- /* harmony import */ var _envelop_graphql_jit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7886);
2793
- /* harmony import */ var _envelop_parser_cache__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4656);
2794
- /* harmony import */ var _envelop_validation_cache__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6093);
2795
- /* harmony import */ var _faststore_api__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7397);
2796
- /* harmony import */ var graphql__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7343);
2797
- /* harmony import */ var graphql__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(graphql__WEBPACK_IMPORTED_MODULE_6__);
2798
- /* harmony import */ var _graphql_tools_schema__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(6550);
2799
- /* harmony import */ var _graphql_tools_load_files__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(5774);
2800
- /* harmony import */ var _generated_graphql_persisted_json__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(6984);
2801
- /* harmony import */ var _customizations_src_graphql_vtex_resolvers__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(8299);
2802
- /* harmony import */ var _customizations_src_graphql_thirdParty_resolvers__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(9297);
2803
- /* harmony import */ var _options__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1001);
2804
- var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_envelop_core__WEBPACK_IMPORTED_MODULE_1__, _envelop_graphql_jit__WEBPACK_IMPORTED_MODULE_2__, _envelop_parser_cache__WEBPACK_IMPORTED_MODULE_3__, _envelop_validation_cache__WEBPACK_IMPORTED_MODULE_4__, _faststore_api__WEBPACK_IMPORTED_MODULE_5__, _graphql_tools_schema__WEBPACK_IMPORTED_MODULE_7__, _graphql_tools_load_files__WEBPACK_IMPORTED_MODULE_8__]);
2805
- ([_envelop_core__WEBPACK_IMPORTED_MODULE_1__, _envelop_graphql_jit__WEBPACK_IMPORTED_MODULE_2__, _envelop_parser_cache__WEBPACK_IMPORTED_MODULE_3__, _envelop_validation_cache__WEBPACK_IMPORTED_MODULE_4__, _faststore_api__WEBPACK_IMPORTED_MODULE_5__, _graphql_tools_schema__WEBPACK_IMPORTED_MODULE_7__, _graphql_tools_load_files__WEBPACK_IMPORTED_MODULE_8__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
2806
- /* eslint-disable react-hooks/rules-of-hooks */
2807
-
2808
-
2809
-
2810
-
2811
-
2812
-
2813
-
2814
-
2815
-
2816
-
2817
-
2818
-
2819
-
2820
- const persistedQueries = new Map(Object.entries(_generated_graphql_persisted_json__WEBPACK_IMPORTED_MODULE_9__));
2821
- const apiContextFactory = (0,_faststore_api__WEBPACK_IMPORTED_MODULE_5__/* .getContextFactory */ .E9)(_options__WEBPACK_IMPORTED_MODULE_10__/* .apiOptions */ .e);
2822
-
2823
- const formatError = err => {
2824
- if (err instanceof graphql__WEBPACK_IMPORTED_MODULE_6__.GraphQLError && (0,_faststore_api__WEBPACK_IMPORTED_MODULE_5__/* .isFastStoreError */ .T9)(err.originalError)) {
2825
- return err;
2826
- }
2827
-
2828
- console.error(err);
2829
- return new graphql__WEBPACK_IMPORTED_MODULE_6__.GraphQLError('Sorry, something went wrong.');
2830
- };
2831
-
2832
- function loadGeneratedSchema() {
2833
- return (0,_graphql_tools_load_files__WEBPACK_IMPORTED_MODULE_8__.loadFilesSync)(path__WEBPACK_IMPORTED_MODULE_0___default().join(process.cwd(), '@generated', 'graphql'), {
2834
- extensions: ['graphql']
2835
- });
2836
- }
2837
-
2838
- function getFinalAPISchema() {
2839
- const generatedSchema = loadGeneratedSchema();
2840
- const nativeResolvers = (0,_faststore_api__WEBPACK_IMPORTED_MODULE_5__/* .getResolvers */ .yd)(_options__WEBPACK_IMPORTED_MODULE_10__/* .apiOptions */ .e);
2841
- return (0,_graphql_tools_schema__WEBPACK_IMPORTED_MODULE_7__.makeExecutableSchema)({
2842
- typeDefs: generatedSchema,
2843
- resolvers: [nativeResolvers, _customizations_src_graphql_vtex_resolvers__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .Z, _customizations_src_graphql_thirdParty_resolvers__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .Z]
2844
- });
2845
- }
2846
-
2847
- const getEnvelop = async () => (0,_envelop_core__WEBPACK_IMPORTED_MODULE_1__.envelop)({
2848
- plugins: [(0,_envelop_core__WEBPACK_IMPORTED_MODULE_1__.useSchema)(getFinalAPISchema()), (0,_envelop_core__WEBPACK_IMPORTED_MODULE_1__.useExtendContext)(apiContextFactory), (0,_envelop_core__WEBPACK_IMPORTED_MODULE_1__.useMaskedErrors)({
2849
- formatError
2850
- }), (0,_envelop_graphql_jit__WEBPACK_IMPORTED_MODULE_2__.useGraphQlJit)(), (0,_envelop_validation_cache__WEBPACK_IMPORTED_MODULE_4__.useValidationCache)(), (0,_envelop_parser_cache__WEBPACK_IMPORTED_MODULE_3__.useParserCache)()]
2851
- });
2852
- const envelopPromise = getEnvelop();
2853
- const execute = async (options, envelopContext = {
2854
- headers: {}
2855
- }) => {
2856
- const {
2857
- operationName,
2858
- variables,
2859
- query: maybeQuery
2860
- } = options;
2861
- const query = maybeQuery ?? persistedQueries.get(operationName);
2862
-
2863
- if (query == null) {
2864
- throw new Error(`No query found for operationName: ${operationName}`);
2865
- }
2866
-
2867
- const enveloped = await envelopPromise;
2868
- const {
2869
- parse,
2870
- contextFactory,
2871
- execute: run,
2872
- schema
2873
- } = enveloped(envelopContext);
2874
- const contextValue = await contextFactory(envelopContext);
2875
- const {
2876
- data,
2877
- errors
2878
- } = await run({
2879
- schema,
2880
- document: parse(query),
2881
- variableValues: variables,
2882
- contextValue,
2883
- operationName
2884
- });
2885
- return {
2886
- data,
2887
- errors,
2888
- extensions: {
2889
- cookies: contextValue.storage.cookies,
2890
- cacheControl: contextValue.cacheControl
2891
- }
2892
- };
2893
- };
2894
- __webpack_async_result__();
2895
- } catch(e) { __webpack_async_result__(e); } });
2896
-
2897
- /***/ }),
2898
-
2899
- /***/ 1001:
2900
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2901
-
2902
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2903
- /* harmony export */ "e": () => (/* binding */ apiOptions)
2904
- /* harmony export */ });
2905
- /* harmony import */ var _faststore_config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7183);
2906
- /* harmony import */ var _faststore_config__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_faststore_config__WEBPACK_IMPORTED_MODULE_0__);
2907
-
2908
- const apiOptions = {
2909
- platform: (_faststore_config__WEBPACK_IMPORTED_MODULE_0___default().platform),
2910
- account: (_faststore_config__WEBPACK_IMPORTED_MODULE_0___default().api.storeId),
2911
- environment: (_faststore_config__WEBPACK_IMPORTED_MODULE_0___default().api.environment),
2912
- hideUnavailableItems: (_faststore_config__WEBPACK_IMPORTED_MODULE_0___default().api.hideUnavailableItems),
2913
- incrementAddress: (_faststore_config__WEBPACK_IMPORTED_MODULE_0___default().api.incrementAddress),
2914
- channel: (_faststore_config__WEBPACK_IMPORTED_MODULE_0___default().session.channel),
2915
- locale: (_faststore_config__WEBPACK_IMPORTED_MODULE_0___default().session.locale),
2916
- flags: {
2917
- enableOrderFormSync: true
2918
- }
2919
- };
2920
-
2921
- /***/ }),
2922
-
2923
- /***/ 2828:
2924
- /***/ ((module) => {
2925
-
2926
- module.exports = JSON.parse('{"u2":"@faststore/api","i8":"2.2.69"}');
2927
-
2928
- /***/ }),
2929
-
2930
- /***/ 6984:
2931
- /***/ ((module) => {
2932
-
2933
- module.exports = JSON.parse('{"ServerCollectionPageQuery":"query ServerCollectionPageQuery($slug: String!) {\\n collection(slug: $slug) {\\n id\\n seo {\\n title\\n description\\n }\\n breadcrumbList {\\n itemListElement {\\n item\\n name\\n position\\n }\\n }\\n meta {\\n selectedFacets {\\n key\\n value\\n }\\n }\\n }\\n}\\n","ServerProductQuery":"query ServerProductQuery($locator: [IStoreSelectedFacet!]!) {\\n product(locator: $locator) {\\n id: productID\\n seo {\\n title\\n description\\n canonical\\n }\\n brand {\\n name\\n }\\n sku\\n gtin\\n name\\n description\\n releaseDate\\n breadcrumbList {\\n itemListElement {\\n item\\n name\\n position\\n }\\n }\\n image {\\n url\\n alternateName\\n }\\n offers {\\n lowPrice\\n highPrice\\n priceCurrency\\n offers {\\n availability\\n price\\n priceValidUntil\\n priceCurrency\\n itemCondition\\n seller {\\n identifier\\n }\\n listPrice\\n }\\n }\\n isVariantOf {\\n productGroupID\\n name\\n skuVariants {\\n activeVariations\\n slugsMap\\n availableVariations\\n }\\n }\\n additionalProperty {\\n propertyID\\n name\\n value\\n valueReference\\n }\\n }\\n}\\n","ValidateCartMutation":"mutation ValidateCartMutation($cart: IStoreCart!, $session: IStoreSession!) {\\n validateCart(cart: $cart, session: $session) {\\n order {\\n orderNumber\\n acceptedOffer {\\n seller {\\n identifier\\n }\\n quantity\\n price\\n listPrice\\n itemOffered {\\n sku\\n name\\n image {\\n url\\n alternateName\\n }\\n brand {\\n name\\n }\\n isVariantOf {\\n productGroupID\\n name\\n skuVariants {\\n activeVariations\\n slugsMap\\n availableVariations\\n }\\n }\\n gtin\\n additionalProperty {\\n propertyID\\n name\\n value\\n valueReference\\n }\\n }\\n }\\n }\\n messages {\\n text\\n status\\n }\\n }\\n}\\n","SubscribeToNewsletter":"mutation SubscribeToNewsletter($data: IPersonNewsletter!) {\\n subscribeToNewsletter(data: $data) {\\n id\\n }\\n}\\n","ClientManyProductsQuery":"query ClientManyProductsQuery($first: Int!, $after: String, $sort: StoreSort!, $term: String!, $selectedFacets: [IStoreSelectedFacet!]!) {\\n search(\\n first: $first\\n after: $after\\n sort: $sort\\n term: $term\\n selectedFacets: $selectedFacets\\n ) {\\n products {\\n pageInfo {\\n totalCount\\n }\\n edges {\\n node {\\n id: productID\\n slug\\n sku\\n brand {\\n brandName: name\\n name\\n }\\n name\\n gtin\\n isVariantOf {\\n productGroupID\\n name\\n }\\n image {\\n url\\n alternateName\\n }\\n offers {\\n lowPrice\\n offers {\\n availability\\n price\\n listPrice\\n quantity\\n seller {\\n identifier\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n}\\n","ClientProductGalleryQuery":"query ClientProductGalleryQuery($first: Int!, $after: String!, $sort: StoreSort!, $term: String!, $selectedFacets: [IStoreSelectedFacet!]!) {\\n search(\\n first: $first\\n after: $after\\n sort: $sort\\n term: $term\\n selectedFacets: $selectedFacets\\n ) {\\n products {\\n pageInfo {\\n totalCount\\n }\\n }\\n facets {\\n ... on StoreFacetRange {\\n key\\n label\\n min {\\n selected\\n absolute\\n }\\n max {\\n selected\\n absolute\\n }\\n __typename\\n }\\n ... on StoreFacetBoolean {\\n key\\n label\\n values {\\n label\\n value\\n selected\\n quantity\\n }\\n __typename\\n }\\n }\\n metadata {\\n isTermMisspelled\\n logicalOperator\\n }\\n }\\n}\\n","ClientProductQuery":"query ClientProductQuery($locator: [IStoreSelectedFacet!]!) {\\n product(locator: $locator) {\\n id: productID\\n sku\\n name\\n gtin\\n description\\n isVariantOf {\\n name\\n productGroupID\\n skuVariants {\\n activeVariations\\n slugsMap\\n availableVariations\\n }\\n }\\n image {\\n url\\n alternateName\\n }\\n brand {\\n name\\n }\\n offers {\\n lowPrice\\n offers {\\n availability\\n price\\n listPrice\\n seller {\\n identifier\\n }\\n }\\n }\\n additionalProperty {\\n propertyID\\n name\\n value\\n valueReference\\n }\\n }\\n}\\n","ClientSearchSuggestionsQuery":"query ClientSearchSuggestionsQuery($term: String!, $selectedFacets: [IStoreSelectedFacet!]) {\\n search(first: 5, term: $term, selectedFacets: $selectedFacets) {\\n suggestions {\\n terms {\\n value\\n }\\n products {\\n id: productID\\n slug\\n sku\\n brand {\\n brandName: name\\n name\\n }\\n name\\n gtin\\n isVariantOf {\\n productGroupID\\n name\\n }\\n image {\\n url\\n alternateName\\n }\\n offers {\\n lowPrice\\n offers {\\n availability\\n price\\n listPrice\\n quantity\\n seller {\\n identifier\\n }\\n }\\n }\\n }\\n }\\n products {\\n pageInfo {\\n totalCount\\n }\\n }\\n metadata {\\n isTermMisspelled\\n logicalOperator\\n }\\n }\\n}\\n","ClientTopSearchSuggestionsQuery":"query ClientTopSearchSuggestionsQuery($term: String!, $selectedFacets: [IStoreSelectedFacet!]) {\\n search(first: 5, term: $term, selectedFacets: $selectedFacets) {\\n suggestions {\\n terms {\\n value\\n }\\n }\\n }\\n}\\n","ValidateSession":"mutation ValidateSession($session: IStoreSession!, $search: String!) {\\n validateSession(session: $session, search: $search) {\\n locale\\n channel\\n country\\n addressType\\n postalCode\\n deliveryMode {\\n deliveryChannel\\n deliveryMethod\\n deliveryWindow {\\n startDate\\n endDate\\n }\\n }\\n geoCoordinates {\\n latitude\\n longitude\\n }\\n currency {\\n code\\n symbol\\n }\\n person {\\n id\\n email\\n givenName\\n familyName\\n }\\n }\\n}\\n","ClientShippingSimulationQuery":"query ClientShippingSimulationQuery($postalCode: String!, $country: String!, $items: [IShippingItem!]!) {\\n shipping(items: $items, postalCode: $postalCode, country: $country) {\\n address {\\n city\\n neighborhood\\n state\\n }\\n logisticsInfo {\\n slas {\\n carrier\\n price\\n availableDeliveryWindows {\\n startDateUtc\\n endDateUtc\\n price\\n listPrice\\n }\\n shippingEstimate\\n localizedEstimates\\n }\\n }\\n }\\n}\\n"}');
2934
-
2935
- /***/ })
2936
-
2937
- };
2938
- ;