@faststore/core 3.0.17 → 3.0.21

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