@vtex/api 6.48.1-beta → 6.48.1-beta.2

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 (440) hide show
  1. package/gen/manifest.schema +5 -3
  2. package/lib/HttpClient/GraphQLClient.d.ts +3 -2
  3. package/lib/HttpClient/GraphQLClient.js +5 -1
  4. package/lib/HttpClient/HttpClient.d.ts +9 -7
  5. package/lib/HttpClient/HttpClient.js +70 -27
  6. package/lib/HttpClient/agents.d.ts +6 -0
  7. package/lib/HttpClient/agents.js +43 -0
  8. package/lib/HttpClient/index.d.ts +1 -7
  9. package/lib/HttpClient/index.js +22 -16
  10. package/lib/HttpClient/middlewares/cache.d.ts +9 -3
  11. package/lib/HttpClient/middlewares/cache.js +130 -35
  12. package/lib/HttpClient/middlewares/cancellationToken.d.ts +2 -2
  13. package/lib/HttpClient/middlewares/cancellationToken.js +5 -2
  14. package/lib/HttpClient/middlewares/inflight.d.ts +1 -1
  15. package/lib/HttpClient/middlewares/inflight.js +7 -3
  16. package/lib/HttpClient/middlewares/memoization.d.ts +1 -1
  17. package/lib/HttpClient/middlewares/memoization.js +13 -4
  18. package/lib/HttpClient/middlewares/metrics.js +25 -38
  19. package/lib/HttpClient/middlewares/notFound.d.ts +1 -1
  20. package/lib/HttpClient/middlewares/notFound.js +5 -2
  21. package/lib/HttpClient/middlewares/recorder.d.ts +1 -1
  22. package/lib/HttpClient/middlewares/recorder.js +21 -12
  23. package/lib/HttpClient/middlewares/request/HttpAgentSingleton.d.ts +11 -0
  24. package/lib/HttpClient/middlewares/request/HttpAgentSingleton.js +31 -0
  25. package/lib/HttpClient/middlewares/request/index.d.ts +18 -0
  26. package/lib/HttpClient/middlewares/request/index.js +88 -0
  27. package/lib/HttpClient/middlewares/request/setupAxios/index.d.ts +1 -0
  28. package/lib/HttpClient/middlewares/request/setupAxios/index.js +22 -0
  29. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.d.ts +2 -0
  30. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +55 -0
  31. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.d.ts +2 -0
  32. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +8 -0
  33. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.d.ts +8 -0
  34. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.js +56 -0
  35. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.d.ts +4 -0
  36. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +32 -0
  37. package/lib/HttpClient/middlewares/tracing.d.ts +15 -0
  38. package/lib/HttpClient/middlewares/tracing.js +62 -0
  39. package/lib/HttpClient/typings.d.ts +46 -12
  40. package/lib/HttpClient/typings.js +1 -0
  41. package/lib/caches/DiskCache.d.ts +1 -1
  42. package/lib/caches/DiskCache.js +3 -2
  43. package/lib/caches/LRUCache.d.ts +3 -3
  44. package/lib/caches/LRUCache.js +6 -1
  45. package/lib/caches/LRUDiskCache.d.ts +2 -2
  46. package/lib/caches/LRUDiskCache.js +8 -3
  47. package/lib/caches/MultilayeredCache.d.ts +2 -2
  48. package/lib/caches/MultilayeredCache.js +8 -7
  49. package/lib/caches/index.js +20 -7
  50. package/lib/caches/typings.d.ts +5 -5
  51. package/lib/clients/IOClient.d.ts +13 -0
  52. package/lib/clients/IOClient.js +20 -0
  53. package/lib/clients/IOClients.d.ts +29 -25
  54. package/lib/clients/IOClients.js +36 -28
  55. package/lib/{HttpClient → clients}/IOGraphQLClient.d.ts +4 -4
  56. package/lib/{HttpClient → clients}/IOGraphQLClient.js +3 -2
  57. package/lib/{HttpClient → clients/apps}/AppClient.d.ts +3 -3
  58. package/lib/{HttpClient → clients/apps}/AppClient.js +11 -5
  59. package/lib/{HttpClient → clients/apps}/AppGraphQLClient.d.ts +3 -3
  60. package/lib/{HttpClient → clients/apps}/AppGraphQLClient.js +11 -5
  61. package/lib/clients/apps/Billing.d.ts +12 -0
  62. package/lib/clients/{Billing.js → apps/Billing.js} +9 -3
  63. package/lib/clients/{Builder.d.ts → apps/Builder.d.ts} +12 -11
  64. package/lib/clients/{Builder.js → apps/Builder.js} +51 -23
  65. package/lib/clients/apps/MessagesGraphQL.d.ts +61 -0
  66. package/lib/clients/apps/MessagesGraphQL.js +122 -0
  67. package/lib/clients/{Settings.d.ts → apps/Settings.d.ts} +5 -4
  68. package/lib/clients/apps/Settings.js +39 -0
  69. package/lib/clients/apps/catalogGraphQL/brand.d.ts +13 -0
  70. package/lib/clients/apps/catalogGraphQL/brand.js +19 -0
  71. package/lib/clients/apps/catalogGraphQL/category.d.ts +11 -0
  72. package/lib/clients/apps/catalogGraphQL/category.js +17 -0
  73. package/lib/clients/apps/catalogGraphQL/index.d.ts +22 -0
  74. package/lib/clients/apps/catalogGraphQL/index.js +89 -0
  75. package/lib/clients/apps/catalogGraphQL/product.d.ts +25 -0
  76. package/lib/clients/apps/catalogGraphQL/product.js +31 -0
  77. package/lib/clients/apps/catalogGraphQL/sku.d.ts +26 -0
  78. package/lib/clients/apps/catalogGraphQL/sku.js +31 -0
  79. package/lib/clients/apps/index.d.ts +7 -0
  80. package/lib/clients/apps/index.js +23 -0
  81. package/lib/{HttpClient → clients/external}/ExternalClient.d.ts +3 -3
  82. package/lib/{HttpClient → clients/external}/ExternalClient.js +10 -2
  83. package/lib/clients/external/ID.d.ts +23 -0
  84. package/lib/clients/external/ID.js +61 -0
  85. package/lib/clients/external/Masterdata.d.ts +94 -0
  86. package/lib/clients/external/Masterdata.js +225 -0
  87. package/lib/clients/external/PaymentProvider.d.ts +31 -0
  88. package/lib/clients/external/PaymentProvider.js +43 -0
  89. package/lib/clients/external/index.d.ts +4 -0
  90. package/lib/clients/external/index.js +20 -0
  91. package/lib/clients/index.d.ts +9 -21
  92. package/lib/clients/index.js +27 -24
  93. package/lib/clients/infra/Apps.d.ts +93 -0
  94. package/lib/clients/infra/Apps.js +511 -0
  95. package/lib/clients/infra/Assets.d.ts +35 -0
  96. package/lib/clients/infra/Assets.js +166 -0
  97. package/lib/clients/infra/BillingMetrics.d.ts +13 -0
  98. package/lib/clients/infra/BillingMetrics.js +16 -0
  99. package/lib/clients/infra/Events.d.ts +12 -0
  100. package/lib/clients/infra/Events.js +34 -0
  101. package/lib/clients/infra/Housekeeper.d.ts +10 -0
  102. package/lib/clients/infra/Housekeeper.js +31 -0
  103. package/lib/{HttpClient → clients/infra}/InfraClient.d.ts +3 -3
  104. package/lib/{HttpClient → clients/infra}/InfraClient.js +10 -4
  105. package/lib/clients/infra/Registry.d.ts +65 -0
  106. package/lib/clients/infra/Registry.js +209 -0
  107. package/lib/clients/infra/Router.d.ts +34 -0
  108. package/lib/clients/infra/Router.js +82 -0
  109. package/lib/clients/infra/Sphinx.d.ts +13 -0
  110. package/lib/clients/infra/Sphinx.js +30 -0
  111. package/lib/clients/infra/VBase.d.ts +61 -0
  112. package/lib/clients/infra/VBase.js +197 -0
  113. package/lib/clients/infra/Workspaces.d.ts +18 -0
  114. package/lib/clients/infra/Workspaces.js +66 -0
  115. package/lib/clients/infra/index.d.ts +11 -0
  116. package/lib/clients/infra/index.js +27 -0
  117. package/lib/{HttpClient → clients/janus}/JanusClient.d.ts +4 -4
  118. package/lib/{HttpClient → clients/janus}/JanusClient.js +8 -3
  119. package/lib/clients/janus/LicenseManager.d.ts +7 -0
  120. package/lib/clients/janus/LicenseManager.js +59 -0
  121. package/lib/clients/{Segment.d.ts → janus/Segment.d.ts} +7 -11
  122. package/lib/clients/janus/Segment.js +89 -0
  123. package/lib/clients/{Session.d.ts → janus/Session.d.ts} +4 -4
  124. package/lib/clients/{Session.js → janus/Session.js} +25 -13
  125. package/lib/clients/{Tenant.d.ts → janus/Tenant.d.ts} +7 -8
  126. package/lib/clients/janus/Tenant.js +29 -0
  127. package/lib/clients/janus/index.d.ts +5 -0
  128. package/lib/clients/janus/index.js +21 -0
  129. package/lib/constants.d.ts +50 -2
  130. package/lib/constants.js +55 -1
  131. package/lib/errors/AuthenticationError.js +1 -0
  132. package/lib/errors/ForbiddenError.js +1 -0
  133. package/lib/errors/NotFoundError.js +1 -0
  134. package/lib/errors/RequestCancelledError.js +1 -0
  135. package/lib/errors/ResolverError.d.ts +1 -1
  136. package/lib/errors/ResolverError.js +4 -3
  137. package/lib/errors/ResolverWarning.d.ts +1 -1
  138. package/lib/errors/ResolverWarning.js +3 -2
  139. package/lib/errors/TooManyRequestsError.js +1 -0
  140. package/lib/errors/UserInputError.js +1 -0
  141. package/lib/errors/index.js +22 -11
  142. package/lib/index.d.ts +9 -7
  143. package/lib/index.js +31 -16
  144. package/lib/metrics/MetricsAccumulator.d.ts +3 -20
  145. package/lib/metrics/MetricsAccumulator.js +44 -27
  146. package/lib/responses.d.ts +5 -46
  147. package/lib/service/index.d.ts +2 -0
  148. package/lib/service/index.js +35 -0
  149. package/lib/service/loaders.d.ts +8 -0
  150. package/lib/service/loaders.js +57 -0
  151. package/lib/service/logger/console.d.ts +10 -0
  152. package/lib/service/logger/console.js +40 -0
  153. package/lib/service/logger/index.d.ts +2 -28
  154. package/lib/service/logger/index.js +16 -68
  155. package/lib/service/logger/logger.d.ts +29 -0
  156. package/lib/service/logger/logger.js +62 -0
  157. package/lib/service/logger/metricsLogger.d.ts +40 -0
  158. package/lib/service/logger/metricsLogger.js +150 -0
  159. package/lib/service/master.d.ts +2 -0
  160. package/lib/service/master.js +89 -0
  161. package/lib/service/metrics/requestMetricsMiddleware.d.ts +2 -0
  162. package/lib/service/metrics/requestMetricsMiddleware.js +46 -0
  163. package/lib/service/tracing/TracerSingleton.d.ts +7 -0
  164. package/lib/service/tracing/TracerSingleton.js +49 -0
  165. package/lib/service/tracing/metrics/MetricNames.d.ts +60 -0
  166. package/lib/service/tracing/metrics/MetricNames.js +45 -0
  167. package/lib/service/tracing/metrics/instruments.d.ts +9 -0
  168. package/lib/service/tracing/metrics/instruments.js +19 -0
  169. package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.d.ts +9 -0
  170. package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +26 -0
  171. package/lib/service/tracing/tracingMiddlewares.d.ts +5 -0
  172. package/lib/service/tracing/tracingMiddlewares.js +117 -0
  173. package/lib/service/worker/index.d.ts +11 -0
  174. package/lib/service/worker/index.js +197 -0
  175. package/lib/service/worker/listeners.d.ts +3 -0
  176. package/lib/{utils/unhandled.js → service/worker/listeners.js} +12 -16
  177. package/lib/service/{Service.d.ts → worker/runtime/Service.d.ts} +5 -5
  178. package/lib/service/{Service.js → worker/runtime/Service.js} +3 -1
  179. package/lib/service/worker/runtime/builtIn/handlers.d.ts +4 -0
  180. package/lib/service/worker/runtime/builtIn/handlers.js +34 -0
  181. package/lib/service/worker/runtime/builtIn/middlewares.d.ts +4 -0
  182. package/lib/service/worker/runtime/builtIn/middlewares.js +43 -0
  183. package/lib/service/worker/runtime/events/index.d.ts +4 -0
  184. package/lib/service/worker/runtime/events/index.js +48 -0
  185. package/lib/service/worker/runtime/events/middlewares/body.d.ts +3 -0
  186. package/lib/service/worker/runtime/events/middlewares/body.js +26 -0
  187. package/lib/service/worker/runtime/events/middlewares/context.d.ts +3 -0
  188. package/lib/service/worker/runtime/events/middlewares/context.js +23 -0
  189. package/lib/service/worker/runtime/events/router.d.ts +2 -0
  190. package/lib/service/worker/runtime/events/router.js +29 -0
  191. package/lib/service/worker/runtime/graphql/index.d.ts +6 -0
  192. package/lib/service/worker/runtime/graphql/index.js +29 -0
  193. package/lib/service/worker/runtime/graphql/middlewares/context.d.ts +2 -0
  194. package/lib/service/worker/runtime/graphql/middlewares/context.js +17 -0
  195. package/lib/service/worker/runtime/graphql/middlewares/error.js +97 -0
  196. package/lib/service/worker/runtime/graphql/middlewares/query.d.ts +3 -0
  197. package/lib/service/worker/runtime/graphql/middlewares/query.js +54 -0
  198. package/lib/service/worker/runtime/graphql/middlewares/response.js +39 -0
  199. package/lib/service/worker/runtime/graphql/middlewares/run.d.ts +2 -0
  200. package/lib/service/worker/runtime/graphql/middlewares/run.js +21 -0
  201. package/lib/service/worker/runtime/graphql/middlewares/updateSchema.d.ts +5 -0
  202. package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +30 -0
  203. package/lib/service/worker/runtime/graphql/middlewares/upload.d.ts +4 -0
  204. package/lib/service/{graphql → worker/runtime/graphql}/middlewares/upload.js +2 -1
  205. package/lib/service/worker/runtime/graphql/schema/index.d.ts +7 -0
  206. package/lib/service/worker/runtime/graphql/schema/index.js +33 -0
  207. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +6 -0
  208. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +81 -0
  209. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Auth.d.ts +1 -0
  210. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Auth.js +17 -10
  211. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.d.ts +7 -0
  212. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.js +38 -0
  213. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.d.ts +11 -0
  214. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +62 -0
  215. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.d.ts +7 -0
  216. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.js +41 -0
  217. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Sanitize.d.ts +1 -0
  218. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Sanitize.js +7 -0
  219. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.d.ts +6 -0
  220. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +35 -0
  221. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/SmartCacheDirective.d.ts +1 -0
  222. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/SmartCacheDirective.js +9 -3
  223. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.d.ts +7 -0
  224. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +40 -0
  225. package/lib/service/{graphql/schema/schemaDirectives/Translatable.d.ts → worker/runtime/graphql/schema/schemaDirectives/TranslateTo.d.ts} +2 -1
  226. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +34 -0
  227. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.d.ts +22 -0
  228. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +37 -0
  229. package/lib/service/worker/runtime/graphql/schema/typeDefs/index.d.ts +8 -0
  230. package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +14 -0
  231. package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/ioUpload.js +1 -0
  232. package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/sanitizedString.js +8 -3
  233. package/lib/service/worker/runtime/graphql/typings.d.ts +31 -0
  234. package/lib/service/worker/runtime/graphql/utils/cacheControl.d.ts +2 -0
  235. package/lib/service/worker/runtime/graphql/utils/cacheControl.js +34 -0
  236. package/lib/service/worker/runtime/graphql/utils/error.d.ts +2 -0
  237. package/lib/service/worker/runtime/graphql/utils/error.js +78 -0
  238. package/lib/service/worker/runtime/graphql/utils/pathname.js +9 -0
  239. package/lib/service/worker/runtime/graphql/utils/translations.d.ts +14 -0
  240. package/lib/service/worker/runtime/graphql/utils/translations.js +42 -0
  241. package/lib/service/worker/runtime/http/index.d.ts +5 -0
  242. package/lib/service/worker/runtime/http/index.js +61 -0
  243. package/lib/service/worker/runtime/http/middlewares/authTokens.d.ts +3 -0
  244. package/lib/service/{http → worker/runtime/http}/middlewares/authTokens.js +1 -0
  245. package/lib/service/worker/runtime/http/middlewares/cancellationToken.d.ts +3 -0
  246. package/lib/service/{http → worker/runtime/http}/middlewares/cancellationToken.js +3 -1
  247. package/lib/service/worker/runtime/http/middlewares/clients.d.ts +4 -0
  248. package/lib/service/{http → worker/runtime/http}/middlewares/clients.js +1 -0
  249. package/lib/service/worker/runtime/http/middlewares/context.d.ts +4 -0
  250. package/lib/service/worker/runtime/http/middlewares/context.js +39 -0
  251. package/lib/service/worker/runtime/http/middlewares/error.d.ts +2 -0
  252. package/lib/service/{http → worker/runtime/http}/middlewares/error.js +29 -16
  253. package/lib/service/worker/runtime/http/middlewares/rateLimit.d.ts +6 -0
  254. package/lib/service/worker/runtime/http/middlewares/rateLimit.js +43 -0
  255. package/lib/service/{http → worker/runtime/http}/middlewares/requestStats.d.ts +3 -3
  256. package/lib/service/{http → worker/runtime/http}/middlewares/requestStats.js +1 -0
  257. package/lib/service/worker/runtime/http/middlewares/setCookie.d.ts +3 -0
  258. package/lib/service/{http → worker/runtime/http}/middlewares/setCookie.js +6 -5
  259. package/lib/service/worker/runtime/http/middlewares/settings.d.ts +9 -0
  260. package/lib/service/worker/runtime/http/middlewares/settings.js +49 -0
  261. package/lib/service/worker/runtime/http/middlewares/timings.d.ts +3 -0
  262. package/lib/service/{http → worker/runtime/http}/middlewares/timings.js +25 -11
  263. package/lib/service/worker/runtime/http/middlewares/vary.d.ts +3 -0
  264. package/lib/service/{http → worker/runtime/http}/middlewares/vary.js +4 -3
  265. package/lib/service/worker/runtime/http/router.d.ts +2 -0
  266. package/lib/service/worker/runtime/http/router.js +25 -0
  267. package/lib/service/worker/runtime/http/routes.d.ts +19 -0
  268. package/lib/service/worker/runtime/http/routes.js +16 -0
  269. package/lib/service/worker/runtime/method.d.ts +9 -0
  270. package/lib/service/{method.js → worker/runtime/method.js} +2 -1
  271. package/lib/service/worker/runtime/statusTrack.d.ts +14 -0
  272. package/lib/service/worker/runtime/statusTrack.js +43 -0
  273. package/lib/service/worker/runtime/typings.d.ts +173 -0
  274. package/lib/service/worker/runtime/utils/compose.d.ts +5 -0
  275. package/lib/service/worker/runtime/utils/compose.js +14 -0
  276. package/lib/service/worker/runtime/utils/context.d.ts +5 -0
  277. package/lib/service/worker/runtime/utils/context.js +42 -0
  278. package/lib/service/worker/runtime/utils/diff.d.ts +12 -0
  279. package/lib/service/worker/runtime/utils/diff.js +22 -0
  280. package/lib/service/worker/runtime/utils/recorder.d.ts +8 -0
  281. package/lib/service/worker/runtime/utils/recorder.js +38 -0
  282. package/lib/service/worker/runtime/utils/toArray.js +5 -0
  283. package/lib/service/worker/runtime/utils/tokenBucket.d.ts +2 -0
  284. package/lib/service/worker/runtime/utils/tokenBucket.js +17 -0
  285. package/lib/tracing/LogEvents.d.ts +31 -0
  286. package/lib/{service/graphql/utils/array.js → tracing/LogEvents.js} +1 -1
  287. package/lib/tracing/LogFields.d.ts +66 -0
  288. package/lib/tracing/LogFields.js +3 -0
  289. package/lib/tracing/Tags.d.ts +81 -0
  290. package/lib/tracing/Tags.js +8 -0
  291. package/lib/tracing/UserLandTracer.d.ts +27 -0
  292. package/lib/tracing/UserLandTracer.js +58 -0
  293. package/lib/tracing/errorReporting/ErrorReport.d.ts +31 -0
  294. package/lib/tracing/errorReporting/ErrorReport.js +71 -0
  295. package/lib/tracing/index.d.ts +9 -0
  296. package/lib/tracing/index.js +20 -0
  297. package/lib/tracing/spanReference/SpanReferenceTypes.d.ts +4 -0
  298. package/lib/tracing/spanReference/SpanReferenceTypes.js +8 -0
  299. package/lib/tracing/spanReference/createSpanReference.d.ts +3 -0
  300. package/lib/tracing/spanReference/createSpanReference.js +9 -0
  301. package/lib/tracing/utils.d.ts +13 -0
  302. package/lib/tracing/utils.js +42 -0
  303. package/lib/utils/MineWinsConflictsResolver.d.ts +7 -5
  304. package/lib/utils/MineWinsConflictsResolver.js +40 -22
  305. package/lib/utils/app.d.ts +3 -1
  306. package/lib/utils/app.js +40 -21
  307. package/lib/utils/appsStaleIfError.d.ts +2 -1
  308. package/lib/utils/appsStaleIfError.js +33 -12
  309. package/lib/utils/billingOptions.d.ts +36 -3
  310. package/lib/utils/billingOptions.js +9 -3
  311. package/lib/utils/binding.d.ts +3 -3
  312. package/lib/utils/binding.js +5 -2
  313. package/lib/utils/cancel.d.ts +2 -2
  314. package/lib/utils/cancel.js +3 -1
  315. package/lib/utils/conflicts.mock.d.ts +17 -0
  316. package/lib/utils/conflicts.mock.js +28 -0
  317. package/lib/utils/domain.js +2 -1
  318. package/lib/utils/error.js +6 -4
  319. package/lib/utils/index.js +23 -12
  320. package/lib/utils/json.js +1 -0
  321. package/lib/utils/log.d.ts +1 -3
  322. package/lib/utils/log.js +6 -4
  323. package/lib/utils/message.js +11 -4
  324. package/lib/utils/renameBy.js +3 -1
  325. package/lib/utils/retry.js +10 -7
  326. package/lib/utils/status.js +3 -1
  327. package/lib/utils/tenant.d.ts +3 -3
  328. package/lib/utils/tenant.js +5 -2
  329. package/lib/utils/throwOnGraphQLErrors.js +1 -0
  330. package/lib/utils/time.d.ts +7 -7
  331. package/lib/utils/time.js +29 -12
  332. package/package.json +3 -3
  333. package/lib/HttpClient/IOClient.d.ts +0 -13
  334. package/lib/HttpClient/IOClient.js +0 -14
  335. package/lib/HttpClient/factories/index.d.ts +0 -8
  336. package/lib/HttpClient/factories/index.js +0 -31
  337. package/lib/HttpClient/middlewares/request.d.ts +0 -10
  338. package/lib/HttpClient/middlewares/request.js +0 -87
  339. package/lib/IODataSource.d.ts +0 -27
  340. package/lib/IODataSource.js +0 -46
  341. package/lib/clients/Apps.d.ts +0 -84
  342. package/lib/clients/Apps.js +0 -326
  343. package/lib/clients/Assets.d.ts +0 -21
  344. package/lib/clients/Assets.js +0 -110
  345. package/lib/clients/Billing.d.ts +0 -11
  346. package/lib/clients/BillingMetrics.d.ts +0 -12
  347. package/lib/clients/BillingMetrics.js +0 -10
  348. package/lib/clients/Events.d.ts +0 -6
  349. package/lib/clients/Events.js +0 -19
  350. package/lib/clients/Housekeeper.d.ts +0 -11
  351. package/lib/clients/Housekeeper.js +0 -24
  352. package/lib/clients/ID.d.ts +0 -22
  353. package/lib/clients/ID.js +0 -48
  354. package/lib/clients/LicenseManager.d.ts +0 -6
  355. package/lib/clients/LicenseManager.js +0 -43
  356. package/lib/clients/Logger.d.ts +0 -27
  357. package/lib/clients/Logger.js +0 -32
  358. package/lib/clients/Messages.d.ts +0 -18
  359. package/lib/clients/Messages.js +0 -20
  360. package/lib/clients/MessagesGraphQL.d.ts +0 -63
  361. package/lib/clients/MessagesGraphQL.js +0 -50
  362. package/lib/clients/Metadata.d.ts +0 -25
  363. package/lib/clients/Metadata.js +0 -53
  364. package/lib/clients/Registry.d.ts +0 -61
  365. package/lib/clients/Registry.js +0 -147
  366. package/lib/clients/Router.d.ts +0 -33
  367. package/lib/clients/Router.js +0 -50
  368. package/lib/clients/Segment.js +0 -69
  369. package/lib/clients/Settings.js +0 -44
  370. package/lib/clients/Sphinx.d.ts +0 -12
  371. package/lib/clients/Sphinx.js +0 -19
  372. package/lib/clients/Tenant.js +0 -13
  373. package/lib/clients/VBase.d.ts +0 -57
  374. package/lib/clients/VBase.js +0 -116
  375. package/lib/clients/Workspaces.d.ts +0 -17
  376. package/lib/clients/Workspaces.js +0 -38
  377. package/lib/service/Runtime.d.ts +0 -18
  378. package/lib/service/Runtime.js +0 -57
  379. package/lib/service/events/index.d.ts +0 -3
  380. package/lib/service/events/index.js +0 -21
  381. package/lib/service/graphql/index.d.ts +0 -7
  382. package/lib/service/graphql/index.js +0 -33
  383. package/lib/service/graphql/middlewares/error.js +0 -107
  384. package/lib/service/graphql/middlewares/formatters.d.ts +0 -2
  385. package/lib/service/graphql/middlewares/formatters.js +0 -64
  386. package/lib/service/graphql/middlewares/query.d.ts +0 -2
  387. package/lib/service/graphql/middlewares/query.js +0 -32
  388. package/lib/service/graphql/middlewares/response.js +0 -36
  389. package/lib/service/graphql/middlewares/run.d.ts +0 -4
  390. package/lib/service/graphql/middlewares/run.js +0 -55
  391. package/lib/service/graphql/middlewares/schema.d.ts +0 -2
  392. package/lib/service/graphql/middlewares/schema.js +0 -8
  393. package/lib/service/graphql/middlewares/timings.d.ts +0 -2
  394. package/lib/service/graphql/middlewares/timings.js +0 -10
  395. package/lib/service/graphql/middlewares/upload.d.ts +0 -7
  396. package/lib/service/graphql/schema/index.d.ts +0 -3
  397. package/lib/service/graphql/schema/index.js +0 -66
  398. package/lib/service/graphql/schema/messagesLoader.d.ts +0 -4
  399. package/lib/service/graphql/schema/messagesLoader.js +0 -41
  400. package/lib/service/graphql/schema/messagesLoaderV2.d.ts +0 -5
  401. package/lib/service/graphql/schema/messagesLoaderV2.js +0 -44
  402. package/lib/service/graphql/schema/schemaDirectives/Translatable.js +0 -54
  403. package/lib/service/graphql/schema/schemaDirectives/TranslatableV2.d.ts +0 -13
  404. package/lib/service/graphql/schema/schemaDirectives/TranslatableV2.js +0 -67
  405. package/lib/service/graphql/schema/schemaDirectives/index.d.ts +0 -13
  406. package/lib/service/graphql/schema/schemaDirectives/index.js +0 -17
  407. package/lib/service/graphql/schema/typeDefs/index.d.ts +0 -16
  408. package/lib/service/graphql/schema/typeDefs/index.js +0 -21
  409. package/lib/service/graphql/schema/typeDefs/ioMessage.d.ts +0 -8
  410. package/lib/service/graphql/schema/typeDefs/ioMessage.js +0 -33
  411. package/lib/service/graphql/typings.d.ts +0 -21
  412. package/lib/service/graphql/utils/cacheControl.d.ts +0 -6
  413. package/lib/service/graphql/utils/cacheControl.js +0 -38
  414. package/lib/service/graphql/utils/maxAgeEnum.d.ts +0 -6
  415. package/lib/service/graphql/utils/maxAgeEnum.js +0 -17
  416. package/lib/service/graphql/utils/pathname.js +0 -7
  417. package/lib/service/http/index.d.ts +0 -3
  418. package/lib/service/http/index.js +0 -18
  419. package/lib/service/http/middlewares/authTokens.d.ts +0 -3
  420. package/lib/service/http/middlewares/cancellationToken.d.ts +0 -3
  421. package/lib/service/http/middlewares/clients.d.ts +0 -4
  422. package/lib/service/http/middlewares/error.d.ts +0 -3
  423. package/lib/service/http/middlewares/setCookie.d.ts +0 -3
  424. package/lib/service/http/middlewares/timings.d.ts +0 -3
  425. package/lib/service/http/middlewares/vary.d.ts +0 -3
  426. package/lib/service/method.d.ts +0 -9
  427. package/lib/service/typings.d.ts +0 -139
  428. package/lib/service/utils/compose.d.ts +0 -4
  429. package/lib/service/utils/compose.js +0 -11
  430. package/lib/utils/MineWinsConflictsResolver.test.d.ts +0 -1
  431. package/lib/utils/MineWinsConflictsResolver.test.js +0 -134
  432. package/lib/utils/unhandled.d.ts +0 -1
  433. /package/lib/service/{graphql → worker/runtime/graphql}/middlewares/error.d.ts +0 -0
  434. /package/lib/service/{graphql → worker/runtime/graphql}/middlewares/response.d.ts +0 -0
  435. /package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/ioUpload.d.ts +0 -0
  436. /package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/sanitizedString.d.ts +0 -0
  437. /package/lib/service/{graphql → worker/runtime/graphql}/typings.js +0 -0
  438. /package/lib/service/{graphql → worker/runtime/graphql}/utils/pathname.d.ts +0 -0
  439. /package/lib/service/{typings.js → worker/runtime/typings.js} +0 -0
  440. /package/lib/service/{graphql/utils/array.d.ts → worker/runtime/utils/toArray.d.ts} +0 -0
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deprecatedDirectiveTypeDefs = exports.Deprecated = void 0;
4
+ const graphql_1 = require("graphql");
5
+ const graphql_tools_1 = require("graphql-tools");
6
+ const listeners_1 = require("../../../../listeners");
7
+ let lastLog = process.hrtime();
8
+ const LOG_PERIOD_S = 60;
9
+ const hrtimeToS = (time) => time[0] + (time[1] / 1e9);
10
+ class Deprecated extends graphql_tools_1.SchemaDirectiveVisitor {
11
+ visitArgumentDefinition(argument) {
12
+ this.maybeLogToSplunk({
13
+ description: argument.description,
14
+ name: argument.name,
15
+ });
16
+ }
17
+ visitInputFieldDefinition(field) {
18
+ this.maybeLogToSplunk({
19
+ description: field.description,
20
+ name: field.name,
21
+ });
22
+ }
23
+ visitFieldDefinition(field) {
24
+ const { resolve = graphql_1.defaultFieldResolver, name, type } = field;
25
+ const { reason } = this.args;
26
+ field.resolve = (root, args, ctx, info) => {
27
+ var _a, _b, _c;
28
+ this.maybeLogToSplunk({
29
+ headers: ctx.request.headers,
30
+ name,
31
+ query: ((_a = ctx.graphql.query) === null || _a === void 0 ? void 0 : _a.document) && (0, graphql_1.print)((_b = ctx.graphql.query) === null || _b === void 0 ? void 0 : _b.document),
32
+ reason,
33
+ variables: (_c = ctx.graphql.query) === null || _c === void 0 ? void 0 : _c.variables,
34
+ }, ctx.vtex.logger);
35
+ return resolve(root, args, ctx, info);
36
+ };
37
+ }
38
+ maybeLogToSplunk(payload, logger = listeners_1.logger) {
39
+ const now = process.hrtime();
40
+ const timeSinceLastLog = hrtimeToS([
41
+ now[0] - lastLog[0],
42
+ now[1] - lastLog[1],
43
+ ]);
44
+ if (timeSinceLastLog > LOG_PERIOD_S) {
45
+ lastLog = now;
46
+ logger.warn({
47
+ message: 'Deprecated field in use',
48
+ ...payload,
49
+ });
50
+ }
51
+ }
52
+ }
53
+ exports.Deprecated = Deprecated;
54
+ exports.deprecatedDirectiveTypeDefs = `
55
+ directive @deprecated(
56
+ reason: String = "No longer supported"
57
+ ) on
58
+ FIELD_DEFINITION
59
+ | INPUT_FIELD_DEFINITION
60
+ | ARGUMENT_DEFINITION
61
+ | FRAGMENT_DEFINITION
62
+ `;
@@ -0,0 +1,7 @@
1
+ import { GraphQLField } from 'graphql';
2
+ import { SchemaDirectiveVisitor } from 'graphql-tools';
3
+ import { GraphQLServiceContext } from '../../typings';
4
+ export declare class Metric extends SchemaDirectiveVisitor {
5
+ visitFieldDefinition(field: GraphQLField<any, GraphQLServiceContext>): void;
6
+ }
7
+ export declare const metricDirectiveTypeDefs = "\ndirective @metric (\n name: String\n) on FIELD_DEFINITION\n";
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.metricDirectiveTypeDefs = exports.Metric = void 0;
4
+ const graphql_1 = require("graphql");
5
+ const graphql_tools_1 = require("graphql-tools");
6
+ const __1 = require("../../../../../..");
7
+ class Metric extends graphql_tools_1.SchemaDirectiveVisitor {
8
+ visitFieldDefinition(field) {
9
+ const { resolve = graphql_1.defaultFieldResolver, name: fieldName } = field;
10
+ const { name = `${__1.APP.NAME}-${fieldName}` } = this.args;
11
+ field.resolve = async (root, args, ctx, info) => {
12
+ let failedToResolve = false;
13
+ let result = null;
14
+ let ellapsed = [0, 0];
15
+ try {
16
+ const start = process.hrtime();
17
+ result = await resolve(root, args, ctx, info);
18
+ ellapsed = process.hrtime(start);
19
+ }
20
+ catch (error) {
21
+ result = error;
22
+ failedToResolve = true;
23
+ }
24
+ ctx.graphql.status = failedToResolve ? 'error' : 'success';
25
+ const payload = {
26
+ [ctx.graphql.status]: 1,
27
+ };
28
+ metrics.batch(`graphql-metric-${name}`, failedToResolve ? undefined : ellapsed, payload);
29
+ if (failedToResolve) {
30
+ throw result;
31
+ }
32
+ return result;
33
+ };
34
+ }
35
+ }
36
+ exports.Metric = Metric;
37
+ exports.metricDirectiveTypeDefs = `
38
+ directive @metric (
39
+ name: String
40
+ ) on FIELD_DEFINITION
41
+ `;
@@ -6,3 +6,4 @@ export declare class SanitizeDirective extends SchemaDirectiveVisitor {
6
6
  visitArgumentDefinition(argument: GraphQLArgument): void;
7
7
  wrapType(field: any): void;
8
8
  }
