@vtex/api 6.48.0 → 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 (243) hide show
  1. package/gen/manifest.schema +2 -3
  2. package/lib/HttpClient/GraphQLClient.d.ts +1 -1
  3. package/lib/HttpClient/GraphQLClient.js +1 -0
  4. package/lib/HttpClient/HttpClient.d.ts +4 -3
  5. package/lib/HttpClient/HttpClient.js +15 -14
  6. package/lib/HttpClient/agents.d.ts +5 -2
  7. package/lib/HttpClient/agents.js +23 -4
  8. package/lib/HttpClient/index.js +22 -10
  9. package/lib/HttpClient/middlewares/cache.d.ts +1 -1
  10. package/lib/HttpClient/middlewares/cache.js +48 -42
  11. package/lib/HttpClient/middlewares/cancellationToken.d.ts +1 -1
  12. package/lib/HttpClient/middlewares/cancellationToken.js +3 -1
  13. package/lib/HttpClient/middlewares/inflight.d.ts +1 -1
  14. package/lib/HttpClient/middlewares/inflight.js +7 -3
  15. package/lib/HttpClient/middlewares/memoization.d.ts +1 -1
  16. package/lib/HttpClient/middlewares/memoization.js +10 -8
  17. package/lib/HttpClient/middlewares/metrics.js +13 -7
  18. package/lib/HttpClient/middlewares/notFound.d.ts +1 -1
  19. package/lib/HttpClient/middlewares/notFound.js +5 -2
  20. package/lib/HttpClient/middlewares/recorder.js +7 -1
  21. package/lib/HttpClient/middlewares/request/HttpAgentSingleton.js +2 -1
  22. package/lib/HttpClient/middlewares/request/index.d.ts +1 -1
  23. package/lib/HttpClient/middlewares/request/index.js +13 -9
  24. package/lib/HttpClient/middlewares/request/setupAxios/index.js +6 -4
  25. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +7 -5
  26. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +4 -3
  27. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.js +9 -6
  28. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +10 -7
  29. package/lib/HttpClient/middlewares/tracing.js +16 -10
  30. package/lib/HttpClient/typings.d.ts +3 -3
  31. package/lib/HttpClient/typings.js +1 -0
  32. package/lib/caches/DiskCache.d.ts +1 -1
  33. package/lib/caches/DiskCache.js +3 -2
  34. package/lib/caches/LRUCache.d.ts +3 -3
  35. package/lib/caches/LRUCache.js +1 -0
  36. package/lib/caches/LRUDiskCache.d.ts +2 -2
  37. package/lib/caches/LRUDiskCache.js +3 -2
  38. package/lib/caches/MultilayeredCache.d.ts +2 -2
  39. package/lib/caches/MultilayeredCache.js +8 -7
  40. package/lib/caches/index.js +20 -7
  41. package/lib/caches/typings.d.ts +5 -5
  42. package/lib/clients/IOClient.d.ts +1 -1
  43. package/lib/clients/IOClient.js +1 -0
  44. package/lib/clients/IOClients.d.ts +1 -1
  45. package/lib/clients/IOClients.js +1 -0
  46. package/lib/clients/IOGraphQLClient.js +1 -0
  47. package/lib/clients/apps/AppClient.js +2 -1
  48. package/lib/clients/apps/AppGraphQLClient.js +2 -1
  49. package/lib/clients/apps/Billing.d.ts +1 -1
  50. package/lib/clients/apps/Billing.js +1 -0
  51. package/lib/clients/apps/Builder.d.ts +7 -7
  52. package/lib/clients/apps/Builder.js +2 -1
  53. package/lib/clients/apps/MessagesGraphQL.d.ts +1 -1
  54. package/lib/clients/apps/MessagesGraphQL.js +4 -3
  55. package/lib/clients/apps/Settings.js +4 -3
  56. package/lib/clients/apps/catalogGraphQL/brand.js +1 -0
  57. package/lib/clients/apps/catalogGraphQL/category.js +1 -0
  58. package/lib/clients/apps/catalogGraphQL/index.d.ts +4 -4
  59. package/lib/clients/apps/catalogGraphQL/index.js +5 -4
  60. package/lib/clients/apps/catalogGraphQL/product.js +1 -0
  61. package/lib/clients/apps/catalogGraphQL/sku.js +1 -0
  62. package/lib/clients/apps/index.js +21 -10
  63. package/lib/clients/external/ExternalClient.js +1 -0
  64. package/lib/clients/external/ID.d.ts +4 -4
  65. package/lib/clients/external/ID.js +1 -0
  66. package/lib/clients/external/Masterdata.js +1 -0
  67. package/lib/clients/external/PaymentProvider.d.ts +2 -2
  68. package/lib/clients/external/PaymentProvider.js +1 -0
  69. package/lib/clients/external/index.js +18 -7
  70. package/lib/clients/index.js +22 -10
  71. package/lib/clients/infra/Apps.d.ts +32 -27
  72. package/lib/clients/infra/Apps.js +19 -16
  73. package/lib/clients/infra/Assets.d.ts +6 -5
  74. package/lib/clients/infra/Assets.js +12 -11
  75. package/lib/clients/infra/BillingMetrics.d.ts +1 -1
  76. package/lib/clients/infra/BillingMetrics.js +1 -0
  77. package/lib/clients/infra/Events.d.ts +1 -1
  78. package/lib/clients/infra/Events.js +2 -1
  79. package/lib/clients/infra/Housekeeper.d.ts +3 -3
  80. package/lib/clients/infra/Housekeeper.js +1 -0
  81. package/lib/clients/infra/InfraClient.js +1 -0
  82. package/lib/clients/infra/Registry.d.ts +23 -17
  83. package/lib/clients/infra/Registry.js +5 -3
  84. package/lib/clients/infra/Router.d.ts +8 -8
  85. package/lib/clients/infra/Router.js +1 -0
  86. package/lib/clients/infra/Sphinx.d.ts +2 -2
  87. package/lib/clients/infra/Sphinx.js +1 -0
  88. package/lib/clients/infra/VBase.d.ts +15 -14
  89. package/lib/clients/infra/VBase.js +4 -3
  90. package/lib/clients/infra/Workspaces.d.ts +7 -7
  91. package/lib/clients/infra/Workspaces.js +1 -0
  92. package/lib/clients/infra/index.js +25 -14
  93. package/lib/clients/janus/JanusClient.d.ts +1 -1
  94. package/lib/clients/janus/JanusClient.js +1 -0
  95. package/lib/clients/janus/LicenseManager.js +2 -1
  96. package/lib/clients/janus/Segment.d.ts +3 -3
  97. package/lib/clients/janus/Segment.js +3 -2
  98. package/lib/clients/janus/Session.d.ts +2 -2
  99. package/lib/clients/janus/Session.js +1 -0
  100. package/lib/clients/janus/Tenant.d.ts +1 -1
  101. package/lib/clients/janus/Tenant.js +1 -0
  102. package/lib/clients/janus/index.js +19 -8
  103. package/lib/constants.d.ts +1 -1
  104. package/lib/constants.js +2 -1
  105. package/lib/errors/AuthenticationError.js +1 -0
  106. package/lib/errors/ForbiddenError.js +1 -0
  107. package/lib/errors/NotFoundError.js +1 -0
  108. package/lib/errors/RequestCancelledError.js +1 -0
  109. package/lib/errors/ResolverError.js +2 -1
  110. package/lib/errors/ResolverWarning.js +1 -0
  111. package/lib/errors/TooManyRequestsError.js +1 -0
  112. package/lib/errors/UserInputError.js +1 -0
  113. package/lib/errors/index.js +22 -11
  114. package/lib/index.js +31 -18
  115. package/lib/metrics/MetricsAccumulator.d.ts +2 -2
  116. package/lib/metrics/MetricsAccumulator.js +10 -9
  117. package/lib/responses.d.ts +4 -4
  118. package/lib/service/index.js +11 -6
  119. package/lib/service/loaders.js +9 -6
  120. package/lib/service/logger/console.js +8 -4
  121. package/lib/service/logger/index.js +16 -5
  122. package/lib/service/logger/logger.js +3 -2
  123. package/lib/service/logger/metricsLogger.js +11 -10
  124. package/lib/service/master.js +8 -6
  125. package/lib/service/metrics/requestMetricsMiddleware.d.ts +1 -1
  126. package/lib/service/metrics/requestMetricsMiddleware.js +15 -13
  127. package/lib/service/tracing/TracerSingleton.js +10 -9
  128. package/lib/service/tracing/metrics/MetricNames.js +13 -12
  129. package/lib/service/tracing/metrics/instruments.js +15 -7
  130. package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +6 -5
  131. package/lib/service/tracing/tracingMiddlewares.d.ts +3 -3
  132. package/lib/service/tracing/tracingMiddlewares.js +25 -15
  133. package/lib/service/worker/index.js +25 -23
  134. package/lib/service/worker/listeners.js +3 -1
  135. package/lib/service/worker/runtime/Service.js +2 -1
  136. package/lib/service/worker/runtime/builtIn/handlers.d.ts +3 -3
  137. package/lib/service/worker/runtime/builtIn/handlers.js +7 -3
  138. package/lib/service/worker/runtime/builtIn/middlewares.d.ts +2 -2
  139. package/lib/service/worker/runtime/builtIn/middlewares.js +6 -3
  140. package/lib/service/worker/runtime/events/index.d.ts +2 -2
  141. package/lib/service/worker/runtime/events/index.js +12 -10
  142. package/lib/service/worker/runtime/events/middlewares/body.js +6 -2
  143. package/lib/service/worker/runtime/events/middlewares/context.js +2 -1
  144. package/lib/service/worker/runtime/events/router.d.ts +2 -2
  145. package/lib/service/worker/runtime/events/router.js +4 -2
  146. package/lib/service/worker/runtime/graphql/index.js +9 -7
  147. package/lib/service/worker/runtime/graphql/middlewares/context.js +1 -0
  148. package/lib/service/worker/runtime/graphql/middlewares/error.js +9 -5
  149. package/lib/service/worker/runtime/graphql/middlewares/query.d.ts +2 -1
  150. package/lib/service/worker/runtime/graphql/middlewares/query.js +8 -6
  151. package/lib/service/worker/runtime/graphql/middlewares/response.js +2 -1
  152. package/lib/service/worker/runtime/graphql/middlewares/run.d.ts +2 -2
  153. package/lib/service/worker/runtime/graphql/middlewares/run.js +4 -2
  154. package/lib/service/worker/runtime/graphql/middlewares/updateSchema.d.ts +2 -1
  155. package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +5 -3
  156. package/lib/service/worker/runtime/graphql/middlewares/upload.js +2 -1
  157. package/lib/service/worker/runtime/graphql/schema/index.d.ts +1 -1
  158. package/lib/service/worker/runtime/graphql/schema/index.js +9 -7
  159. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +2 -2
  160. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +5 -3
  161. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Auth.js +2 -1
  162. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.js +1 -0
  163. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +2 -1
  164. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.js +1 -0
  165. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Sanitize.js +1 -0
  166. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +2 -1
  167. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/SmartCacheDirective.js +1 -0
  168. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +3 -2
  169. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +3 -2
  170. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +3 -2
  171. package/lib/service/worker/runtime/graphql/schema/typeDefs/index.d.ts +2 -1
  172. package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +3 -1
  173. package/lib/service/worker/runtime/graphql/schema/typeDefs/ioUpload.js +1 -0
  174. package/lib/service/worker/runtime/graphql/schema/typeDefs/sanitizedString.js +3 -2
  175. package/lib/service/worker/runtime/graphql/typings.d.ts +3 -3
  176. package/lib/service/worker/runtime/graphql/utils/cacheControl.d.ts +2 -1
  177. package/lib/service/worker/runtime/graphql/utils/cacheControl.js +3 -1
  178. package/lib/service/worker/runtime/graphql/utils/error.d.ts +2 -1
  179. package/lib/service/worker/runtime/graphql/utils/error.js +11 -9
  180. package/lib/service/worker/runtime/graphql/utils/pathname.js +4 -2
  181. package/lib/service/worker/runtime/graphql/utils/translations.d.ts +1 -1
  182. package/lib/service/worker/runtime/graphql/utils/translations.js +8 -4
  183. package/lib/service/worker/runtime/http/index.d.ts +3 -3
  184. package/lib/service/worker/runtime/http/index.js +23 -20
  185. package/lib/service/worker/runtime/http/middlewares/authTokens.js +1 -0
  186. package/lib/service/worker/runtime/http/middlewares/cancellationToken.js +1 -0
  187. package/lib/service/worker/runtime/http/middlewares/clients.js +1 -0
  188. package/lib/service/worker/runtime/http/middlewares/context.js +8 -5
  189. package/lib/service/worker/runtime/http/middlewares/error.js +10 -6
  190. package/lib/service/worker/runtime/http/middlewares/rateLimit.js +2 -1
  191. package/lib/service/worker/runtime/http/middlewares/requestStats.js +1 -0
  192. package/lib/service/worker/runtime/http/middlewares/setCookie.js +6 -5
  193. package/lib/service/worker/runtime/http/middlewares/settings.d.ts +1 -1
  194. package/lib/service/worker/runtime/http/middlewares/settings.js +14 -9
  195. package/lib/service/worker/runtime/http/middlewares/timings.js +4 -3
  196. package/lib/service/worker/runtime/http/middlewares/vary.js +1 -0
  197. package/lib/service/worker/runtime/http/router.d.ts +1 -1
  198. package/lib/service/worker/runtime/http/router.js +4 -2
  199. package/lib/service/worker/runtime/http/routes.js +9 -5
  200. package/lib/service/worker/runtime/method.d.ts +2 -2
  201. package/lib/service/worker/runtime/method.js +2 -1
  202. package/lib/service/worker/runtime/statusTrack.d.ts +2 -2
  203. package/lib/service/worker/runtime/statusTrack.js +11 -5
  204. package/lib/service/worker/runtime/typings.d.ts +10 -10
  205. package/lib/service/worker/runtime/utils/compose.d.ts +3 -3
  206. package/lib/service/worker/runtime/utils/compose.js +5 -2
  207. package/lib/service/worker/runtime/utils/context.d.ts +4 -1
  208. package/lib/service/worker/runtime/utils/context.js +6 -4
  209. package/lib/service/worker/runtime/utils/diff.js +1 -0
  210. package/lib/service/worker/runtime/utils/recorder.js +2 -1
  211. package/lib/service/worker/runtime/utils/toArray.js +3 -1
  212. package/lib/service/worker/runtime/utils/tokenBucket.js +1 -0
  213. package/lib/tracing/Tags.js +2 -1
  214. package/lib/tracing/UserLandTracer.js +4 -2
  215. package/lib/tracing/errorReporting/ErrorReport.js +14 -13
  216. package/lib/tracing/index.js +10 -9
  217. package/lib/tracing/spanReference/SpanReferenceTypes.js +1 -0
  218. package/lib/tracing/spanReference/createSpanReference.js +1 -0
  219. package/lib/tracing/utils.js +6 -4
  220. package/lib/utils/MineWinsConflictsResolver.d.ts +4 -4
  221. package/lib/utils/MineWinsConflictsResolver.js +11 -10
  222. package/lib/utils/app.js +40 -23
  223. package/lib/utils/appsStaleIfError.d.ts +1 -0
  224. package/lib/utils/appsStaleIfError.js +33 -12
  225. package/lib/utils/billingOptions.js +3 -1
  226. package/lib/utils/binding.js +5 -2
  227. package/lib/utils/cancel.js +1 -0
  228. package/lib/utils/conflicts.mock.js +1 -0
  229. package/lib/utils/domain.js +2 -1
  230. package/lib/utils/error.js +6 -4
  231. package/lib/utils/index.js +23 -12
  232. package/lib/utils/json.js +1 -0
  233. package/lib/utils/log.js +4 -2
  234. package/lib/utils/message.js +9 -5
  235. package/lib/utils/renameBy.js +3 -1
  236. package/lib/utils/retry.js +10 -7
  237. package/lib/utils/status.js +3 -1
  238. package/lib/utils/tenant.js +5 -2
  239. package/lib/utils/throwOnGraphQLErrors.js +1 -0
  240. package/lib/utils/time.d.ts +3 -5
  241. package/lib/utils/time.js +24 -14
  242. package/package.json +4 -4
  243. package/CHANGELOG.md +0 -1858
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Apps = void 0;
6
7
  const archiver_1 = __importDefault(require("archiver"));
