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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/lib/HttpClient/GraphQLClient.d.ts +1 -1
  2. package/lib/HttpClient/HttpClient.d.ts +2 -3
  3. package/lib/HttpClient/HttpClient.js +14 -14
  4. package/lib/HttpClient/agents.d.ts +2 -5
  5. package/lib/HttpClient/agents.js +4 -10
  6. package/lib/HttpClient/index.js +2 -7
  7. package/lib/HttpClient/middlewares/cache.d.ts +1 -1
  8. package/lib/HttpClient/middlewares/cache.js +36 -38
  9. package/lib/HttpClient/middlewares/cancellationToken.d.ts +1 -1
  10. package/lib/HttpClient/middlewares/cancellationToken.js +1 -2
  11. package/lib/HttpClient/middlewares/inflight.d.ts +1 -1
  12. package/lib/HttpClient/middlewares/inflight.js +3 -6
  13. package/lib/HttpClient/middlewares/memoization.d.ts +1 -1
  14. package/lib/HttpClient/middlewares/memoization.js +8 -9
  15. package/lib/HttpClient/middlewares/metrics.js +7 -8
  16. package/lib/HttpClient/middlewares/notFound.d.ts +1 -1
  17. package/lib/HttpClient/middlewares/notFound.js +2 -4
  18. package/lib/HttpClient/middlewares/recorder.js +1 -2
  19. package/lib/HttpClient/middlewares/request/HttpAgentSingleton.js +1 -1
  20. package/lib/HttpClient/middlewares/request/index.d.ts +1 -1
  21. package/lib/HttpClient/middlewares/request/index.js +10 -13
  22. package/lib/HttpClient/middlewares/request/setupAxios/index.d.ts +1 -0
  23. package/lib/HttpClient/middlewares/request/setupAxios/index.js +4 -5
  24. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +5 -6
  25. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +0 -1
  26. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.js +8 -8
  27. package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +8 -10
  28. package/lib/HttpClient/middlewares/tracing.js +10 -11
  29. package/lib/HttpClient/typings.d.ts +2 -2
  30. package/lib/caches/DiskCache.js +2 -2
  31. package/lib/caches/LRUCache.d.ts +2 -2
  32. package/lib/caches/LRUDiskCache.d.ts +1 -1
  33. package/lib/caches/LRUDiskCache.js +2 -2
  34. package/lib/caches/MultilayeredCache.d.ts +2 -2
  35. package/lib/caches/MultilayeredCache.js +6 -6
  36. package/lib/caches/index.js +2 -6
  37. package/lib/caches/typings.d.ts +5 -5
  38. package/lib/clients/IOClient.d.ts +1 -1
  39. package/lib/clients/IOClients.d.ts +1 -1
  40. package/lib/clients/apps/AppClient.js +1 -1
  41. package/lib/clients/apps/AppGraphQLClient.js +1 -1
  42. package/lib/clients/apps/Billing.d.ts +1 -1
  43. package/lib/clients/apps/Builder.d.ts +7 -7
  44. package/lib/clients/apps/Builder.js +1 -1
  45. package/lib/clients/apps/MessagesGraphQL.d.ts +1 -1
  46. package/lib/clients/apps/MessagesGraphQL.js +3 -3
  47. package/lib/clients/apps/Settings.js +3 -3
  48. package/lib/clients/apps/catalogGraphQL/index.d.ts +4 -4
  49. package/lib/clients/apps/catalogGraphQL/index.js +4 -4
  50. package/lib/clients/apps/index.js +2 -6
  51. package/lib/clients/external/ID.d.ts +4 -4
  52. package/lib/clients/external/PaymentProvider.d.ts +2 -2
  53. package/lib/clients/external/index.js +2 -6
  54. package/lib/clients/index.js +2 -6
  55. package/lib/clients/infra/Apps.d.ts +27 -32
  56. package/lib/clients/infra/Apps.js +16 -16
  57. package/lib/clients/infra/Assets.d.ts +5 -6
  58. package/lib/clients/infra/Assets.js +11 -11
  59. package/lib/clients/infra/BillingMetrics.d.ts +1 -1
  60. package/lib/clients/infra/Events.d.ts +1 -1
  61. package/lib/clients/infra/Events.js +1 -1
  62. package/lib/clients/infra/Housekeeper.d.ts +3 -3
  63. package/lib/clients/infra/Registry.d.ts +17 -23
  64. package/lib/clients/infra/Registry.js +3 -3
  65. package/lib/clients/infra/Router.d.ts +8 -8
  66. package/lib/clients/infra/Sphinx.d.ts +2 -2
  67. package/lib/clients/infra/VBase.d.ts +14 -15
  68. package/lib/clients/infra/VBase.js +2 -2
  69. package/lib/clients/infra/Workspaces.d.ts +7 -7
  70. package/lib/clients/infra/index.js +2 -6
  71. package/lib/clients/janus/JanusClient.d.ts +1 -1
  72. package/lib/clients/janus/LicenseManager.js +1 -1
  73. package/lib/clients/janus/Segment.d.ts +3 -3
  74. package/lib/clients/janus/Segment.js +2 -2
  75. package/lib/clients/janus/Session.d.ts +2 -2
  76. package/lib/clients/janus/Tenant.d.ts +1 -1
  77. package/lib/clients/janus/index.js +2 -6
  78. package/lib/constants.d.ts +1 -1
  79. package/lib/constants.js +1 -1
  80. package/lib/errors/ResolverError.js +1 -1
  81. package/lib/errors/index.js +2 -6
  82. package/lib/index.js +2 -6
  83. package/lib/metrics/MetricsAccumulator.d.ts +2 -2
  84. package/lib/metrics/MetricsAccumulator.js +9 -9
  85. package/lib/responses.d.ts +4 -4
  86. package/lib/service/index.js +6 -7
  87. package/lib/service/loaders.js +6 -8
  88. package/lib/service/logger/console.js +4 -7
  89. package/lib/service/logger/index.js +2 -6
  90. package/lib/service/logger/logger.js +2 -2
  91. package/lib/service/logger/metricsLogger.js +10 -10
  92. package/lib/service/master.js +6 -7
  93. package/lib/service/metrics/requestMetricsMiddleware.js +13 -14
  94. package/lib/service/tracing/TracerSingleton.js +9 -9
  95. package/lib/service/tracing/metrics/MetricNames.js +12 -12
  96. package/lib/service/tracing/metrics/instruments.js +7 -14
  97. package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +5 -5
  98. package/lib/service/tracing/tracingMiddlewares.js +15 -18
  99. package/lib/service/worker/index.js +23 -24
  100. package/lib/service/worker/listeners.js +1 -2
  101. package/lib/service/worker/runtime/Service.js +1 -1
  102. package/lib/service/worker/runtime/builtIn/handlers.js +3 -6
  103. package/lib/service/worker/runtime/builtIn/middlewares.js +3 -5
  104. package/lib/service/worker/runtime/events/index.d.ts +1 -1
  105. package/lib/service/worker/runtime/events/index.js +10 -11
  106. package/lib/service/worker/runtime/events/middlewares/body.js +2 -2
  107. package/lib/service/worker/runtime/events/middlewares/context.js +1 -1
  108. package/lib/service/worker/runtime/events/router.js +2 -3
  109. package/lib/service/worker/runtime/graphql/index.js +7 -8
  110. package/lib/service/worker/runtime/graphql/middlewares/error.js +5 -5
  111. package/lib/service/worker/runtime/graphql/middlewares/query.js +6 -7
  112. package/lib/service/worker/runtime/graphql/middlewares/response.js +1 -1
  113. package/lib/service/worker/runtime/graphql/middlewares/run.js +2 -3
  114. package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +3 -4
  115. package/lib/service/worker/runtime/graphql/middlewares/upload.js +1 -1
  116. package/lib/service/worker/runtime/graphql/schema/index.d.ts +1 -1
  117. package/lib/service/worker/runtime/graphql/schema/index.js +7 -8
  118. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +2 -2
  119. package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +3 -4
  120. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +1 -1
  121. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +1 -1
  122. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +2 -2
  123. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +2 -2
  124. package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +1 -1
  125. package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +1 -2
  126. package/lib/service/worker/runtime/graphql/schema/typeDefs/sanitizedString.js +2 -2
  127. package/lib/service/worker/runtime/graphql/typings.d.ts +3 -3
  128. package/lib/service/worker/runtime/graphql/utils/cacheControl.js +1 -2
  129. package/lib/service/worker/runtime/graphql/utils/error.js +9 -10
  130. package/lib/service/worker/runtime/graphql/utils/pathname.js +2 -3
  131. package/lib/service/worker/runtime/graphql/utils/translations.d.ts +1 -1
  132. package/lib/service/worker/runtime/graphql/utils/translations.js +4 -7
  133. package/lib/service/worker/runtime/http/index.d.ts +2 -2
  134. package/lib/service/worker/runtime/http/index.js +20 -22
  135. package/lib/service/worker/runtime/http/middlewares/context.js +5 -7
  136. package/lib/service/worker/runtime/http/middlewares/error.js +1 -1
  137. package/lib/service/worker/runtime/http/middlewares/rateLimit.js +1 -1
  138. package/lib/service/worker/runtime/http/middlewares/setCookie.js +5 -5
  139. package/lib/service/worker/runtime/http/middlewares/settings.d.ts +1 -1
  140. package/lib/service/worker/runtime/http/middlewares/settings.js +9 -13
  141. package/lib/service/worker/runtime/http/middlewares/timings.js +3 -3
  142. package/lib/service/worker/runtime/http/router.js +2 -3
  143. package/lib/service/worker/runtime/http/routes.js +5 -8
  144. package/lib/service/worker/runtime/method.d.ts +2 -2
  145. package/lib/service/worker/runtime/method.js +1 -1
  146. package/lib/service/worker/runtime/statusTrack.d.ts +1 -1
  147. package/lib/service/worker/runtime/statusTrack.js +5 -10
  148. package/lib/service/worker/runtime/typings.d.ts +10 -10
  149. package/lib/service/worker/runtime/utils/compose.d.ts +2 -2
  150. package/lib/service/worker/runtime/utils/compose.js +2 -4
  151. package/lib/service/worker/runtime/utils/context.d.ts +2 -2
  152. package/lib/service/worker/runtime/utils/context.js +4 -5
  153. package/lib/service/worker/runtime/utils/recorder.js +1 -1
  154. package/lib/service/worker/runtime/utils/toArray.js +1 -2
  155. package/lib/tracing/UserLandTracer.js +2 -3
  156. package/lib/tracing/errorReporting/ErrorReport.js +13 -13
  157. package/lib/tracing/index.js +1 -1
  158. package/lib/tracing/utils.js +4 -5
  159. package/lib/utils/MineWinsConflictsResolver.d.ts +4 -4
  160. package/lib/utils/MineWinsConflictsResolver.js +10 -10
  161. package/lib/utils/app.js +23 -39
  162. package/lib/utils/appsStaleIfError.d.ts +0 -1
  163. package/lib/utils/appsStaleIfError.js +9 -17
  164. package/lib/utils/billingOptions.js +1 -2
  165. package/lib/utils/binding.js +2 -4
  166. package/lib/utils/buildFullPath.d.ts +11 -0
  167. package/lib/utils/buildFullPath.js +54 -0
  168. package/lib/utils/domain.js +1 -1
  169. package/lib/utils/error.js +4 -5
  170. package/lib/utils/index.js +2 -6
  171. package/lib/utils/log.js +2 -3
  172. package/lib/utils/message.js +5 -8
  173. package/lib/utils/renameBy.js +1 -2
  174. package/lib/utils/retry.js +6 -8
  175. package/lib/utils/status.js +1 -2
  176. package/lib/utils/tenant.js +2 -4
  177. package/lib/utils/time.d.ts +1 -1
  178. package/lib/utils/time.js +14 -23
  179. package/package.json +2 -2
