@vtex/api 6.47.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 (404) 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 -29
  56. package/lib/clients/IOClients.js +26 -36
  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 +5 -11
  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 -5
  168. package/lib/utils/MineWinsConflictsResolver.js +17 -23
  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 -1846
  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/Metadata.d.ts +0 -26
  242. package/lib/clients/infra/Metadata.js +0 -83
  243. package/lib/clients/infra/Registry.d.ts +0 -59
  244. package/lib/clients/infra/Router.d.ts +0 -34
  245. package/lib/clients/infra/Router.js +0 -81
  246. package/lib/clients/infra/Sphinx.d.ts +0 -13
  247. package/lib/clients/infra/Sphinx.js +0 -29
  248. package/lib/clients/infra/VBase.d.ts +0 -60
  249. package/lib/clients/infra/VBase.js +0 -196
  250. package/lib/clients/infra/Workspaces.d.ts +0 -18
  251. package/lib/clients/infra/Workspaces.js +0 -65
  252. package/lib/clients/infra/index.d.ts +0 -12
  253. package/lib/clients/infra/index.js +0 -17
  254. package/lib/clients/janus/LicenseManager.d.ts +0 -7
  255. package/lib/clients/janus/Segment.js +0 -88
  256. package/lib/clients/janus/Tenant.js +0 -28
  257. package/lib/clients/janus/index.d.ts +0 -5
  258. package/lib/clients/janus/index.js +0 -10
  259. package/lib/service/index.d.ts +0 -2
  260. package/lib/service/index.js +0 -30
  261. package/lib/service/loaders.d.ts +0 -8
  262. package/lib/service/loaders.js +0 -54
  263. package/lib/service/logger/console.d.ts +0 -10
  264. package/lib/service/logger/console.js +0 -36
  265. package/lib/service/logger/logger.d.ts +0 -29
  266. package/lib/service/logger/logger.js +0 -61
  267. package/lib/service/logger/metricsLogger.d.ts +0 -40
  268. package/lib/service/logger/metricsLogger.js +0 -149
  269. package/lib/service/master.d.ts +0 -2
  270. package/lib/service/master.js +0 -87
  271. package/lib/service/metrics/requestMetricsMiddleware.d.ts +0 -2
  272. package/lib/service/metrics/requestMetricsMiddleware.js +0 -44
  273. package/lib/service/tracing/TracerSingleton.d.ts +0 -7
  274. package/lib/service/tracing/TracerSingleton.js +0 -48
  275. package/lib/service/tracing/metrics/MetricNames.d.ts +0 -60
  276. package/lib/service/tracing/metrics/MetricNames.js +0 -44
  277. package/lib/service/tracing/metrics/instruments.d.ts +0 -9
  278. package/lib/service/tracing/metrics/instruments.js +0 -11
  279. package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.d.ts +0 -9
  280. package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +0 -25
  281. package/lib/service/tracing/tracingMiddlewares.d.ts +0 -5
  282. package/lib/service/tracing/tracingMiddlewares.js +0 -107
  283. package/lib/service/worker/index.d.ts +0 -11
  284. package/lib/service/worker/index.js +0 -195
  285. package/lib/service/worker/listeners.d.ts +0 -3
  286. package/lib/service/worker/runtime/builtIn/handlers.d.ts +0 -4
  287. package/lib/service/worker/runtime/builtIn/handlers.js +0 -30
  288. package/lib/service/worker/runtime/builtIn/middlewares.d.ts +0 -4
  289. package/lib/service/worker/runtime/builtIn/middlewares.js +0 -40
  290. package/lib/service/worker/runtime/events/index.d.ts +0 -4
  291. package/lib/service/worker/runtime/events/index.js +0 -46
  292. package/lib/service/worker/runtime/events/middlewares/body.d.ts +0 -3
  293. package/lib/service/worker/runtime/events/middlewares/body.js +0 -22
  294. package/lib/service/worker/runtime/events/middlewares/context.d.ts +0 -3
  295. package/lib/service/worker/runtime/events/middlewares/context.js +0 -22
  296. package/lib/service/worker/runtime/events/router.d.ts +0 -2
  297. package/lib/service/worker/runtime/events/router.js +0 -27
  298. package/lib/service/worker/runtime/graphql/index.d.ts +0 -6
  299. package/lib/service/worker/runtime/graphql/index.js +0 -27
  300. package/lib/service/worker/runtime/graphql/middlewares/context.d.ts +0 -2
  301. package/lib/service/worker/runtime/graphql/middlewares/context.js +0 -16
  302. package/lib/service/worker/runtime/graphql/middlewares/error.js +0 -93
  303. package/lib/service/worker/runtime/graphql/middlewares/query.d.ts +0 -2
  304. package/lib/service/worker/runtime/graphql/middlewares/query.js +0 -52
  305. package/lib/service/worker/runtime/graphql/middlewares/response.js +0 -38
  306. package/lib/service/worker/runtime/graphql/middlewares/run.d.ts +0 -2
  307. package/lib/service/worker/runtime/graphql/middlewares/run.js +0 -19
  308. package/lib/service/worker/runtime/graphql/middlewares/updateSchema.d.ts +0 -4
  309. package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +0 -28
  310. package/lib/service/worker/runtime/graphql/middlewares/upload.d.ts +0 -4
  311. package/lib/service/worker/runtime/graphql/schema/index.d.ts +0 -7
  312. package/lib/service/worker/runtime/graphql/schema/index.js +0 -31
  313. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +0 -6
  314. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +0 -79
  315. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.d.ts +0 -7
  316. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.js +0 -37
  317. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.d.ts +0 -11
  318. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +0 -61
  319. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.d.ts +0 -7
  320. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.js +0 -40
  321. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.d.ts +0 -6
  322. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +0 -34
  323. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.d.ts +0 -7
  324. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +0 -39
  325. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +0 -33
  326. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.d.ts +0 -22
  327. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +0 -36
  328. package/lib/service/worker/runtime/graphql/schema/typeDefs/index.d.ts +0 -7
  329. package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +0 -12
  330. package/lib/service/worker/runtime/graphql/typings.d.ts +0 -31
  331. package/lib/service/worker/runtime/graphql/utils/cacheControl.d.ts +0 -1
  332. package/lib/service/worker/runtime/graphql/utils/cacheControl.js +0 -32
  333. package/lib/service/worker/runtime/graphql/utils/error.d.ts +0 -1
  334. package/lib/service/worker/runtime/graphql/utils/error.js +0 -76
  335. package/lib/service/worker/runtime/graphql/utils/translations.d.ts +0 -14
  336. package/lib/service/worker/runtime/graphql/utils/translations.js +0 -38
  337. package/lib/service/worker/runtime/http/index.d.ts +0 -5
  338. package/lib/service/worker/runtime/http/index.js +0 -58
  339. package/lib/service/worker/runtime/http/middlewares/authTokens.d.ts +0 -3
  340. package/lib/service/worker/runtime/http/middlewares/cancellationToken.d.ts +0 -3
  341. package/lib/service/worker/runtime/http/middlewares/clients.d.ts +0 -4
  342. package/lib/service/worker/runtime/http/middlewares/context.d.ts +0 -4
  343. package/lib/service/worker/runtime/http/middlewares/context.js +0 -36
  344. package/lib/service/worker/runtime/http/middlewares/error.d.ts +0 -2
  345. package/lib/service/worker/runtime/http/middlewares/rateLimit.d.ts +0 -6
  346. package/lib/service/worker/runtime/http/middlewares/rateLimit.js +0 -42
  347. package/lib/service/worker/runtime/http/middlewares/setCookie.d.ts +0 -3
  348. package/lib/service/worker/runtime/http/middlewares/settings.d.ts +0 -9
  349. package/lib/service/worker/runtime/http/middlewares/settings.js +0 -44
  350. package/lib/service/worker/runtime/http/middlewares/timings.d.ts +0 -3
  351. package/lib/service/worker/runtime/http/middlewares/vary.d.ts +0 -3
  352. package/lib/service/worker/runtime/http/router.d.ts +0 -2
  353. package/lib/service/worker/runtime/http/router.js +0 -23
  354. package/lib/service/worker/runtime/http/routes.d.ts +0 -19
  355. package/lib/service/worker/runtime/http/routes.js +0 -12
  356. package/lib/service/worker/runtime/method.d.ts +0 -9
  357. package/lib/service/worker/runtime/statusTrack.d.ts +0 -14
  358. package/lib/service/worker/runtime/statusTrack.js +0 -37
  359. package/lib/service/worker/runtime/utils/compose.d.ts +0 -5
  360. package/lib/service/worker/runtime/utils/context.d.ts +0 -2
  361. package/lib/service/worker/runtime/utils/context.js +0 -40
  362. package/lib/service/worker/runtime/utils/diff.d.ts +0 -12
  363. package/lib/service/worker/runtime/utils/diff.js +0 -21
  364. package/lib/service/worker/runtime/utils/recorder.d.ts +0 -8
  365. package/lib/service/worker/runtime/utils/recorder.js +0 -37
  366. package/lib/service/worker/runtime/utils/tokenBucket.d.ts +0 -2
  367. package/lib/service/worker/runtime/utils/tokenBucket.js +0 -16
  368. package/lib/tracing/LogEvents.d.ts +0 -31
  369. package/lib/tracing/LogEvents.js +0 -3
  370. package/lib/tracing/LogFields.d.ts +0 -66
  371. package/lib/tracing/LogFields.js +0 -3
  372. package/lib/tracing/Tags.d.ts +0 -81
  373. package/lib/tracing/Tags.js +0 -7
  374. package/lib/tracing/UserLandTracer.d.ts +0 -27
  375. package/lib/tracing/UserLandTracer.js +0 -56
  376. package/lib/tracing/errorReporting/ErrorReport.d.ts +0 -31
  377. package/lib/tracing/errorReporting/ErrorReport.js +0 -70
  378. package/lib/tracing/index.d.ts +0 -9
  379. package/lib/tracing/index.js +0 -19
  380. package/lib/tracing/spanReference/SpanReferenceTypes.d.ts +0 -4
  381. package/lib/tracing/spanReference/SpanReferenceTypes.js +0 -7
  382. package/lib/tracing/spanReference/createSpanReference.d.ts +0 -3
  383. package/lib/tracing/spanReference/createSpanReference.js +0 -8
  384. package/lib/tracing/utils.d.ts +0 -13
  385. package/lib/tracing/utils.js +0 -40
  386. package/lib/utils/conflicts.mock.d.ts +0 -17
  387. package/lib/utils/conflicts.mock.js +0 -27
  388. /package/lib/service/{worker/runtime/graphql → graphql}/middlewares/error.d.ts +0 -0
  389. /package/lib/service/{worker/runtime/graphql → graphql}/middlewares/response.d.ts +0 -0
  390. /package/lib/service/{worker/runtime/graphql → graphql}/middlewares/upload.js +0 -0
  391. /package/lib/service/{worker/runtime/graphql → graphql}/schema/typeDefs/ioUpload.d.ts +0 -0
  392. /package/lib/service/{worker/runtime/graphql → graphql}/schema/typeDefs/ioUpload.js +0 -0
  393. /package/lib/service/{worker/runtime/graphql → graphql}/schema/typeDefs/sanitizedString.d.ts +0 -0
  394. /package/lib/service/{worker/runtime/graphql → graphql}/typings.js +0 -0
  395. /package/lib/service/{worker/runtime/utils/toArray.d.ts → graphql/utils/array.d.ts} +0 -0
  396. /package/lib/service/{worker/runtime/utils/toArray.js → graphql/utils/array.js} +0 -0
  397. /package/lib/service/{worker/runtime/graphql → graphql}/utils/pathname.d.ts +0 -0
  398. /package/lib/service/{worker/runtime/graphql → graphql}/utils/pathname.js +0 -0
  399. /package/lib/service/{worker/runtime/http → http}/middlewares/authTokens.js +0 -0
  400. /package/lib/service/{worker/runtime/http → http}/middlewares/clients.js +0 -0
  401. /package/lib/service/{worker/runtime/http → http}/middlewares/requestStats.js +0 -0
  402. /package/lib/service/{worker/runtime/http → http}/middlewares/setCookie.js +0 -0
  403. /package/lib/service/{worker/runtime/method.js → method.js} +0 -0
  404. /package/lib/service/{worker/runtime/typings.js → typings.js} +0 -0
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_1 = require("../../constants");
4
- const InfraClient_1 = require("./InfraClient");
5
- const routes = {
6
- Account: (account) => `/${account}`,
7
- Promote: (account) => `${routes.Workspace(account, constants_1.DEFAULT_WORKSPACE)}/_promote`,
8
- Workspace: (account, workspace) => `${routes.Account(account)}/${workspace}`,
9
- };
10
- class Workspaces extends InfraClient_1.InfraClient {
11
- constructor(context, options) {
12
- super('router', context, options, true);
13
- this.list = (account, tracingConfig) => {
14
- const metric = 'workspaces-list';
15
- return this.http.get(routes.Account(account), { metric, tracing: {
16
- requestSpanNameSuffix: metric,
17
- ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
18
- } });
19
- };
20
- this.get = (account, workspace, tracingConfig) => {
21
- const metric = 'workspaces-get';
22
- return this.http.get(routes.Workspace(account, workspace), { metric, tracing: {
23
- requestSpanNameSuffix: metric,
24
- ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
25
- } });
26
- };
27
- this.set = (account, workspace, metadata, tracingConfig) => {
28
- const metric = 'workspaces-set';
29
- return this.http.put(routes.Workspace(account, workspace), metadata, { metric, tracing: {
30
- requestSpanNameSuffix: metric,
31
- ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
32
- } });
33
- };
34
- this.create = (account, workspace, production, tracingConfig) => {
35
- const metric = 'workspaces-create';
36
- return this.http.post(routes.Account(account), { name: workspace, production }, { metric, tracing: {
37
- requestSpanNameSuffix: metric,
38
- ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
39
- } });
40
- };
41
- this.delete = (account, workspace, tracingConfig) => {
42
- const metric = 'workspaces-delete';
43
- return this.http.delete(routes.Workspace(account, workspace), { metric, tracing: {
44
- requestSpanNameSuffix: metric,
45
- ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
46
- } });
47
- };
48
- this.reset = (account, workspace, metadata = {}, tracingConfig) => {
49
- const params = { reset: true };
50
- const metric = 'workspaces-reset';
51
- return this.http.put(routes.Workspace(account, workspace), metadata, { metric, params, tracing: {
52
- requestSpanNameSuffix: metric,
53
- ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
54
- } });
55
- };
56
- this.promote = (account, workspace, tracingConfig) => {
57
- const metric = 'workspaces-promote';
58
- return this.http.put(routes.Promote(account), { workspace }, { metric, tracing: {
59
- requestSpanNameSuffix: metric,
60
- ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
61
- } });
62
- };
63
- }
64
- }
65
- exports.Workspaces = Workspaces;
@@ -1,12 +0,0 @@
1
- export * from './Apps';
2
- export * from './Assets';
3
- export * from './BillingMetrics';
4
- export * from './Events';
5
- export * from './Housekeeper';
6
- export * from './InfraClient';
7
- export * from './Metadata';
8
- export * from './Registry';
9
- export * from './Router';
10
- export * from './VBase';
11
- export * from './Workspaces';
12
- export * from './Sphinx';
@@ -1,17 +0,0 @@
1
- "use strict";
2
- function __export(m) {
3
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
- }
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- __export(require("./Apps"));
7
- __export(require("./Assets"));
8
- __export(require("./BillingMetrics"));
9
- __export(require("./Events"));
10
- __export(require("./Housekeeper"));
11
- __export(require("./InfraClient"));
12
- __export(require("./Metadata"));
13
- __export(require("./Registry"));
14
- __export(require("./Router"));
15
- __export(require("./VBase"));
16
- __export(require("./Workspaces"));
17
- __export(require("./Sphinx"));
@@ -1,7 +0,0 @@
1
- import { RequestTracingConfig } from '../../HttpClient';
2
- import { JanusClient } from './JanusClient';
3
- export declare class LicenseManager extends JanusClient {
4
- getAccountData(VtexIdclientAutCookie: string, tracingConfig?: RequestTracingConfig): Promise<any>;
5
- getTopbarData(VtexIdclientAutCookie: string, tracingConfig?: RequestTracingConfig): Promise<any>;
6
- canAccessResource(VtexIdclientAutCookie: string, resourceKey: string, tracingConfig?: RequestTracingConfig): Promise<boolean>;
7
- }
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const cookie_1 = __importDefault(require("cookie"));
7
- const ramda_1 = require("ramda");
8
- const constants_1 = require("../../constants");
9
- const HttpClient_1 = require("../../HttpClient");
10
- const JanusClient_1 = require("./JanusClient");
11
- const SEGMENT_COOKIE = 'vtex_segment';
12
- const SEGMENT_MAX_AGE_S = 60 * 60; // 60 minutes - segment is actually immutable
13
- const ALLOWED_QUERY_PREFIXES = ['utm', 'cultureInfo', 'supportedLocales', '__bindingId'];
14
- const filterAndSortQuery = (query) => {
15
- if (!query) {
16
- return null;
17
- }
18
- const filteredKeys = Object.keys(query)
19
- .filter((k) => !!k && ALLOWED_QUERY_PREFIXES.some((prefix) => k.startsWith(prefix)))
20
- .sort();
21
- return filteredKeys.reduce((acc, val) => {
22
- acc[val] = query[val];
23
- return acc;
24
- }, {});
25
- };
26
- const routes = {
27
- base: '/api/segments',
28
- segments: (token) => (token ? `${routes.base}/${token}` : routes.base),
29
- };
30
- class Segment extends JanusClient_1.JanusClient {
31
- constructor() {
32
- super(...arguments);
33
- /**
34
- * Get the segment data using the current `ctx.vtex.segmentToken`
35
- *
36
- * @memberof Segment
37
- */
38
- this.getSegment = (tracingConfig) => this.rawSegment(this.context.segmentToken, undefined, tracingConfig).then(ramda_1.prop('data'));
39
- /**
40
- * Get the segment data from this specific segment token
41
- *
42
- * @memberof Segment
43
- */
44
- this.getSegmentByToken = (token, tracingConfig) => this.rawSegment(token, undefined, tracingConfig).then(ramda_1.prop('data'));
45
- this.getOrCreateSegment = async (query, token, tracingConfig) => {
46
- const { data: segmentData, headers } = await this.rawSegment(token, query, tracingConfig);
47
- return {
48
- segmentData,
49
- segmentToken: extractSegmentCookie(headers),
50
- };
51
- };
52
- this.rawSegment = (token, query, tracingConfig) => {
53
- const { product, workspace } = this.context;
54
- const filteredQuery = filterAndSortQuery(query);
55
- const metric = token ? 'segment-get-token' : 'segment-get-new';
56
- return this.http.getRaw(routes.segments(token), {
57
- forceMaxAge: SEGMENT_MAX_AGE_S,
58
- headers: {
59
- 'Content-Type': 'application/json',
60
- [constants_1.PRODUCT_HEADER]: product || '',
61
- },
62
- inflightKey: HttpClient_1.inflightUrlWithQuery,
63
- metric,
64
- params: {
65
- ...filteredQuery,
66
- session_path: product || '',
67
- workspace,
68
- },
69
- tracing: {
70
- requestSpanNameSuffix: metric,
71
- ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
72
- },
73
- });
74
- };
75
- }
76
- }
77
- exports.Segment = Segment;
78
- function extractSegmentCookie(headers) {
79
- var _a;
80
- for (const setCookie of (_a = headers['set-cookie']) !== null && _a !== void 0 ? _a : []) {
81
- const parsedCookie = cookie_1.default.parse(setCookie);
82
- const segmentCookie = parsedCookie[SEGMENT_COOKIE];
83
- if (segmentCookie != null) {
84
- return segmentCookie;
85
- }
86
- }
87
- return null;
88
- }
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const HttpClient_1 = require("../../HttpClient");
4
- const JanusClient_1 = require("./JanusClient");
5
- class TenantClient extends JanusClient_1.JanusClient {
6
- constructor(ctx, opts) {
7
- super(ctx, {
8
- ...opts,
9
- params: {
10
- q: ctx.account,
11
- },
12
- });
13
- this.info = (config) => {
14
- const metric = 'get-tenant-info';
15
- return this.http.get('/api/tenant/tenants', {
16
- inflightKey: HttpClient_1.inflightUrlWithQuery,
17
- memoizeable: true,
18
- metric,
19
- ...config,
20
- tracing: {
21
- requestSpanNameSuffix: metric,
22
- ...config === null || config === void 0 ? void 0 : config.tracing,
23
- },
24
- });
25
- };
26
- }
27
- }
28
- exports.TenantClient = TenantClient;
@@ -1,5 +0,0 @@
1
- export * from './JanusClient';
2
- export * from './LicenseManager';
3
- export * from './Segment';
4
- export * from './Session';
5
- export * from './Tenant';
@@ -1,10 +0,0 @@
1
- "use strict";
2
- function __export(m) {
3
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
- }
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- __export(require("./JanusClient"));
7
- __export(require("./LicenseManager"));
8
- __export(require("./Segment"));
9
- __export(require("./Session"));
10
- __export(require("./Tenant"));
@@ -1,2 +0,0 @@
1
- export declare const startApp: () => void;
2
- export { appPath } from './loaders';
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const cluster_1 = __importDefault(require("cluster"));
7
- const constants_1 = require("../constants");
8
- const loaders_1 = require("./loaders");
9
- const logger_1 = require("./logger");
10
- const master_1 = require("./master");
11
- const worker_1 = require("./worker");
12
- exports.startApp = () => {
13
- const serviceJSON = loaders_1.getServiceJSON();
14
- try {
15
- // if it is a master process then call setting up worker process
16
- if (cluster_1.default.isMaster) {
17
- master_1.startMaster(serviceJSON);
18
- }
19
- else {
20
- // to setup server configurations and share port address for incoming requests
21
- worker_1.startWorker(serviceJSON).listen(constants_1.HTTP_SERVER_PORT);
22
- }
23
- }
24
- catch (err) {
25
- logger_1.logOnceToDevConsole(err.stack || err.message, logger_1.LogLevel.Error);
26
- process.exit(2);
27
- }
28
- };
29
- var loaders_2 = require("./loaders");
30
- exports.appPath = loaders_2.appPath;
@@ -1,8 +0,0 @@
1
- import { IOClients } from '../clients/IOClients';
2
- import { Service } from './worker/runtime/Service';
3
- import { ParamsContext, RecorderState, ServiceJSON } from './worker/runtime/typings';
4
- export declare const appPath: string;
5
- export declare const bundlePath: string;
6
- export declare const serviceJsonPath: string;
7
- export declare const getServiceJSON: () => ServiceJSON;
8
- export declare const getService: () => Service<IOClients, RecorderState, ParamsContext>;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const os_1 = require("os");
4
- const path_1 = require("path");
5
- const IOClients_1 = require("../clients/IOClients");
6
- const constants_1 = require("../constants");
7
- exports.appPath = path_1.join(process.cwd(), './service/src/node/');
8
- exports.bundlePath = path_1.join(exports.appPath, 'index');
9
- exports.serviceJsonPath = path_1.join(process.cwd(), './service/service.json');
10
- const getWorkers = (workers) => {
11
- // We need to have only one worker while linking so the debugger
12
- // works properly
13
- if (constants_1.LINKED) {
14
- return 1;
15
- }
16
- // If user didn't set workers property, let's use the cpu count
17
- const workersFromUser = workers && Number.isInteger(workers) ? workers : os_1.cpus().length;
18
- // never spawns more than MAX_WORKERS
19
- return Math.min(workersFromUser, constants_1.MAX_WORKERS);
20
- };
21
- exports.getServiceJSON = () => {
22
- const service = require(exports.serviceJsonPath);
23
- return {
24
- ...service,
25
- workers: getWorkers(service.workers),
26
- };
27
- };
28
- const defaultClients = {
29
- options: {
30
- messages: {
31
- concurrency: 10,
32
- retries: 2,
33
- timeout: 1000,
34
- },
35
- messagesGraphQL: {
36
- concurrency: 12,
37
- retries: 2,
38
- timeout: 2000,
39
- },
40
- },
41
- };
42
- exports.getService = () => {
43
- var _a;
44
- const { default: service } = require(exports.bundlePath);
45
- const { config: { clients } } = service;
46
- service.config.clients = {
47
- implementation: (_a = clients === null || clients === void 0 ? void 0 : clients.implementation) !== null && _a !== void 0 ? _a : IOClients_1.IOClients,
48
- options: {
49
- ...defaultClients.options,
50
- ...clients === null || clients === void 0 ? void 0 : clients.options,
51
- },
52
- };
53
- return service;
54
- };
@@ -1,10 +0,0 @@
1
- import { LogLevel } from './logger';
2
- export interface LogMessage {
3
- cmd: typeof LOG_ONCE;
4
- message: string;
5
- level: LogLevel;
6
- }
7
- export declare const LOG_ONCE = "logOnce";
8
- export declare const isLog: (message: any) => message is LogMessage;
9
- export declare const log: (message: any, level: LogLevel) => void;
10
- export declare const logOnceToDevConsole: (message: any, level: LogLevel) => void;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const cluster_1 = require("cluster");
4
- const caches_1 = require("../../caches");
5
- const history = new caches_1.LRUCache({
6
- max: 42,
7
- });
8
- exports.LOG_ONCE = 'logOnce';
9
- exports.isLog = (message) => (message === null || message === void 0 ? void 0 : message.cmd) === exports.LOG_ONCE;
10
- exports.log = (message, level) => {
11
- const logger = console[level];
12
- if (typeof logger === 'function') {
13
- logger(message);
14
- }
15
- };
16
- // Since we are now using clusters, if we simply console.log something,
17
- // it may overwhelm the programmer's console with lots of repeated info.
18
- // This function should be used when you want to warn about something
19
- // only once
20
- exports.logOnceToDevConsole = (message, level) => {
21
- const strigified = JSON.stringify(message);
22
- if (!history.has(strigified)) {
23
- history.set(strigified, true);
24
- if (cluster_1.isMaster) {
25
- exports.log(message, level);
26
- }
27
- else if (cluster_1.isWorker && process.send) {
28
- const logMessage = {
29
- cmd: exports.LOG_ONCE,
30
- level,
31
- message,
32
- };
33
- process.send(logMessage);
34
- }
35
- }
36
- };
@@ -1,29 +0,0 @@
1
- import { IUserLandTracer } from '../../tracing';
2
- import { IOContext } from '../worker/runtime/typings';
3
- export interface LoggerTracingContext {
4
- requestTracer: IUserLandTracer;
5
- }
6
- export declare enum LogLevel {
7
- Debug = "debug",
8
- Info = "info",
9
- Warn = "warn",
10
- Error = "error"
11
- }
12
- interface LoggerContext extends Pick<IOContext, 'account' | 'workspace' | 'requestId' | 'operationId' | 'production'> {
13
- tracer?: IOContext['tracer'];
14
- }
15
- export declare class Logger {
16
- private account;
17
- private workspace;
18
- private operationId;
19
- private requestId;
20
- private production;
21
- private tracingState?;
22
- constructor(ctx: LoggerContext);
23
- debug: (message: any) => void;
24
- info: (message: any) => void;
25
- warn: (warning: any) => void;
26
- error: (error: any) => void;
27
- log: (message: any, level: LogLevel) => void;
28
- }
29
- export {};
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_1 = require("../../constants");
4
- const error_1 = require("../../utils/error");
5
- const log_1 = require("../../utils/log");
6
- const linked = !!process.env.VTEX_APP_LINK;
7
- const app = constants_1.APP.ID;
8
- const EMPTY_MESSAGE = 'Logger.log was called with null or undefined message';
9
- var LogLevel;
10
- (function (LogLevel) {
11
- LogLevel["Debug"] = "debug";
12
- LogLevel["Info"] = "info";
13
- LogLevel["Warn"] = "warn";
14
- LogLevel["Error"] = "error";
15
- })(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
16
- class Logger {
17
- constructor(ctx) {
18
- this.debug = (message) => this.log(message, LogLevel.Debug);
19
- this.info = (message) => this.log(message, LogLevel.Info);
20
- this.warn = (warning) => this.log(warning, LogLevel.Warn);
21
- this.error = (error) => this.log(error, LogLevel.Error);
22
- this.log = (message, level) => {
23
- var _a;
24
- const data = message ? error_1.cleanError(message) : EMPTY_MESSAGE;
25
- log_1.cleanLog(data);
26
- /* tslint:disable:object-literal-sort-keys */
27
- const inflatedLog = {
28
- __VTEX_IO_LOG: true,
29
- level,
30
- app,
31
- account: this.account,
32
- workspace: this.workspace,
33
- production: this.production,
34
- data,
35
- operationId: this.operationId,
36
- requestId: this.requestId,
37
- ...(((_a = this.tracingState) === null || _a === void 0 ? void 0 : _a.isTraceSampled) ? { traceId: this.tracingState.traceId } : null),
38
- };
39
- // Mark third-party apps logs to send to skidder
40
- if (constants_1.APP.IS_THIRD_PARTY()) {
41
- Object.assign(inflatedLog, {
42
- __SKIDDER_TOPIC_1: `skidder.vendor.${constants_1.APP.VENDOR}`,
43
- __SKIDDER_TOPIC_2: `skidder.app.${constants_1.APP.VENDOR}.${constants_1.APP.NAME}`,
44
- });
45
- }
46
- console.log(JSON.stringify(inflatedLog));
47
- };
48
- this.account = ctx.account;
49
- this.workspace = ctx.workspace;
50
- this.requestId = ctx.requestId;
51
- this.operationId = ctx.operationId;
52
- this.production = ctx.production;
53
- if (ctx.tracer) {
54
- this.tracingState = {
55
- isTraceSampled: ctx.tracer.isTraceSampled,
56
- traceId: ctx.tracer.traceId,
57
- };
58
- }
59
- }
60
- }
61
- exports.Logger = Logger;
@@ -1,40 +0,0 @@
1
- /// <reference types="node" />
2
- interface ProcessEnv {
3
- appName: string;
4
- appVersion: string;
5
- region: string;
6
- vendor: string;
7
- production: boolean;
8
- }
9
- interface Key {
10
- name: string;
11
- }
12
- interface Metric {
13
- Count: number;
14
- Data: {
15
- key: Key;
16
- processEnv: ProcessEnv;
17
- summary: NumericSummary | NodeJS.MemoryUsage | NodeJS.CpuUsage;
18
- };
19
- Max: number;
20
- Min: number;
21
- Name: string;
22
- Sum: number;
23
- Timestamp: number;
24
- Unit: string;
25
- }
26
- interface NumericSummary {
27
- count: number;
28
- max: number;
29
- median: number;
30
- min: number;
31
- percentile95: number;
32
- percentile99: number;
33
- sum: number;
34
- }
35
- export declare class MetricsLogger {
36
- add: (key: Key, value: number) => void;
37
- getSummaries: () => Metric[];
38
- constructor();
39
- }
40
- export {};
@@ -1,149 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
7
- const ramda_1 = require("ramda");
8
- const stats_lite_1 = require("stats-lite");
9
- const constants_1 = require("../../constants");
10
- const diff_1 = require("../worker/runtime/utils/diff");
11
- const runtimeBaseDefaultMetricNames = ['routeStats'];
12
- const runtimeNodeDefaultMetricNames = {
13
- cpuUsage: 'cpuUsage',
14
- memoryUsage: 'memoryUsage',
15
- };
16
- const invalidMetricNames = runtimeBaseDefaultMetricNames.concat(Object.values(runtimeNodeDefaultMetricNames));
17
- class MetricsLogger {
18
- constructor() {
19
- //////////////////////
20
- // private attributes
21
- //////////////////////
22
- let samples = {};
23
- let lastCpu = diff_1.cpuSnapshot();
24
- //////////////////////
25
- // private methods definitions
26
- //////////////////////
27
- const summaries = ramda_1.compose(ramda_1.reject(ramda_1.isNil), ramda_1.values, ramda_1.mapObjIndexed(getSummary));
28
- function getDefaultStoredashProperties() {
29
- return {
30
- Count: 1,
31
- Max: 0,
32
- Min: 0,
33
- Name: 'runtime',
34
- Sum: 0,
35
- Timestamp: (new Date()).getTime(),
36
- Unit: '',
37
- };
38
- }
39
- function getProcessEnv() {
40
- return {
41
- appName: process.env.VTEX_APP_NAME || '',
42
- appVersion: process.env.VTEX_APP_VERSION || '',
43
- production: constants_1.PRODUCTION,
44
- region: process.env.VTEX_REGION || '',
45
- vendor: process.env.VTEX_APP_VENDOR || '',
46
- };
47
- }
48
- function getCpuUsage() {
49
- const cpu = diff_1.cpuSnapshot();
50
- const cpuDiff = diff_1.snapshotDiff(cpu, lastCpu);
51
- lastCpu = cpu;
52
- const metric = {
53
- Data: {
54
- key: {
55
- name: runtimeNodeDefaultMetricNames.cpuUsage,
56
- },
57
- processEnv: getProcessEnv(),
58
- summary: cpuDiff,
59
- },
60
- ...getDefaultStoredashProperties(),
61
- };
62
- return metric;
63
- }
64
- function getMemoryUsage() {
65
- const metric = {
66
- Data: {
67
- key: {
68
- name: runtimeNodeDefaultMetricNames.memoryUsage,
69
- },
70
- processEnv: getProcessEnv(),
71
- summary: process.memoryUsage(),
72
- },
73
- ...getDefaultStoredashProperties(),
74
- };
75
- return metric;
76
- }
77
- function getRuntimeSummaries() {
78
- return [getCpuUsage(), getMemoryUsage()];
79
- }
80
- function getSummary(vals, strKey) {
81
- if (strKey in samples) {
82
- const summary = getNumericSummary(vals);
83
- const keyObj = JSON.parse(strKey);
84
- const metric = {
85
- Data: {
86
- key: keyObj,
87
- processEnv: getProcessEnv(),
88
- summary,
89
- },
90
- ...getDefaultStoredashProperties(),
91
- };
92
- return metric;
93
- }
94
- return null;
95
- }
96
- // TODO: create some kind of alert/log if metric is not valid
97
- function validKey(key) {
98
- if (!('name' in key)) {
99
- return false;
100
- }
101
- if (invalidMetricNames.includes(key.name)) {
102
- return false;
103
- }
104
- try {
105
- fast_json_stable_stringify_1.default(key);
106
- }
107
- catch {
108
- return false;
109
- }
110
- return true;
111
- }
112
- function getStrKey(key) {
113
- return fast_json_stable_stringify_1.default(key);
114
- }
115
- function getNumericSummary(vals) {
116
- return {
117
- count: vals.length,
118
- max: Math.max(...vals),
119
- median: stats_lite_1.median(vals),
120
- min: Math.min(...vals),
121
- percentile95: stats_lite_1.percentile(vals, 0.95),
122
- percentile99: stats_lite_1.percentile(vals, 0.99),
123
- sum: stats_lite_1.sum(vals),
124
- };
125
- }
126
- //////////////////////
127
- // public methods definitions
128
- //////////////////////
129
- this.add = (key, value) => {
130
- if (validKey(key)) {
131
- const strKey = getStrKey(key);
132
- if (!(strKey in samples)) {
133
- samples[strKey] = [];
134
- }
135
- samples[strKey].push(value);
136
- }
137
- };
138
- this.getSummaries = () => {
139
- const appSummaries = summaries(samples);
140
- samples = {};
141
- const runtimeSummaries = getRuntimeSummaries();
142
- return runtimeSummaries.concat(appSummaries);
143
- };
144
- //////////////////////
145
- // real constructor
146
- //////////////////////
147
- }
148
- }
149
- exports.MetricsLogger = MetricsLogger;