@vtex/api 6.45.4

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 (360) hide show
  1. package/CHANGELOG.md +1685 -0
  2. package/README.md +65 -0
  3. package/gen/manifest.schema +189 -0
  4. package/lib/HttpClient/GraphQLClient.d.ts +28 -0
  5. package/lib/HttpClient/GraphQLClient.js +30 -0
  6. package/lib/HttpClient/HttpClient.d.ts +29 -0
  7. package/lib/HttpClient/HttpClient.js +130 -0
  8. package/lib/HttpClient/agents.d.ts +3 -0
  9. package/lib/HttpClient/agents.js +24 -0
  10. package/lib/HttpClient/index.d.ts +6 -0
  11. package/lib/HttpClient/index.js +14 -0
  12. package/lib/HttpClient/middlewares/cache.d.ts +35 -0
  13. package/lib/HttpClient/middlewares/cache.js +173 -0
  14. package/lib/HttpClient/middlewares/cancellationToken.d.ts +3 -0
  15. package/lib/HttpClient/middlewares/cancellationToken.js +72 -0
  16. package/lib/HttpClient/middlewares/inflight.d.ts +5 -0
  17. package/lib/HttpClient/middlewares/inflight.js +50 -0
  18. package/lib/HttpClient/middlewares/memoization.d.ts +7 -0
  19. package/lib/HttpClient/middlewares/memoization.js +40 -0
  20. package/lib/HttpClient/middlewares/metrics.d.ts +9 -0
  21. package/lib/HttpClient/middlewares/metrics.js +110 -0
  22. package/lib/HttpClient/middlewares/notFound.d.ts +7 -0
  23. package/lib/HttpClient/middlewares/notFound.js +20 -0
  24. package/lib/HttpClient/middlewares/recorder.d.ts +3 -0
  25. package/lib/HttpClient/middlewares/recorder.js +21 -0
  26. package/lib/HttpClient/middlewares/request/HttpAgentSingleton.d.ts +14 -0
  27. package/lib/HttpClient/middlewares/request/HttpAgentSingleton.js +37 -0
  28. package/lib/HttpClient/middlewares/request/index.d.ts +18 -0
  29. package/lib/HttpClient/middlewares/request/index.js +83 -0
  30. package/lib/HttpClient/middlewares/request/setupAxios/index.d.ts +1 -0
  31. package/lib/HttpClient/middlewares/request/setupAxios/index.js +20 -0
  32. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.d.ts +2 -0
  33. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +48 -0
  34. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.d.ts +2 -0
  35. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +7 -0
  36. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.d.ts +8 -0
  37. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.js +51 -0
  38. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.d.ts +4 -0
  39. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +29 -0
  40. package/lib/HttpClient/middlewares/tracing.d.ts +15 -0
  41. package/lib/HttpClient/middlewares/tracing.js +54 -0
  42. package/lib/HttpClient/typings.d.ts +123 -0
  43. package/lib/HttpClient/typings.js +11 -0
  44. package/lib/caches/CacheLayer.d.ts +7 -0
  45. package/lib/caches/CacheLayer.js +2 -0
  46. package/lib/caches/DiskCache.d.ts +17 -0
  47. package/lib/caches/DiskCache.js +70 -0
  48. package/lib/caches/LRUCache.d.ts +16 -0
  49. package/lib/caches/LRUCache.js +48 -0
  50. package/lib/caches/LRUDiskCache.d.ts +21 -0
  51. package/lib/caches/LRUDiskCache.js +132 -0
  52. package/lib/caches/MultilayeredCache.d.ts +14 -0
  53. package/lib/caches/MultilayeredCache.js +68 -0
  54. package/lib/caches/index.d.ts +6 -0
  55. package/lib/caches/index.js +9 -0
  56. package/lib/caches/typings.d.ts +48 -0
  57. package/lib/caches/typings.js +2 -0
  58. package/lib/clients/IOClient.d.ts +13 -0
  59. package/lib/clients/IOClient.js +19 -0
  60. package/lib/clients/IOClients.d.ts +37 -0
  61. package/lib/clients/IOClients.js +89 -0
  62. package/lib/clients/IOGraphQLClient.d.ts +13 -0
  63. package/lib/clients/IOGraphQLClient.js +16 -0
  64. package/lib/clients/apps/AppClient.d.ts +9 -0
  65. package/lib/clients/apps/AppClient.js +34 -0
  66. package/lib/clients/apps/AppGraphQLClient.d.ts +9 -0
  67. package/lib/clients/apps/AppGraphQLClient.js +34 -0
  68. package/lib/clients/apps/Billing.d.ts +12 -0
  69. package/lib/clients/apps/Billing.js +21 -0
  70. package/lib/clients/apps/Builder.d.ts +45 -0
  71. package/lib/clients/apps/Builder.js +114 -0
  72. package/lib/clients/apps/MessagesGraphQL.d.ts +61 -0
  73. package/lib/clients/apps/MessagesGraphQL.js +121 -0
  74. package/lib/clients/apps/Settings.d.ts +14 -0
  75. package/lib/clients/apps/Settings.js +38 -0
  76. package/lib/clients/apps/catalogGraphQL/brand.d.ts +13 -0
  77. package/lib/clients/apps/catalogGraphQL/brand.js +18 -0
  78. package/lib/clients/apps/catalogGraphQL/category.d.ts +11 -0
  79. package/lib/clients/apps/catalogGraphQL/category.js +16 -0
  80. package/lib/clients/apps/catalogGraphQL/index.d.ts +22 -0
  81. package/lib/clients/apps/catalogGraphQL/index.js +88 -0
  82. package/lib/clients/apps/catalogGraphQL/product.d.ts +25 -0
  83. package/lib/clients/apps/catalogGraphQL/product.js +30 -0
  84. package/lib/clients/apps/catalogGraphQL/sku.d.ts +26 -0
  85. package/lib/clients/apps/catalogGraphQL/sku.js +30 -0
  86. package/lib/clients/apps/index.d.ts +7 -0
  87. package/lib/clients/apps/index.js +12 -0
  88. package/lib/clients/external/ExternalClient.d.ts +9 -0
  89. package/lib/clients/external/ExternalClient.js +21 -0
  90. package/lib/clients/external/ID.d.ts +23 -0
  91. package/lib/clients/external/ID.js +60 -0
  92. package/lib/clients/external/Masterdata.d.ts +93 -0
  93. package/lib/clients/external/Masterdata.js +223 -0
  94. package/lib/clients/external/PaymentProvider.d.ts +31 -0
  95. package/lib/clients/external/PaymentProvider.js +42 -0
  96. package/lib/clients/external/index.d.ts +4 -0
  97. package/lib/clients/external/index.js +9 -0
  98. package/lib/clients/index.d.ts +9 -0
  99. package/lib/clients/index.js +17 -0
  100. package/lib/clients/infra/Apps.d.ts +88 -0
  101. package/lib/clients/infra/Apps.js +508 -0
  102. package/lib/clients/infra/Assets.d.ts +34 -0
  103. package/lib/clients/infra/Assets.js +165 -0
  104. package/lib/clients/infra/BillingMetrics.d.ts +13 -0
  105. package/lib/clients/infra/BillingMetrics.js +15 -0
  106. package/lib/clients/infra/Events.d.ts +12 -0
  107. package/lib/clients/infra/Events.js +33 -0
  108. package/lib/clients/infra/Housekeeper.d.ts +10 -0
  109. package/lib/clients/infra/Housekeeper.js +30 -0
  110. package/lib/clients/infra/InfraClient.d.ts +9 -0
  111. package/lib/clients/infra/InfraClient.js +34 -0
  112. package/lib/clients/infra/Metadata.d.ts +26 -0
  113. package/lib/clients/infra/Metadata.js +83 -0
  114. package/lib/clients/infra/Registry.d.ts +59 -0
  115. package/lib/clients/infra/Registry.js +207 -0
  116. package/lib/clients/infra/Router.d.ts +34 -0
  117. package/lib/clients/infra/Router.js +81 -0
  118. package/lib/clients/infra/Sphinx.d.ts +13 -0
  119. package/lib/clients/infra/Sphinx.js +29 -0
  120. package/lib/clients/infra/VBase.d.ts +60 -0
  121. package/lib/clients/infra/VBase.js +171 -0
  122. package/lib/clients/infra/Workspaces.d.ts +18 -0
  123. package/lib/clients/infra/Workspaces.js +65 -0
  124. package/lib/clients/infra/index.d.ts +12 -0
  125. package/lib/clients/infra/index.js +17 -0
  126. package/lib/clients/janus/JanusClient.d.ts +21 -0
  127. package/lib/clients/janus/JanusClient.js +30 -0
  128. package/lib/clients/janus/LicenseManager.d.ts +7 -0
  129. package/lib/clients/janus/LicenseManager.js +58 -0
  130. package/lib/clients/janus/Segment.d.ts +36 -0
  131. package/lib/clients/janus/Segment.js +79 -0
  132. package/lib/clients/janus/Session.d.ts +15 -0
  133. package/lib/clients/janus/Session.js +75 -0
  134. package/lib/clients/janus/Tenant.d.ts +29 -0
  135. package/lib/clients/janus/Tenant.js +28 -0
  136. package/lib/clients/janus/index.d.ts +5 -0
  137. package/lib/clients/janus/index.js +10 -0
  138. package/lib/constants.d.ts +59 -0
  139. package/lib/constants.js +65 -0
  140. package/lib/errors/AuthenticationError.d.ts +18 -0
  141. package/lib/errors/AuthenticationError.js +24 -0
  142. package/lib/errors/ForbiddenError.d.ts +18 -0
  143. package/lib/errors/ForbiddenError.js +24 -0
  144. package/lib/errors/NotFoundError.d.ts +18 -0
  145. package/lib/errors/NotFoundError.js +24 -0
  146. package/lib/errors/RequestCancelledError.d.ts +6 -0
  147. package/lib/errors/RequestCancelledError.js +11 -0
  148. package/lib/errors/ResolverError.d.ts +29 -0
  149. package/lib/errors/ResolverError.js +35 -0
  150. package/lib/errors/ResolverWarning.d.ts +21 -0
  151. package/lib/errors/ResolverWarning.js +28 -0
  152. package/lib/errors/TooManyRequestsError.d.ts +4 -0
  153. package/lib/errors/TooManyRequestsError.js +9 -0
  154. package/lib/errors/UserInputError.d.ts +18 -0
  155. package/lib/errors/UserInputError.js +24 -0
  156. package/lib/errors/customGraphQLError.d.ts +4 -0
  157. package/lib/errors/customGraphQLError.js +9 -0
  158. package/lib/errors/index.d.ts +8 -0
  159. package/lib/errors/index.js +13 -0
  160. package/lib/index.d.ts +17 -0
  161. package/lib/index.js +21 -0
  162. package/lib/metrics/MetricsAccumulator.d.ts +35 -0
  163. package/lib/metrics/MetricsAccumulator.js +125 -0
  164. package/lib/responses.d.ts +79 -0
  165. package/lib/responses.js +2 -0
  166. package/lib/service/index.d.ts +2 -0
  167. package/lib/service/index.js +30 -0
  168. package/lib/service/loaders.d.ts +8 -0
  169. package/lib/service/loaders.js +54 -0
  170. package/lib/service/logger/console.d.ts +10 -0
  171. package/lib/service/logger/console.js +36 -0
  172. package/lib/service/logger/index.d.ts +2 -0
  173. package/lib/service/logger/index.js +7 -0
  174. package/lib/service/logger/logger.d.ts +35 -0
  175. package/lib/service/logger/logger.js +73 -0
  176. package/lib/service/logger/metricsLogger.d.ts +40 -0
  177. package/lib/service/logger/metricsLogger.js +149 -0
  178. package/lib/service/master.d.ts +2 -0
  179. package/lib/service/master.js +91 -0
  180. package/lib/service/tracing/TracerSingleton.d.ts +7 -0
  181. package/lib/service/tracing/TracerSingleton.js +54 -0
  182. package/lib/service/tracing/metrics/MetricNames.d.ts +60 -0
  183. package/lib/service/tracing/metrics/MetricNames.js +44 -0
  184. package/lib/service/tracing/metrics/instruments.d.ts +9 -0
  185. package/lib/service/tracing/metrics/instruments.js +11 -0
  186. package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.d.ts +9 -0
  187. package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +25 -0
  188. package/lib/service/tracing/tracingMiddlewares.d.ts +5 -0
  189. package/lib/service/tracing/tracingMiddlewares.js +119 -0
  190. package/lib/service/worker/index.d.ts +11 -0
  191. package/lib/service/worker/index.js +193 -0
  192. package/lib/service/worker/listeners.d.ts +3 -0
  193. package/lib/service/worker/listeners.js +43 -0
  194. package/lib/service/worker/runtime/Service.d.ts +17 -0
  195. package/lib/service/worker/runtime/Service.js +23 -0
  196. package/lib/service/worker/runtime/builtIn/handlers.d.ts +4 -0
  197. package/lib/service/worker/runtime/builtIn/handlers.js +27 -0
  198. package/lib/service/worker/runtime/builtIn/middlewares.d.ts +4 -0
  199. package/lib/service/worker/runtime/builtIn/middlewares.js +40 -0
  200. package/lib/service/worker/runtime/events/index.d.ts +4 -0
  201. package/lib/service/worker/runtime/events/index.js +46 -0
  202. package/lib/service/worker/runtime/events/middlewares/body.d.ts +3 -0
  203. package/lib/service/worker/runtime/events/middlewares/body.js +22 -0
  204. package/lib/service/worker/runtime/events/middlewares/context.d.ts +3 -0
  205. package/lib/service/worker/runtime/events/middlewares/context.js +22 -0
  206. package/lib/service/worker/runtime/events/router.d.ts +2 -0
  207. package/lib/service/worker/runtime/events/router.js +27 -0
  208. package/lib/service/worker/runtime/graphql/index.d.ts +6 -0
  209. package/lib/service/worker/runtime/graphql/index.js +27 -0
  210. package/lib/service/worker/runtime/graphql/middlewares/context.d.ts +2 -0
  211. package/lib/service/worker/runtime/graphql/middlewares/context.js +16 -0
  212. package/lib/service/worker/runtime/graphql/middlewares/error.d.ts +2 -0
  213. package/lib/service/worker/runtime/graphql/middlewares/error.js +93 -0
  214. package/lib/service/worker/runtime/graphql/middlewares/query.d.ts +2 -0
  215. package/lib/service/worker/runtime/graphql/middlewares/query.js +52 -0
  216. package/lib/service/worker/runtime/graphql/middlewares/response.d.ts +2 -0
  217. package/lib/service/worker/runtime/graphql/middlewares/response.js +38 -0
  218. package/lib/service/worker/runtime/graphql/middlewares/run.d.ts +2 -0
  219. package/lib/service/worker/runtime/graphql/middlewares/run.js +19 -0
  220. package/lib/service/worker/runtime/graphql/middlewares/updateSchema.d.ts +4 -0
  221. package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +28 -0
  222. package/lib/service/worker/runtime/graphql/middlewares/upload.d.ts +4 -0
  223. package/lib/service/worker/runtime/graphql/middlewares/upload.js +12 -0
  224. package/lib/service/worker/runtime/graphql/schema/index.d.ts +7 -0
  225. package/lib/service/worker/runtime/graphql/schema/index.js +31 -0
  226. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +6 -0
  227. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +79 -0
  228. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Auth.d.ts +6 -0
  229. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Auth.js +73 -0
  230. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.d.ts +7 -0
  231. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.js +37 -0
  232. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.d.ts +11 -0
  233. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +61 -0
  234. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.d.ts +7 -0
  235. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.js +40 -0
  236. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Sanitize.d.ts +9 -0
  237. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Sanitize.js +35 -0
  238. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.d.ts +6 -0
  239. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +34 -0
  240. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/SmartCacheDirective.d.ts +6 -0
  241. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/SmartCacheDirective.js +29 -0
  242. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.d.ts +7 -0
  243. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +39 -0
  244. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.d.ts +7 -0
  245. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +33 -0
  246. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.d.ts +22 -0
  247. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +36 -0
  248. package/lib/service/worker/runtime/graphql/schema/typeDefs/index.d.ts +7 -0
  249. package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +12 -0
  250. package/lib/service/worker/runtime/graphql/schema/typeDefs/ioUpload.d.ts +3 -0
  251. package/lib/service/worker/runtime/graphql/schema/typeDefs/ioUpload.js +16 -0
  252. package/lib/service/worker/runtime/graphql/schema/typeDefs/sanitizedString.d.ts +10 -0
  253. package/lib/service/worker/runtime/graphql/schema/typeDefs/sanitizedString.js +39 -0
  254. package/lib/service/worker/runtime/graphql/typings.d.ts +31 -0
  255. package/lib/service/worker/runtime/graphql/typings.js +2 -0
  256. package/lib/service/worker/runtime/graphql/utils/cacheControl.d.ts +1 -0
  257. package/lib/service/worker/runtime/graphql/utils/cacheControl.js +32 -0
  258. package/lib/service/worker/runtime/graphql/utils/error.d.ts +1 -0
  259. package/lib/service/worker/runtime/graphql/utils/error.js +76 -0
  260. package/lib/service/worker/runtime/graphql/utils/pathname.d.ts +1 -0
  261. package/lib/service/worker/runtime/graphql/utils/pathname.js +7 -0
  262. package/lib/service/worker/runtime/graphql/utils/translations.d.ts +14 -0
  263. package/lib/service/worker/runtime/graphql/utils/translations.js +38 -0
  264. package/lib/service/worker/runtime/http/index.d.ts +5 -0
  265. package/lib/service/worker/runtime/http/index.js +58 -0
  266. package/lib/service/worker/runtime/http/middlewares/authTokens.d.ts +3 -0
  267. package/lib/service/worker/runtime/http/middlewares/authTokens.js +12 -0
  268. package/lib/service/worker/runtime/http/middlewares/cancellationToken.d.ts +3 -0
  269. package/lib/service/worker/runtime/http/middlewares/cancellationToken.js +18 -0
  270. package/lib/service/worker/runtime/http/middlewares/clients.d.ts +4 -0
  271. package/lib/service/worker/runtime/http/middlewares/clients.js +12 -0
  272. package/lib/service/worker/runtime/http/middlewares/context.d.ts +4 -0
  273. package/lib/service/worker/runtime/http/middlewares/context.js +36 -0
  274. package/lib/service/worker/runtime/http/middlewares/error.d.ts +2 -0
  275. package/lib/service/worker/runtime/http/middlewares/error.js +84 -0
  276. package/lib/service/worker/runtime/http/middlewares/rateLimit.d.ts +6 -0
  277. package/lib/service/worker/runtime/http/middlewares/rateLimit.js +42 -0
  278. package/lib/service/worker/runtime/http/middlewares/requestStats.d.ts +17 -0
  279. package/lib/service/worker/runtime/http/middlewares/requestStats.js +40 -0
  280. package/lib/service/worker/runtime/http/middlewares/setCookie.d.ts +3 -0
  281. package/lib/service/worker/runtime/http/middlewares/setCookie.js +52 -0
  282. package/lib/service/worker/runtime/http/middlewares/settings.d.ts +9 -0
  283. package/lib/service/worker/runtime/http/middlewares/settings.js +43 -0
  284. package/lib/service/worker/runtime/http/middlewares/timings.d.ts +3 -0
  285. package/lib/service/worker/runtime/http/middlewares/timings.js +45 -0
  286. package/lib/service/worker/runtime/http/middlewares/vary.d.ts +3 -0
  287. package/lib/service/worker/runtime/http/middlewares/vary.js +52 -0
  288. package/lib/service/worker/runtime/http/router.d.ts +2 -0
  289. package/lib/service/worker/runtime/http/router.js +23 -0
  290. package/lib/service/worker/runtime/http/routes.d.ts +19 -0
  291. package/lib/service/worker/runtime/http/routes.js +12 -0
  292. package/lib/service/worker/runtime/method.d.ts +9 -0
  293. package/lib/service/worker/runtime/method.js +23 -0
  294. package/lib/service/worker/runtime/statusTrack.d.ts +14 -0
  295. package/lib/service/worker/runtime/statusTrack.js +37 -0
  296. package/lib/service/worker/runtime/typings.d.ts +172 -0
  297. package/lib/service/worker/runtime/typings.js +2 -0
  298. package/lib/service/worker/runtime/utils/compose.d.ts +5 -0
  299. package/lib/service/worker/runtime/utils/compose.js +11 -0
  300. package/lib/service/worker/runtime/utils/context.d.ts +2 -0
  301. package/lib/service/worker/runtime/utils/context.js +40 -0
  302. package/lib/service/worker/runtime/utils/diff.d.ts +12 -0
  303. package/lib/service/worker/runtime/utils/diff.js +21 -0
  304. package/lib/service/worker/runtime/utils/recorder.d.ts +8 -0
  305. package/lib/service/worker/runtime/utils/recorder.js +37 -0
  306. package/lib/service/worker/runtime/utils/toArray.d.ts +1 -0
  307. package/lib/service/worker/runtime/utils/toArray.js +3 -0
  308. package/lib/service/worker/runtime/utils/tokenBucket.d.ts +2 -0
  309. package/lib/service/worker/runtime/utils/tokenBucket.js +16 -0
  310. package/lib/tracing/LogEvents.d.ts +31 -0
  311. package/lib/tracing/LogEvents.js +3 -0
  312. package/lib/tracing/LogFields.d.ts +61 -0
  313. package/lib/tracing/LogFields.js +3 -0
  314. package/lib/tracing/Tags.d.ts +79 -0
  315. package/lib/tracing/Tags.js +7 -0
  316. package/lib/tracing/UserLandTracer.d.ts +27 -0
  317. package/lib/tracing/UserLandTracer.js +55 -0
  318. package/lib/tracing/errorReporting/ErrorReport.d.ts +31 -0
  319. package/lib/tracing/errorReporting/ErrorReport.js +61 -0
  320. package/lib/tracing/index.d.ts +9 -0
  321. package/lib/tracing/index.js +19 -0
  322. package/lib/tracing/spanReference/SpanReferenceTypes.d.ts +4 -0
  323. package/lib/tracing/spanReference/SpanReferenceTypes.js +7 -0
  324. package/lib/tracing/spanReference/createSpanReference.d.ts +3 -0
  325. package/lib/tracing/spanReference/createSpanReference.js +8 -0
  326. package/lib/tracing/utils.d.ts +13 -0
  327. package/lib/tracing/utils.js +40 -0
  328. package/lib/utils/MineWinsConflictsResolver.d.ts +28 -0
  329. package/lib/utils/MineWinsConflictsResolver.js +130 -0
  330. package/lib/utils/app.d.ts +23 -0
  331. package/lib/utils/app.js +48 -0
  332. package/lib/utils/appsStaleIfError.d.ts +11 -0
  333. package/lib/utils/appsStaleIfError.js +63 -0
  334. package/lib/utils/billingOptions.d.ts +36 -0
  335. package/lib/utils/billingOptions.js +9 -0
  336. package/lib/utils/binding.d.ts +13 -0
  337. package/lib/utils/binding.js +38 -0
  338. package/lib/utils/cancel.d.ts +3 -0
  339. package/lib/utils/cancel.js +12 -0
  340. package/lib/utils/domain.d.ts +1 -0
  341. package/lib/utils/domain.js +5 -0
  342. package/lib/utils/error.d.ts +8 -0
  343. package/lib/utils/error.js +94 -0
  344. package/lib/utils/index.d.ts +9 -0
  345. package/lib/utils/index.js +14 -0
  346. package/lib/utils/message.d.ts +25 -0
  347. package/lib/utils/message.js +23 -0
  348. package/lib/utils/renameBy.d.ts +1 -0
  349. package/lib/utils/renameBy.js +4 -0
  350. package/lib/utils/retry.d.ts +4 -0
  351. package/lib/utils/retry.js +32 -0
  352. package/lib/utils/status.d.ts +1 -0
  353. package/lib/utils/status.js +11 -0
  354. package/lib/utils/tenant.d.ts +5 -0
  355. package/lib/utils/tenant.js +6 -0
  356. package/lib/utils/throwOnGraphQLErrors.d.ts +2 -0
  357. package/lib/utils/throwOnGraphQLErrors.js +15 -0
  358. package/lib/utils/time.d.ts +31 -0
  359. package/lib/utils/time.js +118 -0
  360. package/package.json +127 -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