package/lib/utils/app.js CHANGED
@@ -7,59 +7,43 @@ exports.majorEqualAndGreaterThan = exports.sameMajor = exports.isValidAppIdOrLoc
7
7
  const semver_1 = __importDefault(require("semver"));
8
8
  // Note: The name that composes the part of the appId that precedes the
9
9
  // character '@' includes the name given to the app and the vendor name.
10
- const removeBuild = (id) => id.split('+')[0];
11
- exports.removeBuild = removeBuild;
12
- const removeVersionFromAppId = (appId) => appId.split('@')[0];
13
- exports.removeVersionFromAppId = removeVersionFromAppId;
14
- const extractVersionFromAppId = (appId) => appId.split('@').slice(-1)[0];
15
- exports.extractVersionFromAppId = extractVersionFromAppId;
16
- const transformToLinkedLocator = (appId) => appId.replace(/\+build.*$/, '+linked');
17
- exports.transformToLinkedLocator = transformToLinkedLocator;
18
- const formatLocator = (name, versionAndBuild) => `${name}@${(0, exports.removeBuild)(versionAndBuild)}`;
19
- exports.formatLocator = formatLocator;
20
- const isLinkedApp = (app) => app.id.includes('+build');
21
- exports.isLinkedApp = isLinkedApp;
22
- const parseAppId = (appId) => {
23
- const name = (0, exports.removeVersionFromAppId)(appId);
24
- const version = (0, exports.extractVersionFromAppId)(appId);
10
+ exports.removeBuild = (id) => id.split('+')[0];
11
+ exports.removeVersionFromAppId = (appId) => appId.split('@')[0];
12
+ exports.extractVersionFromAppId = (appId) => appId.split('@').slice(-1)[0];
13
+ exports.transformToLinkedLocator = (appId) => appId.replace(/\+build.*$/, '+linked');
14
+ exports.formatLocator = (name, versionAndBuild) => `${name}@${exports.removeBuild(versionAndBuild)}`;
15
+ exports.isLinkedApp = (app) => app.id.includes('+build');
16
+ exports.parseAppId = (appId) => {
17
+ const name = exports.removeVersionFromAppId(appId);
18
+ const version = exports.extractVersionFromAppId(appId);
25
19
  const splittedVersion = version.split('+');
26
20
  return {
27
21
  build: splittedVersion[1],
28
- locator: (0, exports.formatLocator)(name, version),
22
+ locator: exports.formatLocator(name, version),
29
23
  name,
30
24
  version: splittedVersion[0],
31
25
  };
32
26
  };
33
- exports.parseAppId = parseAppId;
34
- const formatAppId = ({ locator, build }) => (build ? `${locator}+${build}` : locator);
35
- exports.formatAppId = formatAppId;
36
- const satisfies = (appId, version) => {
37
- const { version: appVer } = (0, exports.parseAppId)(appId);
27
+ exports.formatAppId = ({ locator, build }) => (build ? `${locator}+${build}` : locator);
28
+ exports.satisfies = (appId, version) => {
29
+ const { version: appVer } = exports.parseAppId(appId);
38
30
  return semver_1.default.satisfies(appVer, version);
39
31
  };
40
- exports.satisfies = satisfies;
41
- const versionToMajor = (version) => version.split('.')[0];
42
- exports.versionToMajor = versionToMajor;
43
- const versionToMajorRange = (version) => `${(0, exports.versionToMajor)(version)}.x`;
44
- exports.versionToMajorRange = versionToMajorRange;
45
- const formatMajorLocator = (name, version) => {
46
- const majorRange = (0, exports.versionToMajorRange)(version);
32
+ exports.versionToMajor = (version) => version.split('.')[0];
33
+ exports.versionToMajorRange = (version) => `${exports.versionToMajor(version)}.x`;
34
+ exports.formatMajorLocator = (name, version) => {
35
+ const majorRange = exports.versionToMajorRange(version);
47
36
  return `${name}@${majorRange}`;
48
37
  };
49
- exports.formatMajorLocator = formatMajorLocator;
50
- const appIdToAppAtMajor = (appId) => {
51
- const { name, version } = (0, exports.parseAppId)(appId);
52
- const majorRange = (0, exports.versionToMajorRange)(version);
38
+ exports.appIdToAppAtMajor = (appId) => {
39
+ const { name, version } = exports.parseAppId(appId);
40
+ const majorRange = exports.versionToMajorRange(version);
53
41
  return `${name}@${majorRange}`;
54
42
  };
55
- exports.appIdToAppAtMajor = appIdToAppAtMajor;
56
43
  // SemVer regex from https://github.com/sindresorhus/semver-regex
57
44
  const APP_ID_REGEX = /^[\w\-]+\.[\w\-]+@(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?$/;
58
- const isValidAppIdOrLocator = (appId) => {
45
+ exports.isValidAppIdOrLocator = (appId) => {
59
46
  return APP_ID_REGEX.test(appId);
60
47
  };
61
- exports.isValidAppIdOrLocator = isValidAppIdOrLocator;
62
- const sameMajor = (v1, v2) => (0, exports.versionToMajor)(v1) === (0, exports.versionToMajor)(v2);
63
- exports.sameMajor = sameMajor;
64
- const majorEqualAndGreaterThan = (v1, v2) => (0, exports.sameMajor)(v1, v2) && semver_1.default.gt(v1, v2);
65
- exports.majorEqualAndGreaterThan = majorEqualAndGreaterThan;
48
+ exports.sameMajor = (v1, v2) => exports.versionToMajor(v1) === exports.versionToMajor(v2);
49
+ exports.majorEqualAndGreaterThan = (v1, v2) => exports.sameMajor(v1, v2) && semver_1.default.gt(v1, v2);
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { AppMetaInfo, Apps } from '..';
4
3
  import { CacheLayer } from '../caches';
5
4
  import { Logger } from '../service/logger';
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
5
  }) : (function(o, m, k, k2) {
10
6
  if (k2 === undefined) k2 = k;
11
7
  o[k2] = m[k];
@@ -18,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
14
  var __importStar = (this && this.__importStar) || function (mod) {
19
15
  if (mod && mod.__esModule) return mod;
20
16
  var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
18
  __setModuleDefault(result, mod);
23
19
  return result;
24
20
  };
@@ -30,17 +26,16 @@ exports.getFallbackFile = exports.saveVersion = exports.updateMetaInfoCache = ex
30
26
  const crypto_1 = __importDefault(require("crypto"));
31
27
  const ramda_1 = require("ramda");
32
28
  const semver = __importStar(require("semver"));
33
- const getMetaInfoKey = (account, workspace) => `${account}-${workspace}-meta-infos`;
34
- exports.getMetaInfoKey = getMetaInfoKey;
29
+ exports.getMetaInfoKey = (account, workspace) => `${account}-${workspace}-meta-infos`;
35
30
  const hashMD5 = (text) => crypto_1.default
36
31
  .createHash('md5')
37
32
  .update(text)
38
33
  .digest('hex');
39
- const updateMetaInfoCache = async (cacheStorage, account, workspace, dependencies, logger) => {
34
+ exports.updateMetaInfoCache = async (cacheStorage, account, workspace, dependencies, logger) => {
40
35
  if (workspace !== 'master') {
41
36
  return;
42
37
  }
43
- const key = (0, exports.getMetaInfoKey)(account, workspace);
38
+ const key = exports.getMetaInfoKey(account, workspace);
44
39
  const hash = hashMD5(dependencies.toString());
45
40
  try {
46
41
  const storedDependencies = await cacheStorage.get(key) || '';
@@ -53,11 +48,10 @@ const updateMetaInfoCache = async (cacheStorage, account, workspace, dependencie
53
48
  }
54
49
  return;
55
50
  };
56
- exports.updateMetaInfoCache = updateMetaInfoCache;
57
51
  const getFallbackKey = (appName, major) => `${appName}@${major}`;
58
- const saveVersion = async (app, cacheStorage) => {
52
+ exports.saveVersion = async (app, cacheStorage) => {
59
53
  const [appName, version] = app.split('@');
60
- const major = (0, ramda_1.head)(version.split('.')) || '';
54
+ const major = ramda_1.head(version.split('.')) || '';
61
55
  const fallbackKey = getFallbackKey(appName, major);
62
56
  if (cacheStorage.has(fallbackKey)) {
63
57
  const savedVersion = await cacheStorage.get(fallbackKey);
@@ -69,10 +63,9 @@ const saveVersion = async (app, cacheStorage) => {
69
63
  await cacheStorage.set(fallbackKey, version);
70
64
  }
71
65
  };
72
- exports.saveVersion = saveVersion;
73
- const getFallbackFile = async (app, path, cacheStorage, apps) => {
66
+ exports.getFallbackFile = async (app, path, cacheStorage, apps) => {
74
67
  const [appName, version] = app.split('@');
75
- const major = (0, ramda_1.head)(version.split('.')) || '';
68
+ const major = ramda_1.head(version.split('.')) || '';
76
69
  const fallbackKey = getFallbackKey(appName, major);
77
70
  const fallbackVersion = await cacheStorage.get(fallbackKey);
78
71
  if (fallbackVersion) {
@@ -81,4 +74,3 @@ const getFallbackFile = async (app, path, cacheStorage, apps) => {
81
74
  }
82
75
  throw Error('Fallback version was not found');
83
76
  };
84
- exports.getFallbackFile = getFallbackFile;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BILLING_TYPE = exports.isFreeBillingOptions = void 0;
4
- const isFreeBillingOptions = (billingOptions) => billingOptions.type === BILLING_TYPE.FREE;
5
- exports.isFreeBillingOptions = isFreeBillingOptions;
4
+ exports.isFreeBillingOptions = (billingOptions) => billingOptions.type === BILLING_TYPE.FREE;
6
5
  var BILLING_TYPE;
7
6
  (function (BILLING_TYPE) {
8
7
  BILLING_TYPE["FREE"] = "free";
@@ -6,7 +6,7 @@ var BindingHeaderFormat;
6
6
  BindingHeaderFormat["webframework0"] = "v0+webframework";
7
7
  BindingHeaderFormat["kuberouter0"] = "v0+kuberouter";
8
8
  })(BindingHeaderFormat || (BindingHeaderFormat = {}));
9
- const formatBindingHeaderValue = (binding, format = BindingHeaderFormat.webframework0) => {
9
+ exports.formatBindingHeaderValue = (binding, format = BindingHeaderFormat.webframework0) => {
10
10
  if (format === BindingHeaderFormat.webframework0) {
11
11
  const jsonString = JSON.stringify(binding);
12
12
  return Buffer.from(jsonString, 'utf8').toString('base64');
@@ -22,8 +22,7 @@ const formatBindingHeaderValue = (binding, format = BindingHeaderFormat.webframe
22
22
  }
23
23
  throw new Error(`Unkown binding format: ${format}`);
24
24
  };
25
- exports.formatBindingHeaderValue = formatBindingHeaderValue;
26
- const parseBindingHeaderValue = (value) => {
25
+ exports.parseBindingHeaderValue = (value) => {
27
26
  if (value[0] === '0' && value[1] === ',') {
28
27
  // v0+kuberouter
29
28
  const [, id, rootPath, locale, currency] = value.split(',');
@@ -38,4 +37,3 @@ const parseBindingHeaderValue = (value) => {
38
37
  const jsonString = Buffer.from(value, 'base64').toString('utf8');
39
38
  return JSON.parse(jsonString);
40
39
  };
41
- exports.parseBindingHeaderValue = parseBindingHeaderValue;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Creates a new URL by combining the baseURL with the requestedURL,
3
+ * only when the requestedURL is not already an absolute URL.
4
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
5
+ *
6
+ * @param {string} baseURL The base URL
7
+ * @param {string} requestedURL Absolute or relative URL to combine
8
+ *
9
+ * @returns {string} The combined full path
10
+ */
11
+ export default function (baseURL?: string, requestedURL?: string, allowAbsoluteUrls?: boolean): string | undefined;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ // This module is part of the Axios library.
3
+ // It is used to build a full URL by combining a base URL with a relative URL.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ // It is originally not intended to be used directly, but rather as a utility function within the Axios library.
6
+ // Since Axios 1.0, this function is not exported by default, and the team does not recommend using it directly,
7
+ // as it may not be available in future versions.
8
+ // The function takes a base URL and a relative URL as input, and returns the full URL.
9
+ // It handles both absolute and relative URLs, and ensures that the resulting URL is properly formatted.
10
+ // It is used internally by Axios to construct the full URL for HTTP requests.
11
+ /**
12
+ * Creates a new URL by combining the baseURL with the requestedURL,
13
+ * only when the requestedURL is not already an absolute URL.
14
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
15
+ *
16
+ * @param {string} baseURL The base URL
17
+ * @param {string} requestedURL Absolute or relative URL to combine
18
+ *
19
+ * @returns {string} The combined full path
20
+ */
21
+ function default_1(baseURL, requestedURL, allowAbsoluteUrls) {
22
+ let isRelativeUrl = !isAbsoluteURL(requestedURL);
23
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
24
+ return combineURLs(baseURL, requestedURL);
25
+ }
26
+ return requestedURL;
27
+ }
28
+ exports.default = default_1;
29
+ /**
30
+ * Determines whether the specified URL is absolute
31
+ *
32
+ * @param {string} url The URL to test
33
+ *
34
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
35
+ */
36
+ function isAbsoluteURL(url) {
37
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
38
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
39
+ // by any combination of letters, digits, plus, period, or hyphen.
40
+ return !!url && /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
41
+ }
42
+ /**
43
+ * Creates a new URL by combining the specified URLs
44
+ *
45
+ * @param {string} baseURL The base URL
46
+ * @param {string} relativeURL The relative URL
47
+ *
48
+ * @returns {string} The combined URL
49
+ */
50
+ function combineURLs(baseURL, relativeURL) {
51
+ return relativeURL && baseURL
52
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
53
+ : baseURL;
54
+ }
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PUBLIC_DOMAINS = void 0;
4
4
  const ramda_1 = require("ramda");
5
5
  const VTEX_PUBLIC_ENDPOINT = process.env.VTEX_PUBLIC_ENDPOINT || 'myvtex.com';
6
- exports.PUBLIC_DOMAINS = (0, ramda_1.uniq)([VTEX_PUBLIC_ENDPOINT, 'myvtex.com', 'mygocommerce.com', 'vtexsmb.com']);
6
+ exports.PUBLIC_DOMAINS = ramda_1.uniq([VTEX_PUBLIC_ENDPOINT, 'myvtex.com', 'mygocommerce.com', 'vtexsmb.com']);
@@ -6,7 +6,7 @@ const ramda_1 = require("ramda");
6
6
  exports.PICKED_AXIOS_PROPS = ['baseURL', 'cacheable', 'data', 'finished', 'headers', 'method', 'timeout', 'status', 'path', 'url', 'metric', 'inflightKey', 'forceMaxAge', 'params', 'responseType'];
7
7
  exports.SENSITIVE_EXCEPTION_FIELDS = ['config', 'request', 'stack'];
8
8
  const MAX_ERROR_STRING_LENGTH = process.env.MAX_ERROR_STRING_LENGTH ? parseInt(process.env.MAX_ERROR_STRING_LENGTH, 10) : 8 * 1024;
9
- const findCaseInsensitive = (target, set) => (0, ramda_1.find)(t => t.toLocaleLowerCase() === target, set);
9
+ const findCaseInsensitive = (target, set) => ramda_1.find(t => t.toLocaleLowerCase() === target, set);
10
10
  const destroyCircular = (from, seen) => {
11
11
  const to = Array.isArray(from) ? [] : {};
12
12
  seen.push(from);
@@ -53,10 +53,10 @@ const destroyCircular = (from, seen) => {
53
53
  ];
54
54
  for (const property of axiosProperties) {
55
55
  if (to[property] != null && typeof to[property] === 'object') {
56
- to[property] = (0, ramda_1.pick)(exports.PICKED_AXIOS_PROPS, to[property]);
56
+ to[property] = ramda_1.pick(exports.PICKED_AXIOS_PROPS, to[property]);
57
57
  const headers = to[property] && to[property].headers;
58
58
  if (headers) {
59
- const headerNames = (0, ramda_1.keys)(headers);
59
+ const headerNames = ramda_1.keys(headers);
60
60
  const authorization = findCaseInsensitive('authorization', headerNames);
61
61
  if (!!authorization) {
62
62
  delete headers[authorization];
@@ -82,7 +82,7 @@ const destroyCircular = (from, seen) => {
82
82
  *
83
83
  * @param value an Error instance
84
84
  */
85
- const cleanError = (value) => {
85
+ exports.cleanError = (value) => {
86
86
  if (typeof value === 'object') {
87
87
  return destroyCircular(value, []);
88
88
  }
@@ -93,4 +93,3 @@ const cleanError = (value) => {
93
93
  }
94
94
  return value;
95
95
  };
96
- exports.cleanError = cleanError;
@@ -1,17 +1,13 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
5
  }) : (function(o, m, k, k2) {
10
6
  if (k2 === undefined) k2 = k;
11
7
  o[k2] = m[k];
12
8
  }));
13
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
10
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
15
11
  };
16
12
  Object.defineProperty(exports, "__esModule", { value: true });
17
13
  __exportStar(require("./app"), exports);
package/lib/utils/log.js CHANGED
@@ -16,7 +16,6 @@ const SENSITIVE_FIELDS = [
16
16
  'x-vtex-credential',
17
17
  'x-vtex-session',
18
18
  ];
19
- const cleanLog = (log) => {
20
- return (0, json_1.cleanJson)(log, SENSITIVE_FIELDS);
19
+ exports.cleanLog = (log) => {
20
+ return json_1.cleanJson(log, SENSITIVE_FIELDS);
21
21
  };
22
- exports.cleanLog = cleanLog;
@@ -2,12 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.removeProviderFromId = exports.parseIOMessageId = exports.providerFromMessage = exports.PROVIDER_SPACER = void 0;
4
4
  exports.PROVIDER_SPACER = '::';
5
- const providerFromMessage = (message) => {
6
- const { provider } = (0, exports.parseIOMessageId)(message);
5
+ exports.providerFromMessage = (message) => {
6
+ const { provider } = exports.parseIOMessageId(message);
7
7
  return provider || 'unknown';
8
8
  };
9
- exports.providerFromMessage = providerFromMessage;
10
- const parseIOMessageId = ({ id }) => {
9
+ exports.parseIOMessageId = ({ id }) => {
11
10
  const splitted = id.split(exports.PROVIDER_SPACER);
12
11
  if (splitted.length === 2) {
13
12
  return {
@@ -19,9 +18,7 @@ const parseIOMessageId = ({ id }) => {
19
18
  locator: splitted[0],
20
19
  };
21
20
  };
22
- exports.parseIOMessageId = parseIOMessageId;
23
- const removeProviderFromId = (message) => ({
21
+ exports.removeProviderFromId = (message) => ({
24
22
  ...message,
25
- id: (0, exports.parseIOMessageId)(message).locator,
23
+ id: exports.parseIOMessageId(message).locator,
26
24
  });
27
- exports.removeProviderFromId = removeProviderFromId;
@@ -2,5 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renameBy = void 0;
4
4
  const ramda_1 = require("ramda");
5
- const renameBy = (fn, obj) => (0, ramda_1.compose)(ramda_1.fromPairs, (0, ramda_1.map)(([key, val]) => [fn(key), val]), ramda_1.toPairs)(obj);
6
- exports.renameBy = renameBy;
5
+ exports.renameBy = (fn, obj) => ramda_1.compose(ramda_1.fromPairs, ramda_1.map(([key, val]) => [fn(key), val]), ramda_1.toPairs)(obj);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exponentialDelay = exports.isNetworkOrIdempotentRequestError = exports.isAbortedOrNetworkErrorOrRouterTimeout = exports.isNetworkErrorOrRouterTimeout = exports.TIMEOUT_CODE = void 0;
3
+ exports.isAbortedOrNetworkErrorOrRouterTimeout = exports.isNetworkErrorOrRouterTimeout = exports.TIMEOUT_CODE = void 0;
4
4
  const axios_retry_1 = require("axios-retry");
5
5
  exports.TIMEOUT_CODE = 'ProxyTimeout';
6
6
  const printLabel = (e, message) => {
@@ -9,27 +9,25 @@ const printLabel = (e, message) => {
9
9
  }
10
10
  console.warn(e.config.label, message);
11
11
  };
12
- const isNetworkErrorOrRouterTimeout = (e) => {
13
- if ((0, axios_retry_1.isNetworkOrIdempotentRequestError)(e)) {
12
+ exports.isNetworkErrorOrRouterTimeout = (e) => {
13
+ if (axios_retry_1.isNetworkOrIdempotentRequestError(e)) {
14
14
  printLabel(e, 'Retry from network error');
15
15
  return true;
16
16
  }
17
- if (e && (0, axios_retry_1.isSafeRequestError)(e) && e.response && e.response.data && e.response.data.code === exports.TIMEOUT_CODE) {
17
+ if (e && axios_retry_1.isSafeRequestError(e) && e.response && e.response.data && e.response.data.code === exports.TIMEOUT_CODE) {
18
18
  printLabel(e, 'Retry from timeout');
19
19
  return true;
20
20
  }
21
21
  return false;
22
22
  };
23
- exports.isNetworkErrorOrRouterTimeout = isNetworkErrorOrRouterTimeout;
24
23
  // Retry on timeout from our end
25
- const isAbortedOrNetworkErrorOrRouterTimeout = (e) => {
24
+ exports.isAbortedOrNetworkErrorOrRouterTimeout = (e) => {
26
25
  if (e && e.code === 'ECONNABORTED') {
27
26
  printLabel(e, 'Retry from abort');
28
27
  return true;
29
28
  }
30
- return (0, exports.isNetworkErrorOrRouterTimeout)(e);
29
+ return exports.isNetworkErrorOrRouterTimeout(e);
31
30
  };
32
- exports.isAbortedOrNetworkErrorOrRouterTimeout = isAbortedOrNetworkErrorOrRouterTimeout;
33
31
  var axios_retry_2 = require("axios-retry");
34
32
  Object.defineProperty(exports, "isNetworkOrIdempotentRequestError", { enumerable: true, get: function () { return axios_retry_2.isNetworkOrIdempotentRequestError; } });
35
33
  Object.defineProperty(exports, "exponentialDelay", { enumerable: true, get: function () { return axios_retry_2.exponentialDelay; } });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.statusLabel = void 0;
4
- const statusLabel = (status) => {
4
+ exports.statusLabel = (status) => {
5
5
  if (status >= 500) {
6
6
  return 'error';
7
7
  }
@@ -10,4 +10,3 @@ const statusLabel = (status) => {
10
10
  }
11
11
  return `${Math.floor(status / 100)}xx`;
12
12
  };
13
- exports.statusLabel = statusLabel;
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseTenantHeaderValue = exports.formatTenantHeaderValue = void 0;
4
- const formatTenantHeaderValue = (tenant) => tenant.locale;
5
- exports.formatTenantHeaderValue = formatTenantHeaderValue;
6
- const parseTenantHeaderValue = (value) => ({
4
+ exports.formatTenantHeaderValue = (tenant) => tenant.locale;
5
+ exports.parseTenantHeaderValue = (value) => ({
7
6
  locale: value,
8
7
  });
9
- exports.parseTenantHeaderValue = parseTenantHeaderValue;
@@ -8,7 +8,7 @@ export declare const hrToNano: ([seconds, nanoseconds]: [number, number]) => num
8
8
  export declare const formatNano: (nanoseconds: number) => string;
9
9
  export declare const reduceHrToNano: (values: import("ramda").List<[number, number]>) => number;
10
10
  export declare const shrinkTimings: (name: string) => string;
11
- type TimingFormat = ReturnType<typeof parseTimingName>;
11
+ declare type TimingFormat = ReturnType<typeof parseTimingName>;
12
12
  export declare const formatTimingName: ({ hopNumber, target, source }: TimingFormat) => string;
13
13
  export declare const parseTimingName: (timing: string | undefined) => {
14
14
  hopNumber: number | null;
package/lib/utils/time.js CHANGED
@@ -3,26 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.timerForEvents = exports.timer = exports.reduceTimings = exports.parseTimingName = exports.formatTimingName = exports.shrinkTimings = exports.reduceHrToNano = exports.formatNano = exports.hrToNano = exports.nanosecondsToSeconds = exports.hrToMillisFloat = exports.hrToMillis = void 0;
4
4
  const ramda_1 = require("ramda");
5
5
  const logger_1 = require("../service/logger");
6
- const hrToMillis = ([seconds, nanoseconds]) => Math.round((seconds * 1e3) + (nanoseconds / 1e6));
7
- exports.hrToMillis = hrToMillis;
8
- const hrToMillisFloat = ([seconds, nanoseconds]) => {
6
+ exports.hrToMillis = ([seconds, nanoseconds]) => Math.round((seconds * 1e3) + (nanoseconds / 1e6));
7
+ exports.hrToMillisFloat = ([seconds, nanoseconds]) => {
9
8
  return (seconds * 1e3) + (nanoseconds / 1e6);
10
9
  };
11
- exports.hrToMillisFloat = hrToMillisFloat;
12
- const nanosecondsToSeconds = (nanoseconds) => {
10
+ exports.nanosecondsToSeconds = (nanoseconds) => {
13
11
  return nanoseconds / 1e9;
14
12
  };
15
- exports.nanosecondsToSeconds = nanosecondsToSeconds;
16
- const hrToNano = ([seconds, nanoseconds]) => seconds * 1e9 + nanoseconds;
17
- exports.hrToNano = hrToNano;
18
- const formatNano = (nanoseconds) => `${(nanoseconds / 1e9).toFixed(0)}s ${((nanoseconds / 1e6) % 1e3).toFixed(0)}ms`;
19
- exports.formatNano = formatNano;
20
- exports.reduceHrToNano = (0, ramda_1.reduce)((acc, hr) => acc + (0, exports.hrToNano)(hr), 0);
21
- const shrinkTimings = (name) => name.replace(/graphql/g, 'gql').replace(/server/g, 'srv');
22
- exports.shrinkTimings = shrinkTimings;
23
- const formatTimingName = ({ hopNumber, target, source }) => `${Number.isNaN(hopNumber) ? '' : hopNumber}.${source || ''}#${target || ''}`;
24
- exports.formatTimingName = formatTimingName;
25
- const parseTimingName = (timing) => {
13
+ exports.hrToNano = ([seconds, nanoseconds]) => seconds * 1e9 + nanoseconds;
14
+ exports.formatNano = (nanoseconds) => `${(nanoseconds / 1e9).toFixed(0)}s ${((nanoseconds / 1e6) % 1e3).toFixed(0)}ms`;
15
+ exports.reduceHrToNano = ramda_1.reduce((acc, hr) => acc + exports.hrToNano(hr), 0);
16
+ exports.shrinkTimings = (name) => name.replace(/graphql/g, 'gql').replace(/server/g, 'srv');
17
+ exports.formatTimingName = ({ hopNumber, target, source }) => `${Number.isNaN(hopNumber) ? '' : hopNumber}.${source || ''}#${target || ''}`;
18
+ exports.parseTimingName = (timing) => {
26
19
  const [hopNumber, sourceAndTarget] = timing ? timing.split('.') : [null, null];
27
20
  const [source, target] = sourceAndTarget ? sourceAndTarget.split('#') : [null, null];
28
21
  return {
@@ -31,9 +24,7 @@ const parseTimingName = (timing) => {
31
24
  target,
32
25
  };
33
26
  };
34
- exports.parseTimingName = parseTimingName;
35
- const reduceTimings = (timingsObj) => (0, ramda_1.compose)((0, ramda_1.reduce)((acc, [key, dur]) => `${key};dur=${dur}, ${acc}`, ''), ramda_1.toPairs)(timingsObj);
36
- exports.reduceTimings = reduceTimings;
27
+ exports.reduceTimings = (timingsObj) => ramda_1.compose(ramda_1.reduce((acc, [key, dur]) => `${key};dur=${dur}, ${acc}`, ''), ramda_1.toPairs)(timingsObj);
37
28
  function recordTimings(start, name, timings, middlewareMetrics, success) {
38
29
  // Capture the total amount of time spent in this middleware, which includes following middlewares
39
30
  const end = process.hrtime(start);
@@ -53,9 +44,9 @@ function recordTimings(start, name, timings, middlewareMetrics, success) {
53
44
  metrics.batch(label, success ? elapsed : undefined, { success: success ? 1 : 0 });
54
45
  // This middleware has added it's own metrics
55
46
  // Just add them to `timings` scoped by the middleware's name and batch them
56
- const middlewareMetricsKeys = (0, ramda_1.keys)(middlewareMetrics);
47
+ const middlewareMetricsKeys = ramda_1.keys(middlewareMetrics);
57
48
  if (success && middlewareMetricsKeys.length > 0) {
58
- (0, ramda_1.forEach)((k) => {
49
+ ramda_1.forEach((k) => {
59
50
  const metricEnd = middlewareMetrics[k];
60
51
  // Delete own metrics so next middleware can have empty state but still accumulate metrics batched after `await`
61
52
  delete middlewareMetrics[k];
@@ -70,7 +61,7 @@ function timer(middleware) {
70
61
  return middleware;
71
62
  }
72
63
  if (!middleware.name) {
73
- (0, logger_1.logOnceToDevConsole)(`Please use a named function as handler for better metrics. ${middleware.toString()}`, logger_1.LogLevel.Warn);
64
+ logger_1.logOnceToDevConsole(`Please use a named function as handler for better metrics. ${middleware.toString()}`, logger_1.LogLevel.Warn);
74
65
  }
75
66
  return async (ctx, next) => {
76
67
  if (!ctx.serverTiming) {
@@ -102,7 +93,7 @@ function timerForEvents(middleware) {
102
93
  return middleware;
103
94
  }
104
95
  if (!middleware.name) {
105
- (0, logger_1.logOnceToDevConsole)(`Please use a named function as handler for better metrics. ${middleware.toString()}`, logger_1.LogLevel.Warn);
96
+ logger_1.logOnceToDevConsole(`Please use a named function as handler for better metrics. ${middleware.toString()}`, logger_1.LogLevel.Warn);
106
97
  }
107
98
  return async (ctx, next) => {
108
99
  if (!ctx.timings) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/api",
3
- "version": "6.48.1-beta.2",
3
+ "version": "6.48.1-beta.3",
4
4
  "description": "VTEX I/O API client",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -121,7 +121,7 @@
121
121
  "tslint-config-vtex": "^2.1.0",
122
122
  "tslint-eslint-rules": "^5.4.0",
123
123
  "typemoq": "^2.1.0",
124
- "typescript": "4.9.5",
124
+ "typescript": "3.9.7",
125
125
  "typescript-json-schema": "^0.65.1"
126
126
  }
127
127
  }