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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (440) hide show
  1. package/gen/manifest.schema +5 -3
  2. package/lib/HttpClient/GraphQLClient.d.ts +3 -2
  3. package/lib/HttpClient/GraphQLClient.js +5 -1
  4. package/lib/HttpClient/HttpClient.d.ts +9 -7
  5. package/lib/HttpClient/HttpClient.js +70 -27
  6. package/lib/HttpClient/agents.d.ts +6 -0
  7. package/lib/HttpClient/agents.js +43 -0
  8. package/lib/HttpClient/index.d.ts +1 -7
  9. package/lib/HttpClient/index.js +22 -16
  10. package/lib/HttpClient/middlewares/cache.d.ts +9 -3
  11. package/lib/HttpClient/middlewares/cache.js +130 -35
  12. package/lib/HttpClient/middlewares/cancellationToken.d.ts +2 -2
  13. package/lib/HttpClient/middlewares/cancellationToken.js +5 -2
  14. package/lib/HttpClient/middlewares/inflight.d.ts +1 -1
  15. package/lib/HttpClient/middlewares/inflight.js +7 -3
  16. package/lib/HttpClient/middlewares/memoization.d.ts +1 -1
  17. package/lib/HttpClient/middlewares/memoization.js +13 -4
  18. package/lib/HttpClient/middlewares/metrics.js +25 -38
  19. package/lib/HttpClient/middlewares/notFound.d.ts +1 -1
  20. package/lib/HttpClient/middlewares/notFound.js +5 -2
  21. package/lib/HttpClient/middlewares/recorder.d.ts +1 -1
  22. package/lib/HttpClient/middlewares/recorder.js +21 -12
  23. package/lib/HttpClient/middlewares/request/HttpAgentSingleton.d.ts +11 -0
  24. package/lib/HttpClient/middlewares/request/HttpAgentSingleton.js +31 -0
  25. package/lib/HttpClient/middlewares/request/index.d.ts +18 -0
  26. package/lib/HttpClient/middlewares/request/index.js +88 -0
  27. package/lib/HttpClient/middlewares/request/setupAxios/index.d.ts +1 -0
  28. package/lib/HttpClient/middlewares/request/setupAxios/index.js +22 -0
  29. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.d.ts +2 -0
  30. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +55 -0
  31. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.d.ts +2 -0
  32. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +8 -0
  33. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.d.ts +8 -0
  34. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.js +56 -0
  35. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.d.ts +4 -0
  36. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +32 -0
  37. package/lib/HttpClient/middlewares/tracing.d.ts +15 -0
  38. package/lib/HttpClient/middlewares/tracing.js +62 -0
  39. package/lib/HttpClient/typings.d.ts +46 -12
  40. package/lib/HttpClient/typings.js +1 -0
  41. package/lib/caches/DiskCache.d.ts +1 -1
  42. package/lib/caches/DiskCache.js +3 -2
  43. package/lib/caches/LRUCache.d.ts +3 -3
  44. package/lib/caches/LRUCache.js +6 -1
  45. package/lib/caches/LRUDiskCache.d.ts +2 -2
  46. package/lib/caches/LRUDiskCache.js +8 -3
  47. package/lib/caches/MultilayeredCache.d.ts +2 -2
  48. package/lib/caches/MultilayeredCache.js +8 -7
  49. package/lib/caches/index.js +20 -7
  50. package/lib/caches/typings.d.ts +5 -5
  51. package/lib/clients/IOClient.d.ts +13 -0
  52. package/lib/clients/IOClient.js +20 -0
  53. package/lib/clients/IOClients.d.ts +29 -25
  54. package/lib/clients/IOClients.js +36 -28
  55. package/lib/{HttpClient → clients}/IOGraphQLClient.d.ts +4 -4
  56. package/lib/{HttpClient → clients}/IOGraphQLClient.js +3 -2
  57. package/lib/{HttpClient → clients/apps}/AppClient.d.ts +3 -3
  58. package/lib/{HttpClient → clients/apps}/AppClient.js +11 -5
  59. package/lib/{HttpClient → clients/apps}/AppGraphQLClient.d.ts +3 -3
  60. package/lib/{HttpClient → clients/apps}/AppGraphQLClient.js +11 -5
  61. package/lib/clients/apps/Billing.d.ts +12 -0
  62. package/lib/clients/{Billing.js → apps/Billing.js} +9 -3
  63. package/lib/clients/{Builder.d.ts → apps/Builder.d.ts} +12 -11
  64. package/lib/clients/{Builder.js → apps/Builder.js} +51 -23
  65. package/lib/clients/apps/MessagesGraphQL.d.ts +61 -0
  66. package/lib/clients/apps/MessagesGraphQL.js +122 -0
  67. package/lib/clients/{Settings.d.ts → apps/Settings.d.ts} +5 -4
  68. package/lib/clients/apps/Settings.js +39 -0
  69. package/lib/clients/apps/catalogGraphQL/brand.d.ts +13 -0
  70. package/lib/clients/apps/catalogGraphQL/brand.js +19 -0
  71. package/lib/clients/apps/catalogGraphQL/category.d.ts +11 -0
  72. package/lib/clients/apps/catalogGraphQL/category.js +17 -0
  73. package/lib/clients/apps/catalogGraphQL/index.d.ts +22 -0
  74. package/lib/clients/apps/catalogGraphQL/index.js +89 -0
  75. package/lib/clients/apps/catalogGraphQL/product.d.ts +25 -0
  76. package/lib/clients/apps/catalogGraphQL/product.js +31 -0
  77. package/lib/clients/apps/catalogGraphQL/sku.d.ts +26 -0
  78. package/lib/clients/apps/catalogGraphQL/sku.js +31 -0
  79. package/lib/clients/apps/index.d.ts +7 -0
  80. package/lib/clients/apps/index.js +23 -0
  81. package/lib/{HttpClient → clients/external}/ExternalClient.d.ts +3 -3
  82. package/lib/{HttpClient → clients/external}/ExternalClient.js +10 -2
  83. package/lib/clients/external/ID.d.ts +23 -0
  84. package/lib/clients/external/ID.js +61 -0
  85. package/lib/clients/external/Masterdata.d.ts +94 -0
  86. package/lib/clients/external/Masterdata.js +225 -0
  87. package/lib/clients/external/PaymentProvider.d.ts +31 -0
  88. package/lib/clients/external/PaymentProvider.js +43 -0
  89. package/lib/clients/external/index.d.ts +4 -0
  90. package/lib/clients/external/index.js +20 -0
  91. package/lib/clients/index.d.ts +9 -21
  92. package/lib/clients/index.js +27 -24
  93. package/lib/clients/infra/Apps.d.ts +93 -0
  94. package/lib/clients/infra/Apps.js +511 -0
  95. package/lib/clients/infra/Assets.d.ts +35 -0
  96. package/lib/clients/infra/Assets.js +166 -0
  97. package/lib/clients/infra/BillingMetrics.d.ts +13 -0
  98. package/lib/clients/infra/BillingMetrics.js +16 -0
  99. package/lib/clients/infra/Events.d.ts +12 -0
  100. package/lib/clients/infra/Events.js +34 -0
  101. package/lib/clients/infra/Housekeeper.d.ts +10 -0
  102. package/lib/clients/infra/Housekeeper.js +31 -0
  103. package/lib/{HttpClient → clients/infra}/InfraClient.d.ts +3 -3
  104. package/lib/{HttpClient → clients/infra}/InfraClient.js +10 -4
  105. package/lib/clients/infra/Registry.d.ts +65 -0
  106. package/lib/clients/infra/Registry.js +209 -0
  107. package/lib/clients/infra/Router.d.ts +34 -0
  108. package/lib/clients/infra/Router.js +82 -0
  109. package/lib/clients/infra/Sphinx.d.ts +13 -0
  110. package/lib/clients/infra/Sphinx.js +30 -0
  111. package/lib/clients/infra/VBase.d.ts +61 -0
  112. package/lib/clients/infra/VBase.js +197 -0
  113. package/lib/clients/infra/Workspaces.d.ts +18 -0
  114. package/lib/clients/infra/Workspaces.js +66 -0
  115. package/lib/clients/infra/index.d.ts +11 -0
  116. package/lib/clients/infra/index.js +27 -0
  117. package/lib/{HttpClient → clients/janus}/JanusClient.d.ts +4 -4
  118. package/lib/{HttpClient → clients/janus}/JanusClient.js +8 -3
  119. package/lib/clients/janus/LicenseManager.d.ts +7 -0
  120. package/lib/clients/janus/LicenseManager.js +59 -0
  121. package/lib/clients/{Segment.d.ts → janus/Segment.d.ts} +7 -11
  122. package/lib/clients/janus/Segment.js +89 -0
  123. package/lib/clients/{Session.d.ts → janus/Session.d.ts} +4 -4
  124. package/lib/clients/{Session.js → janus/Session.js} +25 -13
  125. package/lib/clients/{Tenant.d.ts → janus/Tenant.d.ts} +7 -8
  126. package/lib/clients/janus/Tenant.js +29 -0
  127. package/lib/clients/janus/index.d.ts +5 -0
  128. package/lib/clients/janus/index.js +21 -0
  129. package/lib/constants.d.ts +50 -2
  130. package/lib/constants.js +55 -1
  131. package/lib/errors/AuthenticationError.js +1 -0
  132. package/lib/errors/ForbiddenError.js +1 -0
  133. package/lib/errors/NotFoundError.js +1 -0
  134. package/lib/errors/RequestCancelledError.js +1 -0
  135. package/lib/errors/ResolverError.d.ts +1 -1
  136. package/lib/errors/ResolverError.js +4 -3
  137. package/lib/errors/ResolverWarning.d.ts +1 -1
  138. package/lib/errors/ResolverWarning.js +3 -2
  139. package/lib/errors/TooManyRequestsError.js +1 -0
  140. package/lib/errors/UserInputError.js +1 -0
  141. package/lib/errors/index.js +22 -11
  142. package/lib/index.d.ts +9 -7
  143. package/lib/index.js +31 -16
  144. package/lib/metrics/MetricsAccumulator.d.ts +3 -20
  145. package/lib/metrics/MetricsAccumulator.js +44 -27
  146. package/lib/responses.d.ts +5 -46
  147. package/lib/service/index.d.ts +2 -0
  148. package/lib/service/index.js +35 -0
  149. package/lib/service/loaders.d.ts +8 -0
  150. package/lib/service/loaders.js +57 -0
  151. package/lib/service/logger/console.d.ts +10 -0
  152. package/lib/service/logger/console.js +40 -0
  153. package/lib/service/logger/index.d.ts +2 -28
  154. package/lib/service/logger/index.js +16 -68
  155. package/lib/service/logger/logger.d.ts +29 -0
  156. package/lib/service/logger/logger.js +62 -0
  157. package/lib/service/logger/metricsLogger.d.ts +40 -0
  158. package/lib/service/logger/metricsLogger.js +150 -0
  159. package/lib/service/master.d.ts +2 -0
  160. package/lib/service/master.js +89 -0
  161. package/lib/service/metrics/requestMetricsMiddleware.d.ts +2 -0
  162. package/lib/service/metrics/requestMetricsMiddleware.js +46 -0
  163. package/lib/service/tracing/TracerSingleton.d.ts +7 -0
  164. package/lib/service/tracing/TracerSingleton.js +49 -0
  165. package/lib/service/tracing/metrics/MetricNames.d.ts +60 -0
  166. package/lib/service/tracing/metrics/MetricNames.js +45 -0
  167. package/lib/service/tracing/metrics/instruments.d.ts +9 -0
  168. package/lib/service/tracing/metrics/instruments.js +19 -0
  169. package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.d.ts +9 -0
  170. package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +26 -0
  171. package/lib/service/tracing/tracingMiddlewares.d.ts +5 -0
  172. package/lib/service/tracing/tracingMiddlewares.js +117 -0
  173. package/lib/service/worker/index.d.ts +11 -0
  174. package/lib/service/worker/index.js +197 -0
  175. package/lib/service/worker/listeners.d.ts +3 -0
  176. package/lib/{utils/unhandled.js → service/worker/listeners.js} +12 -16
  177. package/lib/service/{Service.d.ts → worker/runtime/Service.d.ts} +5 -5
  178. package/lib/service/{Service.js → worker/runtime/Service.js} +3 -1
  179. package/lib/service/worker/runtime/builtIn/handlers.d.ts +4 -0
  180. package/lib/service/worker/runtime/builtIn/handlers.js +34 -0
  181. package/lib/service/worker/runtime/builtIn/middlewares.d.ts +4 -0
  182. package/lib/service/worker/runtime/builtIn/middlewares.js +43 -0
  183. package/lib/service/worker/runtime/events/index.d.ts +4 -0
  184. package/lib/service/worker/runtime/events/index.js +48 -0
  185. package/lib/service/worker/runtime/events/middlewares/body.d.ts +3 -0
  186. package/lib/service/worker/runtime/events/middlewares/body.js +26 -0
  187. package/lib/service/worker/runtime/events/middlewares/context.d.ts +3 -0
  188. package/lib/service/worker/runtime/events/middlewares/context.js +23 -0
  189. package/lib/service/worker/runtime/events/router.d.ts +2 -0
  190. package/lib/service/worker/runtime/events/router.js +29 -0
  191. package/lib/service/worker/runtime/graphql/index.d.ts +6 -0
  192. package/lib/service/worker/runtime/graphql/index.js +29 -0
  193. package/lib/service/worker/runtime/graphql/middlewares/context.d.ts +2 -0
  194. package/lib/service/worker/runtime/graphql/middlewares/context.js +17 -0
  195. package/lib/service/worker/runtime/graphql/middlewares/error.js +97 -0
  196. package/lib/service/worker/runtime/graphql/middlewares/query.d.ts +3 -0
  197. package/lib/service/worker/runtime/graphql/middlewares/query.js +54 -0
  198. package/lib/service/worker/runtime/graphql/middlewares/response.js +39 -0
  199. package/lib/service/worker/runtime/graphql/middlewares/run.d.ts +2 -0
  200. package/lib/service/worker/runtime/graphql/middlewares/run.js +21 -0
  201. package/lib/service/worker/runtime/graphql/middlewares/updateSchema.d.ts +5 -0
  202. package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +30 -0
  203. package/lib/service/worker/runtime/graphql/middlewares/upload.d.ts +4 -0
  204. package/lib/service/{graphql → worker/runtime/graphql}/middlewares/upload.js +2 -1
  205. package/lib/service/worker/runtime/graphql/schema/index.d.ts +7 -0
  206. package/lib/service/worker/runtime/graphql/schema/index.js +33 -0
  207. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +6 -0
  208. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +81 -0
  209. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Auth.d.ts +1 -0
  210. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Auth.js +17 -10
  211. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.d.ts +7 -0
  212. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.js +38 -0
  213. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.d.ts +11 -0
  214. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +62 -0
  215. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.d.ts +7 -0
  216. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.js +41 -0
  217. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Sanitize.d.ts +1 -0
  218. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Sanitize.js +7 -0
  219. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.d.ts +6 -0
  220. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +35 -0
  221. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/SmartCacheDirective.d.ts +1 -0
  222. package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/SmartCacheDirective.js +9 -3
  223. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.d.ts +7 -0
  224. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +40 -0
  225. package/lib/service/{graphql/schema/schemaDirectives/Translatable.d.ts → worker/runtime/graphql/schema/schemaDirectives/TranslateTo.d.ts} +2 -1
  226. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +34 -0
  227. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.d.ts +22 -0
  228. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +37 -0
  229. package/lib/service/worker/runtime/graphql/schema/typeDefs/index.d.ts +8 -0
  230. package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +14 -0
  231. package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/ioUpload.js +1 -0
  232. package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/sanitizedString.js +8 -3
  233. package/lib/service/worker/runtime/graphql/typings.d.ts +31 -0
  234. package/lib/service/worker/runtime/graphql/utils/cacheControl.d.ts +2 -0
  235. package/lib/service/worker/runtime/graphql/utils/cacheControl.js +34 -0
  236. package/lib/service/worker/runtime/graphql/utils/error.d.ts +2 -0
  237. package/lib/service/worker/runtime/graphql/utils/error.js +78 -0
  238. package/lib/service/worker/runtime/graphql/utils/pathname.js +9 -0
  239. package/lib/service/worker/runtime/graphql/utils/translations.d.ts +14 -0
  240. package/lib/service/worker/runtime/graphql/utils/translations.js +42 -0
  241. package/lib/service/worker/runtime/http/index.d.ts +5 -0
  242. package/lib/service/worker/runtime/http/index.js +61 -0
  243. package/lib/service/worker/runtime/http/middlewares/authTokens.d.ts +3 -0
  244. package/lib/service/{http → worker/runtime/http}/middlewares/authTokens.js +1 -0
  245. package/lib/service/worker/runtime/http/middlewares/cancellationToken.d.ts +3 -0
  246. package/lib/service/{http → worker/runtime/http}/middlewares/cancellationToken.js +3 -1
  247. package/lib/service/worker/runtime/http/middlewares/clients.d.ts +4 -0
  248. package/lib/service/{http → worker/runtime/http}/middlewares/clients.js +1 -0
  249. package/lib/service/worker/runtime/http/middlewares/context.d.ts +4 -0
  250. package/lib/service/worker/runtime/http/middlewares/context.js +39 -0
  251. package/lib/service/worker/runtime/http/middlewares/error.d.ts +2 -0
  252. package/lib/service/{http → worker/runtime/http}/middlewares/error.js +29 -16
  253. package/lib/service/worker/runtime/http/middlewares/rateLimit.d.ts +6 -0
  254. package/lib/service/worker/runtime/http/middlewares/rateLimit.js +43 -0
  255. package/lib/service/{http → worker/runtime/http}/middlewares/requestStats.d.ts +3 -3
  256. package/lib/service/{http → worker/runtime/http}/middlewares/requestStats.js +1 -0
  257. package/lib/service/worker/runtime/http/middlewares/setCookie.d.ts +3 -0
  258. package/lib/service/{http → worker/runtime/http}/middlewares/setCookie.js +6 -5
  259. package/lib/service/worker/runtime/http/middlewares/settings.d.ts +9 -0
  260. package/lib/service/worker/runtime/http/middlewares/settings.js +49 -0
  261. package/lib/service/worker/runtime/http/middlewares/timings.d.ts +3 -0
  262. package/lib/service/{http → worker/runtime/http}/middlewares/timings.js +25 -11
  263. package/lib/service/worker/runtime/http/middlewares/vary.d.ts +3 -0
  264. package/lib/service/{http → worker/runtime/http}/middlewares/vary.js +4 -3
  265. package/lib/service/worker/runtime/http/router.d.ts +2 -0
  266. package/lib/service/worker/runtime/http/router.js +25 -0
  267. package/lib/service/worker/runtime/http/routes.d.ts +19 -0
  268. package/lib/service/worker/runtime/http/routes.js +16 -0
  269. package/lib/service/worker/runtime/method.d.ts +9 -0
  270. package/lib/service/{method.js → worker/runtime/method.js} +2 -1
  271. package/lib/service/worker/runtime/statusTrack.d.ts +14 -0
  272. package/lib/service/worker/runtime/statusTrack.js +43 -0
  273. package/lib/service/worker/runtime/typings.d.ts +173 -0
  274. package/lib/service/worker/runtime/utils/compose.d.ts +5 -0
  275. package/lib/service/worker/runtime/utils/compose.js +14 -0
  276. package/lib/service/worker/runtime/utils/context.d.ts +5 -0
  277. package/lib/service/worker/runtime/utils/context.js +42 -0
  278. package/lib/service/worker/runtime/utils/diff.d.ts +12 -0
  279. package/lib/service/worker/runtime/utils/diff.js +22 -0
  280. package/lib/service/worker/runtime/utils/recorder.d.ts +8 -0
  281. package/lib/service/worker/runtime/utils/recorder.js +38 -0
  282. package/lib/service/worker/runtime/utils/toArray.js +5 -0
  283. package/lib/service/worker/runtime/utils/tokenBucket.d.ts +2 -0
  284. package/lib/service/worker/runtime/utils/tokenBucket.js +17 -0
  285. package/lib/tracing/LogEvents.d.ts +31 -0
  286. package/lib/{service/graphql/utils/array.js → tracing/LogEvents.js} +1 -1
  287. package/lib/tracing/LogFields.d.ts +66 -0
  288. package/lib/tracing/LogFields.js +3 -0
  289. package/lib/tracing/Tags.d.ts +81 -0
  290. package/lib/tracing/Tags.js +8 -0
  291. package/lib/tracing/UserLandTracer.d.ts +27 -0
  292. package/lib/tracing/UserLandTracer.js +58 -0
  293. package/lib/tracing/errorReporting/ErrorReport.d.ts +31 -0
  294. package/lib/tracing/errorReporting/ErrorReport.js +71 -0
  295. package/lib/tracing/index.d.ts +9 -0
  296. package/lib/tracing/index.js +20 -0
  297. package/lib/tracing/spanReference/SpanReferenceTypes.d.ts +4 -0
  298. package/lib/tracing/spanReference/SpanReferenceTypes.js +8 -0
  299. package/lib/tracing/spanReference/createSpanReference.d.ts +3 -0
  300. package/lib/tracing/spanReference/createSpanReference.js +9 -0
  301. package/lib/tracing/utils.d.ts +13 -0
  302. package/lib/tracing/utils.js +42 -0
  303. package/lib/utils/MineWinsConflictsResolver.d.ts +7 -5
  304. package/lib/utils/MineWinsConflictsResolver.js +40 -22
  305. package/lib/utils/app.d.ts +3 -1
  306. package/lib/utils/app.js +40 -21
  307. package/lib/utils/appsStaleIfError.d.ts +2 -1
  308. package/lib/utils/appsStaleIfError.js +33 -12
  309. package/lib/utils/billingOptions.d.ts +36 -3
  310. package/lib/utils/billingOptions.js +9 -3
  311. package/lib/utils/binding.d.ts +3 -3
  312. package/lib/utils/binding.js +5 -2
  313. package/lib/utils/cancel.d.ts +2 -2
  314. package/lib/utils/cancel.js +3 -1
  315. package/lib/utils/conflicts.mock.d.ts +17 -0
  316. package/lib/utils/conflicts.mock.js +28 -0
  317. package/lib/utils/domain.js +2 -1
  318. package/lib/utils/error.js +6 -4
  319. package/lib/utils/index.js +23 -12
  320. package/lib/utils/json.js +1 -0
  321. package/lib/utils/log.d.ts +1 -3
  322. package/lib/utils/log.js +6 -4
  323. package/lib/utils/message.js +11 -4
  324. package/lib/utils/renameBy.js +3 -1
  325. package/lib/utils/retry.js +10 -7
  326. package/lib/utils/status.js +3 -1
  327. package/lib/utils/tenant.d.ts +3 -3
  328. package/lib/utils/tenant.js +5 -2
  329. package/lib/utils/throwOnGraphQLErrors.js +1 -0
  330. package/lib/utils/time.d.ts +7 -7
  331. package/lib/utils/time.js +29 -12
  332. package/package.json +3 -3
  333. package/lib/HttpClient/IOClient.d.ts +0 -13
  334. package/lib/HttpClient/IOClient.js +0 -14
  335. package/lib/HttpClient/factories/index.d.ts +0 -8
  336. package/lib/HttpClient/factories/index.js +0 -31
  337. package/lib/HttpClient/middlewares/request.d.ts +0 -10
  338. package/lib/HttpClient/middlewares/request.js +0 -87
  339. package/lib/IODataSource.d.ts +0 -27
  340. package/lib/IODataSource.js +0 -46
  341. package/lib/clients/Apps.d.ts +0 -84
  342. package/lib/clients/Apps.js +0 -326
  343. package/lib/clients/Assets.d.ts +0 -21
  344. package/lib/clients/Assets.js +0 -110
  345. package/lib/clients/Billing.d.ts +0 -11
  346. package/lib/clients/BillingMetrics.d.ts +0 -12
  347. package/lib/clients/BillingMetrics.js +0 -10
  348. package/lib/clients/Events.d.ts +0 -6
  349. package/lib/clients/Events.js +0 -19
  350. package/lib/clients/Housekeeper.d.ts +0 -11
  351. package/lib/clients/Housekeeper.js +0 -24
  352. package/lib/clients/ID.d.ts +0 -22
  353. package/lib/clients/ID.js +0 -48
  354. package/lib/clients/LicenseManager.d.ts +0 -6
  355. package/lib/clients/LicenseManager.js +0 -43
  356. package/lib/clients/Logger.d.ts +0 -27
  357. package/lib/clients/Logger.js +0 -32
  358. package/lib/clients/Messages.d.ts +0 -18
  359. package/lib/clients/Messages.js +0 -20
  360. package/lib/clients/MessagesGraphQL.d.ts +0 -63
  361. package/lib/clients/MessagesGraphQL.js +0 -50
  362. package/lib/clients/Metadata.d.ts +0 -25
  363. package/lib/clients/Metadata.js +0 -53
  364. package/lib/clients/Registry.d.ts +0 -61
  365. package/lib/clients/Registry.js +0 -147
  366. package/lib/clients/Router.d.ts +0 -33
  367. package/lib/clients/Router.js +0 -50
  368. package/lib/clients/Segment.js +0 -69
  369. package/lib/clients/Settings.js +0 -44
  370. package/lib/clients/Sphinx.d.ts +0 -12
  371. package/lib/clients/Sphinx.js +0 -19
  372. package/lib/clients/Tenant.js +0 -13
  373. package/lib/clients/VBase.d.ts +0 -57
  374. package/lib/clients/VBase.js +0 -116
  375. package/lib/clients/Workspaces.d.ts +0 -17
  376. package/lib/clients/Workspaces.js +0 -38
  377. package/lib/service/Runtime.d.ts +0 -18
  378. package/lib/service/Runtime.js +0 -57
  379. package/lib/service/events/index.d.ts +0 -3
  380. package/lib/service/events/index.js +0 -21
  381. package/lib/service/graphql/index.d.ts +0 -7
  382. package/lib/service/graphql/index.js +0 -33
  383. package/lib/service/graphql/middlewares/error.js +0 -107
  384. package/lib/service/graphql/middlewares/formatters.d.ts +0 -2
  385. package/lib/service/graphql/middlewares/formatters.js +0 -64
  386. package/lib/service/graphql/middlewares/query.d.ts +0 -2
  387. package/lib/service/graphql/middlewares/query.js +0 -32
  388. package/lib/service/graphql/middlewares/response.js +0 -36
  389. package/lib/service/graphql/middlewares/run.d.ts +0 -4
  390. package/lib/service/graphql/middlewares/run.js +0 -55
  391. package/lib/service/graphql/middlewares/schema.d.ts +0 -2
  392. package/lib/service/graphql/middlewares/schema.js +0 -8
  393. package/lib/service/graphql/middlewares/timings.d.ts +0 -2
  394. package/lib/service/graphql/middlewares/timings.js +0 -10
  395. package/lib/service/graphql/middlewares/upload.d.ts +0 -7
  396. package/lib/service/graphql/schema/index.d.ts +0 -3
  397. package/lib/service/graphql/schema/index.js +0 -66
  398. package/lib/service/graphql/schema/messagesLoader.d.ts +0 -4
  399. package/lib/service/graphql/schema/messagesLoader.js +0 -41
  400. package/lib/service/graphql/schema/messagesLoaderV2.d.ts +0 -5
  401. package/lib/service/graphql/schema/messagesLoaderV2.js +0 -44
  402. package/lib/service/graphql/schema/schemaDirectives/Translatable.js +0 -54
  403. package/lib/service/graphql/schema/schemaDirectives/TranslatableV2.d.ts +0 -13
  404. package/lib/service/graphql/schema/schemaDirectives/TranslatableV2.js +0 -67
  405. package/lib/service/graphql/schema/schemaDirectives/index.d.ts +0 -13
  406. package/lib/service/graphql/schema/schemaDirectives/index.js +0 -17
  407. package/lib/service/graphql/schema/typeDefs/index.d.ts +0 -16
  408. package/lib/service/graphql/schema/typeDefs/index.js +0 -21
  409. package/lib/service/graphql/schema/typeDefs/ioMessage.d.ts +0 -8
  410. package/lib/service/graphql/schema/typeDefs/ioMessage.js +0 -33
  411. package/lib/service/graphql/typings.d.ts +0 -21
  412. package/lib/service/graphql/utils/cacheControl.d.ts +0 -6
  413. package/lib/service/graphql/utils/cacheControl.js +0 -38
  414. package/lib/service/graphql/utils/maxAgeEnum.d.ts +0 -6
  415. package/lib/service/graphql/utils/maxAgeEnum.js +0 -17
  416. package/lib/service/graphql/utils/pathname.js +0 -7
  417. package/lib/service/http/index.d.ts +0 -3
  418. package/lib/service/http/index.js +0 -18
  419. package/lib/service/http/middlewares/authTokens.d.ts +0 -3
  420. package/lib/service/http/middlewares/cancellationToken.d.ts +0 -3
  421. package/lib/service/http/middlewares/clients.d.ts +0 -4
  422. package/lib/service/http/middlewares/error.d.ts +0 -3
  423. package/lib/service/http/middlewares/setCookie.d.ts +0 -3
  424. package/lib/service/http/middlewares/timings.d.ts +0 -3
  425. package/lib/service/http/middlewares/vary.d.ts +0 -3
  426. package/lib/service/method.d.ts +0 -9
  427. package/lib/service/typings.d.ts +0 -139
  428. package/lib/service/utils/compose.d.ts +0 -4
  429. package/lib/service/utils/compose.js +0 -11
  430. package/lib/utils/MineWinsConflictsResolver.test.d.ts +0 -1
  431. package/lib/utils/MineWinsConflictsResolver.test.js +0 -134
  432. package/lib/utils/unhandled.d.ts +0 -1
  433. /package/lib/service/{graphql → worker/runtime/graphql}/middlewares/error.d.ts +0 -0
  434. /package/lib/service/{graphql → worker/runtime/graphql}/middlewares/response.d.ts +0 -0
  435. /package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/ioUpload.d.ts +0 -0
  436. /package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/sanitizedString.d.ts +0 -0
  437. /package/lib/service/{graphql → worker/runtime/graphql}/typings.js +0 -0
  438. /package/lib/service/{graphql → worker/runtime/graphql}/utils/pathname.d.ts +0 -0
  439. /package/lib/service/{typings.js → worker/runtime/typings.js} +0 -0
  440. /package/lib/service/{graphql/utils/array.d.ts → worker/runtime/utils/toArray.d.ts} +0 -0
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Router = void 0;
4
+ const InfraClient_1 = require("./InfraClient");
5
+ const routes = {
6
+ AvailableIoVersions: '/_io',
7
+ AvailableServiceVersions: (service) => `${routes.AvailableServices}/${service}`,
8
+ AvailableServices: '/_services',
9
+ InstalledIoVersion: (account, workspace) => `/${account}/${workspace}/io`,
10
+ InstalledService: (account, workspace, name) => `/${routes.InstalledServices(account, workspace)}/services/${name}`,
11
+ InstalledServices: (account, workspace) => `/${account}/${workspace}/services`,
12
+ };
13
+ class Router extends InfraClient_1.InfraClient {
14
+ constructor(ioContext, opts) {
15
+ super('router', ioContext, opts, true);
16
+ this.listAvailableIoVersions = (tracingConfig) => {
17
+ return this.http.get(routes.AvailableIoVersions, { tracing: {
18
+ requestSpanNameSuffix: 'list-io-versions',
19
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
20
+ } });
21
+ };
22
+ this.getInstalledIoVersion = (tracingConfig) => {
23
+ if (!this.context.account || !this.context.workspace) {
24
+ throw new Error('Missing client parameters: {account, workspace}');
25
+ }
26
+ return this.http.get(routes.InstalledIoVersion(this.context.account, this.context.workspace), {
27
+ tracing: {
28
+ requestSpanNameSuffix: 'get-installed-io-version',
29
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
30
+ },
31
+ });
32
+ };
33
+ this.installIo = (version, tracingConfig) => {
34
+ if (!this.context.account || !this.context.workspace) {
35
+ throw new Error('Missing client parameters: {account, workspace}');
36
+ }
37
+ return this.http.put(routes.InstalledIoVersion(this.context.account, this.context.workspace), { version }, { tracing: {
38
+ requestSpanNameSuffix: 'install-io',
39
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
40
+ } });
41
+ };
42
+ this.listAvailableServices = (tracingConfig) => {
43
+ return this.http.get(routes.AvailableServices, {
44
+ tracing: {
45
+ requestSpanNameSuffix: 'list-available-services',
46
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
47
+ },
48
+ });
49
+ };
50
+ this.getAvailableVersions = (name, tracingConfig) => {
51
+ return this.http.get(routes.AvailableServiceVersions(name), {
52
+ tracing: {
53
+ requestSpanNameSuffix: 'get-versions',
54
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
55
+ },
56
+ });
57
+ };
58
+ this.listInstalledServices = (tracingConfig) => {
59
+ if (!this.context.account || !this.context.workspace) {
60
+ throw new Error('Missing client parameters: {account, workspace}');
61
+ }
62
+ return this.http.get(routes.InstalledServices(this.context.account, this.context.workspace), {
63
+ tracing: {
64
+ requestSpanNameSuffix: 'list-installed-services',
65
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
66
+ },
67
+ });
68
+ };
69
+ this.installService = (name, version, tracingConfig) => {
70
+ if (!this.context.account || !this.context.workspace) {
71
+ throw new Error('Missing client parameters: {account, workspace}');
72
+ }
73
+ return this.http.post(routes.InstalledServices(this.context.account, this.context.workspace), { name, version }, {
74
+ tracing: {
75
+ requestSpanNameSuffix: 'install-service',
76
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
77
+ },
78
+ });
79
+ };
80
+ }
81
+ }
82
+ exports.Router = Router;
@@ -0,0 +1,13 @@
1
+ import { InstanceOptions, RequestTracingConfig } from '../../HttpClient/typings';
2
+ import { IOContext } from '../../service/worker/runtime/typings';
3
+ import { InfraClient } from './InfraClient';
4
+ export declare class Sphinx extends InfraClient {
5
+ constructor(ioContext: IOContext, opts?: InstanceOptions);
6
+ validatePolicies: (policies: PolicyRequest[], tracingConfig?: RequestTracingConfig) => Promise<void>;
7
+ isAdmin: (email: string, tracingConfig?: RequestTracingConfig) => Promise<boolean>;
8
+ }
9
+ export interface PolicyRequest {
10
+ name: string;
11
+ reason: string;
12
+ attrs: Record<string, string>;
13
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Sphinx = void 0;
4
+ const InfraClient_1 = require("./InfraClient");
5
+ class Sphinx extends InfraClient_1.InfraClient {
6
+ constructor(ioContext, opts) {
7
+ super('sphinx@0.x', ioContext, opts, false);
8
+ this.validatePolicies = (policies, tracingConfig) => {
9
+ const metric = 'sphinx-validate-policy';
10
+ return this.http.post('/policies/validate', { policies }, {
11
+ metric,
12
+ tracing: {
13
+ requestSpanNameSuffix: metric,
14
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
15
+ },
16
+ });
17
+ };
18
+ this.isAdmin = (email, tracingConfig) => {
19
+ const metric = 'sphinx-is-admin';
20
+ return this.http.get(`/user/${email}/isAdmin`, {
21
+ metric,
22
+ tracing: {
23
+ requestSpanNameSuffix: metric,
24
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
25
+ },
26
+ });
27
+ };
28
+ }
29
+ }
30
+ exports.Sphinx = Sphinx;
@@ -0,0 +1,61 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { IncomingMessage } from 'http';
4
+ import { Readable } from 'stream';
5
+ import { Logger } from './../../service/logger/logger';
6
+ import { InstanceOptions, IOResponse, RequestTracingConfig } from '../../HttpClient';
7
+ import { BucketMetadata, FileListItem, VBaseSaveResponse } from '../../responses';
8
+ import { IOContext } from '../../service/worker/runtime/typings';
9
+ import { InfraClient } from './InfraClient';
10
+ export declare class VBase extends InfraClient {
11
+ constructor(context: IOContext, options?: InstanceOptions);
12
+ getBucket: (bucket: string, tracingConfig?: RequestTracingConfig) => Promise<BucketMetadata>;
13
+ resetBucket: (bucket: string, tracingConfig?: RequestTracingConfig) => Promise<IOResponse<void>>;
14
+ listFiles: (bucket: string, opts?: string | VBaseOptions, tracingConfig?: RequestTracingConfig) => Promise<BucketFileList>;
15
+ getFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig) => Promise<{
16
+ data: Buffer;
17
+ headers: any;
18
+ }>;
19
+ getJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean, conflictsResolver?: ConflictsResolver<T> | undefined, tracingConfig?: RequestTracingConfig) => Promise<T>;
20
+ getRawJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean, conflictsResolver?: ConflictsResolver<T> | undefined, tracingConfig?: RequestTracingConfig) => Promise<IOResponse<T>>;
21
+ getFileStream: (bucket: string, path: string, tracingConfig?: RequestTracingConfig) => Promise<IncomingMessage>;
22
+ saveFile: (bucket: string, path: string, stream: Readable, gzip?: boolean, ttl?: number, tracingConfig?: RequestTracingConfig, ifMatch?: string) => Promise<void>;
23
+ getFileMetadata: (bucket: string, path: string, tracingConfig?: RequestTracingConfig) => Promise<IOResponse<void>>;
24
+ saveJSON: <T>(bucket: string, path: string, data: T, tracingConfig?: RequestTracingConfig, ifMatch?: string) => Promise<VBaseSaveResponse>;
25
+ saveZippedContent: (bucket: string, path: string, stream: Readable, tracingConfig?: RequestTracingConfig, ifMatch?: string) => Promise<void>;
26
+ deleteFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig, ifMatch?: string) => Promise<IOResponse<void>>;
27
+ getConflicts: <T>(bucket: string, tracingConfig?: RequestTracingConfig) => Promise<T>;
28
+ resolveConflict: <T>(bucket: string, path: string, content: any, tracingConfig?: RequestTracingConfig) => Promise<T>;
29
+ private saveContent;
30
+ }
31
+ export interface BucketFileList {
32
+ data: FileListItem[];
33
+ next: string;
34
+ smartCacheHeaders: any;
35
+ }
36
+ export interface VBaseOptions {
37
+ prefix?: string;
38
+ next?: string;
39
+ limit?: number;
40
+ }
41
+ export interface VBaseSaveOptions {
42
+ gzip?: boolean;
43
+ unzip?: boolean;
44
+ ttl?: number;
45
+ }
46
+ export interface VBaseConflictData {
47
+ path: string;
48
+ base: VBaseConflict;
49
+ master: VBaseConflict;
50
+ mine: VBaseConflict;
51
+ }
52
+ export interface VBaseConflict {
53
+ contentOmitted: boolean;
54
+ deleted: boolean;
55
+ mimeType: string;
56
+ parsedContent?: any;
57
+ content: string;
58
+ }
59
+ export interface ConflictsResolver<T> {
60
+ resolve: (logger?: Logger) => T | Promise<T>;
61
+ }
@@ -0,0 +1,197 @@
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
+ exports.VBase = void 0;
7
+ const mime_types_1 = __importDefault(require("mime-types"));
8
+ const path_1 = require("path");
9
+ const zlib_1 = require("zlib");
10
+ const HttpClient_1 = require("../../HttpClient");
11
+ const InfraClient_1 = require("./InfraClient");
12
+ const appId = process.env.VTEX_APP_ID;
13
+ const [runningAppName] = appId ? appId.split('@') : [''];
14
+ const routes = {
15
+ Bucket: (bucket) => `/buckets/${runningAppName}/${bucket}`,
16
+ Conflicts: (bucket) => `/buckets/${runningAppName}/${bucket}/conflicts`,
17
+ File: (bucket, path) => `${routes.Bucket(bucket)}/files/${path}`,
18
+ Files: (bucket) => `${routes.Bucket(bucket)}/files`,
19
+ };
20
+ const isVBaseOptions = (opts) => {
21
+ return typeof opts !== 'string' && !(opts instanceof String);
22
+ };
23
+ class VBase extends InfraClient_1.InfraClient {
24
+ constructor(context, options) {
25
+ super('vbase@2.x', context, options);
26
+ this.getBucket = (bucket, tracingConfig) => {
27
+ const inflightKey = HttpClient_1.inflightURL;
28
+ const metric = 'vbase-get-bucket';
29
+ return this.http.get(routes.Bucket(bucket), { inflightKey, metric, tracing: {
30
+ requestSpanNameSuffix: metric,
31
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
32
+ } });
33
+ };
34
+ this.resetBucket = (bucket, tracingConfig) => {
35
+ const metric = 'vbase-reset-bucket';
36
+ return this.http.delete(routes.Files(bucket), { metric, tracing: {
37
+ requestSpanNameSuffix: metric,
38
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
39
+ } });
40
+ };
41
+ this.listFiles = (bucket, opts, tracingConfig) => {
42
+ let params = {};
43
+ if (isVBaseOptions(opts)) {
44
+ params = opts;
45
+ }
46
+ else if (opts) {
47
+ params = { prefix: opts };
48
+ }
49
+ const metric = 'vbase-list';
50
+ const inflightKey = HttpClient_1.inflightUrlWithQuery;
51
+ return this.http.get(routes.Files(bucket), { inflightKey, metric, params, tracing: {
52
+ requestSpanNameSuffix: metric,
53
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
54
+ } });
55
+ };
56
+ this.getFile = (bucket, path, tracingConfig) => {
57
+ const inflightKey = HttpClient_1.inflightURL;
58
+ const metric = 'vbase-get-file';
59
+ return this.http.getBuffer(routes.File(bucket, path), { inflightKey, metric, tracing: {
60
+ requestSpanNameSuffix: metric,
61
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
62
+ } });
63
+ };
64
+ this.getJSON = (bucket, path, nullIfNotFound, conflictsResolver, tracingConfig) => {
65
+ return this.getRawJSON(bucket, path, nullIfNotFound, conflictsResolver, tracingConfig)
66
+ .then(response => response.data);
67
+ };
68
+ this.getRawJSON = (bucket, path, nullIfNotFound, conflictsResolver, tracingConfig) => {
69
+ const headers = conflictsResolver ? { 'X-Vtex-Detect-Conflicts': true } : {};
70
+ const inflightKey = HttpClient_1.inflightURL;
71
+ const metric = 'vbase-get-json';
72
+ return this.http
73
+ .getRaw(routes.File(bucket, path), {
74
+ headers,
75
+ inflightKey,
76
+ metric,
77
+ nullIfNotFound,
78
+ tracing: {
79
+ requestSpanNameSuffix: metric,
80
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
81
+ },
82
+ })
83
+ .catch(async (error) => {
84
+ const { response } = error;
85
+ if (response && response.status === 409 && conflictsResolver) {
86
+ try {
87
+ const conflictsMergedData = await conflictsResolver.resolve(this.context.logger);
88
+ return { ...response, data: conflictsMergedData };
89
+ }
90
+ catch (resolverError) {
91
+ const typedResolverError = resolverError;
92
+ if ((typedResolverError === null || typedResolverError === void 0 ? void 0 : typedResolverError.status) === 404) {
93
+ return this.http.getRaw(routes.File(bucket, path), {
94
+ 'X-Vtex-Detect-Conflicts': false,
95
+ inflightKey,
96
+ metric,
97
+ nullIfNotFound,
98
+ tracing: {
99
+ requestSpanNameSuffix: metric,
100
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
101
+ },
102
+ });
103
+ }
104
+ throw resolverError;
105
+ }
106
+ }
107
+ throw error;
108
+ });
109
+ };
110
+ this.getFileStream = (bucket, path, tracingConfig) => {
111
+ const metric = 'vbase-get-file-s';
112
+ return this.http.getStream(routes.File(bucket, path), { metric, tracing: {
113
+ requestSpanNameSuffix: metric,
114
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
115
+ } });
116
+ };
117
+ this.saveFile = (bucket, path, stream, gzip = true, ttl, tracingConfig, ifMatch) => {
118
+ return this.saveContent(bucket, path, stream, { gzip, ttl }, tracingConfig, ifMatch);
119
+ };
120
+ this.getFileMetadata = (bucket, path, tracingConfig) => {
121
+ const metric = 'vbase-get-file-metadata';
122
+ return this.http.head(routes.File(bucket, path), { metric, tracing: {
123
+ requestSpanNameSuffix: metric,
124
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
125
+ } });
126
+ };
127
+ this.saveJSON = (bucket, path, data, tracingConfig, ifMatch) => {
128
+ const headers = { 'Content-Type': 'application/json' };
129
+ if (ifMatch) {
130
+ headers['If-Match'] = ifMatch;
131
+ }
132
+ const metric = 'vbase-save-json';
133
+ return this.http.put(routes.File(bucket, path), data, { headers, metric, tracing: {
134
+ requestSpanNameSuffix: metric,
135
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
136
+ } });
137
+ };
138
+ this.saveZippedContent = (bucket, path, stream, tracingConfig, ifMatch) => {
139
+ return this.saveContent(bucket, path, stream, { unzip: true }, tracingConfig, ifMatch);
140
+ };
141
+ this.deleteFile = (bucket, path, tracingConfig, ifMatch) => {
142
+ const headers = ifMatch ? { 'If-Match': ifMatch } : {};
143
+ const metric = 'vbase-delete-file';
144
+ return this.http.delete(routes.File(bucket, path), { headers, metric, tracing: {
145
+ requestSpanNameSuffix: metric,
146
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
147
+ } });
148
+ };
149
+ this.getConflicts = (bucket, tracingConfig) => {
150
+ const metric = 'vbase-get-conflicts';
151
+ return this.http.get(routes.Conflicts(bucket), { metric, tracing: {
152
+ requestSpanNameSuffix: metric,
153
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
154
+ } });
155
+ };
156
+ this.resolveConflict = (bucket, path, content, tracingConfig) => {
157
+ const data = [{
158
+ op: 'replace',
159
+ path,
160
+ value: content,
161
+ }];
162
+ const metric = 'vbase-resolve-conflicts';
163
+ return this.http.patch(routes.Conflicts(bucket), data, { metric, tracing: {
164
+ requestSpanNameSuffix: metric,
165
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
166
+ } });
167
+ };
168
+ this.saveContent = (bucket, path, stream, opts = {}, tracingConfig, ifMatch) => {
169
+ if (!stream.pipe || !stream.on) {
170
+ throw new Error(`Argument stream must be a readable stream`);
171
+ }
172
+ const params = opts.unzip ? { unzip: opts.unzip } : {};
173
+ const headers = {};
174
+ let finalStream = stream;
175
+ headers['Content-Type'] = mime_types_1.default.contentType((0, path_1.basename)(path)) || 'application/octet-stream';
176
+ if (opts.gzip) {
177
+ headers['Content-Encoding'] = 'gzip';
178
+ finalStream = stream.pipe((0, zlib_1.createGzip)());
179
+ }
180
+ if (opts.ttl && Number.isInteger(opts.ttl)) {
181
+ headers['X-VTEX-TTL'] = opts.ttl;
182
+ }
183
+ if (ifMatch) {
184
+ headers['If-Match'] = ifMatch;
185
+ }
186
+ const metric = 'vbase-save-blob';
187
+ return this.http.put(routes.File(bucket, path), finalStream, { headers, metric, params, tracing: {
188
+ requestSpanNameSuffix: metric,
189
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
190
+ } });
191
+ };
192
+ if (runningAppName === '') {
193
+ throw new Error(`Invalid path to access VBase. Variable VTEX_APP_ID is not available.`);
194
+ }
195
+ }
196
+ }
197
+ exports.VBase = VBase;
@@ -0,0 +1,18 @@
1
+ import { InstanceOptions, RequestTracingConfig } from '../../HttpClient';
2
+ import { IOContext } from '../../service/worker/runtime/typings';
3
+ import { InfraClient } from './InfraClient';
4
+ export declare class Workspaces extends InfraClient {
5
+ constructor(context: IOContext, options?: InstanceOptions);
6
+ list: (account: string, tracingConfig?: RequestTracingConfig) => Promise<WorkspaceMetadata[]>;
7
+ get: (account: string, workspace: string, tracingConfig?: RequestTracingConfig) => Promise<WorkspaceMetadata>;
8
+ set: (account: string, workspace: string, metadata: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig) => Promise<void>;
9
+ create: (account: string, workspace: string, production: boolean, tracingConfig?: RequestTracingConfig) => Promise<void>;
10
+ delete: (account: string, workspace: string, tracingConfig?: RequestTracingConfig) => Promise<import("../../HttpClient").IOResponse<void>>;
11
+ reset: (account: string, workspace: string, metadata?: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig) => Promise<void>;
12
+ promote: (account: string, workspace: string, tracingConfig?: RequestTracingConfig) => Promise<void>;
13
+ }
14
+ export interface WorkspaceMetadata {
15
+ name: string;
16
+ weight: number;
17
+ production: boolean;
18
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Workspaces = void 0;
4
+ const constants_1 = require("../../constants");
5
+ const InfraClient_1 = require("./InfraClient");
6
+ const routes = {
7
+ Account: (account) => `/${account}`,
8
+ Promote: (account) => `${routes.Workspace(account, constants_1.DEFAULT_WORKSPACE)}/_promote`,
9
+ Workspace: (account, workspace) => `${routes.Account(account)}/${workspace}`,
10
+ };
11
+ class Workspaces extends InfraClient_1.InfraClient {
12
+ constructor(context, options) {
13
+ super('router', context, options, true);
14
+ this.list = (account, tracingConfig) => {
15
+ const metric = 'workspaces-list';
16
+ return this.http.get(routes.Account(account), { metric, tracing: {
17
+ requestSpanNameSuffix: metric,
18
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
19
+ } });
20
+ };
21
+ this.get = (account, workspace, tracingConfig) => {
22
+ const metric = 'workspaces-get';
23
+ return this.http.get(routes.Workspace(account, workspace), { metric, tracing: {
24
+ requestSpanNameSuffix: metric,
25
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
26
+ } });
27
+ };
28
+ this.set = (account, workspace, metadata, tracingConfig) => {
29
+ const metric = 'workspaces-set';
30
+ return this.http.put(routes.Workspace(account, workspace), metadata, { metric, tracing: {
31
+ requestSpanNameSuffix: metric,
32
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
33
+ } });
34
+ };
35
+ this.create = (account, workspace, production, tracingConfig) => {
36
+ const metric = 'workspaces-create';
37
+ return this.http.post(routes.Account(account), { name: workspace, production }, { metric, tracing: {
38
+ requestSpanNameSuffix: metric,
39
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
40
+ } });
41
+ };
42
+ this.delete = (account, workspace, tracingConfig) => {
43
+ const metric = 'workspaces-delete';
44
+ return this.http.delete(routes.Workspace(account, workspace), { metric, tracing: {
45
+ requestSpanNameSuffix: metric,
46
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
47
+ } });
48
+ };
49
+ this.reset = (account, workspace, metadata = {}, tracingConfig) => {
50
+ const params = { reset: true };
51
+ const metric = 'workspaces-reset';
52
+ return this.http.put(routes.Workspace(account, workspace), metadata, { metric, params, tracing: {
53
+ requestSpanNameSuffix: metric,
54
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
55
+ } });
56
+ };
57
+ this.promote = (account, workspace, tracingConfig) => {
58
+ const metric = 'workspaces-promote';
59
+ return this.http.put(routes.Promote(account), { workspace }, { metric, tracing: {
60
+ requestSpanNameSuffix: metric,
61
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
62
+ } });
63
+ };
64
+ }
65
+ }
66
+ exports.Workspaces = Workspaces;
@@ -0,0 +1,11 @@
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 './Registry';
8
+ export * from './Router';
9
+ export * from './VBase';
10
+ export * from './Workspaces';
11
+ export * from './Sphinx';
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Apps"), exports);
18
+ __exportStar(require("./Assets"), exports);
19
+ __exportStar(require("./BillingMetrics"), exports);
20
+ __exportStar(require("./Events"), exports);
21
+ __exportStar(require("./Housekeeper"), exports);
22
+ __exportStar(require("./InfraClient"), exports);
23
+ __exportStar(require("./Registry"), exports);
24
+ __exportStar(require("./Router"), exports);
25
+ __exportStar(require("./VBase"), exports);
26
+ __exportStar(require("./Workspaces"), exports);
27
+ __exportStar(require("./Sphinx"), exports);
@@ -1,7 +1,7 @@
1
- import { IOContext } from '../service/typings';
2
- import { ExternalClient } from './ExternalClient';
3
- import { InstanceOptions } from './typings';
4
- declare type Environment = 'stable' | 'beta';
1
+ import { InstanceOptions } from '../../HttpClient/typings';
2
+ import { IOContext } from '../../service/worker/runtime/typings';
3
+ import { ExternalClient } from '../external/ExternalClient';
4
+ type Environment = 'stable' | 'beta';
5
5
  /**
6
6
  * Used to perform calls on APIs in the VTEX Janus infrastructure, to which you must declare an outbound policy.
7
7
  *
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const ExternalClient_1 = require("./ExternalClient");
3
+ exports.JanusClient = void 0;
4
+ const ExternalClient_1 = require("../external/ExternalClient");
4
5
  /**
5
6
  * Used to perform calls on APIs in the VTEX Janus infrastructure, to which you must declare an outbound policy.
6
7
  *
@@ -18,9 +19,13 @@ class JanusClient extends ExternalClient_1.ExternalClient {
18
19
  constructor(context, options, environment) {
19
20
  const { account } = context;
20
21
  const env = context.janusEnv === 'beta' || environment === 'beta' ? 'beta' : 'stable';
21
- super(`http://portal.vtexcommerce${env}.com.br`, context, Object.assign({}, options, { params: {
22
+ super(`http://portal.vtexcommerce${env}.com.br`, context, {
23
+ ...options,
24
+ params: {
22
25
  an: account,
23
- } }));
26
+ ...options === null || options === void 0 ? void 0 : options.params,
27
+ },
28
+ });
24
29
  }
25
30
  }
26
31
  exports.JanusClient = JanusClient;
@@ -0,0 +1,7 @@
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
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LicenseManager = void 0;
4
+ const qs_1 = require("qs");
5
+ const JanusClient_1 = require("./JanusClient");
6
+ const TWO_MINUTES_S = 2 * 60;
7
+ const BASE_URL = '/api/license-manager';
8
+ const routes = {
9
+ accountData: `${BASE_URL}/account`,
10
+ resourceAccess: `${BASE_URL}/resources`,
11
+ topbarData: `${BASE_URL}/site/pvt/newtopbar`,
12
+ };
13
+ const inflightKey = ({ baseURL, url, params }) => {
14
+ return baseURL + url + (0, qs_1.stringify)(params, { arrayFormat: 'repeat', addQueryPrefix: true });
15
+ };
16
+ class LicenseManager extends JanusClient_1.JanusClient {
17
+ getAccountData(VtexIdclientAutCookie, tracingConfig) {
18
+ const metric = 'lm-account-data';
19
+ return this.http.get(routes.accountData, {
20
+ forceMaxAge: TWO_MINUTES_S,
21
+ headers: {
22
+ VtexIdclientAutCookie,
23
+ },
24
+ inflightKey,
25
+ metric,
26
+ tracing: {
27
+ requestSpanNameSuffix: metric,
28
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
29
+ },
30
+ });
31
+ }
32
+ getTopbarData(VtexIdclientAutCookie, tracingConfig) {
33
+ const metric = 'lm-topbar-data';
34
+ return this.http.get(routes.topbarData, {
35
+ headers: {
36
+ VtexIdclientAutCookie,
37
+ },
38
+ metric,
39
+ tracing: {
40
+ requestSpanNameSuffix: metric,
41
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
42
+ },
43
+ });
44
+ }
45
+ canAccessResource(VtexIdclientAutCookie, resourceKey, tracingConfig) {
46
+ const metric = 'lm-resource-access';
47
+ return this.http.get(`${routes.resourceAccess}/${resourceKey}/access`, {
48
+ headers: {
49
+ VtexIdclientAutCookie,
50
+ },
51
+ metric,
52
+ tracing: {
53
+ requestSpanNameSuffix: metric,
54
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
55
+ },
56
+ }).then(() => true, () => false);
57
+ }
58
+ }
59
+ exports.LicenseManager = LicenseManager;