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

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 (430) hide show
  1. package/gen/manifest.schema +5 -3
  2. package/lib/HttpClient/GraphQLClient.d.ts +2 -1
  3. package/lib/HttpClient/GraphQLClient.js +5 -1
  4. package/lib/HttpClient/HttpClient.d.ts +6 -5
  5. package/lib/HttpClient/HttpClient.js +64 -21
  6. package/lib/HttpClient/agents.d.ts +3 -0
  7. package/lib/HttpClient/agents.js +37 -0
  8. package/lib/HttpClient/index.d.ts +1 -7
  9. package/lib/HttpClient/index.js +17 -16
  10. package/lib/HttpClient/middlewares/cache.d.ts +8 -2
  11. package/lib/HttpClient/middlewares/cache.js +126 -33
  12. package/lib/HttpClient/middlewares/cancellationToken.d.ts +1 -1
  13. package/lib/HttpClient/middlewares/cancellationToken.js +3 -1
  14. package/lib/HttpClient/middlewares/inflight.js +1 -0
  15. package/lib/HttpClient/middlewares/memoization.js +9 -1
  16. package/lib/HttpClient/middlewares/metrics.js +17 -31
  17. package/lib/HttpClient/middlewares/notFound.js +1 -0
  18. package/lib/HttpClient/middlewares/recorder.d.ts +1 -1
  19. package/lib/HttpClient/middlewares/recorder.js +20 -12
  20. package/lib/HttpClient/middlewares/request/HttpAgentSingleton.d.ts +11 -0
  21. package/lib/HttpClient/middlewares/request/HttpAgentSingleton.js +31 -0
  22. package/lib/HttpClient/middlewares/request/index.d.ts +18 -0
  23. package/lib/HttpClient/middlewares/request/index.js +85 -0
  24. package/lib/HttpClient/middlewares/request/setupAxios/index.d.ts +2 -0
  25. package/lib/HttpClient/middlewares/request/setupAxios/index.js +21 -0
  26. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.d.ts +2 -0
  27. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +54 -0
  28. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.d.ts +2 -0
  29. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +7 -0
  30. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.d.ts +8 -0
  31. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.js +56 -0
  32. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.d.ts +4 -0
  33. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +30 -0
  34. package/lib/HttpClient/middlewares/tracing.d.ts +15 -0
  35. package/lib/HttpClient/middlewares/tracing.js +61 -0
  36. package/lib/HttpClient/typings.d.ts +44 -10
  37. package/lib/HttpClient/typings.js +1 -0
  38. package/lib/caches/DiskCache.d.ts +1 -1
  39. package/lib/caches/DiskCache.js +1 -0
  40. package/lib/caches/LRUCache.d.ts +2 -2
  41. package/lib/caches/LRUCache.js +6 -1
  42. package/lib/caches/LRUDiskCache.d.ts +1 -1
  43. package/lib/caches/LRUDiskCache.js +6 -1
  44. package/lib/caches/MultilayeredCache.d.ts +1 -1
  45. package/lib/caches/MultilayeredCache.js +2 -1
  46. package/lib/caches/index.js +16 -7
  47. package/lib/{HttpClient → clients}/IOClient.d.ts +4 -4
  48. package/lib/clients/IOClient.js +20 -0
  49. package/lib/clients/IOClients.d.ts +28 -24
  50. package/lib/clients/IOClients.js +36 -28
  51. package/lib/{HttpClient → clients}/IOGraphQLClient.d.ts +4 -4
  52. package/lib/{HttpClient → clients}/IOGraphQLClient.js +3 -2
  53. package/lib/{HttpClient → clients/apps}/AppClient.d.ts +3 -3
  54. package/lib/{HttpClient → clients/apps}/AppClient.js +11 -5
  55. package/lib/{HttpClient → clients/apps}/AppGraphQLClient.d.ts +3 -3
  56. package/lib/{HttpClient → clients/apps}/AppGraphQLClient.js +11 -5
  57. package/lib/clients/apps/Billing.d.ts +12 -0
  58. package/lib/clients/{Billing.js → apps/Billing.js} +9 -3
  59. package/lib/clients/{Builder.d.ts → apps/Builder.d.ts} +12 -11
  60. package/lib/clients/{Builder.js → apps/Builder.js} +50 -22
  61. package/lib/clients/apps/MessagesGraphQL.d.ts +61 -0
  62. package/lib/clients/apps/MessagesGraphQL.js +122 -0
  63. package/lib/clients/{Settings.d.ts → apps/Settings.d.ts} +5 -4
  64. package/lib/clients/{Settings.js → apps/Settings.js} +15 -20
  65. package/lib/clients/apps/catalogGraphQL/brand.d.ts +13 -0
  66. package/lib/clients/apps/catalogGraphQL/brand.js +19 -0
  67. package/lib/clients/apps/catalogGraphQL/category.d.ts +11 -0
  68. package/lib/clients/apps/catalogGraphQL/category.js +17 -0
  69. package/lib/clients/apps/catalogGraphQL/index.d.ts +22 -0
  70. package/lib/clients/apps/catalogGraphQL/index.js +89 -0
  71. package/lib/clients/apps/catalogGraphQL/product.d.ts +25 -0
  72. package/lib/clients/apps/catalogGraphQL/product.js +31 -0
  73. package/lib/clients/apps/catalogGraphQL/sku.d.ts +26 -0
  74. package/lib/clients/apps/catalogGraphQL/sku.js +31 -0
  75. package/lib/clients/apps/index.d.ts +7 -0
  76. package/lib/clients/apps/index.js +19 -0
  77. package/lib/{HttpClient → clients/external}/ExternalClient.d.ts +3 -3
  78. package/lib/{HttpClient → clients/external}/ExternalClient.js +10 -2
  79. package/lib/clients/external/ID.d.ts +23 -0
  80. package/lib/clients/external/ID.js +61 -0
  81. package/lib/clients/external/Masterdata.d.ts +94 -0
  82. package/lib/clients/external/Masterdata.js +225 -0
  83. package/lib/clients/external/PaymentProvider.d.ts +31 -0
  84. package/lib/clients/external/PaymentProvider.js +43 -0
  85. package/lib/clients/external/index.d.ts +4 -0
  86. package/lib/clients/external/index.js +16 -0
  87. package/lib/clients/index.d.ts +9 -21
  88. package/lib/clients/index.js +23 -24
  89. package/lib/clients/infra/Apps.d.ts +88 -0
  90. package/lib/clients/infra/Apps.js +511 -0
  91. package/lib/clients/infra/Assets.d.ts +34 -0
  92. package/lib/clients/{Assets.js → infra/Assets.js} +75 -19
  93. package/lib/clients/infra/BillingMetrics.d.ts +13 -0
  94. package/lib/clients/infra/BillingMetrics.js +16 -0
  95. package/lib/clients/infra/Events.d.ts +12 -0
  96. package/lib/clients/infra/Events.js +34 -0
  97. package/lib/clients/infra/Housekeeper.d.ts +10 -0
  98. package/lib/clients/infra/Housekeeper.js +31 -0
  99. package/lib/{HttpClient → clients/infra}/InfraClient.d.ts +3 -3
  100. package/lib/{HttpClient → clients/infra}/InfraClient.js +10 -4
  101. package/lib/clients/infra/Registry.d.ts +59 -0
  102. package/lib/clients/{Registry.js → infra/Registry.js} +95 -33
  103. package/lib/clients/infra/Router.d.ts +34 -0
  104. package/lib/clients/infra/Router.js +82 -0
  105. package/lib/clients/infra/Sphinx.d.ts +13 -0
  106. package/lib/clients/infra/Sphinx.js +30 -0
  107. package/lib/clients/infra/VBase.d.ts +60 -0
  108. package/lib/clients/infra/VBase.js +197 -0
  109. package/lib/clients/infra/Workspaces.d.ts +18 -0
  110. package/lib/clients/infra/Workspaces.js +66 -0
  111. package/lib/clients/infra/index.d.ts +11 -0
  112. package/lib/clients/infra/index.js +23 -0
  113. package/lib/{HttpClient → clients/janus}/JanusClient.d.ts +3 -3
  114. package/lib/{HttpClient → clients/janus}/JanusClient.js +8 -3
  115. package/lib/clients/janus/LicenseManager.d.ts +7 -0
  116. package/lib/clients/{LicenseManager.js → janus/LicenseManager.js} +24 -8
  117. package/lib/clients/{Segment.d.ts → janus/Segment.d.ts} +7 -11
  118. package/lib/clients/janus/Segment.js +89 -0
  119. package/lib/clients/{Session.d.ts → janus/Session.d.ts} +4 -4
  120. package/lib/clients/{Session.js → janus/Session.js} +25 -13
  121. package/lib/clients/{Tenant.d.ts → janus/Tenant.d.ts} +6 -7
  122. package/lib/clients/janus/Tenant.js +29 -0
  123. package/lib/clients/janus/index.d.ts +5 -0
  124. package/lib/clients/janus/index.js +17 -0
  125. package/lib/constants.d.ts +49 -1
  126. package/lib/constants.js +55 -1
  127. package/lib/errors/AuthenticationError.js +1 -0
  128. package/lib/errors/ForbiddenError.js +1 -0
  129. package/lib/errors/NotFoundError.js +1 -0
  130. package/lib/errors/RequestCancelledError.js +1 -0
  131. package/lib/errors/ResolverError.d.ts +1 -1
  132. package/lib/errors/ResolverError.js +3 -2
  133. package/lib/errors/ResolverWarning.d.ts +1 -1
  134. package/lib/errors/ResolverWarning.js +3 -2
  135. package/lib/errors/TooManyRequestsError.js +1 -0
  136. package/lib/errors/UserInputError.js +1 -0
  137. package/lib/errors/index.js +18 -11
  138. package/lib/index.d.ts +9 -7
  139. package/lib/index.js +27 -16
  140. package/lib/metrics/MetricsAccumulator.d.ts +1 -18
  141. package/lib/metrics/MetricsAccumulator.js +39 -22
  142. package/lib/responses.d.ts +3 -44
  143. package/lib/service/index.d.ts +2 -0
  144. package/lib/service/index.js +34 -0
  145. package/lib/service/loaders.d.ts +8 -0
  146. package/lib/service/loaders.js +55 -0
  147. package/lib/service/logger/console.d.ts +10 -0
  148. package/lib/service/logger/console.js +37 -0
  149. package/lib/service/logger/index.d.ts +2 -28
  150. package/lib/service/logger/index.js +12 -68
  151. package/lib/service/logger/logger.d.ts +29 -0
  152. package/lib/service/logger/logger.js +62 -0
  153. package/lib/service/logger/metricsLogger.d.ts +40 -0
  154. package/lib/service/logger/metricsLogger.js +150 -0
  155. package/lib/service/master.d.ts +2 -0
  156. package/lib/service/master.js +88 -0
  157. package/lib/service/metrics/requestMetricsMiddleware.d.ts +2 -0
  158. package/lib/service/metrics/requestMetricsMiddleware.js +45 -0
  159. package/lib/service/tracing/TracerSingleton.d.ts +7 -0
  160. package/lib/service/tracing/TracerSingleton.js +49 -0
  161. package/lib/service/tracing/metrics/MetricNames.d.ts +60 -0
  162. package/lib/service/tracing/metrics/MetricNames.js +45 -0
  163. package/lib/service/tracing/metrics/instruments.d.ts +9 -0
  164. package/lib/service/tracing/metrics/instruments.js +12 -0
  165. package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.d.ts +9 -0
  166. package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +26 -0
  167. package/lib/service/tracing/tracingMiddlewares.d.ts +5 -0
  168. package/lib/service/tracing/tracingMiddlewares.js +114 -0
  169. package/lib/service/worker/index.d.ts +11 -0
  170. package/lib/service/worker/index.js +196 -0
  171. package/lib/service/worker/listeners.d.ts +3 -0
  172. package/lib/{utils/unhandled.js → service/worker/listeners.js} +10 -15
  173. package/lib/service/{Service.d.ts → worker/runtime/Service.d.ts} +5 -5
  174. package/lib/service/{Service.js → worker/runtime/Service.js} +3 -1
  175. package/lib/service/worker/runtime/builtIn/handlers.d.ts +4 -0
  176. package/lib/service/worker/runtime/builtIn/handlers.js +31 -0
  177. package/lib/service/worker/runtime/builtIn/middlewares.d.ts +4 -0
  178. package/lib/service/worker/runtime/builtIn/middlewares.js +41 -0
  179. package/lib/service/worker/runtime/events/index.d.ts +4 -0
  180. package/lib/service/worker/runtime/events/index.js +47 -0
  181. package/lib/service/worker/runtime/events/middlewares/body.d.ts +3 -0
  182. package/lib/service/worker/runtime/events/middlewares/body.js +26 -0
  183. package/lib/service/worker/runtime/events/middlewares/context.d.ts +3 -0
  184. package/lib/service/worker/runtime/events/middlewares/context.js +23 -0
  185. package/lib/service/worker/runtime/events/router.d.ts +2 -0
  186. package/lib/service/worker/runtime/events/router.js +28 -0
  187. package/lib/service/worker/runtime/graphql/index.d.ts +6 -0
  188. package/lib/service/worker/runtime/graphql/index.js +28 -0
  189. package/lib/service/worker/runtime/graphql/middlewares/context.d.ts +2 -0
  190. package/lib/service/worker/runtime/graphql/middlewares/context.js +17 -0
  191. package/lib/service/worker/runtime/graphql/middlewares/error.js +97 -0
  192. package/lib/service/worker/runtime/graphql/middlewares/query.d.ts +3 -0
  193. package/lib/service/worker/runtime/graphql/middlewares/query.js +53 -0
  194. package/lib/service/worker/runtime/graphql/middlewares/response.js +39 -0
  195. package/lib/service/worker/runtime/graphql/middlewares/run.d.ts +2 -0
  196. package/lib/service/worker/runtime/graphql/middlewares/run.js +20 -0
  197. package/lib/service/worker/runtime/graphql/middlewares/updateSchema.d.ts +5 -0
  198. package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +29 -0
  199. package/lib/service/worker/runtime/graphql/middlewares/upload.d.ts +4 -0
  200. package/lib/service/{graphql → worker/runtime/graphql}/middlewares/upload.js +1 -0
  201. package/lib/service/worker/runtime/graphql/schema/index.d.ts +7 -0
  202. package/lib/service/worker/runtime/graphql/schema/index.js +32 -0
  203. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +6 -0
  204. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +80 -0
  205. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Auth.d.ts +1 -0
  206. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Auth.js +17 -10
  207. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.d.ts +7 -0
  208. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.js +38 -0
  209. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.d.ts +11 -0
  210. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +62 -0
  211. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.d.ts +7 -0
  212. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.js +41 -0
  213. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Sanitize.d.ts +1 -0
  214. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Sanitize.js +7 -0
  215. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.d.ts +6 -0
  216. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +35 -0
  217. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/SmartCacheDirective.d.ts +1 -0
  218. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/SmartCacheDirective.js +9 -3
  219. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.d.ts +7 -0
  220. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +40 -0
  221. package/lib/service/{graphql/schema/schemaDirectives/Translatable.d.ts → worker/runtime/graphql/schema/schemaDirectives/TranslateTo.d.ts} +2 -1
  222. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +34 -0
  223. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.d.ts +22 -0
  224. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +37 -0
  225. package/lib/service/worker/runtime/graphql/schema/typeDefs/index.d.ts +8 -0
  226. package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +13 -0
  227. package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/ioUpload.js +1 -0
  228. package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/sanitizedString.js +6 -1
  229. package/lib/service/worker/runtime/graphql/typings.d.ts +31 -0
  230. package/lib/service/worker/runtime/graphql/utils/cacheControl.d.ts +2 -0
  231. package/lib/service/worker/runtime/graphql/utils/cacheControl.js +33 -0
  232. package/lib/service/worker/runtime/graphql/utils/error.d.ts +2 -0
  233. package/lib/service/worker/runtime/graphql/utils/error.js +77 -0
  234. package/lib/service/{graphql → worker/runtime/graphql}/utils/pathname.js +1 -0
  235. package/lib/service/worker/runtime/graphql/utils/translations.d.ts +14 -0
  236. package/lib/service/worker/runtime/graphql/utils/translations.js +39 -0
  237. package/lib/service/worker/runtime/http/index.d.ts +5 -0
  238. package/lib/service/worker/runtime/http/index.js +59 -0
  239. package/lib/service/worker/runtime/http/middlewares/authTokens.d.ts +3 -0
  240. package/lib/service/{http → worker/runtime/http}/middlewares/authTokens.js +1 -0
  241. package/lib/service/worker/runtime/http/middlewares/cancellationToken.d.ts +3 -0
  242. package/lib/service/{http → worker/runtime/http}/middlewares/cancellationToken.js +3 -1
  243. package/lib/service/worker/runtime/http/middlewares/clients.d.ts +4 -0
  244. package/lib/service/{http → worker/runtime/http}/middlewares/clients.js +1 -0
  245. package/lib/service/worker/runtime/http/middlewares/context.d.ts +4 -0
  246. package/lib/service/worker/runtime/http/middlewares/context.js +37 -0
  247. package/lib/service/worker/runtime/http/middlewares/error.d.ts +2 -0
  248. package/lib/service/{http → worker/runtime/http}/middlewares/error.js +28 -15
  249. package/lib/service/worker/runtime/http/middlewares/rateLimit.d.ts +6 -0
  250. package/lib/service/worker/runtime/http/middlewares/rateLimit.js +43 -0
  251. package/lib/service/{http → worker/runtime/http}/middlewares/requestStats.d.ts +3 -3
  252. package/lib/service/{http → worker/runtime/http}/middlewares/requestStats.js +1 -0
  253. package/lib/service/worker/runtime/http/middlewares/setCookie.d.ts +3 -0
  254. package/lib/service/{http → worker/runtime/http}/middlewares/setCookie.js +1 -0
  255. package/lib/service/worker/runtime/http/middlewares/settings.d.ts +9 -0
  256. package/lib/service/worker/runtime/http/middlewares/settings.js +45 -0
  257. package/lib/service/worker/runtime/http/middlewares/timings.d.ts +3 -0
  258. package/lib/service/{http → worker/runtime/http}/middlewares/timings.js +22 -8
  259. package/lib/service/worker/runtime/http/middlewares/vary.d.ts +3 -0
  260. package/lib/service/{http → worker/runtime/http}/middlewares/vary.js +4 -3
  261. package/lib/service/worker/runtime/http/router.d.ts +2 -0
  262. package/lib/service/worker/runtime/http/router.js +24 -0
  263. package/lib/service/worker/runtime/http/routes.d.ts +19 -0
  264. package/lib/service/worker/runtime/http/routes.js +13 -0
  265. package/lib/service/worker/runtime/method.d.ts +9 -0
  266. package/lib/service/{method.js → worker/runtime/method.js} +1 -0
  267. package/lib/service/worker/runtime/statusTrack.d.ts +14 -0
  268. package/lib/service/worker/runtime/statusTrack.js +38 -0
  269. package/lib/service/{typings.d.ts → worker/runtime/typings.d.ts} +70 -36
  270. package/lib/service/worker/runtime/utils/compose.d.ts +5 -0
  271. package/lib/service/{utils → worker/runtime/utils}/compose.js +3 -2
  272. package/lib/service/worker/runtime/utils/context.d.ts +5 -0
  273. package/lib/service/worker/runtime/utils/context.js +41 -0
  274. package/lib/service/worker/runtime/utils/diff.d.ts +12 -0
  275. package/lib/service/worker/runtime/utils/diff.js +22 -0
  276. package/lib/service/worker/runtime/utils/recorder.d.ts +8 -0
  277. package/lib/service/worker/runtime/utils/recorder.js +38 -0
  278. package/lib/service/{graphql/utils/array.js → worker/runtime/utils/toArray.js} +1 -0
  279. package/lib/service/worker/runtime/utils/tokenBucket.d.ts +2 -0
  280. package/lib/service/worker/runtime/utils/tokenBucket.js +17 -0
  281. package/lib/tracing/LogEvents.d.ts +31 -0
  282. package/lib/tracing/LogEvents.js +3 -0
  283. package/lib/tracing/LogFields.d.ts +66 -0
  284. package/lib/tracing/LogFields.js +3 -0
  285. package/lib/tracing/Tags.d.ts +81 -0
  286. package/lib/tracing/Tags.js +8 -0
  287. package/lib/tracing/UserLandTracer.d.ts +27 -0
  288. package/lib/tracing/UserLandTracer.js +57 -0
  289. package/lib/tracing/errorReporting/ErrorReport.d.ts +31 -0
  290. package/lib/tracing/errorReporting/ErrorReport.js +71 -0
  291. package/lib/tracing/index.d.ts +9 -0
  292. package/lib/tracing/index.js +20 -0
  293. package/lib/tracing/spanReference/SpanReferenceTypes.d.ts +4 -0
  294. package/lib/tracing/spanReference/SpanReferenceTypes.js +8 -0
  295. package/lib/tracing/spanReference/createSpanReference.d.ts +3 -0
  296. package/lib/tracing/spanReference/createSpanReference.js +9 -0
  297. package/lib/tracing/utils.d.ts +13 -0
  298. package/lib/tracing/utils.js +41 -0
  299. package/lib/utils/MineWinsConflictsResolver.d.ts +6 -4
  300. package/lib/utils/MineWinsConflictsResolver.js +35 -17
  301. package/lib/utils/app.d.ts +3 -1
  302. package/lib/utils/app.js +4 -1
  303. package/lib/utils/appsStaleIfError.d.ts +1 -1
  304. package/lib/utils/appsStaleIfError.js +20 -7
  305. package/lib/utils/billingOptions.d.ts +36 -3
  306. package/lib/utils/billingOptions.js +8 -3
  307. package/lib/utils/binding.d.ts +3 -3
  308. package/lib/utils/binding.js +1 -0
  309. package/lib/utils/buildFullPath.d.ts +11 -0
  310. package/lib/utils/buildFullPath.js +54 -0
  311. package/lib/utils/cancel.d.ts +2 -2
  312. package/lib/utils/cancel.js +3 -1
  313. package/lib/utils/conflicts.mock.d.ts +17 -0
  314. package/lib/utils/conflicts.mock.js +28 -0
  315. package/lib/utils/domain.js +1 -0
  316. package/lib/utils/error.js +1 -0
  317. package/lib/utils/index.js +19 -12
  318. package/lib/utils/json.js +1 -0
  319. package/lib/utils/log.d.ts +1 -3
  320. package/lib/utils/log.js +3 -2
  321. package/lib/utils/message.js +5 -1
  322. package/lib/utils/renameBy.js +1 -0
  323. package/lib/utils/retry.js +3 -2
  324. package/lib/utils/status.js +1 -0
  325. package/lib/utils/tenant.d.ts +3 -3
  326. package/lib/utils/tenant.js +1 -0
  327. package/lib/utils/throwOnGraphQLErrors.js +1 -0
  328. package/lib/utils/time.d.ts +7 -7
  329. package/lib/utils/time.js +10 -2
  330. package/package.json +3 -3
  331. package/lib/HttpClient/IOClient.js +0 -14
  332. package/lib/HttpClient/factories/index.d.ts +0 -8
  333. package/lib/HttpClient/factories/index.js +0 -31
  334. package/lib/HttpClient/middlewares/request.d.ts +0 -10
  335. package/lib/HttpClient/middlewares/request.js +0 -87
  336. package/lib/IODataSource.d.ts +0 -27
  337. package/lib/IODataSource.js +0 -46
  338. package/lib/clients/Apps.d.ts +0 -84
  339. package/lib/clients/Apps.js +0 -326
  340. package/lib/clients/Assets.d.ts +0 -21
  341. package/lib/clients/Billing.d.ts +0 -11
  342. package/lib/clients/BillingMetrics.d.ts +0 -12
  343. package/lib/clients/BillingMetrics.js +0 -10
  344. package/lib/clients/Events.d.ts +0 -6
  345. package/lib/clients/Events.js +0 -19
  346. package/lib/clients/Housekeeper.d.ts +0 -11
  347. package/lib/clients/Housekeeper.js +0 -24
  348. package/lib/clients/ID.d.ts +0 -22
  349. package/lib/clients/ID.js +0 -48
  350. package/lib/clients/LicenseManager.d.ts +0 -6
  351. package/lib/clients/Logger.d.ts +0 -27
  352. package/lib/clients/Logger.js +0 -32
  353. package/lib/clients/Messages.d.ts +0 -18
  354. package/lib/clients/Messages.js +0 -20
  355. package/lib/clients/MessagesGraphQL.d.ts +0 -63
  356. package/lib/clients/MessagesGraphQL.js +0 -50
  357. package/lib/clients/Metadata.d.ts +0 -25
  358. package/lib/clients/Metadata.js +0 -53
  359. package/lib/clients/Registry.d.ts +0 -61
  360. package/lib/clients/Router.d.ts +0 -33
  361. package/lib/clients/Router.js +0 -50
  362. package/lib/clients/Segment.js +0 -69
  363. package/lib/clients/Sphinx.d.ts +0 -12
  364. package/lib/clients/Sphinx.js +0 -19
  365. package/lib/clients/Tenant.js +0 -13
  366. package/lib/clients/VBase.d.ts +0 -57
  367. package/lib/clients/VBase.js +0 -116
  368. package/lib/clients/Workspaces.d.ts +0 -17
  369. package/lib/clients/Workspaces.js +0 -38
  370. package/lib/service/Runtime.d.ts +0 -18
  371. package/lib/service/Runtime.js +0 -57
  372. package/lib/service/events/index.d.ts +0 -3
  373. package/lib/service/events/index.js +0 -21
  374. package/lib/service/graphql/index.d.ts +0 -7
  375. package/lib/service/graphql/index.js +0 -33
  376. package/lib/service/graphql/middlewares/error.js +0 -107
  377. package/lib/service/graphql/middlewares/formatters.d.ts +0 -2
  378. package/lib/service/graphql/middlewares/formatters.js +0 -64
  379. package/lib/service/graphql/middlewares/query.d.ts +0 -2
  380. package/lib/service/graphql/middlewares/query.js +0 -32
  381. package/lib/service/graphql/middlewares/response.js +0 -36
  382. package/lib/service/graphql/middlewares/run.d.ts +0 -4
  383. package/lib/service/graphql/middlewares/run.js +0 -55
  384. package/lib/service/graphql/middlewares/schema.d.ts +0 -2
  385. package/lib/service/graphql/middlewares/schema.js +0 -8
  386. package/lib/service/graphql/middlewares/timings.d.ts +0 -2
  387. package/lib/service/graphql/middlewares/timings.js +0 -10
  388. package/lib/service/graphql/middlewares/upload.d.ts +0 -7
  389. package/lib/service/graphql/schema/index.d.ts +0 -3
  390. package/lib/service/graphql/schema/index.js +0 -66
  391. package/lib/service/graphql/schema/messagesLoader.d.ts +0 -4
  392. package/lib/service/graphql/schema/messagesLoader.js +0 -41
  393. package/lib/service/graphql/schema/messagesLoaderV2.d.ts +0 -5
  394. package/lib/service/graphql/schema/messagesLoaderV2.js +0 -44
  395. package/lib/service/graphql/schema/schemaDirectives/Translatable.js +0 -54
  396. package/lib/service/graphql/schema/schemaDirectives/TranslatableV2.d.ts +0 -13
  397. package/lib/service/graphql/schema/schemaDirectives/TranslatableV2.js +0 -67
  398. package/lib/service/graphql/schema/schemaDirectives/index.d.ts +0 -13
  399. package/lib/service/graphql/schema/schemaDirectives/index.js +0 -17
  400. package/lib/service/graphql/schema/typeDefs/index.d.ts +0 -16
  401. package/lib/service/graphql/schema/typeDefs/index.js +0 -21
  402. package/lib/service/graphql/schema/typeDefs/ioMessage.d.ts +0 -8
  403. package/lib/service/graphql/schema/typeDefs/ioMessage.js +0 -33
  404. package/lib/service/graphql/typings.d.ts +0 -21
  405. package/lib/service/graphql/utils/cacheControl.d.ts +0 -6
  406. package/lib/service/graphql/utils/cacheControl.js +0 -38
  407. package/lib/service/graphql/utils/maxAgeEnum.d.ts +0 -6
  408. package/lib/service/graphql/utils/maxAgeEnum.js +0 -17
  409. package/lib/service/http/index.d.ts +0 -3
  410. package/lib/service/http/index.js +0 -18
  411. package/lib/service/http/middlewares/authTokens.d.ts +0 -3
  412. package/lib/service/http/middlewares/cancellationToken.d.ts +0 -3
  413. package/lib/service/http/middlewares/clients.d.ts +0 -4
  414. package/lib/service/http/middlewares/error.d.ts +0 -3
  415. package/lib/service/http/middlewares/setCookie.d.ts +0 -3
  416. package/lib/service/http/middlewares/timings.d.ts +0 -3
  417. package/lib/service/http/middlewares/vary.d.ts +0 -3
  418. package/lib/service/method.d.ts +0 -9
  419. package/lib/service/utils/compose.d.ts +0 -4
  420. package/lib/utils/MineWinsConflictsResolver.test.d.ts +0 -1
  421. package/lib/utils/MineWinsConflictsResolver.test.js +0 -134
  422. package/lib/utils/unhandled.d.ts +0 -1
  423. /package/lib/service/{graphql → worker/runtime/graphql}/middlewares/error.d.ts +0 -0
  424. /package/lib/service/{graphql → worker/runtime/graphql}/middlewares/response.d.ts +0 -0
  425. /package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/ioUpload.d.ts +0 -0
  426. /package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/sanitizedString.d.ts +0 -0
  427. /package/lib/service/{graphql → worker/runtime/graphql}/typings.js +0 -0
  428. /package/lib/service/{graphql → worker/runtime/graphql}/utils/pathname.d.ts +0 -0
  429. /package/lib/service/{typings.js → worker/runtime/typings.js} +0 -0
  430. /package/lib/service/{graphql/utils/array.d.ts → worker/runtime/utils/toArray.d.ts} +0 -0