9
+ export declare const sanitizeDirectiveTypeDefs = "\ndirective @sanitize(\n allowHTMLTags: Boolean\n stripIgnoreTag: Boolean\n) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION\n";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sanitizeDirectiveTypeDefs = exports.SanitizeDirective = void 0;
3
4
  const graphql_1 = require("graphql");
4
5
  const graphql_tools_1 = require("graphql-tools");
5
6
  const sanitizedString_1 = require("../typeDefs/sanitizedString");
@@ -27,3 +28,9 @@ class SanitizeDirective extends graphql_tools_1.SchemaDirectiveVisitor {
27
28
  }
28
29
  }
29
30
  exports.SanitizeDirective = SanitizeDirective;
31
+ exports.sanitizeDirectiveTypeDefs = `
32
+ directive @sanitize(
33
+ allowHTMLTags: Boolean
34
+ stripIgnoreTag: Boolean
35
+ ) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION
36
+ `;
@@ -0,0 +1,6 @@
1
+ import { GraphQLField } from 'graphql';
2
+ import { SchemaDirectiveVisitor } from 'graphql-tools';
3
+ export declare class SettingsDirective extends SchemaDirectiveVisitor {
4
+ visitFieldDefinition(field: GraphQLField<any, any>): void;
5
+ }
6
+ export declare const settingsDirectiveTypeDefs = "\ndirective @settings(\n settingsType: String\n) on FIELD_DEFINITION\n";
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.settingsDirectiveTypeDefs = exports.SettingsDirective = void 0;
4
+ const graphql_1 = require("graphql");
5
+ const graphql_tools_1 = require("graphql-tools");
6
+ const settings_1 = require("../../../http/middlewares/settings");
7
+ const addSettings = async (settings, ctx) => {
8
+ if (settings === 'pure') {
9
+ return ctx;
10
+ }
11
+ const { clients: { apps, assets } } = ctx;
12
+ const dependenciesSettings = await (0, settings_1.getDependenciesSettings)(apps, assets);
13
+ if (!ctx.vtex) {
14
+ ctx.vtex = {};
15
+ }
16
+ ctx.vtex.settings = { ...ctx.vtex.settings, dependenciesSettings };
17
+ };
18
+ class SettingsDirective extends graphql_tools_1.SchemaDirectiveVisitor {
19
+ visitFieldDefinition(field) {
20
+ const { resolve = graphql_1.defaultFieldResolver } = field;
21
+ const { settingsType } = this.args;
22
+ field.resolve = async (root, args, ctx, info) => {
23
+ if (settingsType) {
24
+ await addSettings(settingsType, ctx);
25
+ }
26
+ return resolve(root, args, ctx, info);
27
+ };
28
+ }
29
+ }
30
+ exports.SettingsDirective = SettingsDirective;
31
+ exports.settingsDirectiveTypeDefs = `
32
+ directive @settings(
33
+ settingsType: String
34
+ ) on FIELD_DEFINITION
35
+ `;
@@ -3,3 +3,4 @@ import { SchemaDirectiveVisitor } from 'graphql-tools';
3
3
  export declare class SmartCacheDirective extends SchemaDirectiveVisitor {
4
4
  visitFieldDefinition(field: GraphQLField<any, any>): void;
5
5
  }
