@vtex/api 6.48.0 → 6.48.1-beta

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