+ }
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ramda_1 = require("ramda");
4
+ const HttpClient_1 = require("../../HttpClient");
5
+ const utils_1 = require("../../utils");
6
+ const InfraClient_1 = require("./InfraClient");
7
+ const dependsOnApp = (appsAtMajor) => (a) => {
8
+ let dependsOn = false;
9
+ appsAtMajor.forEach(appAtMajor => {
10
+ const [name, major] = appAtMajor.split('@');
11
+ const sanitizedMajor = major.includes('.') ? major.split('.')[0] : major;
12
+ const version = a._resolvedDependencies[name];
13
+ if (version) {
14
+ const [depMajor] = version.split('.');
15
+ if (sanitizedMajor === depMajor) {
16
+ dependsOn = true;
17
+ }
18
+ }
19
+ });
20
+ return dependsOn;
21
+ };
22
+ const useBuildJson = (app, appVendorName) => {
23
+ const buildFeatures = app._buildFeatures;
24
+ return buildFeatures && buildFeatures[appVendorName] && ramda_1.contains('build.json', buildFeatures[appVendorName]);
25
+ };
26
+ const appOrRegistry = (workspace, { name, version, build }) => build
27
+ ? `${workspace}/apps/${name}@${version}+${build}`
28
+ : `master/registry/${name}/${version}`;
29
+ const createRoutes = (workspace) => ({
30
+ Bundle: (scope, locator, path) => `/${scope}/${appOrRegistry(workspace, locator)}/bundle/${path}`,
31
+ Files: (scope, locator, path) => `/${scope}/${appOrRegistry(workspace, locator)}/files/${path}`,
32
+ });
33
+ class Assets extends InfraClient_1.InfraClient {
34
+ constructor(context, options) {
35
+ super('apps@0.x', context, options, true);
36
+ this.getAppBundleByVendor = (app, bundlePath, generatePackageJson, tracingConfig) => {
37
+ const locator = utils_1.parseAppId(app);
38
+ const params = generatePackageJson && { _packageJSONEngine: 'npm', _packageJSONFilter: 'vtex.render-builder@x' };
39
+ const metric = locator.build ? 'apps-get-bundle' : 'registry-get-bundle';
40
+ return this.http.getStream(this.routes.Bundle(this.context.account, locator, bundlePath), {
41
+ headers: {
42
+ Accept: 'application/x-gzip',
43
+ 'Accept-Encoding': 'gzip',
44
+ },
45
+ metric,
46
+ params,
47
+ tracing: {
48
+ requestSpanNameSuffix: metric,
49
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
50
+ },
51
+ });
52
+ };
53
+ this.getAppJSONByAccount = (app, path, nullIfNotFound, tracingConfig) => {
54
+ const locator = utils_1.parseAppId(app);
55
+ const inflightKey = HttpClient_1.inflightURL;
56
+ const metric = 'assets-get-json-by-account';
57
+ return this.http.get(this.routes.Files(this.context.account, locator, path), {
58
+ cacheable: HttpClient_1.CacheType.Memory,
59
+ inflightKey,
60
+ metric,
61
+ nullIfNotFound,
62
+ tracing: {
63
+ requestSpanNameSuffix: metric,
64
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
65
+ },
66
+ });
67
+ };
68
+ this.getAppJSONByVendor = (app, path, nullIfNotFound, tracingConfig) => {
69
+ const locator = utils_1.parseAppId(app);
70
+ const vendor = locator.name.split('.')[0];
71
+ const inflightKey = HttpClient_1.inflightURL;
72
+ const metric = 'assets-get-json-by-vendor';
73
+ return this.http.get(this.routes.Files(vendor, locator, path), {
74
+ cacheable: HttpClient_1.CacheType.Any,
75
+ inflightKey,
76
+ metric,
77
+ nullIfNotFound,
78
+ tracing: {
79
+ requestSpanNameSuffix: metric,
80
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
81
+ },
82
+ });
83
+ };
84
+ this.getAppFileByAccount = (app, path, nullIfNotFound, tracingConfig) => {
85
+ const locator = utils_1.parseAppId(app);
86
+ const inflightKey = HttpClient_1.inflightURL;
87
+ const metric = 'assets-get-file-by-account';
88
+ return this.http.getBuffer(this.routes.Files(this.context.account, locator, path), {
89
+ cacheable: HttpClient_1.CacheType.Any,
90
+ inflightKey,
91
+ metric,
92
+ nullIfNotFound,
93
+ tracing: {
94
+ requestSpanNameSuffix: metric,
95
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
96
+ },
97
+ });
98
+ };
99
+ this.getAppFileByVendor = (app, path, nullIfNotFound, tracingConfig) => {
100
+ const locator = utils_1.parseAppId(app);
101
+ const vendor = locator.name.split('.')[0];
102
+ const inflightKey = HttpClient_1.inflightURL;
103
+ const metric = 'assets-get-file-by-vendor';
104
+ return this.http.getBuffer(this.routes.Files(vendor, locator, path), {
105
+ cacheable: HttpClient_1.CacheType.Any,
106
+ inflightKey,
107
+ metric,
108
+ nullIfNotFound,
109
+ tracing: {
110
+ requestSpanNameSuffix: metric,
111
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
112
+ },
113
+ });
114
+ };
115
+ this.routes = createRoutes(this.context.workspace);
116
+ }
117
+ getSettings(dependencies, appAtMajor, params = {}, tracingConfig) {
118
+ const { pick, files } = params;
119
+ const filtered = this.getFilteredDependencies(appAtMajor, dependencies);
120
+ return Promise.all(filtered.map(dependency => {
121
+ const [appVendorName] = appAtMajor.split('@');
122
+ const buildJson = useBuildJson(dependency, appVendorName);
123
+ return buildJson
124
+ ? this.getBuildJSONForApp(dependency, appVendorName, pick, tracingConfig)
125
+ : this.getSettingsFromFilesForApp(dependency, files, tracingConfig);
126
+ }));
127
+ }
128
+ async getBuildJSONForApp(app, appVendorName, pick = [], tracingConfig) {
129
+ const pickArray = Array.isArray(pick) ? pick : [pick];
130
+ const buildJson = await this.getJSON(app.id, `dist/${appVendorName}/build.json`, undefined, tracingConfig);
131
+ const result = !ramda_1.isEmpty(pickArray) ? ramda_1.pick(pickArray, buildJson) : buildJson;
132
+ result.declarer = app.id;
133
+ return result;
134
+ }
135
+ async getSettingsFromFilesForApp(app, files = [], tracingConfig) {
136
+ // If there's no support for build.json, then fetch individual files and zip them into an {[file]: content} object.
137
+ const filesArray = Array.isArray(files) ? files : [files];
138
+ const fetched = await Promise.all(filesArray.map(file => this.getJSON(app.id, file, true, tracingConfig)));
139
+ const result = ramda_1.zipObj(filesArray, fetched);
140
+ result.declarer = app.id;
141
+ return result;
142
+ }
143
+ async getJSON(appId, file, nullIfNotFound, tracingConfig) {
144
+ const locator = utils_1.parseAppId(appId);
145
+ const linked = !!locator.build;
146
+ if (linked) {
147
+ return this.getAppJSONByAccount(appId, file, nullIfNotFound, tracingConfig);
148
+ }
149
+ return this.getAppJSONByVendor(appId, file, nullIfNotFound, tracingConfig);
150
+ }
151
+ async getFile(appId, file, nullIfNotFound, tracingConfig) {
152
+ const locator = utils_1.parseAppId(appId);
153
+ const linked = !!locator.build;
154
+ if (linked) {
155
+ return this.getAppFileByAccount(appId, file, nullIfNotFound, tracingConfig);
156
+ }
157
+ return this.getAppFileByVendor(appId, file, nullIfNotFound, tracingConfig);
158
+ }
159
+ getFilteredDependencies(apps, dependencies) {
160
+ const appsAtMajor = typeof (apps) === 'string' ? [apps] : apps;
161
+ const depends = dependsOnApp(appsAtMajor);
162
+ return ramda_1.filter(depends, dependencies);
163
+ }
164
+ }
165
+ exports.Assets = Assets;
@@ -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,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const InfraClient_1 = require("./InfraClient");
4
+ class BillingMetrics extends InfraClient_1.InfraClient {
5
+ constructor(context, options) {
6
+ super('colossus@0.x', context, options);
7
+ this.sendMetric = (metric, tracingConfig) => {
8
+ return this.http.post('/metrics', metric, { tracing: {
9
+ requestSpanNameSuffix: 'send-metric',
10
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
11
+ } });
12
+ };
13
+ }
14
+ }
15
+ 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,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const util_1 = require("util");
4
+ const InfraClient_1 = require("./InfraClient");
5
+ const ANY_APP = '';
6
+ const eventRoute = (route) => `/events/${route}`;
7
+ const isResourceVRN = (appIdOrResource) => util_1.isObject(appIdOrResource) && !util_1.isNullOrUndefined(appIdOrResource.service);
8
+ class Events extends InfraClient_1.InfraClient {
9
+ constructor({ recorder, ...context }, options) {
10
+ super('courier@0.x', context, options);
11
+ this.sendEvent = (appIdOrResource, route, message, tracingConfig) => {
12
+ const resource = this.resourceFor(appIdOrResource);
13
+ return this.http.put(eventRoute(route), message, {
14
+ metric: 'events-send',
15
+ params: { resource },
16
+ tracing: {
17
+ requestSpanNameSuffix: 'events-send',
18
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
19
+ },
20
+ });
21
+ };
22
+ this.resourceFor = (appIdOrResource) => {
23
+ if (appIdOrResource === ANY_APP) {
24
+ return ANY_APP;
25
+ }
26
+ const { service, path } = isResourceVRN(appIdOrResource)
27
+ ? appIdOrResource
28
+ : { service: 'apps', path: `/apps/${appIdOrResource}` };
29
+ return `vrn:${service}:${this.context.region}:${this.context.account}:${this.context.workspace}:${path}`;
30
+ };
31
+ }
32
+ }
33
+ 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,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const InfraClient_1 = require("./InfraClient");
4
+ class Housekeeper extends InfraClient_1.InfraClient {
5
+ constructor(context, options) {
6
+ super('housekeeper@0.x', context, options);
7
+ this.apply = async (data, tracingConfig) => {
8
+ const metric = 'housekeeper-apply';
9
+ return this.http.post('v2/housekeeping/apply', data, { metric, tracing: {
10
+ requestSpanNameSuffix: metric,
11
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
12
+ } });
13
+ };
14
+ this.perform = async (tracingConfig) => {
15
+ const metric = 'housekeeper-perform';
16
+ return this.http.post('v2/_housekeeping/perform', {}, { metric, tracing: {
17
+ requestSpanNameSuffix: metric,
18
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
19
+ } });
20
+ };
21
+ this.resolve = async (tracingConfig) => {
22
+ const metric = 'housekeeper-resolve';
23
+ return this.http.get('v2/housekeeping/resolve', { metric, tracing: {
24
+ requestSpanNameSuffix: metric,
25
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
26
+ } });
27
+ };
28
+ }
29
+ }
30
+ exports.Housekeeper = Housekeeper;
@@ -0,0 +1,9 @@
1
+ import { InstanceOptions } from '../../HttpClient/typings';
2
+ import { IOContext } from '../../service/worker/runtime/typings';
3
+ import { IOClient } from '../IOClient';
4
+ /**
5
+ * Used to perform calls on infra apps (e.g. sphinx, apps, vbase).
6
+ */
7
+ export declare class InfraClient extends IOClient {
8
+ constructor(app: string, context: IOContext, options?: InstanceOptions, isRoot?: boolean);
9
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_1 = require("../../constants");
4
+ const typings_1 = require("../../HttpClient/typings");
5
+ const IOClient_1 = require("../IOClient");
6
+ const useHttps = !constants_1.IS_IO;
7
+ /**
8
+ * Used to perform calls on infra apps (e.g. sphinx, apps, vbase).
9
+ */
10
+ class InfraClient extends IOClient_1.IOClient {
11
+ constructor(app, context, options, isRoot = false) {
12
+ const { account, workspace, region } = context;
13
+ const [appName, appVersion] = app.split('@');
14
+ const protocol = useHttps ? 'https' : 'http';
15
+ let baseURL;
16
+ if (appVersion) {
17
+ const [appMajor] = appVersion.split('.');
18
+ baseURL = `${protocol}://infra.io.vtex.com/${appName}/v${appMajor}${isRoot ? '' : `/${account}/${workspace}`}`;
19
+ }
20
+ else if (app === 'router') {
21
+ baseURL = `${protocol}://platform.io.vtex.com/${isRoot ? '' : `/${account}/${workspace}`}`;
22
+ }
23
+ else {
24
+ console.warn(`${account} in ${workspace} is using old routing for ${app}. This will stop working soon`);
25
+ baseURL = `http://${app}.${region}.vtex.io${isRoot ? '' : `/${account}/${workspace}`}`;
26
+ }
27
+ super(context, {
28
+ ...options,
29
+ authType: typings_1.AuthType.bearer,
30
+ baseURL,
31
+ });
32
+ }
33
+ }
34
+ exports.InfraClient = InfraClient;
@@ -0,0 +1,26 @@
1
+ import { InstanceOptions, RequestTracingConfig } from '../../HttpClient';
2
+ import { BucketMetadata } from '../../responses';
3
+ import { IOContext } from '../../service/worker/runtime/typings';
4
+ import { InfraClient } from './InfraClient';
5
+ export interface MetadataEntry {
6
+ Key: string;
7
+ Hash: string;
8
+ Value: any;
9
+ }
10
+ export interface MetadataEntryList {
11
+ Data: MetadataEntry[];
12
+ Next: string;
13
+ }
14
+ export declare class Metadata extends InfraClient {
15
+ constructor(context: IOContext, options?: InstanceOptions);
16
+ getBuckets: (bucket: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<BucketMetadata>;
17
+ list: (bucket: string, includeValue: boolean, limit?: number | undefined, nextMarker?: string | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<MetadataEntryList>;
18
+ listAll: (bucket: string, includeValue: boolean, tracingConfig?: RequestTracingConfig | undefined) => Promise<MetadataEntryList>;
19
+ get: (bucket: string, key: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<any>;
20
+ save: (bucket: string, key: string, data: any, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
21
+ saveAll: (bucket: string, data: {
22
+ [key: string]: any;
23
+ }, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
24
+ delete: (bucket: string, key: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<import("../../HttpClient").IOResponse<void>>;
25
+ deleteAll: (bucket: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<import("../../HttpClient").IOResponse<void>>;
26
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const InfraClient_1 = require("./InfraClient");
4
+ const appId = process.env.VTEX_APP_ID;
5
+ const [runningAppName] = appId ? appId.split('@') : [''];
6
+ const routes = {
7
+ Bucket: (bucket) => `/buckets/${runningAppName}/${bucket}`,
8
+ Metadata: (bucket) => `${routes.Bucket(bucket)}/metadata`,
9
+ MetadataKey: (bucket, key) => `${routes.Metadata(bucket)}/${key}`,
10
+ };
11
+ class Metadata extends InfraClient_1.InfraClient {
12
+ constructor(context, options) {
13
+ super('router', context, options);
14
+ this.getBuckets = (bucket, tracingConfig) => {
15
+ const metric = 'meta-get-buckets';
16
+ return this.http.get(routes.Bucket(bucket), { metric, tracing: {
17
+ requestSpanNameSuffix: metric,
18
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
19
+ } });
20
+ };
21
+ this.list = (bucket, includeValue, limit, nextMarker, tracingConfig) => {
22
+ const query = { value: includeValue, _limit: 10 };
23
+ if (limit && limit > 0) {
24
+ query._limit = limit;
25
+ }
26
+ if (nextMarker) {
27
+ query._marker = nextMarker;
28
+ }
29
+ const metric = 'meta-list';
30
+ return this.http.get(routes.Metadata(bucket), { metric, params: query, tracing: {
31
+ requestSpanNameSuffix: metric,
32
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
33
+ } });
34
+ };
35
+ this.listAll = (bucket, includeValue, tracingConfig) => {
36
+ const query = { value: includeValue, _limit: 1000 };
37
+ const metric = 'meta-list-all';
38
+ return this.http.get(routes.Metadata(bucket), { metric, params: query, tracing: {
39
+ requestSpanNameSuffix: metric,
40
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
41
+ } });
42
+ };
43
+ this.get = (bucket, key, tracingConfig) => {
44
+ const metric = 'meta-get';
45
+ return this.http.get(routes.MetadataKey(bucket, key), { metric, tracing: {
46
+ requestSpanNameSuffix: metric,
47
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
48
+ } });
49
+ };
50
+ this.save = (bucket, key, data, tracingConfig) => {
51
+ const metric = 'meta-save';
52
+ return this.http.put(routes.MetadataKey(bucket, key), data, { metric, tracing: {
53
+ requestSpanNameSuffix: metric,
54
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
55
+ } });
56
+ };
57
+ this.saveAll = (bucket, data, tracingConfig) => {
58
+ const metric = 'meta-save-all';
59
+ return this.http.put(routes.Metadata(bucket), data, { metric, tracing: {
60
+ requestSpanNameSuffix: metric,
61
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
62
+ } });
63
+ };
64
+ this.delete = (bucket, key, tracingConfig) => {
65
+ const metric = 'meta-delete';
66
+ return this.http.delete(routes.MetadataKey(bucket, key), { metric, tracing: {
67
+ requestSpanNameSuffix: metric,
68
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
69
+ } });
70
+ };
71
+ this.deleteAll = (bucket, tracingConfig) => {
72
+ const metric = 'meta-delete-all';
73
+ return this.http.delete(routes.Metadata(bucket), { metric, tracing: {
74
+ requestSpanNameSuffix: metric,
75
+ ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
76
+ } });
77
+ };
78
+ if (runningAppName === '') {
79
+ throw new Error(`Invalid path to access Metadata. Variable VTEX_APP_ID is not available.`);
80
+ }
81
+ }
82
+ }
83
+ exports.Metadata = Metadata;