6
+ export declare const smartCacheDirectiveTypeDefs = "\ndirective @smartcache(\n maxAge: String\n) on FIELD_DEFINITION\n";
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.smartCacheDirectiveTypeDefs = exports.SmartCacheDirective = void 0;
3
4
  const graphql_1 = require("graphql");
4
5
  const graphql_tools_1 = require("graphql-tools");
5
- const maxAgeEnum_1 = require("../../utils/maxAgeEnum");
6
+ const constants_1 = require("../../../../../../constants");
6
7
  const ETAG_CONTROL_HEADER = 'x-vtex-etag-control';
7
8
  const DEFAULT_ARGS = {
8
9
  maxAge: undefined,
@@ -11,10 +12,10 @@ class SmartCacheDirective extends graphql_tools_1.SchemaDirectiveVisitor {
11
12
  visitFieldDefinition(field) {
12
13
  const { resolve = graphql_1.defaultFieldResolver } = field;
13
14
  const { maxAge } = this.args || DEFAULT_ARGS;
14
- const maxAgeS = maxAge && maxAgeEnum_1.maxAgeEnums[maxAge];
15
+ const maxAgeS = maxAge && constants_1.MAX_AGE[maxAge];
15
16
  field.resolve = (root, args, context, info) => {
16
17
  if (maxAgeS) {
17
- context.set(ETAG_CONTROL_HEADER, maxAgeS);
18
+ context.set(ETAG_CONTROL_HEADER, `public, max-age=${maxAgeS}`);
18
19
  }
19
20
  context.vtex.recorder = context.state.recorder;
20
21
  return resolve(root, args, context, info);
@@ -22,3 +23,8 @@ class SmartCacheDirective extends graphql_tools_1.SchemaDirectiveVisitor {
22
23
  }
23
24
  }
24
25
  exports.SmartCacheDirective = SmartCacheDirective;
26
+ exports.smartCacheDirectiveTypeDefs = `
27
+ directive @smartcache(
28
+ maxAge: String
29
+ ) on FIELD_DEFINITION
30
+ `;
@@ -0,0 +1,7 @@
1
+ import { GraphQLField } from 'graphql';
2
+ import { SchemaDirectiveVisitor } from 'graphql-tools';
3
+ import { ServiceContext } from '../../../typings';
4
+ export declare class TranslatableV2 extends SchemaDirectiveVisitor {
5
+ visitFieldDefinition(field: GraphQLField<any, ServiceContext>): void;
6
+ }
7
+ export declare const translatableV2DirectiveTypeDefs = "\ndirective @translatableV2(\n behavior: String\n withAppsMetaInfo: Boolean\n) on FIELD_DEFINITION\n";
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.translatableV2DirectiveTypeDefs = exports.TranslatableV2 = void 0;
4
+ const graphql_1 = require("graphql");
5
+ const graphql_tools_1 = require("graphql-tools");
6
+ const translations_1 = require("../../utils/translations");
7
+ const messagesLoaderV2_1 = require("../messagesLoaderV2");
8
+ class TranslatableV2 extends graphql_tools_1.SchemaDirectiveVisitor {
9
+ visitFieldDefinition(field) {
10
+ const { resolve = graphql_1.defaultFieldResolver } = field;
11
+ const { behavior = 'FULL', withAppsMetaInfo = false } = this.args;
12
+ field.resolve = async (root, args, ctx, info) => {
13
+ var _a;
14
+ if (!((_a = ctx.loaders) === null || _a === void 0 ? void 0 : _a.messagesV2)) {
15
+ const { vtex: { locale: to } } = ctx;
16
+ if (to == null) {
17
+ throw new Error('@translatableV2 directive needs the locale variable available in IOContext. You can do this by either setting \`ctx.vtex.locale\` directly or calling this app with \`x-vtex-locale\` header');
18
+ }
19
+ const dependencies = withAppsMetaInfo ? await ctx.clients.apps.getAppsMetaInfos() : undefined;
20
+ ctx.loaders = {
21
+ ...ctx.loaders,
22
+ messagesV2: (0, messagesLoaderV2_1.createMessagesLoader)(ctx.clients, to, dependencies),
23
+ };
24
+ }
25
+ const response = await resolve(root, args, ctx, info);
26
+ const { vtex, loaders: { messagesV2 } } = ctx;
27
+ const handler = (0, translations_1.handleSingleString)(vtex, messagesV2, behavior, 'translatableV2');
28
+ return Array.isArray(response)
29
+ ? Promise.all(response.map(handler))
30
+ : handler(response);
31
+ };
32
+ }
33
+ }
34
+ exports.TranslatableV2 = TranslatableV2;
35
+ exports.translatableV2DirectiveTypeDefs = `
36
+ directive @translatableV2(
37
+ behavior: String
38
+ withAppsMetaInfo: Boolean
39
+ ) on FIELD_DEFINITION
40
+ `;
@@ -1,6 +1,7 @@
1
1
  import { GraphQLField } from 'graphql';
2
2
  import { SchemaDirectiveVisitor } from 'graphql-tools';
3
3
  import { ServiceContext } from '../../../typings';
4
- export declare class Translatable extends SchemaDirectiveVisitor {
4
+ export declare class TranslateTo extends SchemaDirectiveVisitor {
5
5
  visitFieldDefinition(field: GraphQLField<any, ServiceContext>): void;
6
6
  }
7
+ export declare const translateToDirectiveTypeDefs = "\ndirective @translateTo(\n language: String!\n behavior: String\n) on FIELD_DEFINITION\n";
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.translateToDirectiveTypeDefs = exports.TranslateTo = void 0;
4
+ const graphql_1 = require("graphql");
5
+ const graphql_tools_1 = require("graphql-tools");
6
+ const translations_1 = require("../../utils/translations");
7
+ const messagesLoaderV2_1 = require("../messagesLoaderV2");
8
+ class TranslateTo extends graphql_tools_1.SchemaDirectiveVisitor {
9
+ visitFieldDefinition(field) {
10
+ const { resolve = graphql_1.defaultFieldResolver } = field;
11
+ const { language, behavior = 'FULL' } = this.args;
12
+ field.resolve = async (root, args, ctx, info) => {
13
+ var _a;
14
+ if (!((_a = ctx.loaders) === null || _a === void 0 ? void 0 : _a.immutableMessagesV2)) {
15
+ const dependencies = await ctx.clients.apps.getAppsMetaInfos();
16
+ ctx.loaders = {
17
+ ...ctx.loaders,
18
+ immutableMessagesV2: (0, messagesLoaderV2_1.createMessagesLoader)(ctx.clients, language, dependencies),
19
+ };
20
+ }
21
+ const response = (await resolve(root, args, ctx, info));
22
+ const { vtex, loaders: { immutableMessagesV2 }, } = ctx;
23
+ const handler = (0, translations_1.handleSingleString)(vtex, immutableMessagesV2, behavior, 'translateTo');
24
+ return Array.isArray(response) ? Promise.all(response.map(handler)) : handler(response);
25
+ };
26
+ }
27
+ }
28
+ exports.TranslateTo = TranslateTo;
29
+ exports.translateToDirectiveTypeDefs = `
30
+ directive @translateTo(
31
+ language: String!
32
+ behavior: String
33
+ ) on FIELD_DEFINITION
34
+ `;
@@ -0,0 +1,22 @@
1
+ import { Auth } from './Auth';
2
+ import { CacheControl } from './CacheControl';
3
+ import { Deprecated } from './Deprecated';
4
+ import { Metric } from './Metric';
5
+ import { SanitizeDirective } from './Sanitize';
6
+ import { SettingsDirective } from './Settings';
7
+ import { SmartCacheDirective } from './SmartCacheDirective';
8
+ import { TranslatableV2 } from './TranslatableV2';
9
+ import { TranslateTo } from './TranslateTo';
10
+ export { parseTranslatableStringV2, formatTranslatableStringV2 } from '../../utils/translations';
11
+ export declare const nativeSchemaDirectives: {
12
+ auth: typeof Auth;
13
+ cacheControl: typeof CacheControl;
14
+ deprecated: typeof Deprecated;
15
+ metric: typeof Metric;
16
+ sanitize: typeof SanitizeDirective;
17
+ settings: typeof SettingsDirective;
18
+ smartcache: typeof SmartCacheDirective;
19
+ translatableV2: typeof TranslatableV2;
20
+ translateTo: typeof TranslateTo;
21
+ };
22
+ export declare const nativeSchemaDirectivesTypeDefs: string;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nativeSchemaDirectivesTypeDefs = exports.nativeSchemaDirectives = exports.formatTranslatableStringV2 = exports.parseTranslatableStringV2 = void 0;
4
+ const Auth_1 = require("./Auth");
5
+ const CacheControl_1 = require("./CacheControl");
6
+ const Deprecated_1 = require("./Deprecated");
7
+ const Metric_1 = require("./Metric");
8
+ const Sanitize_1 = require("./Sanitize");
9
+ const Settings_1 = require("./Settings");
10
+ const SmartCacheDirective_1 = require("./SmartCacheDirective");
11
+ const TranslatableV2_1 = require("./TranslatableV2");
12
+ const TranslateTo_1 = require("./TranslateTo");
13
+ var translations_1 = require("../../utils/translations");
14
+ Object.defineProperty(exports, "parseTranslatableStringV2", { enumerable: true, get: function () { return translations_1.parseTranslatableStringV2; } });
15
+ Object.defineProperty(exports, "formatTranslatableStringV2", { enumerable: true, get: function () { return translations_1.formatTranslatableStringV2; } });
16
+ exports.nativeSchemaDirectives = {
17
+ auth: Auth_1.Auth,
18
+ cacheControl: CacheControl_1.CacheControl,
19
+ deprecated: Deprecated_1.Deprecated,
20
+ metric: Metric_1.Metric,
21
+ sanitize: Sanitize_1.SanitizeDirective,
22
+ settings: Settings_1.SettingsDirective,
23
+ smartcache: SmartCacheDirective_1.SmartCacheDirective,
24
+ translatableV2: TranslatableV2_1.TranslatableV2,
25
+ translateTo: TranslateTo_1.TranslateTo,
26
+ };
27
+ exports.nativeSchemaDirectivesTypeDefs = [
28
+ Auth_1.authDirectiveTypeDefs,
29
+ CacheControl_1.cacheControlDirectiveTypeDefs,
30
+ Deprecated_1.deprecatedDirectiveTypeDefs,
31
+ Metric_1.metricDirectiveTypeDefs,
32
+ Sanitize_1.sanitizeDirectiveTypeDefs,
33
+ Settings_1.settingsDirectiveTypeDefs,
34
+ SmartCacheDirective_1.smartCacheDirectiveTypeDefs,
35
+ TranslatableV2_1.translatableV2DirectiveTypeDefs,
36
+ TranslateTo_1.translateToDirectiveTypeDefs,
37
+ ].join('\n\n');
@@ -0,0 +1,8 @@
1
+ import { GraphQLScalarType } from 'graphql';
2
+ import { SchemaMetaData } from '../../schema';
3
+ export declare const nativeResolvers: {
4
+ IOSanitizedString: import("./sanitizedString").IOSanitizedStringType;
5
+ IOUpload: GraphQLScalarType;
6
+ Upload: GraphQLScalarType;
7
+ };
8
+ export declare const nativeTypeDefs: (metaData: SchemaMetaData) => string;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nativeTypeDefs = exports.nativeResolvers = void 0;
4
+ const graphql_upload_1 = require("graphql-upload");
5
+ const ramda_1 = require("ramda");
6
+ const ioUpload_1 = require("./ioUpload");
7
+ const sanitizedString_1 = require("./sanitizedString");
8
+ exports.nativeResolvers = {
9
+ 'IOSanitizedString': sanitizedString_1.resolvers,
10
+ 'IOUpload': ioUpload_1.resolvers,
11
+ 'Upload': graphql_upload_1.GraphQLUpload,
12
+ };
13
+ const nativeTypeDefs = (metaData) => (0, ramda_1.reduce)((acc, scalar) => !metaData[scalar] ? `${acc}\nscalar ${scalar}\n` : acc, '', (0, ramda_1.keys)(exports.nativeResolvers));
14
+ exports.nativeTypeDefs = nativeTypeDefs;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvers = exports.scalar = void 0;
3
4
  const graphql_1 = require("graphql");
4
5
  const name = 'IOUpload';
5
6
  exports.scalar = name;
@@ -1,21 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvers = exports.IOSanitizedStringType = exports.scalar = void 0;
3
4
  const graphql_1 = require("graphql");
4
5
  const xss_1 = require("xss");
5
6
  const defaultName = 'IOSanitizedString';
6
7
  exports.scalar = defaultName;
7
8
  const noop = (html) => html;
8
9
  const serialize = (input, options) => {
9
- return xss_1.filterXSS(input, options);
10
+ return (0, xss_1.filterXSS)(input, options);
10
11
  };
11
12
  const parseValue = (value, options) => {
12
- return xss_1.filterXSS(value, options);
13
+ return (0, xss_1.filterXSS)(value, options);
13
14
  };
14
15
  class IOSanitizedStringType extends graphql_1.GraphQLScalarType {
15
16
  constructor(options) {
16
17
  const allowHTMLTags = options && options.allowHTMLTags;
17
18
  const stripIgnoreTag = !options || options.stripIgnoreTag !== false;
18
- const xssOptions = Object.assign({ stripIgnoreTag }, !allowHTMLTags && { whiteList: [] }, stripIgnoreTag && { escapeHtml: noop });
19
+ const xssOptions = {
20
+ stripIgnoreTag,
21
+ ...!allowHTMLTags && { whiteList: [] },
22
+ ...stripIgnoreTag && { escapeHtml: noop },
23
+ };
19
24
  super({
20
25
  name: options ? `Custom${defaultName}` : defaultName,
21
26
  parseLiteral: ast => {
@@ -0,0 +1,31 @@
1
+ import { DocumentNode, execute, GraphQLSchema } from 'graphql';
2
+ import { IOClients } from '../../../../clients/IOClients';
3
+ import { ParamsContext, RecorderState, ServiceContext } from '../typings';
4
+ export interface Query {
5
+ variables?: Record<string, any>;
6
+ operationName?: string;
7
+ document: DocumentNode;
8
+ }
9
+ type TypeFromPromise<T> = T extends Promise<infer U> ? U : T;
10
+ export type GraphQLResponse = TypeFromPromise<ReturnType<typeof execute>>;
11
+ export interface GraphQLCacheControl {
12
+ maxAge: number;
13
+ scope: 'private' | 'public' | 'segment';
14
+ noCache: boolean;
15
+ noStore: boolean;
16
+ }
17
+ export interface GraphQLContext extends ParamsContext {
18
+ graphql: {
19
+ query?: Query;
20
+ graphqlResponse?: GraphQLResponse;
21
+ status: 'success' | 'error';
22
+ cacheControl: GraphQLCacheControl;
23
+ };
24
+ }
25
+ export type GraphQLServiceContext = ServiceContext<IOClients, RecorderState, GraphQLContext>;
26
+ export interface ExecutableSchema {
27
+ schema: GraphQLSchema;
28
+ hasProvider: boolean;
29
+ provider?: string;
30
+ }
31
+ export {};
@@ -0,0 +1,2 @@
1
+ import { GraphQLServiceContext } from '../typings';
2
+ export declare const cacheControlHTTP: (ctx: GraphQLServiceContext) => string;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cacheControlHTTP = void 0;
4
+ const domain_1 = require("../../../../../utils/domain");
5
+ const PRIVATE_ROUTE_REGEX = /_v\/graphql\/private\/v*/;
6
+ const linked = !!process.env.VTEX_APP_LINK;
7
+ const isPrivateRoute = ({ request: { headers } }) => PRIVATE_ROUTE_REGEX.test(headers['x-forwarded-path'] || '');
8
+ const publicRegExp = (endpoint) => new RegExp(`.*${endpoint.replace('.', '\\.')}.*`);
9
+ const isPublicEndpoint = ({ request: { headers } }) => {
10
+ const host = headers['x-forwarded-host'];
11
+ if (headers.origin || !host) {
12
+ return false;
13
+ }
14
+ return domain_1.PUBLIC_DOMAINS.some(endpoint => publicRegExp(endpoint).test(host));
15
+ };
16
+ const cacheControlHTTP = (ctx) => {
17
+ const { graphql: { cacheControl: { maxAge, scope: scopeHint, noCache: noCacheHint, noStore: noStoreHint, }, }, vtex: { production, }, } = ctx;
18
+ const finalHeader = [];
19
+ const noCache = noCacheHint || !production || isPublicEndpoint(ctx);
20
+ if (noCache) {
21
+ finalHeader.push('no-cache');
22
+ }
23
+ const noStore = noStoreHint || linked;
24
+ if (noStore) {
25
+ finalHeader.push('no-store');
26
+ }
27
+ if (!noCache && !noStore) {
28
+ const scope = scopeHint === 'private' || isPrivateRoute(ctx) ? 'private' : 'public';
29
+ finalHeader.push(scope);
30
+ finalHeader.push(`max-age=${maxAge}`);
31
+ }
32
+ return finalHeader.join(',');
33
+ };
34
+ exports.cacheControlHTTP = cacheControlHTTP;
@@ -0,0 +1,2 @@
1
+ import { GraphQLServiceContext } from '../typings';
2
+ export declare const createFormatError: (ctx: GraphQLServiceContext) => (error: any) => any;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createFormatError = void 0;
4
+ const ramda_1 = require("ramda");
5
+ const error_1 = require("../../../../../utils/error");
6
+ const ERROR_FIELD_WHITELIST = ['message', 'path', 'stack', 'extensions', 'statusCode', 'name', 'headers', 'originalError', 'code'];
7
+ const QUERY_FIELDS = ['query', 'operationName', 'variables'];
8
+ const trimVariables = (variables) => {
9
+ if (variables) {
10
+ const stringifiedVariables = JSON.stringify(variables);
11
+ return stringifiedVariables.length <= 1024
12
+ ? stringifiedVariables
13
+ : `${stringifiedVariables.slice(0, 992)} [Truncated: variables too long]`;
14
+ }
15
+ return '';
16
+ };
17
+ const detailsFromCtx = (ctx) => {
18
+ const { headers: { 'x-forwarded-host': forwardedHost, 'x-forwarded-proto': forwardedProto, 'x-vtex-platform': platform, }, vtex: { operationId, requestId, }, } = ctx;
19
+ const queryRest = (0, ramda_1.pick)(QUERY_FIELDS, ctx.graphql.query || {});
20
+ const variables = ctx.request.is('multipart/form-data')
21
+ ? '[GraphQL Upload]'
22
+ : trimVariables(queryRest.variables);
23
+ const query = {
24
+ ...queryRest,
25
+ variables,
26
+ };
27
+ return {
28
+ forwardedHost,
29
+ forwardedProto,
30
+ operationId,
31
+ platform,
32
+ query,
33
+ requestId,
34
+ };
35
+ };
36
+ const formatError = (error, details) => {
37
+ const formattedError = (0, ramda_1.pick)(ERROR_FIELD_WHITELIST, error);
38
+ if (!formattedError.extensions) {
39
+ formattedError.extensions = {
40
+ code: 'INTERNAL_SERVER_ERROR',
41
+ };
42
+ }
43
+ if (formattedError.originalError) {
44
+ formattedError.originalError = (0, error_1.cleanError)(formattedError.originalError);
45
+ if (formattedError.stack === formattedError.originalError.stack) {
46
+ delete formattedError.originalError.stack;
47
+ }
48
+ if (!formattedError.extensions.exception) {
49
+ formattedError.extensions.exception = {
50
+ message: formattedError.originalError.message,
51
+ name: formattedError.originalError.name,
52
+ ...(0, ramda_1.omit)(error_1.SENSITIVE_EXCEPTION_FIELDS, formattedError.originalError),
53
+ sensitive: (0, ramda_1.pick)(error_1.SENSITIVE_EXCEPTION_FIELDS, formattedError.originalError),
54
+ };
55
+ }
56
+ else {
57
+ const mergedException = { ...formattedError.originalError,
58
+ ...formattedError.extensions.exception,
59
+ };
60
+ const extendedException = {
61
+ message: formattedError.originalError.message,
62
+ name: formattedError.originalError.name,
63
+ ...(0, ramda_1.omit)(error_1.SENSITIVE_EXCEPTION_FIELDS, mergedException),
64
+ sensitive: (0, ramda_1.pick)(error_1.SENSITIVE_EXCEPTION_FIELDS, mergedException),
65
+ };
66
+ formattedError.extensions.exception = (0, error_1.cleanError)(extendedException);
67
+ }
68
+ // Make originalError not enumerable to prevent duplicated log and response information
69
+ Object.defineProperty(formattedError, 'originalError', { enumerable: false });
70
+ }
71
+ Object.assign(formattedError, details);
72
+ return formattedError;
73
+ };
74
+ const createFormatError = (ctx) => {
75
+ const details = detailsFromCtx(ctx);
76
+ return (error) => formatError(error, details);
77
+ };
78
+ exports.createFormatError = createFormatError;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generatePathName = void 0;
4
+ const ramda_1 = require("ramda");
5
+ const generatePathName = (rpath) => {
6
+ const pathFieldNames = (0, ramda_1.filter)(value => typeof value === 'string', rpath);
7
+ return pathFieldNames.join('.');
8
+ };
9
+ exports.generatePathName = generatePathName;
@@ -0,0 +1,14 @@
1
+ import { Behavior } from '../../../../../clients';
2
+ import { IOContext } from '../../typings';
3
+ export declare const CONTEXT_REGEX: RegExp;
4
+ export declare const FROM_REGEX: RegExp;
5
+ export declare const CONTENT_REGEX: RegExp;
6
+ export interface TranslatableMessageV2 {
7
+ from?: string;
8
+ content: string;
9
+ context?: string;
10
+ }
11
+ export type TranslationDirectiveType = 'translatableV2' | 'translateTo';
12
+ export declare const parseTranslatableStringV2: (rawMessage: string) => TranslatableMessageV2;
13
+ export declare const formatTranslatableStringV2: ({ from, content, context }: TranslatableMessageV2) => string;
14
+ export declare const handleSingleString: (ctx: IOContext, loader: import("dataloader")<import("../../../../../clients").Message, string>, behavior: Behavior, directiveName: TranslationDirectiveType) => (rawMessage: string | null) => Promise<string | null>;