@vtex/api 6.48.1-beta → 6.48.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gen/manifest.schema +5 -3
- package/lib/HttpClient/GraphQLClient.d.ts +2 -1
- package/lib/HttpClient/GraphQLClient.js +5 -1
- package/lib/HttpClient/HttpClient.d.ts +6 -5
- package/lib/HttpClient/HttpClient.js +64 -21
- package/lib/HttpClient/agents.d.ts +3 -0
- package/lib/HttpClient/agents.js +37 -0
- package/lib/HttpClient/index.d.ts +1 -7
- package/lib/HttpClient/index.js +17 -16
- package/lib/HttpClient/middlewares/cache.d.ts +8 -2
- package/lib/HttpClient/middlewares/cache.js +126 -33
- package/lib/HttpClient/middlewares/cancellationToken.d.ts +1 -1
- package/lib/HttpClient/middlewares/cancellationToken.js +3 -1
- package/lib/HttpClient/middlewares/inflight.js +1 -0
- package/lib/HttpClient/middlewares/memoization.js +9 -1
- package/lib/HttpClient/middlewares/metrics.js +17 -31
- package/lib/HttpClient/middlewares/notFound.js +1 -0
- package/lib/HttpClient/middlewares/recorder.d.ts +1 -1
- package/lib/HttpClient/middlewares/recorder.js +20 -12
- package/lib/HttpClient/middlewares/request/HttpAgentSingleton.d.ts +11 -0
- package/lib/HttpClient/middlewares/request/HttpAgentSingleton.js +31 -0
- package/lib/HttpClient/middlewares/request/index.d.ts +18 -0
- package/lib/HttpClient/middlewares/request/index.js +85 -0
- package/lib/HttpClient/middlewares/request/setupAxios/index.d.ts +2 -0
- package/lib/HttpClient/middlewares/request/setupAxios/index.js +21 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.d.ts +2 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +54 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.d.ts +2 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +7 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.d.ts +8 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.js +56 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.d.ts +4 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +30 -0
- package/lib/HttpClient/middlewares/tracing.d.ts +15 -0
- package/lib/HttpClient/middlewares/tracing.js +61 -0
- package/lib/HttpClient/typings.d.ts +44 -10
- package/lib/HttpClient/typings.js +1 -0
- package/lib/caches/DiskCache.d.ts +1 -1
- package/lib/caches/DiskCache.js +1 -0
- package/lib/caches/LRUCache.d.ts +2 -2
- package/lib/caches/LRUCache.js +6 -1
- package/lib/caches/LRUDiskCache.d.ts +1 -1
- package/lib/caches/LRUDiskCache.js +6 -1
- package/lib/caches/MultilayeredCache.d.ts +1 -1
- package/lib/caches/MultilayeredCache.js +2 -1
- package/lib/caches/index.js +16 -7
- package/lib/{HttpClient → clients}/IOClient.d.ts +4 -4
- package/lib/clients/IOClient.js +20 -0
- package/lib/clients/IOClients.d.ts +28 -24
- package/lib/clients/IOClients.js +36 -28
- package/lib/{HttpClient → clients}/IOGraphQLClient.d.ts +4 -4
- package/lib/{HttpClient → clients}/IOGraphQLClient.js +3 -2
- package/lib/{HttpClient → clients/apps}/AppClient.d.ts +3 -3
- package/lib/{HttpClient → clients/apps}/AppClient.js +11 -5
- package/lib/{HttpClient → clients/apps}/AppGraphQLClient.d.ts +3 -3
- package/lib/{HttpClient → clients/apps}/AppGraphQLClient.js +11 -5
- package/lib/clients/apps/Billing.d.ts +12 -0
- package/lib/clients/{Billing.js → apps/Billing.js} +9 -3
- package/lib/clients/{Builder.d.ts → apps/Builder.d.ts} +12 -11
- package/lib/clients/{Builder.js → apps/Builder.js} +50 -22
- package/lib/clients/apps/MessagesGraphQL.d.ts +61 -0
- package/lib/clients/apps/MessagesGraphQL.js +122 -0
- package/lib/clients/{Settings.d.ts → apps/Settings.d.ts} +5 -4
- package/lib/clients/{Settings.js → apps/Settings.js} +15 -20
- package/lib/clients/apps/catalogGraphQL/brand.d.ts +13 -0
- package/lib/clients/apps/catalogGraphQL/brand.js +19 -0
- package/lib/clients/apps/catalogGraphQL/category.d.ts +11 -0
- package/lib/clients/apps/catalogGraphQL/category.js +17 -0
- package/lib/clients/apps/catalogGraphQL/index.d.ts +22 -0
- package/lib/clients/apps/catalogGraphQL/index.js +89 -0
- package/lib/clients/apps/catalogGraphQL/product.d.ts +25 -0
- package/lib/clients/apps/catalogGraphQL/product.js +31 -0
- package/lib/clients/apps/catalogGraphQL/sku.d.ts +26 -0
- package/lib/clients/apps/catalogGraphQL/sku.js +31 -0
- package/lib/clients/apps/index.d.ts +7 -0
- package/lib/clients/apps/index.js +19 -0
- package/lib/{HttpClient → clients/external}/ExternalClient.d.ts +3 -3
- package/lib/{HttpClient → clients/external}/ExternalClient.js +10 -2
- package/lib/clients/external/ID.d.ts +23 -0
- package/lib/clients/external/ID.js +61 -0
- package/lib/clients/external/Masterdata.d.ts +94 -0
- package/lib/clients/external/Masterdata.js +225 -0
- package/lib/clients/external/PaymentProvider.d.ts +31 -0
- package/lib/clients/external/PaymentProvider.js +43 -0
- package/lib/clients/external/index.d.ts +4 -0
- package/lib/clients/external/index.js +16 -0
- package/lib/clients/index.d.ts +9 -21
- package/lib/clients/index.js +23 -24
- package/lib/clients/infra/Apps.d.ts +88 -0
- package/lib/clients/infra/Apps.js +511 -0
- package/lib/clients/infra/Assets.d.ts +34 -0
- package/lib/clients/{Assets.js → infra/Assets.js} +75 -19
- package/lib/clients/infra/BillingMetrics.d.ts +13 -0
- package/lib/clients/infra/BillingMetrics.js +16 -0
- package/lib/clients/infra/Events.d.ts +12 -0
- package/lib/clients/infra/Events.js +34 -0
- package/lib/clients/infra/Housekeeper.d.ts +10 -0
- package/lib/clients/infra/Housekeeper.js +31 -0
- package/lib/{HttpClient → clients/infra}/InfraClient.d.ts +3 -3
- package/lib/{HttpClient → clients/infra}/InfraClient.js +10 -4
- package/lib/clients/infra/Registry.d.ts +59 -0
- package/lib/clients/{Registry.js → infra/Registry.js} +95 -33
- package/lib/clients/infra/Router.d.ts +34 -0
- package/lib/clients/infra/Router.js +82 -0
- package/lib/clients/infra/Sphinx.d.ts +13 -0
- package/lib/clients/infra/Sphinx.js +30 -0
- package/lib/clients/infra/VBase.d.ts +60 -0
- package/lib/clients/infra/VBase.js +197 -0
- package/lib/clients/infra/Workspaces.d.ts +18 -0
- package/lib/clients/infra/Workspaces.js +66 -0
- package/lib/clients/infra/index.d.ts +11 -0
- package/lib/clients/infra/index.js +23 -0
- package/lib/{HttpClient → clients/janus}/JanusClient.d.ts +3 -3
- package/lib/{HttpClient → clients/janus}/JanusClient.js +8 -3
- package/lib/clients/janus/LicenseManager.d.ts +7 -0
- package/lib/clients/{LicenseManager.js → janus/LicenseManager.js} +24 -8
- package/lib/clients/{Segment.d.ts → janus/Segment.d.ts} +7 -11
- package/lib/clients/janus/Segment.js +89 -0
- package/lib/clients/{Session.d.ts → janus/Session.d.ts} +4 -4
- package/lib/clients/{Session.js → janus/Session.js} +25 -13
- package/lib/clients/{Tenant.d.ts → janus/Tenant.d.ts} +6 -7
- package/lib/clients/janus/Tenant.js +29 -0
- package/lib/clients/janus/index.d.ts +5 -0
- package/lib/clients/janus/index.js +17 -0
- package/lib/constants.d.ts +49 -1
- package/lib/constants.js +55 -1
- package/lib/errors/AuthenticationError.js +1 -0
- package/lib/errors/ForbiddenError.js +1 -0
- package/lib/errors/NotFoundError.js +1 -0
- package/lib/errors/RequestCancelledError.js +1 -0
- package/lib/errors/ResolverError.d.ts +1 -1
- package/lib/errors/ResolverError.js +3 -2
- package/lib/errors/ResolverWarning.d.ts +1 -1
- package/lib/errors/ResolverWarning.js +3 -2
- package/lib/errors/TooManyRequestsError.js +1 -0
- package/lib/errors/UserInputError.js +1 -0
- package/lib/errors/index.js +18 -11
- package/lib/index.d.ts +9 -7
- package/lib/index.js +27 -16
- package/lib/metrics/MetricsAccumulator.d.ts +1 -18
- package/lib/metrics/MetricsAccumulator.js +39 -22
- package/lib/responses.d.ts +3 -44
- package/lib/service/index.d.ts +2 -0
- package/lib/service/index.js +34 -0
- package/lib/service/loaders.d.ts +8 -0
- package/lib/service/loaders.js +55 -0
- package/lib/service/logger/console.d.ts +10 -0
- package/lib/service/logger/console.js +37 -0
- package/lib/service/logger/index.d.ts +2 -28
- package/lib/service/logger/index.js +12 -68
- package/lib/service/logger/logger.d.ts +29 -0
- package/lib/service/logger/logger.js +62 -0
- package/lib/service/logger/metricsLogger.d.ts +40 -0
- package/lib/service/logger/metricsLogger.js +150 -0
- package/lib/service/master.d.ts +2 -0
- package/lib/service/master.js +88 -0
- package/lib/service/metrics/requestMetricsMiddleware.d.ts +2 -0
- package/lib/service/metrics/requestMetricsMiddleware.js +45 -0
- package/lib/service/tracing/TracerSingleton.d.ts +7 -0
- package/lib/service/tracing/TracerSingleton.js +49 -0
- package/lib/service/tracing/metrics/MetricNames.d.ts +60 -0
- package/lib/service/tracing/metrics/MetricNames.js +45 -0
- package/lib/service/tracing/metrics/instruments.d.ts +9 -0
- package/lib/service/tracing/metrics/instruments.js +12 -0
- package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.d.ts +9 -0
- package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +26 -0
- package/lib/service/tracing/tracingMiddlewares.d.ts +5 -0
- package/lib/service/tracing/tracingMiddlewares.js +114 -0
- package/lib/service/worker/index.d.ts +11 -0
- package/lib/service/worker/index.js +196 -0
- package/lib/service/worker/listeners.d.ts +3 -0
- package/lib/{utils/unhandled.js → service/worker/listeners.js} +10 -15
- package/lib/service/{Service.d.ts → worker/runtime/Service.d.ts} +5 -5
- package/lib/service/{Service.js → worker/runtime/Service.js} +3 -1
- package/lib/service/worker/runtime/builtIn/handlers.d.ts +4 -0
- package/lib/service/worker/runtime/builtIn/handlers.js +31 -0
- package/lib/service/worker/runtime/builtIn/middlewares.d.ts +4 -0
- package/lib/service/worker/runtime/builtIn/middlewares.js +41 -0
- package/lib/service/worker/runtime/events/index.d.ts +4 -0
- package/lib/service/worker/runtime/events/index.js +47 -0
- package/lib/service/worker/runtime/events/middlewares/body.d.ts +3 -0
- package/lib/service/worker/runtime/events/middlewares/body.js +26 -0
- package/lib/service/worker/runtime/events/middlewares/context.d.ts +3 -0
- package/lib/service/worker/runtime/events/middlewares/context.js +23 -0
- package/lib/service/worker/runtime/events/router.d.ts +2 -0
- package/lib/service/worker/runtime/events/router.js +28 -0
- package/lib/service/worker/runtime/graphql/index.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/index.js +28 -0
- package/lib/service/worker/runtime/graphql/middlewares/context.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/middlewares/context.js +17 -0
- package/lib/service/worker/runtime/graphql/middlewares/error.js +97 -0
- package/lib/service/worker/runtime/graphql/middlewares/query.d.ts +3 -0
- package/lib/service/worker/runtime/graphql/middlewares/query.js +53 -0
- package/lib/service/worker/runtime/graphql/middlewares/response.js +39 -0
- package/lib/service/worker/runtime/graphql/middlewares/run.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/middlewares/run.js +20 -0
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.d.ts +5 -0
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +29 -0
- package/lib/service/worker/runtime/graphql/middlewares/upload.d.ts +4 -0
- package/lib/service/{graphql → worker/runtime/graphql}/middlewares/upload.js +1 -0
- package/lib/service/worker/runtime/graphql/schema/index.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/index.js +32 -0
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +80 -0
- package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Auth.d.ts +1 -0
- package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Auth.js +17 -10
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.js +38 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.d.ts +11 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +62 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.js +41 -0
- package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Sanitize.d.ts +1 -0
- package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/Sanitize.js +7 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +35 -0
- package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/SmartCacheDirective.d.ts +1 -0
- package/lib/service/{graphql → worker/runtime/graphql}/schema/schemaDirectives/SmartCacheDirective.js +9 -3
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +40 -0
- package/lib/service/{graphql/schema/schemaDirectives/Translatable.d.ts → worker/runtime/graphql/schema/schemaDirectives/TranslateTo.d.ts} +2 -1
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +34 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.d.ts +22 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +37 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/index.d.ts +8 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +13 -0
- package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/ioUpload.js +1 -0
- package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/sanitizedString.js +6 -1
- package/lib/service/worker/runtime/graphql/typings.d.ts +31 -0
- package/lib/service/worker/runtime/graphql/utils/cacheControl.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/utils/cacheControl.js +33 -0
- package/lib/service/worker/runtime/graphql/utils/error.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/utils/error.js +77 -0
- package/lib/service/{graphql → worker/runtime/graphql}/utils/pathname.js +1 -0
- package/lib/service/worker/runtime/graphql/utils/translations.d.ts +14 -0
- package/lib/service/worker/runtime/graphql/utils/translations.js +39 -0
- package/lib/service/worker/runtime/http/index.d.ts +5 -0
- package/lib/service/worker/runtime/http/index.js +59 -0
- package/lib/service/worker/runtime/http/middlewares/authTokens.d.ts +3 -0
- package/lib/service/{http → worker/runtime/http}/middlewares/authTokens.js +1 -0
- package/lib/service/worker/runtime/http/middlewares/cancellationToken.d.ts +3 -0
- package/lib/service/{http → worker/runtime/http}/middlewares/cancellationToken.js +3 -1
- package/lib/service/worker/runtime/http/middlewares/clients.d.ts +4 -0
- package/lib/service/{http → worker/runtime/http}/middlewares/clients.js +1 -0
- package/lib/service/worker/runtime/http/middlewares/context.d.ts +4 -0
- package/lib/service/worker/runtime/http/middlewares/context.js +37 -0
- package/lib/service/worker/runtime/http/middlewares/error.d.ts +2 -0
- package/lib/service/{http → worker/runtime/http}/middlewares/error.js +28 -15
- package/lib/service/worker/runtime/http/middlewares/rateLimit.d.ts +6 -0
- package/lib/service/worker/runtime/http/middlewares/rateLimit.js +43 -0
- package/lib/service/{http → worker/runtime/http}/middlewares/requestStats.d.ts +3 -3
- package/lib/service/{http → worker/runtime/http}/middlewares/requestStats.js +1 -0
- package/lib/service/worker/runtime/http/middlewares/setCookie.d.ts +3 -0
- package/lib/service/{http → worker/runtime/http}/middlewares/setCookie.js +1 -0
- package/lib/service/worker/runtime/http/middlewares/settings.d.ts +9 -0
- package/lib/service/worker/runtime/http/middlewares/settings.js +45 -0
- package/lib/service/worker/runtime/http/middlewares/timings.d.ts +3 -0
- package/lib/service/{http → worker/runtime/http}/middlewares/timings.js +22 -8
- package/lib/service/worker/runtime/http/middlewares/vary.d.ts +3 -0
- package/lib/service/{http → worker/runtime/http}/middlewares/vary.js +4 -3
- package/lib/service/worker/runtime/http/router.d.ts +2 -0
- package/lib/service/worker/runtime/http/router.js +24 -0
- package/lib/service/worker/runtime/http/routes.d.ts +19 -0
- package/lib/service/worker/runtime/http/routes.js +13 -0
- package/lib/service/worker/runtime/method.d.ts +9 -0
- package/lib/service/{method.js → worker/runtime/method.js} +1 -0
- package/lib/service/worker/runtime/statusTrack.d.ts +14 -0
- package/lib/service/worker/runtime/statusTrack.js +38 -0
- package/lib/service/{typings.d.ts → worker/runtime/typings.d.ts} +70 -36
- package/lib/service/worker/runtime/utils/compose.d.ts +5 -0
- package/lib/service/{utils → worker/runtime/utils}/compose.js +3 -2
- package/lib/service/worker/runtime/utils/context.d.ts +5 -0
- package/lib/service/worker/runtime/utils/context.js +41 -0
- package/lib/service/worker/runtime/utils/diff.d.ts +12 -0
- package/lib/service/worker/runtime/utils/diff.js +22 -0
- package/lib/service/worker/runtime/utils/recorder.d.ts +8 -0
- package/lib/service/worker/runtime/utils/recorder.js +38 -0
- package/lib/service/{graphql/utils/array.js → worker/runtime/utils/toArray.js} +1 -0
- package/lib/service/worker/runtime/utils/tokenBucket.d.ts +2 -0
- package/lib/service/worker/runtime/utils/tokenBucket.js +17 -0
- package/lib/tracing/LogEvents.d.ts +31 -0
- package/lib/tracing/LogEvents.js +3 -0
- package/lib/tracing/LogFields.d.ts +66 -0
- package/lib/tracing/LogFields.js +3 -0
- package/lib/tracing/Tags.d.ts +81 -0
- package/lib/tracing/Tags.js +8 -0
- package/lib/tracing/UserLandTracer.d.ts +27 -0
- package/lib/tracing/UserLandTracer.js +57 -0
- package/lib/tracing/errorReporting/ErrorReport.d.ts +31 -0
- package/lib/tracing/errorReporting/ErrorReport.js +71 -0
- package/lib/tracing/index.d.ts +9 -0
- package/lib/tracing/index.js +20 -0
- package/lib/tracing/spanReference/SpanReferenceTypes.d.ts +4 -0
- package/lib/tracing/spanReference/SpanReferenceTypes.js +8 -0
- package/lib/tracing/spanReference/createSpanReference.d.ts +3 -0
- package/lib/tracing/spanReference/createSpanReference.js +9 -0
- package/lib/tracing/utils.d.ts +13 -0
- package/lib/tracing/utils.js +41 -0
- package/lib/utils/MineWinsConflictsResolver.d.ts +6 -4
- package/lib/utils/MineWinsConflictsResolver.js +35 -17
- package/lib/utils/app.d.ts +3 -1
- package/lib/utils/app.js +4 -1
- package/lib/utils/appsStaleIfError.d.ts +1 -1
- package/lib/utils/appsStaleIfError.js +20 -7
- package/lib/utils/billingOptions.d.ts +36 -3
- package/lib/utils/billingOptions.js +8 -3
- package/lib/utils/binding.d.ts +3 -3
- package/lib/utils/binding.js +1 -0
- package/lib/utils/buildFullPath.d.ts +11 -0
- package/lib/utils/buildFullPath.js +54 -0
- package/lib/utils/cancel.d.ts +2 -2
- package/lib/utils/cancel.js +3 -1
- package/lib/utils/conflicts.mock.d.ts +17 -0
- package/lib/utils/conflicts.mock.js +28 -0
- package/lib/utils/domain.js +1 -0
- package/lib/utils/error.js +1 -0
- package/lib/utils/index.js +19 -12
- package/lib/utils/json.js +1 -0
- package/lib/utils/log.d.ts +1 -3
- package/lib/utils/log.js +3 -2
- package/lib/utils/message.js +5 -1
- package/lib/utils/renameBy.js +1 -0
- package/lib/utils/retry.js +3 -2
- package/lib/utils/status.js +1 -0
- package/lib/utils/tenant.d.ts +3 -3
- package/lib/utils/tenant.js +1 -0
- package/lib/utils/throwOnGraphQLErrors.js +1 -0
- package/lib/utils/time.d.ts +7 -7
- package/lib/utils/time.js +10 -2
- package/package.json +3 -3
- package/lib/HttpClient/IOClient.js +0 -14
- package/lib/HttpClient/factories/index.d.ts +0 -8
- package/lib/HttpClient/factories/index.js +0 -31
- package/lib/HttpClient/middlewares/request.d.ts +0 -10
- package/lib/HttpClient/middlewares/request.js +0 -87
- package/lib/IODataSource.d.ts +0 -27
- package/lib/IODataSource.js +0 -46
- package/lib/clients/Apps.d.ts +0 -84
- package/lib/clients/Apps.js +0 -326
- package/lib/clients/Assets.d.ts +0 -21
- package/lib/clients/Billing.d.ts +0 -11
- package/lib/clients/BillingMetrics.d.ts +0 -12
- package/lib/clients/BillingMetrics.js +0 -10
- package/lib/clients/Events.d.ts +0 -6
- package/lib/clients/Events.js +0 -19
- package/lib/clients/Housekeeper.d.ts +0 -11
- package/lib/clients/Housekeeper.js +0 -24
- package/lib/clients/ID.d.ts +0 -22
- package/lib/clients/ID.js +0 -48
- package/lib/clients/LicenseManager.d.ts +0 -6
- package/lib/clients/Logger.d.ts +0 -27
- package/lib/clients/Logger.js +0 -32
- package/lib/clients/Messages.d.ts +0 -18
- package/lib/clients/Messages.js +0 -20
- package/lib/clients/MessagesGraphQL.d.ts +0 -63
- package/lib/clients/MessagesGraphQL.js +0 -50
- package/lib/clients/Metadata.d.ts +0 -25
- package/lib/clients/Metadata.js +0 -53
- package/lib/clients/Registry.d.ts +0 -61
- package/lib/clients/Router.d.ts +0 -33
- package/lib/clients/Router.js +0 -50
- package/lib/clients/Segment.js +0 -69
- package/lib/clients/Sphinx.d.ts +0 -12
- package/lib/clients/Sphinx.js +0 -19
- package/lib/clients/Tenant.js +0 -13
- package/lib/clients/VBase.d.ts +0 -57
- package/lib/clients/VBase.js +0 -116
- package/lib/clients/Workspaces.d.ts +0 -17
- package/lib/clients/Workspaces.js +0 -38
- package/lib/service/Runtime.d.ts +0 -18
- package/lib/service/Runtime.js +0 -57
- package/lib/service/events/index.d.ts +0 -3
- package/lib/service/events/index.js +0 -21
- package/lib/service/graphql/index.d.ts +0 -7
- package/lib/service/graphql/index.js +0 -33
- package/lib/service/graphql/middlewares/error.js +0 -107
- package/lib/service/graphql/middlewares/formatters.d.ts +0 -2
- package/lib/service/graphql/middlewares/formatters.js +0 -64
- package/lib/service/graphql/middlewares/query.d.ts +0 -2
- package/lib/service/graphql/middlewares/query.js +0 -32
- package/lib/service/graphql/middlewares/response.js +0 -36
- package/lib/service/graphql/middlewares/run.d.ts +0 -4
- package/lib/service/graphql/middlewares/run.js +0 -55
- package/lib/service/graphql/middlewares/schema.d.ts +0 -2
- package/lib/service/graphql/middlewares/schema.js +0 -8
- package/lib/service/graphql/middlewares/timings.d.ts +0 -2
- package/lib/service/graphql/middlewares/timings.js +0 -10
- package/lib/service/graphql/middlewares/upload.d.ts +0 -7
- package/lib/service/graphql/schema/index.d.ts +0 -3
- package/lib/service/graphql/schema/index.js +0 -66
- package/lib/service/graphql/schema/messagesLoader.d.ts +0 -4
- package/lib/service/graphql/schema/messagesLoader.js +0 -41
- package/lib/service/graphql/schema/messagesLoaderV2.d.ts +0 -5
- package/lib/service/graphql/schema/messagesLoaderV2.js +0 -44
- package/lib/service/graphql/schema/schemaDirectives/Translatable.js +0 -54
- package/lib/service/graphql/schema/schemaDirectives/TranslatableV2.d.ts +0 -13
- package/lib/service/graphql/schema/schemaDirectives/TranslatableV2.js +0 -67
- package/lib/service/graphql/schema/schemaDirectives/index.d.ts +0 -13
- package/lib/service/graphql/schema/schemaDirectives/index.js +0 -17
- package/lib/service/graphql/schema/typeDefs/index.d.ts +0 -16
- package/lib/service/graphql/schema/typeDefs/index.js +0 -21
- package/lib/service/graphql/schema/typeDefs/ioMessage.d.ts +0 -8
- package/lib/service/graphql/schema/typeDefs/ioMessage.js +0 -33
- package/lib/service/graphql/typings.d.ts +0 -21
- package/lib/service/graphql/utils/cacheControl.d.ts +0 -6
- package/lib/service/graphql/utils/cacheControl.js +0 -38
- package/lib/service/graphql/utils/maxAgeEnum.d.ts +0 -6
- package/lib/service/graphql/utils/maxAgeEnum.js +0 -17
- package/lib/service/http/index.d.ts +0 -3
- package/lib/service/http/index.js +0 -18
- package/lib/service/http/middlewares/authTokens.d.ts +0 -3
- package/lib/service/http/middlewares/cancellationToken.d.ts +0 -3
- package/lib/service/http/middlewares/clients.d.ts +0 -4
- package/lib/service/http/middlewares/error.d.ts +0 -3
- package/lib/service/http/middlewares/setCookie.d.ts +0 -3
- package/lib/service/http/middlewares/timings.d.ts +0 -3
- package/lib/service/http/middlewares/vary.d.ts +0 -3
- package/lib/service/method.d.ts +0 -9
- package/lib/service/utils/compose.d.ts +0 -4
- package/lib/utils/MineWinsConflictsResolver.test.d.ts +0 -1
- package/lib/utils/MineWinsConflictsResolver.test.js +0 -134
- package/lib/utils/unhandled.d.ts +0 -1
- /package/lib/service/{graphql → worker/runtime/graphql}/middlewares/error.d.ts +0 -0
- /package/lib/service/{graphql → worker/runtime/graphql}/middlewares/response.d.ts +0 -0
- /package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/ioUpload.d.ts +0 -0
- /package/lib/service/{graphql → worker/runtime/graphql}/schema/typeDefs/sanitizedString.d.ts +0 -0
- /package/lib/service/{graphql → worker/runtime/graphql}/typings.js +0 -0
- /package/lib/service/{graphql → worker/runtime/graphql}/utils/pathname.d.ts +0 -0
- /package/lib/service/{typings.js → worker/runtime/typings.js} +0 -0
- /package/lib/service/{graphql/utils/array.d.ts → worker/runtime/utils/toArray.d.ts} +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMockConflicts = void 0;
|
|
4
|
+
function jsonToBase64(json) {
|
|
5
|
+
return Buffer.from(JSON.stringify(json)).toString('base64');
|
|
6
|
+
}
|
|
7
|
+
function getMockConflicts(path, base, mine, master) {
|
|
8
|
+
return {
|
|
9
|
+
data: [
|
|
10
|
+
{
|
|
11
|
+
base: {
|
|
12
|
+
content: jsonToBase64(base),
|
|
13
|
+
mimeType: 'application/json',
|
|
14
|
+
},
|
|
15
|
+
master: {
|
|
16
|
+
content: jsonToBase64(master),
|
|
17
|
+
mimeType: 'application/json',
|
|
18
|
+
},
|
|
19
|
+
mine: {
|
|
20
|
+
content: jsonToBase64(mine),
|
|
21
|
+
mimeType: 'application/json',
|
|
22
|
+
},
|
|
23
|
+
path,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.getMockConflicts = getMockConflicts;
|
package/lib/utils/domain.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PUBLIC_DOMAINS = void 0;
|
|
3
4
|
const ramda_1 = require("ramda");
|
|
4
5
|
const VTEX_PUBLIC_ENDPOINT = process.env.VTEX_PUBLIC_ENDPOINT || 'myvtex.com';
|
|
5
6
|
exports.PUBLIC_DOMAINS = ramda_1.uniq([VTEX_PUBLIC_ENDPOINT, 'myvtex.com', 'mygocommerce.com', 'vtexsmb.com']);
|
package/lib/utils/error.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanError = exports.SENSITIVE_EXCEPTION_FIELDS = exports.PICKED_AXIOS_PROPS = void 0;
|
|
3
4
|
// Inspired by https://github.com/sindresorhus/serialize-error
|
|
4
5
|
const ramda_1 = require("ramda");
|
|
5
6
|
exports.PICKED_AXIOS_PROPS = ['baseURL', 'cacheable', 'data', 'finished', 'headers', 'method', 'timeout', 'status', 'path', 'url', 'metric', 'inflightKey', 'forceMaxAge', 'params', 'responseType'];
|
package/lib/utils/index.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
5
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
__exportStar(require("./app"), exports);
|
|
14
|
+
__exportStar(require("./error"), exports);
|
|
15
|
+
__exportStar(require("./retry"), exports);
|
|
16
|
+
__exportStar(require("./time"), exports);
|
|
17
|
+
__exportStar(require("./billingOptions"), exports);
|
|
18
|
+
__exportStar(require("./domain"), exports);
|
|
19
|
+
__exportStar(require("./tenant"), exports);
|
|
20
|
+
__exportStar(require("./binding"), exports);
|
|
21
|
+
__exportStar(require("./MineWinsConflictsResolver"), exports);
|
package/lib/utils/json.js
CHANGED
package/lib/utils/log.d.ts
CHANGED
package/lib/utils/log.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanLog = void 0;
|
|
3
4
|
const json_1 = require("./json");
|
|
4
5
|
const SENSITIVE_FIELDS = [
|
|
5
6
|
'auth',
|
|
6
7
|
'authorization',
|
|
7
8
|
'authtoken',
|
|
8
9
|
'cookie',
|
|
9
|
-
'proxy-
|
|
10
|
+
'proxy-authorization',
|
|
10
11
|
'rawheaders',
|
|
11
12
|
'token',
|
|
12
|
-
'
|
|
13
|
+
'vtexidclientautcookie',
|
|
13
14
|
'x-vtex-api-appkey',
|
|
14
15
|
'x-vtex-api-apptoken',
|
|
15
16
|
'x-vtex-credential',
|
package/lib/utils/message.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeProviderFromId = exports.parseIOMessageId = exports.providerFromMessage = exports.PROVIDER_SPACER = void 0;
|
|
3
4
|
exports.PROVIDER_SPACER = '::';
|
|
4
5
|
exports.providerFromMessage = (message) => {
|
|
5
6
|
const { provider } = exports.parseIOMessageId(message);
|
|
@@ -17,4 +18,7 @@ exports.parseIOMessageId = ({ id }) => {
|
|
|
17
18
|
locator: splitted[0],
|
|
18
19
|
};
|
|
19
20
|
};
|
|
20
|
-
exports.removeProviderFromId = (message) => (
|
|
21
|
+
exports.removeProviderFromId = (message) => ({
|
|
22
|
+
...message,
|
|
23
|
+
id: exports.parseIOMessageId(message).locator,
|
|
24
|
+
});
|
package/lib/utils/renameBy.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renameBy = void 0;
|
|
3
4
|
const ramda_1 = require("ramda");
|
|
4
5
|
exports.renameBy = (fn, obj) => ramda_1.compose(ramda_1.fromPairs, ramda_1.map(([key, val]) => [fn(key), val]), ramda_1.toPairs)(obj);
|
package/lib/utils/retry.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAbortedOrNetworkErrorOrRouterTimeout = exports.isNetworkErrorOrRouterTimeout = exports.TIMEOUT_CODE = void 0;
|
|
3
4
|
const axios_retry_1 = require("axios-retry");
|
|
4
5
|
exports.TIMEOUT_CODE = 'ProxyTimeout';
|
|
5
6
|
const printLabel = (e, message) => {
|
|
@@ -28,5 +29,5 @@ exports.isAbortedOrNetworkErrorOrRouterTimeout = (e) => {
|
|
|
28
29
|
return exports.isNetworkErrorOrRouterTimeout(e);
|
|
29
30
|
};
|
|
30
31
|
var axios_retry_2 = require("axios-retry");
|
|
31
|
-
exports
|
|
32
|
-
exports
|
|
32
|
+
Object.defineProperty(exports, "isNetworkOrIdempotentRequestError", { enumerable: true, get: function () { return axios_retry_2.isNetworkOrIdempotentRequestError; } });
|
|
33
|
+
Object.defineProperty(exports, "exponentialDelay", { enumerable: true, get: function () { return axios_retry_2.exponentialDelay; } });
|
package/lib/utils/status.js
CHANGED
package/lib/utils/tenant.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface TenantHeader {
|
|
2
2
|
locale: string;
|
|
3
3
|
}
|
|
4
|
-
export declare const formatTenantHeaderValue: (tenant:
|
|
5
|
-
export declare const parseTenantHeaderValue: (value: string) =>
|
|
4
|
+
export declare const formatTenantHeaderValue: (tenant: TenantHeader) => string;
|
|
5
|
+
export declare const parseTenantHeaderValue: (value: string) => TenantHeader;
|
package/lib/utils/tenant.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseTenantHeaderValue = exports.formatTenantHeaderValue = void 0;
|
|
3
4
|
exports.formatTenantHeaderValue = (tenant) => tenant.locale;
|
|
4
5
|
exports.parseTenantHeaderValue = (value) => ({
|
|
5
6
|
locale: value,
|
|
@@ -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.throwOnGraphQLErrors = void 0;
|
|
6
7
|
const customGraphQLError_1 = __importDefault(require("../errors/customGraphQLError"));
|
|
7
8
|
function throwOnGraphQLErrors(message) {
|
|
8
9
|
return function maybeGraphQLResponse(response) {
|
package/lib/utils/time.d.ts
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { IOClients } from '../clients/IOClients';
|
|
2
2
|
import { MetricsAccumulator } from '../metrics/MetricsAccumulator';
|
|
3
|
-
import { EventHandler, RouteHandler } from '../service/typings';
|
|
3
|
+
import { EventHandler, ParamsContext, RecorderState, RouteHandler } from '../service/worker/runtime/typings';
|
|
4
4
|
export declare const hrToMillis: ([seconds, nanoseconds]: [number, number]) => number;
|
|
5
|
+
export declare const hrToMillisFloat: ([seconds, nanoseconds]: [number, number]) => number;
|
|
6
|
+
export declare const nanosecondsToSeconds: (nanoseconds: number) => number;
|
|
5
7
|
export declare const hrToNano: ([seconds, nanoseconds]: [number, number]) => number;
|
|
6
8
|
export declare const formatNano: (nanoseconds: number) => string;
|
|
7
9
|
export declare const reduceHrToNano: (values: import("ramda").List<[number, number]>) => number;
|
|
8
10
|
export declare const shrinkTimings: (name: string) => string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
source: string | null;
|
|
12
|
-
target: string | null;
|
|
13
|
-
}) => string;
|
|
11
|
+
declare type TimingFormat = ReturnType<typeof parseTimingName>;
|
|
12
|
+
export declare const formatTimingName: ({ hopNumber, target, source }: TimingFormat) => string;
|
|
14
13
|
export declare const parseTimingName: (timing: string | undefined) => {
|
|
15
14
|
hopNumber: number | null;
|
|
16
15
|
source: string | null;
|
|
17
16
|
target: string | null;
|
|
18
17
|
};
|
|
19
18
|
export declare const reduceTimings: (timingsObj: Record<string, string>) => string;
|
|
20
|
-
export declare function timer<T extends IOClients, U, V>(middleware: RouteHandler<T, U, V>): RouteHandler<T, U, V>;
|
|
19
|
+
export declare function timer<T extends IOClients, U extends RecorderState, V extends ParamsContext>(middleware: RouteHandler<T, U, V>): RouteHandler<T, U, V>;
|
|
21
20
|
export declare function timerForEvents<T extends IOClients, U>(middleware: EventHandler<T, U>): EventHandler<T, U>;
|
|
22
21
|
declare global {
|
|
23
22
|
const metrics: MetricsAccumulator;
|
|
@@ -27,3 +26,4 @@ declare global {
|
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
}
|
|
29
|
+
export {};
|
package/lib/utils/time.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
3
4
|
const ramda_1 = require("ramda");
|
|
5
|
+
const logger_1 = require("../service/logger");
|
|
4
6
|
exports.hrToMillis = ([seconds, nanoseconds]) => Math.round((seconds * 1e3) + (nanoseconds / 1e6));
|
|
7
|
+
exports.hrToMillisFloat = ([seconds, nanoseconds]) => {
|
|
8
|
+
return (seconds * 1e3) + (nanoseconds / 1e6);
|
|
9
|
+
};
|
|
10
|
+
exports.nanosecondsToSeconds = (nanoseconds) => {
|
|
11
|
+
return nanoseconds / 1e9;
|
|
12
|
+
};
|
|
5
13
|
exports.hrToNano = ([seconds, nanoseconds]) => seconds * 1e9 + nanoseconds;
|
|
6
14
|
exports.formatNano = (nanoseconds) => `${(nanoseconds / 1e9).toFixed(0)}s ${((nanoseconds / 1e6) % 1e3).toFixed(0)}ms`;
|
|
7
15
|
exports.reduceHrToNano = ramda_1.reduce((acc, hr) => acc + exports.hrToNano(hr), 0);
|
|
@@ -53,7 +61,7 @@ function timer(middleware) {
|
|
|
53
61
|
return middleware;
|
|
54
62
|
}
|
|
55
63
|
if (!middleware.name) {
|
|
56
|
-
|
|
64
|
+
logger_1.logOnceToDevConsole(`Please use a named function as handler for better metrics. ${middleware.toString()}`, logger_1.LogLevel.Warn);
|
|
57
65
|
}
|
|
58
66
|
return async (ctx, next) => {
|
|
59
67
|
if (!ctx.serverTiming) {
|
|
@@ -85,7 +93,7 @@ function timerForEvents(middleware) {
|
|
|
85
93
|
return middleware;
|
|
86
94
|
}
|
|
87
95
|
if (!middleware.name) {
|
|
88
|
-
|
|
96
|
+
logger_1.logOnceToDevConsole(`Please use a named function as handler for better metrics. ${middleware.toString()}`, logger_1.LogLevel.Warn);
|
|
89
97
|
}
|
|
90
98
|
return async (ctx, next) => {
|
|
91
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",
|
|
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": "
|
|
125
|
-
"typescript-json-schema": "^0.
|
|
124
|
+
"typescript": "3.9.7",
|
|
125
|
+
"typescript-json-schema": "^0.65.1"
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const HttpClient_1 = require("./HttpClient");
|
|
4
|
-
/**
|
|
5
|
-
* A client that can be instantiated by the Service runtime layer.
|
|
6
|
-
*/
|
|
7
|
-
class IOClient {
|
|
8
|
-
constructor(context, options) {
|
|
9
|
-
this.context = context;
|
|
10
|
-
this.options = options;
|
|
11
|
-
this.http = new HttpClient_1.HttpClient(Object.assign({ name: this.constructor.name }, context, options, { metrics: options && options.metrics }));
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.IOClient = IOClient;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { IOContext } from '../../service/typings';
|
|
2
|
-
import { HttpClient } from '../HttpClient';
|
|
3
|
-
import { InstanceOptions } from '../typings';
|
|
4
|
-
export declare const rootURL: (service: string, { region }: IOContext, { baseURL }: InstanceOptions) => string;
|
|
5
|
-
export declare const workspaceURL: (service: string, context: IOContext, opts: InstanceOptions) => string;
|
|
6
|
-
export declare const forWorkspace: (service: string, context: IOContext, opts: InstanceOptions) => HttpClient;
|
|
7
|
-
export declare const forRoot: (service: string, context: IOContext, opts: InstanceOptions) => HttpClient;
|
|
8
|
-
export declare const forExternal: (baseURL: string, context: IOContext, opts: InstanceOptions) => HttpClient;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const HttpClient_1 = require("../HttpClient");
|
|
4
|
-
const typings_1 = require("../typings");
|
|
5
|
-
exports.rootURL = (service, { region }, { baseURL }) => {
|
|
6
|
-
if (baseURL) {
|
|
7
|
-
return 'http://' + baseURL;
|
|
8
|
-
}
|
|
9
|
-
if (region) {
|
|
10
|
-
return `http://${service}.${region}.vtex.io`;
|
|
11
|
-
}
|
|
12
|
-
throw new Error('Missing required: should specify either {region} or {baseURL}');
|
|
13
|
-
};
|
|
14
|
-
exports.workspaceURL = (service, context, opts) => {
|
|
15
|
-
const { account, workspace } = context;
|
|
16
|
-
if (!account || !workspace) {
|
|
17
|
-
throw new Error('Missing required arguments: {account, workspace}');
|
|
18
|
-
}
|
|
19
|
-
return exports.rootURL(service, context, opts) + `/${account}/${workspace}`;
|
|
20
|
-
};
|
|
21
|
-
exports.forWorkspace = (service, context, opts) => {
|
|
22
|
-
const baseURL = exports.workspaceURL(service, context, opts);
|
|
23
|
-
return new HttpClient_1.HttpClient(Object.assign({}, context, opts, { authType: typings_1.AuthType.bearer, baseURL }));
|
|
24
|
-
};
|
|
25
|
-
exports.forRoot = (service, context, opts) => {
|
|
26
|
-
const baseURL = exports.rootURL(service, context, opts);
|
|
27
|
-
return new HttpClient_1.HttpClient(Object.assign({}, context, opts, { authType: typings_1.AuthType.bearer, baseURL }));
|
|
28
|
-
};
|
|
29
|
-
exports.forExternal = (baseURL, context, opts) => {
|
|
30
|
-
return new HttpClient_1.HttpClient(Object.assign({}, context, opts, { baseURL }));
|
|
31
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Limit } from 'p-limit';
|
|
2
|
-
import { MiddlewareContext } from '../typings';
|
|
3
|
-
export declare const defaultsMiddleware: (baseURL: string | undefined, rawHeaders: Record<string, string>, params: Record<string, string> | undefined, timeout: number, retries?: number | undefined, verbose?: boolean | undefined) => (ctx: MiddlewareContext, next: () => Promise<void>) => Promise<void>;
|
|
4
|
-
export declare const routerCacheMiddleware: (ctx: MiddlewareContext, next: () => Promise<void>) => Promise<void>;
|
|
5
|
-
export declare const requestMiddleware: (limit?: Limit | undefined) => (ctx: MiddlewareContext, next: () => Promise<void>) => Promise<void>;
|
|
6
|
-
export declare function httpAgentStats(): {
|
|
7
|
-
freeSockets: number;
|
|
8
|
-
pendingRequests: number;
|
|
9
|
-
sockets: number;
|
|
10
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
6
|
-
if (mod && mod.__esModule) return mod;
|
|
7
|
-
var result = {};
|
|
8
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
9
|
-
result["default"] = mod;
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
const agentkeepalive_1 = __importDefault(require("agentkeepalive"));
|
|
14
|
-
const axios_1 = __importDefault(require("axios"));
|
|
15
|
-
const axios_retry_1 = __importStar(require("axios-retry"));
|
|
16
|
-
const qs_1 = require("qs");
|
|
17
|
-
const ramda_1 = require("ramda");
|
|
18
|
-
const renameBy_1 = require("../../utils/renameBy");
|
|
19
|
-
const retry_1 = require("../../utils/retry");
|
|
20
|
-
const httpAgent = new agentkeepalive_1.default({
|
|
21
|
-
freeSocketTimeout: 30 * 1000,
|
|
22
|
-
keepAlive: true,
|
|
23
|
-
maxFreeSockets: 256,
|
|
24
|
-
socketActiveTTL: 120 * 1000,
|
|
25
|
-
});
|
|
26
|
-
const http = axios_1.default.create({
|
|
27
|
-
httpAgent,
|
|
28
|
-
});
|
|
29
|
-
axios_retry_1.default(http, {
|
|
30
|
-
retries: 0,
|
|
31
|
-
retryCondition: retry_1.isAbortedOrNetworkErrorOrRouterTimeout,
|
|
32
|
-
retryDelay: axios_retry_1.exponentialDelay,
|
|
33
|
-
shouldResetTimeout: true,
|
|
34
|
-
});
|
|
35
|
-
const paramsSerializer = (params) => {
|
|
36
|
-
return qs_1.stringify(params, { arrayFormat: 'repeat' });
|
|
37
|
-
};
|
|
38
|
-
exports.defaultsMiddleware = (baseURL, rawHeaders, params, timeout, retries, verbose) => {
|
|
39
|
-
const countByMetric = {};
|
|
40
|
-
const headers = renameBy_1.renameBy(ramda_1.toLower, rawHeaders);
|
|
41
|
-
return async (ctx, next) => {
|
|
42
|
-
ctx.config = Object.assign({ 'axios-retry': retries ? { retries } : undefined, baseURL, maxRedirects: 0, timeout, validateStatus: status => (status >= 200 && status < 300), verbose }, ctx.config, { headers: Object.assign({}, headers, renameBy_1.renameBy(ramda_1.toLower, ctx.config.headers)), params: Object.assign({}, params, ctx.config.params), paramsSerializer });
|
|
43
|
-
if (ctx.config.verbose && ctx.config.metric) {
|
|
44
|
-
const current = countByMetric[ctx.config.metric];
|
|
45
|
-
countByMetric[ctx.config.metric] = (current || 0) + 1;
|
|
46
|
-
ctx.config.count = countByMetric[ctx.config.metric];
|
|
47
|
-
ctx.config.label = `${ctx.config.metric}#${ctx.config.count}`;
|
|
48
|
-
}
|
|
49
|
-
await next();
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
const ROUTER_CACHE_KEY = 'x-router-cache';
|
|
53
|
-
const ROUTER_CACHE_HIT = 'HIT';
|
|
54
|
-
const ROUTER_CACHE_REVALIDATED = 'REVALIDATED';
|
|
55
|
-
const ROUTER_CACHE_KEY_PATH = ['response', 'headers', ROUTER_CACHE_KEY];
|
|
56
|
-
const ROUTER_RESPONSE_STATUS_PATH = ['response', 'status'];
|
|
57
|
-
exports.routerCacheMiddleware = async (ctx, next) => {
|
|
58
|
-
await next();
|
|
59
|
-
const routerCacheHit = ramda_1.path(ROUTER_CACHE_KEY_PATH, ctx);
|
|
60
|
-
const status = ramda_1.path(ROUTER_RESPONSE_STATUS_PATH, ctx);
|
|
61
|
-
if (routerCacheHit === ROUTER_CACHE_HIT || (routerCacheHit === ROUTER_CACHE_REVALIDATED && status !== 304)) {
|
|
62
|
-
ctx.cacheHit = Object.assign({ memory: 0, revalidated: 0 }, ctx.cacheHit, { router: 1 });
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
exports.requestMiddleware = (limit) => async (ctx, next) => {
|
|
66
|
-
const makeRequest = () => http.request(ctx.config);
|
|
67
|
-
ctx.response = await (limit ? limit(makeRequest) : makeRequest());
|
|
68
|
-
};
|
|
69
|
-
function count(obj) {
|
|
70
|
-
try {
|
|
71
|
-
return Object.values(obj).reduce((acc, val) => acc += val.length, 0);
|
|
72
|
-
}
|
|
73
|
-
catch (_) {
|
|
74
|
-
return 0;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function httpAgentStats() {
|
|
78
|
-
const sockets = count(httpAgent.sockets);
|
|
79
|
-
const freeSockets = count(httpAgent.freeSockets);
|
|
80
|
-
const pendingRequests = count(httpAgent.requests);
|
|
81
|
-
return {
|
|
82
|
-
freeSockets,
|
|
83
|
-
pendingRequests,
|
|
84
|
-
sockets,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
exports.httpAgentStats = httpAgentStats;
|
package/lib/IODataSource.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { DataSource, DataSourceConfig } from 'apollo-datasource';
|
|
2
|
-
import { HttpClient, InstanceOptions } from './HttpClient';
|
|
3
|
-
import { IOContext, ServiceContext } from './service/typings';
|
|
4
|
-
interface HttpClientFactoryOptions {
|
|
5
|
-
service: string | void;
|
|
6
|
-
context: IOContext | void;
|
|
7
|
-
options: InstanceOptions | void;
|
|
8
|
-
}
|
|
9
|
-
export declare type HttpClientFactory = (opts: HttpClientFactoryOptions) => HttpClient | void;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Extend one of the subclasses of IOClient instead.
|
|
12
|
-
*/
|
|
13
|
-
export declare abstract class IODataSource extends DataSource<ServiceContext> {
|
|
14
|
-
protected context?: IOContext | undefined;
|
|
15
|
-
private options;
|
|
16
|
-
protected abstract httpClientFactory: HttpClientFactory;
|
|
17
|
-
protected service: string | void;
|
|
18
|
-
private httpClient;
|
|
19
|
-
private initialized;
|
|
20
|
-
constructor(context?: IOContext | undefined, options?: InstanceOptions);
|
|
21
|
-
initialize(config: DataSourceConfig<ServiceContext>): void;
|
|
22
|
-
readonly http: HttpClient;
|
|
23
|
-
}
|
|
24
|
-
export declare const forWorkspace: HttpClientFactory;
|
|
25
|
-
export declare const forRoot: HttpClientFactory;
|
|
26
|
-
export declare const forExternal: HttpClientFactory;
|
|
27
|
-
export {};
|
package/lib/IODataSource.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const apollo_datasource_1 = require("apollo-datasource");
|
|
4
|
-
const HttpClient_1 = require("./HttpClient");
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Extend one of the subclasses of IOClient instead.
|
|
7
|
-
*/
|
|
8
|
-
class IODataSource extends apollo_datasource_1.DataSource {
|
|
9
|
-
constructor(context, options = {}) {
|
|
10
|
-
super();
|
|
11
|
-
this.context = context;
|
|
12
|
-
this.options = options;
|
|
13
|
-
this.service = undefined;
|
|
14
|
-
this.httpClient = undefined;
|
|
15
|
-
this.initialized = false;
|
|
16
|
-
}
|
|
17
|
-
initialize(config) {
|
|
18
|
-
const { context: { vtex: context }, cache: cacheStorage } = config;
|
|
19
|
-
this.context = context;
|
|
20
|
-
this.httpClient = this.httpClientFactory({
|
|
21
|
-
context,
|
|
22
|
-
options: Object.assign({ cacheStorage }, this.options),
|
|
23
|
-
service: this.service,
|
|
24
|
-
});
|
|
25
|
-
this.initialized = true;
|
|
26
|
-
}
|
|
27
|
-
get http() {
|
|
28
|
-
if (!this.initialized) {
|
|
29
|
-
this.initialize({ context: { vtex: this.context } });
|
|
30
|
-
}
|
|
31
|
-
if (this.httpClient) {
|
|
32
|
-
return this.httpClient;
|
|
33
|
-
}
|
|
34
|
-
throw new Error('IO Datasource was not initialized nor constructed with a context');
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.IODataSource = IODataSource;
|
|
38
|
-
exports.forWorkspace = ({ context, service, options }) => (context && service)
|
|
39
|
-
? HttpClient_1.HttpClient.forWorkspace(service, context, options || {})
|
|
40
|
-
: undefined;
|
|
41
|
-
exports.forRoot = ({ context, service, options }) => (context && service)
|
|
42
|
-
? HttpClient_1.HttpClient.forRoot(service, context, options || {})
|
|
43
|
-
: undefined;
|
|
44
|
-
exports.forExternal = ({ context, service, options }) => (context && service)
|
|
45
|
-
? HttpClient_1.HttpClient.forExternal(service, context, options || {})
|
|
46
|
-
: undefined;
|
package/lib/clients/Apps.d.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IncomingMessage } from 'http';
|
|
3
|
-
import { Readable, Writable } from 'stream';
|
|
4
|
-
import { ZlibOptions } from 'zlib';
|
|
5
|
-
import { InfraClient, InstanceOptions } from '../HttpClient';
|
|
6
|
-
import { AppBundleLinked, AppFilesList, AppManifest } from '../responses';
|
|
7
|
-
import { IOContext } from '../service/typings';
|
|
8
|
-
export declare class Apps extends InfraClient {
|
|
9
|
-
private _routes;
|
|
10
|
-
private diskCache;
|
|
11
|
-
private memoryCache;
|
|
12
|
-
private readonly routes;
|
|
13
|
-
constructor(context: IOContext, options?: InstanceOptions);
|
|
14
|
-
installApp: (descriptor: string) => Promise<void>;
|
|
15
|
-
uninstallApp: (app: string) => Promise<import("..").IOResponse<void>>;
|
|
16
|
-
acknowledgeApp: (app: string, service: string) => Promise<void>;
|
|
17
|
-
link: (app: string, files: Change[], { zlib }?: ZipOptions) => Promise<AppBundleLinked>;
|
|
18
|
-
patch: (app: string, changes: Change[], { zlib }?: ZipOptions) => Promise<void>;
|
|
19
|
-
unlink: (app: string) => Promise<import("..").IOResponse<void>>;
|
|
20
|
-
unlinkAll: () => Promise<import("..").IOResponse<void>>;
|
|
21
|
-
saveAppSettings: (app: string, settings: any) => Promise<void>;
|
|
22
|
-
listApps: ({ oldVersion, since, service }?: ListAppsOptions) => Promise<AppsList>;
|
|
23
|
-
listAppFiles: (app: string, { prefix, nextMarker }?: ListFilesOptions) => Promise<AppFilesList>;
|
|
24
|
-
listLinks: () => Promise<string[]>;
|
|
25
|
-
getAppFile: (app: string, path: string, staleIfError?: boolean | undefined) => Promise<{
|
|
26
|
-
data: Buffer;
|
|
27
|
-
headers: any;
|
|
28
|
-
}>;
|
|
29
|
-
getAppJSON: <T extends object | null>(app: string, path: string, nullIfNotFound?: boolean | undefined) => Promise<T>;
|
|
30
|
-
getLinkedAppByWorkspaceJSON: <T extends object | null>(app: string, path: string, nullIfNotFound?: boolean | undefined) => Promise<T>;
|
|
31
|
-
getAppFileStream: (app: string, path: string) => Promise<IncomingMessage>;
|
|
32
|
-
getApp: (app: string) => Promise<AppManifest>;
|
|
33
|
-
getAppSettings: (app: string) => Promise<any>;
|
|
34
|
-
getAllAppsSettings: (listAppsOptions?: ListAppsOptions) => Promise<AppsSettings>;
|
|
35
|
-
getAppBundle: (app: string, bundlePath: string, generatePackageJson: boolean) => Promise<Readable>;
|
|
36
|
-
unpackAppBundle: (app: string, bundlePath: string, unpackPath: string, generatePackageJson: boolean) => Promise<Writable>;
|
|
37
|
-
getAppsMetaInfos: (filter?: string | undefined, staleWhileRevalidate?: boolean) => Promise<AppMetaInfo[]>;
|
|
38
|
-
getDependencies: (filter?: string) => Promise<Record<string, string[]>>;
|
|
39
|
-
updateDependencies: () => Promise<Record<string, string[]>>;
|
|
40
|
-
updateDependency: (name: string, version: string, registry: string) => Promise<void>;
|
|
41
|
-
resolveDependencies: (apps: string[], registries: string[], filter?: string) => Promise<any>;
|
|
42
|
-
resolveDependenciesWithManifest: (manifest: AppManifest, filter?: string) => Promise<Record<string, string[]>>;
|
|
43
|
-
private installRuntime;
|
|
44
|
-
}
|
|
45
|
-
interface ZipOptions {
|
|
46
|
-
zlib?: ZlibOptions;
|
|
47
|
-
}
|
|
48
|
-
export interface AppMetaInfo {
|
|
49
|
-
id: string;
|
|
50
|
-
settingsSchema?: Record<string, any>;
|
|
51
|
-
_resolvedDependencies: Record<string, string>;
|
|
52
|
-
_isRoot: boolean;
|
|
53
|
-
_buildFeatures: Record<string, string[]>;
|
|
54
|
-
}
|
|
55
|
-
export interface WorkspaceMetaInfo {
|
|
56
|
-
apps: AppMetaInfo[];
|
|
57
|
-
}
|
|
58
|
-
export interface AppsListItem {
|
|
59
|
-
app: string;
|
|
60
|
-
id: string;
|
|
61
|
-
location: string;
|
|
62
|
-
}
|
|
63
|
-
export interface AppsList {
|
|
64
|
-
data: AppsListItem[];
|
|
65
|
-
}
|
|
66
|
-
export interface Change {
|
|
67
|
-
path: string;
|
|
68
|
-
content: string | Readable | Buffer;
|
|
69
|
-
}
|
|
70
|
-
export interface ListAppsOptions {
|
|
71
|
-
oldVersion?: string;
|
|
72
|
-
context?: string[];
|
|
73
|
-
since?: string;
|
|
74
|
-
service?: string;
|
|
75
|
-
}
|
|
76
|
-
export interface ListFilesOptions {
|
|
77
|
-
prefix?: string;
|
|
78
|
-
context?: string[];
|
|
79
|
-
nextMarker?: string;
|
|
80
|
-
}
|
|
81
|
-
export interface AppsSettings {
|
|
82
|
-
[app: string]: any;
|
|
83
|
-
}
|
|
84
|
-
export {};
|