@@ -0,0 +1,34 @@
1
+ /// <reference types="node" />
2
+ import { Readable } from 'stream';
3
+ import { AppMetaInfo } from '../..';
4
+ import { InstanceOptions, RequestTracingConfig } from '../../HttpClient';
5
+ import { IOContext } from '../../service/worker/runtime/typings';
6
+ import { InfraClient } from './InfraClient';
7
+ export interface AssetsParams {
8
+ files?: string[];
9
+ pick?: string[];
10
+ }
11
+ export declare class Assets extends InfraClient {
12
+ private routes;
13
+ constructor(context: IOContext, options?: InstanceOptions);
14
+ getSettings(dependencies: AppMetaInfo[], appAtMajor: string, params?: AssetsParams, tracingConfig?: RequestTracingConfig): Promise<Record<string, any>[]>;
15
+ getBuildJSONForApp(app: AppMetaInfo, appVendorName: string, pick?: string | string[], tracingConfig?: RequestTracingConfig): Promise<Record<string, any>>;
16
+ getSettingsFromFilesForApp(app: AppMetaInfo, files?: string | string[], tracingConfig?: RequestTracingConfig): Promise<Record<string, any>>;
17
+ getJSON<T extends object | null>(appId: string, file: string, nullIfNotFound?: boolean, tracingConfig?: RequestTracingConfig): Promise<T>;
18
+ getFile(appId: string, file: string, nullIfNotFound?: boolean, tracingConfig?: RequestTracingConfig): Promise<{
19
+ data: Buffer;
20
+ headers: any;
21
+ }>;
22
+ getFilteredDependencies(apps: string | string[], dependencies: AppMetaInfo[]): AppMetaInfo[];
23
+ getAppBundleByVendor: (app: string, bundlePath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig | undefined) => Promise<Readable>;
24
+ protected getAppJSONByAccount: <T extends object | null>(app: string, path: string, nullIfNotFound?: boolean | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<T>;
25
+ protected getAppJSONByVendor: <T extends object | null>(app: string, path: string, nullIfNotFound?: boolean | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<T>;
26
+ protected getAppFileByAccount: (app: string, path: string, nullIfNotFound?: boolean | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
27
+ data: Buffer;
28
+ headers: any;
29
+ }>;
30
+ protected getAppFileByVendor: (app: string, path: string, nullIfNotFound?: boolean | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
31
+ data: Buffer;
32
+ headers: any;
33
+ }>;
34
+ }
@@ -1,16 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Assets = void 0;
3
4
  const ramda_1 = require("ramda");
4
- const HttpClient_1 = require("../HttpClient");
5
- const utils_1 = require("../utils");
5
+ const HttpClient_1 = require("../../HttpClient");
6
+ const utils_1 = require("../../utils");
7
+ const InfraClient_1 = require("./InfraClient");
6
8
  const dependsOnApp = (appsAtMajor) => (a) => {
7
9
  let dependsOn = false;
8
10
  appsAtMajor.forEach(appAtMajor => {
9
11
  const [name, major] = appAtMajor.split('@');
12
+ const sanitizedMajor = major.includes('.') ? major.split('.')[0] : major;
10
13
  const version = a._resolvedDependencies[name];
11
14
  if (version) {
12
15
  const [depMajor] = version.split('.');
13
- if (major === depMajor) {
16
+ if (sanitizedMajor === depMajor) {
14
17
  dependsOn = true;
15
18
  }
16
19
  }
@@ -28,10 +31,10 @@ const createRoutes = (workspace) => ({
28
31
  Bundle: (scope, locator, path) => `/${scope}/${appOrRegistry(workspace, locator)}/bundle/${path}`,
29
32
  Files: (scope, locator, path) => `/${scope}/${appOrRegistry(workspace, locator)}/files/${path}`,
30
33
  });
31
- class Assets extends HttpClient_1.InfraClient {
34
+ class Assets extends InfraClient_1.InfraClient {
32
35
  constructor(context, options) {
33
36
  super('apps@0.x', context, options, true);
34
- this.getAppBundleByVendor = (app, bundlePath, generatePackageJson) => {
37
+ this.getAppBundleByVendor = (app, bundlePath, generatePackageJson, tracingConfig) => {
35
38
  const locator = utils_1.parseAppId(app);
36
39
  const params = generatePackageJson && { _packageJSONEngine: 'npm', _packageJSONFilter: 'vtex.render-builder@x' };
37
40
  const metric = locator.build ? 'apps-get-bundle' : 'registry-get-bundle';
@@ -42,64 +45,117 @@ class Assets extends HttpClient_1.InfraClient {
42
45
  },
43
46
  metric,
44
47
  params,
48
+ tracing: {
49
+ requestSpanNameSuffix: metric,
50
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
51
+ },
45
52
  });
46
53
  };
47
- this.getAppFileByAccount = (app, path, nullIfNotFound) => {
54
+ this.getAppJSONByAccount = (app, path, nullIfNotFound, tracingConfig) => {
48
55
  const locator = utils_1.parseAppId(app);
49
56
  const inflightKey = HttpClient_1.inflightURL;
57
+ const metric = 'assets-get-json-by-account';
50
58
  return this.http.get(this.routes.Files(this.context.account, locator, path), {
51
59
  cacheable: HttpClient_1.CacheType.Memory,
52
60
  inflightKey,
53
- metric: 'assets-get-json-by-account',
61
+ metric,
54
62
  nullIfNotFound,
63
+ tracing: {
64
+ requestSpanNameSuffix: metric,
65
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
66
+ },
55
67
  });
56
68
  };
57
- this.getAppFileByVendor = (app, path, nullIfNotFound) => {
69
+ this.getAppJSONByVendor = (app, path, nullIfNotFound, tracingConfig) => {
58
70
  const locator = utils_1.parseAppId(app);
59
71
  const vendor = locator.name.split('.')[0];
60
72
  const inflightKey = HttpClient_1.inflightURL;
73
+ const metric = 'assets-get-json-by-vendor';
61
74
  return this.http.get(this.routes.Files(vendor, locator, path), {
62
75
  cacheable: HttpClient_1.CacheType.Any,
63
76
  inflightKey,
64
- metric: 'assets-get-json-by-vendor',
77
+ metric,
65
78
  nullIfNotFound,
79
+ tracing: {
80
+ requestSpanNameSuffix: metric,
81
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
82
+ },
83
+ });
84
+ };
85
+ this.getAppFileByAccount = (app, path, nullIfNotFound, tracingConfig) => {
86
+ const locator = utils_1.parseAppId(app);
87
+ const inflightKey = HttpClient_1.inflightURL;
88
+ const metric = 'assets-get-file-by-account';
89
+ return this.http.getBuffer(this.routes.Files(this.context.account, locator, path), {
90
+ cacheable: HttpClient_1.CacheType.Any,
91
+ inflightKey,
92
+ metric,
93
+ nullIfNotFound,
94
+ tracing: {
95
+ requestSpanNameSuffix: metric,
96
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
97
+ },
98
+ });
99
+ };
100
+ this.getAppFileByVendor = (app, path, nullIfNotFound, tracingConfig) => {
101
+ const locator = utils_1.parseAppId(app);
102
+ const vendor = locator.name.split('.')[0];
103
+ const inflightKey = HttpClient_1.inflightURL;
104
+ const metric = 'assets-get-file-by-vendor';
105
+ return this.http.getBuffer(this.routes.Files(vendor, locator, path), {
106
+ cacheable: HttpClient_1.CacheType.Any,
107
+ inflightKey,
108
+ metric,
109
+ nullIfNotFound,
110
+ tracing: {
111
+ requestSpanNameSuffix: metric,
112
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
113
+ },
66
114
  });
67
115
  };
68
116
  this.routes = createRoutes(this.context.workspace);
69
117
  }
70
- getSettings(dependencies, appAtMajor, params = {}) {
118
+ getSettings(dependencies, appAtMajor, params = {}, tracingConfig) {
71
119
  const { pick, files } = params;
72
120
  const filtered = this.getFilteredDependencies(appAtMajor, dependencies);
73
121
  return Promise.all(filtered.map(dependency => {
74
122
  const [appVendorName] = appAtMajor.split('@');
75
123
  const buildJson = useBuildJson(dependency, appVendorName);
76
124
  return buildJson
77
- ? this.getBuildJSONForApp(dependency, appVendorName, pick)
78
- : this.getSettingsFromFilesForApp(dependency, files);
125
+ ? this.getBuildJSONForApp(dependency, appVendorName, pick, tracingConfig)
126
+ : this.getSettingsFromFilesForApp(dependency, files, tracingConfig);
79
127
  }));
80
128
  }
81
- async getBuildJSONForApp(app, appVendorName, pick = []) {
129
+ async getBuildJSONForApp(app, appVendorName, pick = [], tracingConfig) {
82
130
  const pickArray = Array.isArray(pick) ? pick : [pick];
83
- const buildJson = await this.getFile(app.id, `dist/${appVendorName}/build.json`);
131
+ const buildJson = await this.getJSON(app.id, `dist/${appVendorName}/build.json`, undefined, tracingConfig);
84
132
  const result = !ramda_1.isEmpty(pickArray) ? ramda_1.pick(pickArray, buildJson) : buildJson;
85
133
  result.declarer = app.id;
86
134
  return result;
87
135
  }
88
- async getSettingsFromFilesForApp(app, files = []) {
136
+ async getSettingsFromFilesForApp(app, files = [], tracingConfig) {
89
137
  // If there's no support for build.json, then fetch individual files and zip them into an {[file]: content} object.
90
138
  const filesArray = Array.isArray(files) ? files : [files];
91
- const fetched = await Promise.all(filesArray.map(file => this.getFile(app.id, file, true)));
139
+ const fetched = await Promise.all(filesArray.map(file => this.getJSON(app.id, file, true, tracingConfig)));
92
140
  const result = ramda_1.zipObj(filesArray, fetched);
93
141
  result.declarer = app.id;
94
142
  return result;
95
143
  }
96
- async getFile(appId, file, nullIfNotFound) {
144
+ async getJSON(appId, file, nullIfNotFound, tracingConfig) {
145
+ const locator = utils_1.parseAppId(appId);
146
+ const linked = !!locator.build;
147
+ if (linked) {
148
+ return this.getAppJSONByAccount(appId, file, nullIfNotFound, tracingConfig);
149
+ }
150
+ return this.getAppJSONByVendor(appId, file, nullIfNotFound, tracingConfig);
151
+ }
152
+ async getFile(appId, file, nullIfNotFound, tracingConfig) {
97
153
  const locator = utils_1.parseAppId(appId);
98
154
  const linked = !!locator.build;
99
155
  if (linked) {
100
- return this.getAppFileByAccount(appId, file, nullIfNotFound);
156
+ return this.getAppFileByAccount(appId, file, nullIfNotFound, tracingConfig);
101
157
  }
102
- return this.getAppFileByVendor(appId, file, nullIfNotFound);
158
+ return this.getAppFileByVendor(appId, file, nullIfNotFound, tracingConfig);
103
159
  }
104
160
  getFilteredDependencies(apps, dependencies) {
105
161
  const appsAtMajor = typeof (apps) === 'string' ? [apps] : apps;
@@ -0,0 +1,13 @@
1
+ import { InstanceOptions, RequestTracingConfig } from '../../HttpClient';
2
+ import { IOContext } from '../../service/worker/runtime/typings';
3
+ import { InfraClient } from './InfraClient';
4
+ export declare class BillingMetrics extends InfraClient {
5
+ constructor(context: IOContext, options?: InstanceOptions);
6
+ sendMetric: (metric: BillingMetric, tracingConfig?: RequestTracingConfig | undefined) => Promise<BillingMetric>;
7
+ }
8
+ export interface BillingMetric {
9
+ value: number;
10
+ unit: string;
11
+ metricId: string;
12
+ timestamp?: number;
13
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BillingMetrics = void 0;
4
+ const InfraClient_1 = require("./InfraClient");
5
+ class BillingMetrics extends InfraClient_1.InfraClient {
6
+ constructor(context, options) {
7
+ super('colossus@0.x', context, options);
8
+ this.sendMetric = (metric, tracingConfig) => {
9
+ return this.http.post('/metrics', metric, { tracing: {
10
+ requestSpanNameSuffix: 'send-metric',
11
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
12
+ } });
13
+ };
14
+ }
15
+ }
16
+ exports.BillingMetrics = BillingMetrics;
@@ -0,0 +1,12 @@
1
+ import { InstanceOptions, RequestTracingConfig } from '../../HttpClient';
2
+ import { IOContext } from '../../service/worker/runtime/typings';
3
+ import { InfraClient } from './InfraClient';
4
+ export declare class Events extends InfraClient {
5
+ constructor({ recorder, ...context }: IOContext, options?: InstanceOptions);
6
+ sendEvent: (appIdOrResource: string | ResourceVRN, route: string, message?: any, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
7
+ private resourceFor;
8
+ }
9
+ export interface ResourceVRN {
10
+ service: string;
11
+ path: string;
12
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Events = void 0;
4
+ const util_1 = require("util");
5
+ const InfraClient_1 = require("./InfraClient");
6
+ const ANY_APP = '';
7
+ const eventRoute = (route) => `/events/${route}`;
8
+ const isResourceVRN = (appIdOrResource) => util_1.isObject(appIdOrResource) && !util_1.isNullOrUndefined(appIdOrResource.service);
9
+ class Events extends InfraClient_1.InfraClient {
10
+ constructor({ recorder, ...context }, options) {
11
+ super('courier@0.x', context, options);
12
+ this.sendEvent = (appIdOrResource, route, message, tracingConfig) => {
13
+ const resource = this.resourceFor(appIdOrResource);
14
+ return this.http.put(eventRoute(route), message, {
15
+ metric: 'events-send',
16
+ params: { resource },
17
+ tracing: {
18
+ requestSpanNameSuffix: 'events-send',
19
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
20
+ },
21
+ });
22
+ };
23
+ this.resourceFor = (appIdOrResource) => {
24
+ if (appIdOrResource === ANY_APP) {
25
+ return ANY_APP;
26
+ }
27
+ const { service, path } = isResourceVRN(appIdOrResource)
28
+ ? appIdOrResource
29
+ : { service: 'apps', path: `/apps/${appIdOrResource}` };
30
+ return `vrn:${service}:${this.context.region}:${this.context.account}:${this.context.workspace}:${path}`;
31
+ };
32
+ }
33
+ }
34
+ exports.Events = Events;
@@ -0,0 +1,10 @@
1
+ import { InstanceOptions, RequestTracingConfig } from '../../HttpClient';
2
+ import { HousekeeperStatesAndUpdates } from '../../responses';
3
+ import { IOContext } from '../../service/worker/runtime/typings';
4
+ import { InfraClient } from './InfraClient';
5
+ export declare class Housekeeper extends InfraClient {
6
+ constructor(context: IOContext, options?: InstanceOptions);
7
+ apply: (data: HousekeeperStatesAndUpdates, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
8
+ perform: (tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
9
+ resolve: (tracingConfig?: RequestTracingConfig | undefined) => Promise<HousekeeperStatesAndUpdates>;
10
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Housekeeper = void 0;
4
+ const InfraClient_1 = require("./InfraClient");
5
+ class Housekeeper extends InfraClient_1.InfraClient {
6
+ constructor(context, options) {
7
+ super('housekeeper@0.x', context, options);
8
+ this.apply = async (data, tracingConfig) => {
9
+ const metric = 'housekeeper-apply';
10
+ return this.http.post('v2/housekeeping/apply', data, { metric, tracing: {
11
+ requestSpanNameSuffix: metric,
12
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
13
+ } });
14
+ };
15
+ this.perform = async (tracingConfig) => {
16
+ const metric = 'housekeeper-perform';
17
+ return this.http.post('v2/_housekeeping/perform', {}, { metric, tracing: {
18
+ requestSpanNameSuffix: metric,
19
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
20
+ } });
21
+ };
22
+ this.resolve = async (tracingConfig) => {
23
+ const metric = 'housekeeper-resolve';
24
+ return this.http.get('v2/housekeeping/resolve', { metric, tracing: {
25
+ requestSpanNameSuffix: metric,
26
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
27
+ } });
28
+ };
29
+ }
30
+ }
31
+ exports.Housekeeper = Housekeeper;
@@ -1,6 +1,6 @@
1
- import { IOContext } from '../service/typings';
2
- import { IOClient } from './IOClient';
3
- import { InstanceOptions } from './typings';
1
+ import { InstanceOptions } from '../../HttpClient/typings';
2
+ import { IOContext } from '../../service/worker/runtime/typings';
3
+ import { IOClient } from '../IOClient';
4
4
  /**
5
5
  * Used to perform calls on infra apps (e.g. sphinx, apps, vbase).
6
6
  */
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const IOClient_1 = require("./IOClient");
4
- const typings_1 = require("./typings");
5
- const useHttps = !process.env.VTEX_IO;
3
+ exports.InfraClient = void 0;
4
+ const constants_1 = require("../../constants");
5
+ const typings_1 = require("../../HttpClient/typings");
6
+ const IOClient_1 = require("../IOClient");
7
+ const useHttps = !constants_1.IS_IO;
6
8
  /**
7
9
  * Used to perform calls on infra apps (e.g. sphinx, apps, vbase).
8
10
  */
@@ -23,7 +25,11 @@ class InfraClient extends IOClient_1.IOClient {
23
25
  console.warn(`${account} in ${workspace} is using old routing for ${app}. This will stop working soon`);
24
26
  baseURL = `http://${app}.${region}.vtex.io${isRoot ? '' : `/${account}/${workspace}`}`;
25
27
  }
26
- super(context, Object.assign({}, options, { authType: typings_1.AuthType.bearer, baseURL }));
28
+ super(context, {
29
+ ...options,
30
+ authType: typings_1.AuthType.bearer,
31
+ baseURL,
32
+ });
27
33
  }
28
34
  }
29
35
  exports.InfraClient = InfraClient;
@@ -0,0 +1,59 @@
1
+ /// <reference types="node" />
2
+ import { IncomingMessage } from 'http';
3
+ import { Readable, Writable } from 'stream';
4
+ import { ZlibOptions } from 'zlib';
5
+ import { InstanceOptions, RequestTracingConfig } from '../../HttpClient';
6
+ import { AppBundlePublished, AppFilesList, AppManifest, AppState } from '../../responses';
7
+ import { IOContext } from '../../service/worker/runtime/typings';
8
+ import { InfraClient } from './InfraClient';
9
+ export declare class Registry extends InfraClient {
10
+ constructor(context: IOContext, options?: InstanceOptions);
11
+ getAppState: (app: string, version: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppState>;
12
+ publishApp: (files: File[], tag?: string | undefined, { zlib }?: ZipOptions, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppBundlePublished>;
13
+ publishAppRc: (files: File[], tag?: string | undefined, { zlib }?: ZipOptions, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppBundlePublished>;
14
+ listApps: (tracingConfig?: RequestTracingConfig | undefined) => Promise<RegistryAppsList>;
15
+ listVersionsByApp: (app: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<RegistryAppVersionsList>;
16
+ deprecateApp: (app: string, version: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
17
+ undeprecateApp: (app: string, version: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
18
+ validateApp: (app: string, version: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
19
+ getAppManifest: (app: string, version: string, opts?: AppsManifestOptions | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppManifest>;
20
+ listAppFiles: (app: string, version: string, opts?: ListAppFilesOptions | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppFilesList>;
21
+ getAppFile: (app: string, version: string, path: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
22
+ data: Buffer;
23
+ headers: any;
24
+ }>;
25
+ getAppJSON: <T extends object | null>(app: string, version: string, path: string, nullIfNotFound?: boolean | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<T>;
26
+ getAppFileStream: (app: string, version: string, path: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<IncomingMessage>;
27
+ getAppBundle: (app: string, version: string, bundlePath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig | undefined) => Promise<Readable>;
28
+ unpackAppBundle: (app: string, version: string, bundlePath: string, unpackPath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig | undefined) => Promise<Writable>;
29
+ resolveDependenciesWithManifest: (manifest: AppManifest, filter?: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<Record<string, string[]>>;
30
+ private publish;
31
+ }
32
+ interface ZipOptions {
33
+ zlib?: ZlibOptions;
34
+ }
35
+ export interface AppsManifestOptions {
36
+ resolveDeps: boolean;
37
+ }
38
+ export interface ListAppFilesOptions {
39
+ prefix: string;
40
+ }
41
+ export interface RegistryAppsListItem {
42
+ partialIdentifier: string;
43
+ location: string;
44
+ }
45
+ export interface RegistryAppsList {
46
+ data: RegistryAppsListItem[];
47
+ }
48
+ export interface RegistryAppVersionsListItem {
49
+ versionIdentifier: string;
50
+ location: string;
51
+ }
52
+ export interface RegistryAppVersionsList {
53
+ data: RegistryAppVersionsListItem[];
54
+ }
55
+ export interface File {
56
+ path: string;
57
+ content: any;
58
+ }
59
+ export {};
@@ -3,11 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Registry = void 0;
6
7
  const archiver_1 = __importDefault(require("archiver"));
7
8
  const tar_fs_1 = require("tar-fs");
8
9
  const zlib_1 = require("zlib");
9
- const constants_1 = require("../constants");
10
- const HttpClient_1 = require("../HttpClient");
10
+ const constants_1 = require("../../constants");
11
+ const HttpClient_1 = require("../../HttpClient");
12
+ const InfraClient_1 = require("./InfraClient");
11
13
  const EMPTY_OBJECT = {};
12
14
  const routes = {
13
15
  App: (app) => `${routes.Registry}/${app}`,
@@ -16,66 +18,103 @@ const routes = {
16
18
  },
17
19
  AppFile: (app, version, path) => `${routes.AppFiles(app, version)}/${path}`,
18
20
  AppFiles: (app, version) => `${routes.AppVersion(app, version)}/files`,
19
- AppQueryString: (basePath, appQueryString) => appQueryString ? `${basePath}?${appQueryString.name}=${appQueryString.value}` : basePath,
21
+ AppState: (app, version) => `${routes.AppVersion(app, version)}/state`,
20
22
  AppVersion: (app, version) => `${routes.App(app)}/${version}`,
21
23
  Publish: '/v2/registry',
22
24
  PublishRc: '/v2/registry/rc',
23
25
  Registry: '/registry',
24
26
  ResolveDependenciesWithManifest: '/v2/registry/_resolve',
25
27
  };
26
- class Registry extends HttpClient_1.InfraClient {
28
+ class Registry extends InfraClient_1.InfraClient {
27
29
  constructor(context, options) {
28
- super('apps@0.x', Object.assign({}, context, { workspace: constants_1.DEFAULT_WORKSPACE }), options);
29
- this.publishApp = (files, tag, { zlib } = {}) => {
30
- return this.publish(routes.Publish, files, tag, { zlib });
30
+ super('apps@0.x', { ...context, workspace: constants_1.DEFAULT_WORKSPACE }, options);
31
+ this.getAppState = (app, version, tracingConfig) => {
32
+ const metric = 'registry-app-state';
33
+ const inflightKey = HttpClient_1.inflightUrlWithQuery;
34
+ return this.http.get(routes.AppState(app, version), {
35
+ inflightKey,
36
+ metric,
37
+ tracing: {
38
+ requestSpanNameSuffix: metric,
39
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
40
+ },
41
+ });
42
+ };
43
+ this.publishApp = (files, tag, { zlib } = {}, tracingConfig) => {
44
+ return this.publish(routes.Publish, files, tag, { zlib }, tracingConfig);
31
45
  };
32
- this.publishAppRc = (files, tag, { zlib } = {}) => {
33
- return this.publish(routes.PublishRc, files, tag, { zlib });
46
+ this.publishAppRc = (files, tag, { zlib } = {}, tracingConfig) => {
47
+ return this.publish(routes.PublishRc, files, tag, { zlib }, tracingConfig);
34
48
  };
35
- this.listApps = () => {
49
+ this.listApps = (tracingConfig) => {
36
50
  const inflightKey = HttpClient_1.inflightURL;
37
51
  const metric = 'registry-list';
38
- return this.http.get(routes.Registry, { metric, inflightKey });
52
+ return this.http.get(routes.Registry, { inflightKey, metric, tracing: {
53
+ requestSpanNameSuffix: metric,
54
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
55
+ } });
39
56
  };
40
- this.listVersionsByApp = (app) => {
57
+ this.listVersionsByApp = (app, tracingConfig) => {
41
58
  const inflightKey = HttpClient_1.inflightURL;
42
59
  const metric = 'registry-list-versions';
43
- return this.http.get(routes.App(app), { metric, inflightKey });
60
+ return this.http.get(routes.App(app), { inflightKey, metric, tracing: {
61
+ requestSpanNameSuffix: metric,
62
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
63
+ } });
44
64
  };
45
- this.deprecateApp = (app, version) => {
65
+ this.deprecateApp = (app, version, tracingConfig) => {
46
66
  const metric = 'registry-deprecate';
47
- return this.http.patch(routes.AppVersion(app, version), { patchState: 'deprecate' }, { metric });
67
+ return this.http.patch(routes.AppVersion(app, version), { patchState: 'deprecate' }, { metric, tracing: {
68
+ requestSpanNameSuffix: metric,
69
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
70
+ } });
48
71
  };
49
- this.undeprecateApp = (app, version) => {
72
+ this.undeprecateApp = (app, version, tracingConfig) => {
50
73
  const metric = 'registry-undeprecate';
51
- return this.http.patch(routes.AppVersion(app, version), { patchState: 'undeprecate' }, { metric });
74
+ return this.http.patch(routes.AppVersion(app, version), { patchState: 'undeprecate' }, { metric, tracing: {
75
+ requestSpanNameSuffix: metric,
76
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
77
+ } });
52
78
  };
53
- this.validateApp = (app, version, appQueryString) => {
79
+ this.validateApp = (app, version, tracingConfig) => {
54
80
  const metric = 'registry-validate';
55
- return this.http.patch(routes.AppQueryString(routes.AppVersion(app, version), appQueryString), { patchState: 'validate' }, { metric });
81
+ return this.http.patch(routes.AppVersion(app, version), { patchState: 'validate' }, { metric, tracing: {
82
+ requestSpanNameSuffix: metric,
83
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
84
+ } });
56
85
  };
57
- this.getAppManifest = (app, version, opts) => {
86
+ this.getAppManifest = (app, version, opts, tracingConfig) => {
58
87
  const inflightKey = HttpClient_1.inflightUrlWithQuery;
59
88
  const params = opts;
60
89
  const metric = 'registry-manifest';
61
- return this.http.get(routes.AppVersion(app, version), { params, metric, inflightKey });
90
+ return this.http.get(routes.AppVersion(app, version), { inflightKey, metric, params, tracing: {
91
+ requestSpanNameSuffix: metric,
92
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
93
+ } });
62
94
  };
63
- this.listAppFiles = (app, version, opts) => {
95
+ this.listAppFiles = (app, version, opts, tracingConfig) => {
64
96
  const inflightKey = HttpClient_1.inflightUrlWithQuery;
65
97
  const params = opts;
66
98
  const metric = 'registry-list-files';
67
- return this.http.get(routes.AppFiles(app, version), { params, metric, inflightKey });
99
+ return this.http.get(routes.AppFiles(app, version), { inflightKey, metric, params, tracing: {
100
+ requestSpanNameSuffix: metric,
101
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
102
+ } });
68
103
  };
69
- this.getAppFile = (app, version, path) => {
104
+ this.getAppFile = (app, version, path, tracingConfig) => {
70
105
  const inflightKey = HttpClient_1.inflightURL;
71
106
  const metric = 'registry-get-file';
72
107
  return this.http.getBuffer(routes.AppFile(app, version, path), {
73
108
  cacheable: HttpClient_1.CacheType.Disk,
74
109
  inflightKey,
75
110
  metric,
111
+ tracing: {
112
+ requestSpanNameSuffix: metric,
113
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
114
+ },
76
115
  });
77
116
  };
78
- this.getAppJSON = (app, version, path, nullIfNotFound) => {
117
+ this.getAppJSON = (app, version, path, nullIfNotFound, tracingConfig) => {
79
118
  const inflightKey = HttpClient_1.inflightURL;
80
119
  const metric = 'registry-get-json';
81
120
  return this.http.get(routes.AppFile(app, version, path), {
@@ -83,12 +122,23 @@ class Registry extends HttpClient_1.InfraClient {
83
122
  inflightKey,
84
123
  metric,
85
124
  nullIfNotFound,
125
+ tracing: {
126
+ requestSpanNameSuffix: metric,
127
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
128
+ },
86
129
  });
87
130
  };
88
- this.getAppFileStream = (app, version, path) => {
89
- return this.http.getStream(routes.AppFile(app, version, path), { metric: 'registry-get-file-s' });
131
+ this.getAppFileStream = (app, version, path, tracingConfig) => {
132
+ const metric = 'registry-get-file-s';
133
+ return this.http.getStream(routes.AppFile(app, version, path), {
134
+ metric,
135
+ tracing: {
136
+ requestSpanNameSuffix: metric,
137
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
138
+ },
139
+ });
90
140
  };
91
- this.getAppBundle = (app, version, bundlePath, generatePackageJson) => {
141
+ this.getAppBundle = (app, version, bundlePath, generatePackageJson, tracingConfig) => {
92
142
  const params = generatePackageJson && { _packageJSONEngine: 'npm', _packageJSONFilter: 'vtex.render-builder@x' };
93
143
  const metric = 'registry-get-bundle';
94
144
  return this.http.getStream(routes.AppBundle(app, version, bundlePath), {
@@ -98,20 +148,27 @@ class Registry extends HttpClient_1.InfraClient {
98
148
  },
99
149
  metric,
100
150
  params,
151
+ tracing: {
152
+ requestSpanNameSuffix: metric,
153
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
154
+ },
101
155
  });
102
156
  };
103
- this.unpackAppBundle = (app, version, bundlePath, unpackPath, generatePackageJson) => {
104
- return this.getAppBundle(app, version, bundlePath, generatePackageJson)
157
+ this.unpackAppBundle = (app, version, bundlePath, unpackPath, generatePackageJson, tracingConfig) => {
158
+ return this.getAppBundle(app, version, bundlePath, generatePackageJson, tracingConfig)
105
159
  .then(stream => stream
106
160
  .pipe(zlib_1.createGunzip())
107
161
  .pipe(tar_fs_1.extract(unpackPath)));
108
162
  };
109
- this.resolveDependenciesWithManifest = (manifest, filter = '') => {
163
+ this.resolveDependenciesWithManifest = (manifest, filter = '', tracingConfig) => {
110
164
  const params = { filter };
111
165
  const metric = 'registry-resolve-deps';
112
- return this.http.post(routes.ResolveDependenciesWithManifest, manifest, { params, metric });
166
+ return this.http.post(routes.ResolveDependenciesWithManifest, manifest, { metric, params, tracing: {
167
+ requestSpanNameSuffix: metric,
168
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
169
+ } });
113
170
  };
114
- this.publish = async (route, files, tag, { zlib } = {}) => {
171
+ this.publish = async (route, files, tag, { zlib } = {}, tracingConfig) => {
115
172
  if (!(files[0] && files[0].path && files[0].content)) {
116
173
  throw new Error('Argument files must be an array of {path, content}, where content can be a String, a Buffer or a ReadableStream.');
117
174
  }
@@ -129,6 +186,10 @@ class Registry extends HttpClient_1.InfraClient {
129
186
  headers: { 'Content-Type': 'application/zip' },
130
187
  metric,
131
188
  params: tag ? { tag } : EMPTY_OBJECT,
189
+ tracing: {
190
+ requestSpanNameSuffix: metric,
191
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
192
+ },
132
193
  });
133
194
  files.forEach(({ content, path }) => zip.append(content, { name: path }));
134
195
  const finalize = zip.finalize();
@@ -138,6 +199,7 @@ class Registry extends HttpClient_1.InfraClient {
138
199
  return response;
139
200
  }
140
201
  catch (e) {
202
+ // See Apps.ts `link` method for more information on this cast
141
203
  e.bundleSize = zip.pointer();
142
204
  throw e;
143
205
  }