7
8
  const tar_fs_1 = require("tar-fs");
8
9
  const zlib_1 = require("zlib");
@@ -36,7 +37,7 @@ const createRoutes = ({ account, workspace }) => {
36
37
  };
37
38
  return routes;
38
39
  };
39
- const getVendorAndName = ({ id }) => utils_1.removeVersionFromAppId(id);
40
+ const getVendorAndName = ({ id }) => (0, utils_1.removeVersionFromAppId)(id);
40
41
  const notFound = (e) => {
41
42
  if (e.response && e.response.status === 404) {
42
43
  return {};
@@ -70,6 +71,9 @@ const workspaceFields = [
70
71
  'version',
71
72
  ].join(',');
72
73
  class Apps extends InfraClient_1.InfraClient {
74
+ get routes() {
75
+ return this._routes;
76
+ }
73
77
  constructor(context, options) {
74
78
  super('apps@0.x', context, options, true);
75
79
  this.installApp = (descriptor, tracingConfig) => {
@@ -117,7 +121,7 @@ class Apps extends InfraClient_1.InfraClient {
117
121
  if (indexOfManifest === -1) {
118
122
  throw new Error('No manifest.json file found in files.');
119
123
  }
120
- const zip = archiver_1.default('zip', { zlib });
124
+ const zip = (0, archiver_1.default)('zip', { zlib });
121
125
  // Throw stream errors so they reject the promise chain.
122
126
  zip.on('error', (e) => {
123
127
  throw e;
@@ -139,6 +143,8 @@ class Apps extends InfraClient_1.InfraClient {
139
143
  return response;
140
144
  }
141
145
  catch (e) {
146
+ // Typing cast for compatibility with error handling in TS versions > 4.0
147
+ // Source: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html#unknown-on-catch-clause-bindings
142
148
  e.bundleSize = zip.pointer();
143
149
  throw e;
144
150
  }
@@ -152,7 +158,7 @@ class Apps extends InfraClient_1.InfraClient {
152
158
  .filter(change => !change.content)
153
159
  .map(change => change.path)
154
160
  .join(':');
155
- const zip = archiver_1.default('zip', { zlib });
161
+ const zip = (0, archiver_1.default)('zip', { zlib });
156
162
  // Throw stream errors so they reject the promise chain.
157
163
  zip.on('error', (e) => {
158
164
  throw e;
@@ -219,7 +225,7 @@ class Apps extends InfraClient_1.InfraClient {
219
225
  });
220
226
  };
221
227
  this.listAppFiles = (app, { prefix, nextMarker } = {}, tracingConfig) => {
222
- const locator = utils_1.parseAppId(app);
228
+ const locator = (0, utils_1.parseAppId)(app);
223
229
  const linked = !!locator.build;
224
230
  const params = {
225
231
  marker: nextMarker,
@@ -251,11 +257,11 @@ class Apps extends InfraClient_1.InfraClient {
251
257
  };
252
258
  this.getAppFile = (app, path, staleIfError, tracingConfig) => {
253
259
  const { logger } = this.context;
254
- const locator = utils_1.parseAppId(app);
260
+ const locator = (0, utils_1.parseAppId)(app);
255
261
  const linked = !!locator.build;
256
262
  const inflightKey = HttpClient_1.inflightURL;
257
263
  if (staleIfError && this.memoryCache) {
258
- appsStaleIfError_1.saveVersion(app, this.memoryCache);
264
+ (0, appsStaleIfError_1.saveVersion)(app, this.memoryCache);
259
265
  }
260
266
  const metric = linked ? 'apps-get-file' : 'registry-get-file';
261
267
  try {
@@ -272,13 +278,13 @@ class Apps extends InfraClient_1.InfraClient {
272
278
  catch (error) {
273
279
  logger.error({ error, message: 'getAppFile failed', app, path });
274
280
  if (staleIfError && this.memoryCache) {
275
- return appsStaleIfError_1.getFallbackFile(app, path, this.memoryCache, this);
281
+ return (0, appsStaleIfError_1.getFallbackFile)(app, path, this.memoryCache, this);
276
282
  }
277
283
  throw error;
278
284
  }
279
285
  };
280
286
  this.getAppJSON = (app, path, nullIfNotFound, tracingConfig) => {
281
- const locator = utils_1.parseAppId(app);
287
+ const locator = (0, utils_1.parseAppId)(app);
282
288
  const linked = !!locator.build;
283
289
  const inflightKey = HttpClient_1.inflightURL;
284
290
  const metric = linked ? 'apps-get-json' : 'registry-get-json';
@@ -308,7 +314,7 @@ class Apps extends InfraClient_1.InfraClient {
308
314
  });
309
315
  };
310
316
  this.getAppFileStream = (app, path, tracingConfig) => {
311
- const locator = utils_1.parseAppId(app);
317
+ const locator = (0, utils_1.parseAppId)(app);
312
318
  const metric = locator.build ? 'apps-get-file-s' : 'registry-get-file-s';
313
319
  return this.http.getStream(this.routes.File(locator, path), {
314
320
  metric,
@@ -352,7 +358,7 @@ class Apps extends InfraClient_1.InfraClient {
352
358
  });
353
359
  };
354
360
  this.getAppBundle = (app, bundlePath, generatePackageJson, tracingConfig) => {
355
- const locator = utils_1.parseAppId(app);
361
+ const locator = (0, utils_1.parseAppId)(app);
356
362
  const params = generatePackageJson && { _packageJSONEngine: 'npm', _packageJSONFilter: 'vtex.render-builder@x' };
357
363
  const metric = locator.build ? 'apps-get-bundle' : 'registry-get-bundle';
358
364
  return this.http.getStream(this.routes.AppBundle(locator, bundlePath), {
@@ -371,15 +377,15 @@ class Apps extends InfraClient_1.InfraClient {
371
377
  this.unpackAppBundle = (app, bundlePath, unpackPath, generatePackageJson, tracingConfig) => {
372
378
  return this.getAppBundle(app, bundlePath, generatePackageJson, tracingConfig)
373
379
  .then(stream => stream
374
- .pipe(zlib_1.createGunzip())
375
- .pipe(tar_fs_1.extract(unpackPath)));
380
+ .pipe((0, zlib_1.createGunzip)())
381
+ .pipe((0, tar_fs_1.extract)(unpackPath)));
376
382
  };
377
383
  this.getAppsMetaInfos = async (filter, staleWhileRevalidate = true, tracingConfig) => {
378
384
  var _a;
379
385
  const { account, production, recorder, workspace, logger } = this.context;
380
386
  const metric = 'get-apps-meta';
381
387
  const inflightKey = HttpClient_1.inflightURL;
382
- const key = appsStaleIfError_1.getMetaInfoKey(account, workspace);
388
+ const key = (0, appsStaleIfError_1.getMetaInfoKey)(account, workspace);
383
389
  const cachedResponse = production && staleWhileRevalidate
384
390
  ? await ((_a = this.diskCache) === null || _a === void 0 ? void 0 : _a.get(key))
385
391
  : undefined;
@@ -501,8 +507,5 @@ class Apps extends InfraClient_1.InfraClient {
501
507
  this.memoryCache = options && options.memoryCache;
502
508
  this._routes = createRoutes(context);
503
509
  }
504
- get routes() {
505
- return this._routes;
506
- }
507
510
  }
508
511
  exports.Apps = Apps;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Readable } from 'stream';
3
4
  import { AppMetaInfo } from '../..';
4
5
  import { InstanceOptions, RequestTracingConfig } from '../../HttpClient';
@@ -20,14 +21,14 @@ export declare class Assets extends InfraClient {
20
21
  headers: any;
21
22
  }>;
22
23
  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<{
24
+ getAppBundleByVendor: (app: string, bundlePath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig) => Promise<Readable>;
25
+ protected getAppJSONByAccount: <T extends object | null>(app: string, path: string, nullIfNotFound?: boolean, tracingConfig?: RequestTracingConfig) => Promise<T>;
26
+ protected getAppJSONByVendor: <T extends object | null>(app: string, path: string, nullIfNotFound?: boolean, tracingConfig?: RequestTracingConfig) => Promise<T>;
27
+ protected getAppFileByAccount: (app: string, path: string, nullIfNotFound?: boolean, tracingConfig?: RequestTracingConfig) => Promise<{
27
28
  data: Buffer;
28
29
  headers: any;
29
30
  }>;
30
- protected getAppFileByVendor: (app: string, path: string, nullIfNotFound?: boolean | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
31
+ protected getAppFileByVendor: (app: string, path: string, nullIfNotFound?: boolean, tracingConfig?: RequestTracingConfig) => Promise<{
31
32
  data: Buffer;
32
33
  headers: any;
33
34
  }>;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Assets = void 0;
3
4
  const ramda_1 = require("ramda");
4
5
  const HttpClient_1 = require("../../HttpClient");
5
6
  const utils_1 = require("../../utils");
@@ -21,7 +22,7 @@ const dependsOnApp = (appsAtMajor) => (a) => {
21
22
  };
22
23
  const useBuildJson = (app, appVendorName) => {
23
24
  const buildFeatures = app._buildFeatures;
24
- return buildFeatures && buildFeatures[appVendorName] && ramda_1.contains('build.json', buildFeatures[appVendorName]);
25
+ return buildFeatures && buildFeatures[appVendorName] && (0, ramda_1.contains)('build.json', buildFeatures[appVendorName]);
25
26
  };
26
27
  const appOrRegistry = (workspace, { name, version, build }) => build
27
28
  ? `${workspace}/apps/${name}@${version}+${build}`
@@ -34,7 +35,7 @@ class Assets extends InfraClient_1.InfraClient {
34
35
  constructor(context, options) {
35
36
  super('apps@0.x', context, options, true);
36
37
  this.getAppBundleByVendor = (app, bundlePath, generatePackageJson, tracingConfig) => {
37
- const locator = utils_1.parseAppId(app);
38
+ const locator = (0, utils_1.parseAppId)(app);
38
39
  const params = generatePackageJson && { _packageJSONEngine: 'npm', _packageJSONFilter: 'vtex.render-builder@x' };
39
40
  const metric = locator.build ? 'apps-get-bundle' : 'registry-get-bundle';
40
41
  return this.http.getStream(this.routes.Bundle(this.context.account, locator, bundlePath), {
@@ -51,7 +52,7 @@ class Assets extends InfraClient_1.InfraClient {
51
52
  });
52
53
  };
53
54
  this.getAppJSONByAccount = (app, path, nullIfNotFound, tracingConfig) => {
54
- const locator = utils_1.parseAppId(app);
55
+ const locator = (0, utils_1.parseAppId)(app);
55
56
  const inflightKey = HttpClient_1.inflightURL;
56
57
  const metric = 'assets-get-json-by-account';
57
58
  return this.http.get(this.routes.Files(this.context.account, locator, path), {
@@ -66,7 +67,7 @@ class Assets extends InfraClient_1.InfraClient {
66
67
  });
67
68
  };
68
69
  this.getAppJSONByVendor = (app, path, nullIfNotFound, tracingConfig) => {
69
- const locator = utils_1.parseAppId(app);
70
+ const locator = (0, utils_1.parseAppId)(app);
70
71
  const vendor = locator.name.split('.')[0];
71
72
  const inflightKey = HttpClient_1.inflightURL;
72
73
  const metric = 'assets-get-json-by-vendor';
@@ -82,7 +83,7 @@ class Assets extends InfraClient_1.InfraClient {
82
83
  });
83
84
  };
84
85
  this.getAppFileByAccount = (app, path, nullIfNotFound, tracingConfig) => {
85
- const locator = utils_1.parseAppId(app);
86
+ const locator = (0, utils_1.parseAppId)(app);
86
87
  const inflightKey = HttpClient_1.inflightURL;
87
88
  const metric = 'assets-get-file-by-account';
88
89
  return this.http.getBuffer(this.routes.Files(this.context.account, locator, path), {
@@ -97,7 +98,7 @@ class Assets extends InfraClient_1.InfraClient {
97
98
  });
98
99
  };
99
100
  this.getAppFileByVendor = (app, path, nullIfNotFound, tracingConfig) => {
100
- const locator = utils_1.parseAppId(app);
101
+ const locator = (0, utils_1.parseAppId)(app);
101
102
  const vendor = locator.name.split('.')[0];
102
103
  const inflightKey = HttpClient_1.inflightURL;
103
104
  const metric = 'assets-get-file-by-vendor';
@@ -128,7 +129,7 @@ class Assets extends InfraClient_1.InfraClient {
128
129
  async getBuildJSONForApp(app, appVendorName, pick = [], tracingConfig) {
129
130
  const pickArray = Array.isArray(pick) ? pick : [pick];
130
131
  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
+ const result = !(0, ramda_1.isEmpty)(pickArray) ? (0, ramda_1.pick)(pickArray, buildJson) : buildJson;
132
133
  result.declarer = app.id;
133
134
  return result;
134
135
  }
@@ -136,12 +137,12 @@ class Assets extends InfraClient_1.InfraClient {
136
137
  // If there's no support for build.json, then fetch individual files and zip them into an {[file]: content} object.
137
138
  const filesArray = Array.isArray(files) ? files : [files];
138
139
  const fetched = await Promise.all(filesArray.map(file => this.getJSON(app.id, file, true, tracingConfig)));
139
- const result = ramda_1.zipObj(filesArray, fetched);
140
+ const result = (0, ramda_1.zipObj)(filesArray, fetched);
140
141
  result.declarer = app.id;
141
142
  return result;
142
143
  }
143
144
  async getJSON(appId, file, nullIfNotFound, tracingConfig) {
144
- const locator = utils_1.parseAppId(appId);
145
+ const locator = (0, utils_1.parseAppId)(appId);
145
146
  const linked = !!locator.build;
146
147
  if (linked) {
147
148
  return this.getAppJSONByAccount(appId, file, nullIfNotFound, tracingConfig);
@@ -149,7 +150,7 @@ class Assets extends InfraClient_1.InfraClient {
149
150
  return this.getAppJSONByVendor(appId, file, nullIfNotFound, tracingConfig);
150
151
  }
151
152
  async getFile(appId, file, nullIfNotFound, tracingConfig) {
152
- const locator = utils_1.parseAppId(appId);
153
+ const locator = (0, utils_1.parseAppId)(appId);
153
154
  const linked = !!locator.build;
154
155
  if (linked) {
155
156
  return this.getAppFileByAccount(appId, file, nullIfNotFound, tracingConfig);
@@ -159,7 +160,7 @@ class Assets extends InfraClient_1.InfraClient {
159
160
  getFilteredDependencies(apps, dependencies) {
160
161
  const appsAtMajor = typeof (apps) === 'string' ? [apps] : apps;
161
162
  const depends = dependsOnApp(appsAtMajor);
162
- return ramda_1.filter(depends, dependencies);
163
+ return (0, ramda_1.filter)(depends, dependencies);
163
164
  }
164
165
  }
165
166
  exports.Assets = Assets;
@@ -3,7 +3,7 @@ import { IOContext } from '../../service/worker/runtime/typings';
3
3
  import { InfraClient } from './InfraClient';
4
4
  export declare class BillingMetrics extends InfraClient {
5
5
  constructor(context: IOContext, options?: InstanceOptions);
6
- sendMetric: (metric: BillingMetric, tracingConfig?: RequestTracingConfig | undefined) => Promise<BillingMetric>;
6
+ sendMetric: (metric: BillingMetric, tracingConfig?: RequestTracingConfig) => Promise<BillingMetric>;
7
7
  }
8
8
  export interface BillingMetric {
9
9
  value: number;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BillingMetrics = void 0;
3
4
  const InfraClient_1 = require("./InfraClient");
4
5
  class BillingMetrics extends InfraClient_1.InfraClient {
5
6
  constructor(context, options) {
@@ -3,7 +3,7 @@ import { IOContext } from '../../service/worker/runtime/typings';
3
3
  import { InfraClient } from './InfraClient';
4
4
  export declare class Events extends InfraClient {
5
5
  constructor({ recorder, ...context }: IOContext, options?: InstanceOptions);
6
- sendEvent: (appIdOrResource: string | ResourceVRN, route: string, message?: any, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
6
+ sendEvent: (appIdOrResource: string | ResourceVRN, route: string, message?: any, tracingConfig?: RequestTracingConfig) => Promise<void>;
7
7
  private resourceFor;
8
8
  }
9
9
  export interface ResourceVRN {
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Events = void 0;
3
4
  const util_1 = require("util");
4
5
  const InfraClient_1 = require("./InfraClient");
5
6
  const ANY_APP = '';
6
7
  const eventRoute = (route) => `/events/${route}`;
7
- const isResourceVRN = (appIdOrResource) => util_1.isObject(appIdOrResource) && !util_1.isNullOrUndefined(appIdOrResource.service);
8
+ const isResourceVRN = (appIdOrResource) => (0, util_1.isObject)(appIdOrResource) && !(0, util_1.isNullOrUndefined)(appIdOrResource.service);
8
9
  class Events extends InfraClient_1.InfraClient {
9
10
  constructor({ recorder, ...context }, options) {
10
11
  super('courier@0.x', context, options);
@@ -4,7 +4,7 @@ import { IOContext } from '../../service/worker/runtime/typings';
4
4
  import { InfraClient } from './InfraClient';
5
5
  export declare class Housekeeper extends InfraClient {
6
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>;
7
+ apply: (data: HousekeeperStatesAndUpdates, tracingConfig?: RequestTracingConfig) => Promise<void>;
8
+ perform: (tracingConfig?: RequestTracingConfig) => Promise<void>;
9
+ resolve: (tracingConfig?: RequestTracingConfig) => Promise<HousekeeperStatesAndUpdates>;
10
10
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Housekeeper = void 0;
3
4
  const InfraClient_1 = require("./InfraClient");
4
5
  class Housekeeper extends InfraClient_1.InfraClient {
5
6
  constructor(context, options) {
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InfraClient = void 0;
3
4
  const constants_1 = require("../../constants");
4
5
  const typings_1 = require("../../HttpClient/typings");
5
6
  const IOClient_1 = require("../IOClient");
@@ -1,32 +1,38 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
2
4
  import { IncomingMessage } from 'http';
3
5
  import { Readable, Writable } from 'stream';
4
6
  import { ZlibOptions } from 'zlib';
5
7
  import { InstanceOptions, RequestTracingConfig } from '../../HttpClient';
6
- import { AppBundlePublished, AppFilesList, AppManifest, AppState } from '../../responses';
8
+ import { AppFilesList, AppManifest, AppState } from '../../responses';
7
9
  import { IOContext } from '../../service/worker/runtime/typings';
8
10
  import { InfraClient } from './InfraClient';
9
11
  export declare class Registry extends InfraClient {
10
12
  constructor(context: IOContext, options?: InstanceOptions);
11
- getAppState: (app: string, version: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppState>;
12
- publishApp: (files: File[], tag?: string | undefined, { zlib }?: ZipOptions, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppBundlePublished>;
13
- publishAppRc: (files: File[], tag?: string | undefined, { zlib }?: ZipOptions, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppBundlePublished>;
14
- listApps: (tracingConfig?: RequestTracingConfig | undefined) => Promise<RegistryAppsList>;
15
- listVersionsByApp: (app: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<RegistryAppVersionsList>;
16
- deprecateApp: (app: string, version: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
17
- undeprecateApp: (app: string, version: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
18
- validateApp: (app: string, version: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
19
- getAppManifest: (app: string, version: string, opts?: AppsManifestOptions | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppManifest>;
20
- listAppFiles: (app: string, version: string, opts?: ListAppFilesOptions | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppFilesList>;
21
- getAppFile: (app: string, version: string, path: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
13
+ getAppState: (app: string, version: string, tracingConfig?: RequestTracingConfig) => Promise<AppState>;
14
+ publishApp: (files: File[], tag?: string, { zlib }?: ZipOptions, tracingConfig?: RequestTracingConfig) => Promise<import("../../responses").AppBundleResponse & {
15
+ bundleSize?: number | undefined;
16
+ }>;
17
+ publishAppRc: (files: File[], tag?: string, { zlib }?: ZipOptions, tracingConfig?: RequestTracingConfig) => Promise<import("../../responses").AppBundleResponse & {
18
+ bundleSize?: number | undefined;
19
+ }>;
20
+ listApps: (tracingConfig?: RequestTracingConfig) => Promise<RegistryAppsList>;
21
+ listVersionsByApp: (app: string, tracingConfig?: RequestTracingConfig) => Promise<RegistryAppVersionsList>;
22
+ deprecateApp: (app: string, version: string, tracingConfig?: RequestTracingConfig) => Promise<void>;
23
+ undeprecateApp: (app: string, version: string, tracingConfig?: RequestTracingConfig) => Promise<void>;
24
+ validateApp: (app: string, version: string, tracingConfig?: RequestTracingConfig) => Promise<void>;
25
+ getAppManifest: (app: string, version: string, opts?: AppsManifestOptions, tracingConfig?: RequestTracingConfig) => Promise<AppManifest>;
26
+ listAppFiles: (app: string, version: string, opts?: ListAppFilesOptions, tracingConfig?: RequestTracingConfig) => Promise<AppFilesList>;
27
+ getAppFile: (app: string, version: string, path: string, tracingConfig?: RequestTracingConfig) => Promise<{
22
28
  data: Buffer;
23
29
  headers: any;
24
30
  }>;
25
- getAppJSON: <T extends object | null>(app: string, version: string, path: string, nullIfNotFound?: boolean | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<T>;
26
- getAppFileStream: (app: string, version: string, path: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<IncomingMessage>;
27
- getAppBundle: (app: string, version: string, bundlePath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig | undefined) => Promise<Readable>;
28
- unpackAppBundle: (app: string, version: string, bundlePath: string, unpackPath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig | undefined) => Promise<Writable>;
29
- resolveDependenciesWithManifest: (manifest: AppManifest, filter?: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<Record<string, string[]>>;
31
+ getAppJSON: <T extends object | null>(app: string, version: string, path: string, nullIfNotFound?: boolean, tracingConfig?: RequestTracingConfig) => Promise<T>;
32
+ getAppFileStream: (app: string, version: string, path: string, tracingConfig?: RequestTracingConfig) => Promise<IncomingMessage>;
33
+ getAppBundle: (app: string, version: string, bundlePath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig) => Promise<Readable>;
34
+ unpackAppBundle: (app: string, version: string, bundlePath: string, unpackPath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig) => Promise<Writable>;
35
+ resolveDependenciesWithManifest: (manifest: AppManifest, filter?: string, tracingConfig?: RequestTracingConfig) => Promise<Record<string, string[]>>;
30
36
  private publish;
31
37
  }
32
38
  interface ZipOptions {
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Registry = void 0;
6
7
  const archiver_1 = __importDefault(require("archiver"));
7
8
  const tar_fs_1 = require("tar-fs");
8
9
  const zlib_1 = require("zlib");
@@ -156,8 +157,8 @@ class Registry extends InfraClient_1.InfraClient {
156
157
  this.unpackAppBundle = (app, version, bundlePath, unpackPath, generatePackageJson, tracingConfig) => {
157
158
  return this.getAppBundle(app, version, bundlePath, generatePackageJson, tracingConfig)
158
159
  .then(stream => stream
159
- .pipe(zlib_1.createGunzip())
160
- .pipe(tar_fs_1.extract(unpackPath)));
160
+ .pipe((0, zlib_1.createGunzip)())
161
+ .pipe((0, tar_fs_1.extract)(unpackPath)));
161
162
  };
162
163
  this.resolveDependenciesWithManifest = (manifest, filter = '', tracingConfig) => {
163
164
  const params = { filter };
@@ -175,7 +176,7 @@ class Registry extends InfraClient_1.InfraClient {
175
176
  if (indexOfManifest === -1) {
176
177
  throw new Error('No manifest.json file found in files.');
177
178
  }
178
- const zip = archiver_1.default('zip', { zlib });
179
+ const zip = (0, archiver_1.default)('zip', { zlib });
179
180
  // Throw stream errors so they reject the promise chain.
180
181
  zip.on('error', (e) => {
181
182
  throw e;
@@ -198,6 +199,7 @@ class Registry extends InfraClient_1.InfraClient {
198
199
  return response;
199
200
  }
200
201
  catch (e) {
202
+ // See Apps.ts `link` method for more information on this cast
201
203
  e.bundleSize = zip.pointer();
202
204
  throw e;
203
205
  }
@@ -3,13 +3,13 @@ import { IOContext } from '../../service/worker/runtime/typings';
3
3
  import { InfraClient } from './InfraClient';
4
4
  export declare class Router extends InfraClient {
5
5
  constructor(ioContext: IOContext, opts?: InstanceOptions);
6
- listAvailableIoVersions: (tracingConfig?: RequestTracingConfig | undefined) => Promise<AvaiableIO[]>;
7
- getInstalledIoVersion: (tracingConfig?: RequestTracingConfig | undefined) => Promise<AvaiableIO>;
8
- installIo: (version: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
9
- listAvailableServices: (tracingConfig?: RequestTracingConfig | undefined) => Promise<AvailableServices>;
10
- getAvailableVersions: (name: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<AvailableServiceVersions>;
11
- listInstalledServices: (tracingConfig?: RequestTracingConfig | undefined) => Promise<InstalledService[]>;
12
- installService: (name: string, version: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
6
+ listAvailableIoVersions: (tracingConfig?: RequestTracingConfig) => Promise<AvaiableIO[]>;
7
+ getInstalledIoVersion: (tracingConfig?: RequestTracingConfig) => Promise<AvaiableIO>;
8
+ installIo: (version: string, tracingConfig?: RequestTracingConfig) => Promise<void>;
9
+ listAvailableServices: (tracingConfig?: RequestTracingConfig) => Promise<AvailableServices>;
10
+ getAvailableVersions: (name: string, tracingConfig?: RequestTracingConfig) => Promise<AvailableServiceVersions>;
11
+ listInstalledServices: (tracingConfig?: RequestTracingConfig) => Promise<InstalledService[]>;
12
+ installService: (name: string, version: string, tracingConfig?: RequestTracingConfig) => Promise<void>;
13
13
  }
14
14
  export interface AvaiableIO {
15
15
  version: string;
@@ -18,7 +18,7 @@ export interface AvaiableIO {
18
18
  [service: string]: string;
19
19
  };
20
20
  }
21
- export declare type InstalledIO = AvaiableIO;
21
+ export type InstalledIO = AvaiableIO;
22
22
  export interface AvailableServiceVersions {
23
23
  versions: {
24
24
  [region: string]: string[];
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Router = void 0;
3
4
  const InfraClient_1 = require("./InfraClient");
4
5
  const routes = {
5
6
  AvailableIoVersions: '/_io',
@@ -3,8 +3,8 @@ import { IOContext } from '../../service/worker/runtime/typings';
3
3
  import { InfraClient } from './InfraClient';
4
4
  export declare class Sphinx extends InfraClient {
5
5
  constructor(ioContext: IOContext, opts?: InstanceOptions);
6
- validatePolicies: (policies: PolicyRequest[], tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
7
- isAdmin: (email: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<boolean>;
6
+ validatePolicies: (policies: PolicyRequest[], tracingConfig?: RequestTracingConfig) => Promise<void>;
7
+ isAdmin: (email: string, tracingConfig?: RequestTracingConfig) => Promise<boolean>;
8
8
  }
9
9
  export interface PolicyRequest {
10
10
  name: string;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Sphinx = void 0;
3
4
  const InfraClient_1 = require("./InfraClient");
4
5
  class Sphinx extends InfraClient_1.InfraClient {
5
6
  constructor(ioContext, opts) {
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { IncomingMessage } from 'http';
3
4
  import { Readable } from 'stream';
4
5
  import { Logger } from './../../service/logger/logger';
@@ -8,23 +9,23 @@ import { IOContext } from '../../service/worker/runtime/typings';
8
9
  import { InfraClient } from './InfraClient';
9
10
  export declare class VBase extends InfraClient {
10
11
  constructor(context: IOContext, options?: InstanceOptions);
11
- getBucket: (bucket: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<BucketMetadata>;
12
- resetBucket: (bucket: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<IOResponse<void>>;
13
- listFiles: (bucket: string, opts?: string | VBaseOptions | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<BucketFileList>;
14
- getFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
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<{
15
16
  data: Buffer;
16
17
  headers: any;
17
18
  }>;
18
- getJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean | undefined, conflictsResolver?: ConflictsResolver<T> | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<T>;
19
- getRawJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean | undefined, conflictsResolver?: ConflictsResolver<T> | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<IOResponse<T>>;
20
- getFileStream: (bucket: string, path: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<IncomingMessage>;
21
- saveFile: (bucket: string, path: string, stream: Readable, gzip?: boolean, ttl?: number | undefined, tracingConfig?: RequestTracingConfig | undefined, ifMatch?: string | undefined) => Promise<void>;
22
- getFileMetadata: (bucket: string, path: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<IOResponse<void>>;
23
- saveJSON: <T>(bucket: string, path: string, data: T, tracingConfig?: RequestTracingConfig | undefined, ifMatch?: string | undefined) => Promise<VBaseSaveResponse>;
24
- saveZippedContent: (bucket: string, path: string, stream: Readable, tracingConfig?: RequestTracingConfig | undefined, ifMatch?: string | undefined) => Promise<void>;
25
- deleteFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig | undefined, ifMatch?: string | undefined) => Promise<IOResponse<void>>;
26
- getConflicts: <T>(bucket: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<T>;
27
- resolveConflict: <T>(bucket: string, path: string, content: any, tracingConfig?: RequestTracingConfig | undefined) => Promise<T>;
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>;
28
29
  private saveContent;
29
30
  }
30
31
  export interface BucketFileList {
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.VBase = void 0;
6
7
  const mime_types_1 = __importDefault(require("mime-types"));
7
8
  const path_1 = require("path");
8
9
  const zlib_1 = require("zlib");
@@ -138,7 +139,7 @@ class VBase extends InfraClient_1.InfraClient {
138
139
  return this.saveContent(bucket, path, stream, { unzip: true }, tracingConfig, ifMatch);
139
140
  };
140
141
  this.deleteFile = (bucket, path, tracingConfig, ifMatch) => {
141
- const headers = ifMatch ? { 'If-Match': ifMatch } : null;
142
+ const headers = ifMatch ? { 'If-Match': ifMatch } : {};
142
143
  const metric = 'vbase-delete-file';
143
144
  return this.http.delete(routes.File(bucket, path), { headers, metric, tracing: {
144
145
  requestSpanNameSuffix: metric,
@@ -171,10 +172,10 @@ class VBase extends InfraClient_1.InfraClient {
171
172
  const params = opts.unzip ? { unzip: opts.unzip } : {};
172
173
  const headers = {};
173
174
  let finalStream = stream;
174
- headers['Content-Type'] = mime_types_1.default.contentType(path_1.basename(path)) || 'application/octet-stream';
175
+ headers['Content-Type'] = mime_types_1.default.contentType((0, path_1.basename)(path)) || 'application/octet-stream';
175
176
  if (opts.gzip) {
176
177
  headers['Content-Encoding'] = 'gzip';
177
- finalStream = stream.pipe(zlib_1.createGzip());
178
+ finalStream = stream.pipe((0, zlib_1.createGzip)());
178
179
  }
179
180
  if (opts.ttl && Number.isInteger(opts.ttl)) {
180
181
  headers['X-VTEX-TTL'] = opts.ttl;
@@ -3,13 +3,13 @@ import { IOContext } from '../../service/worker/runtime/typings';
3
3
  import { InfraClient } from './InfraClient';
4
4
  export declare class Workspaces extends InfraClient {
5
5
  constructor(context: IOContext, options?: InstanceOptions);
6
- list: (account: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<WorkspaceMetadata[]>;
7
- get: (account: string, workspace: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<WorkspaceMetadata>;
8
- set: (account: string, workspace: string, metadata: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
9
- create: (account: string, workspace: string, production: boolean, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
10
- delete: (account: string, workspace: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<import("../../HttpClient").IOResponse<void>>;
11
- reset: (account: string, workspace: string, metadata?: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
12
- promote: (account: string, workspace: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
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
13
  }
14
14
  export interface WorkspaceMetadata {
15
15
  name: string;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Workspaces = void 0;
3
4
  const constants_1 = require("../../constants");
4
5
  const InfraClient_1 = require("./InfraClient");
5
6
  const routes = {