@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
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const constants_1 = require("../constants");
|
|
4
|
-
const HttpClient_1 = require("../HttpClient");
|
|
5
|
-
const routes = {
|
|
6
|
-
Account: (account) => `/${account}`,
|
|
7
|
-
Promote: (account) => `${routes.Workspace(account, constants_1.DEFAULT_WORKSPACE)}/_promote`,
|
|
8
|
-
Workspace: (account, workspace) => `${routes.Account(account)}/${workspace}`,
|
|
9
|
-
};
|
|
10
|
-
class Workspaces extends HttpClient_1.InfraClient {
|
|
11
|
-
constructor(context, options) {
|
|
12
|
-
super('router', context, options, true);
|
|
13
|
-
this.list = (account) => {
|
|
14
|
-
return this.http.get(routes.Account(account), { metric: 'workspaces-list' });
|
|
15
|
-
};
|
|
16
|
-
this.get = (account, workspace) => {
|
|
17
|
-
return this.http.get(routes.Workspace(account, workspace), { metric: 'workspaces-get' });
|
|
18
|
-
};
|
|
19
|
-
this.set = (account, workspace, metadata) => {
|
|
20
|
-
return this.http.put(routes.Workspace(account, workspace), metadata, { metric: 'workspaces-set' });
|
|
21
|
-
};
|
|
22
|
-
this.create = (account, workspace, production) => {
|
|
23
|
-
return this.http.post(routes.Account(account), { name: workspace, production }, { metric: 'workspaces-create' });
|
|
24
|
-
};
|
|
25
|
-
this.delete = (account, workspace) => {
|
|
26
|
-
return this.http.delete(routes.Workspace(account, workspace), { metric: 'workspaces-delete' });
|
|
27
|
-
};
|
|
28
|
-
this.reset = (account, workspace, metadata = {}) => {
|
|
29
|
-
const params = { reset: true };
|
|
30
|
-
const metric = 'workspaces-reset';
|
|
31
|
-
return this.http.put(routes.Workspace(account, workspace), metadata, { params, metric });
|
|
32
|
-
};
|
|
33
|
-
this.promote = (account, workspace, conflictResolutionStrategy) => {
|
|
34
|
-
return this.http.put(routes.Promote(account), { workspace, conflictResolutionStrategy }, { metric: 'workspaces-promote' });
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.Workspaces = Workspaces;
|
package/lib/service/Runtime.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { IOClients } from '../clients/IOClients';
|
|
2
|
-
import { EnvMetric, MetricsAccumulator } from '../metrics/MetricsAccumulator';
|
|
3
|
-
import { Service } from './Service';
|
|
4
|
-
import { RouteHandler, ServiceDescriptor } from './typings';
|
|
5
|
-
export declare class Runtime<ClientsT extends IOClients = IOClients, StateT = void, CustomT = void> {
|
|
6
|
-
routes: Record<string, RouteHandler<ClientsT, StateT, CustomT>>;
|
|
7
|
-
events: any;
|
|
8
|
-
statusTrack?: () => EnvMetric[];
|
|
9
|
-
__is_service: true;
|
|
10
|
-
constructor(service: Service<ClientsT, StateT, CustomT>, descriptor: ServiceDescriptor);
|
|
11
|
-
}
|
|
12
|
-
declare global {
|
|
13
|
-
namespace NodeJS {
|
|
14
|
-
interface Global {
|
|
15
|
-
metrics: MetricsAccumulator;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
package/lib/service/Runtime.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ramda_1 = require("ramda");
|
|
4
|
-
const IOClients_1 = require("../clients/IOClients");
|
|
5
|
-
const MetricsAccumulator_1 = require("../metrics/MetricsAccumulator");
|
|
6
|
-
const unhandled_1 = require("../utils/unhandled");
|
|
7
|
-
const events_1 = require("./events");
|
|
8
|
-
const graphql_1 = require("./graphql");
|
|
9
|
-
const http_1 = require("./http");
|
|
10
|
-
const linked = !!process.env.VTEX_APP_LINK;
|
|
11
|
-
const noop = () => [];
|
|
12
|
-
const defaultClients = {
|
|
13
|
-
options: {
|
|
14
|
-
messages: {
|
|
15
|
-
concurrency: 10,
|
|
16
|
-
retries: 2,
|
|
17
|
-
timeout: 1000,
|
|
18
|
-
},
|
|
19
|
-
messagesGraphQL: {
|
|
20
|
-
concurrency: 10,
|
|
21
|
-
retries: 2,
|
|
22
|
-
timeout: 1000,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
class Runtime {
|
|
27
|
-
constructor(service,
|
|
28
|
-
// tslint:disable-next-line
|
|
29
|
-
descriptor) {
|
|
30
|
-
this.__is_service = true; // tslint:disable-line
|
|
31
|
-
const { config } = service;
|
|
32
|
-
const clients = {
|
|
33
|
-
implementation: config.clients && config.clients.implementation || IOClients_1.IOClients,
|
|
34
|
-
options: Object.assign({}, defaultClients.options, config.clients ? config.clients.options : null),
|
|
35
|
-
};
|
|
36
|
-
const Clients = clients.implementation;
|
|
37
|
-
this.routes = config.routes
|
|
38
|
-
? ramda_1.map(http_1.createHttpRoute(Clients, clients.options), config.routes)
|
|
39
|
-
: {};
|
|
40
|
-
if (config.graphql) {
|
|
41
|
-
let graphqlRoute = graphql_1.GRAPHQL_ROUTE;
|
|
42
|
-
if (descriptor.routes && descriptor.routes[graphql_1.GRAPHQL_ROUTE_LEGACY]) {
|
|
43
|
-
console.warn('Using legacy graphql route id', graphql_1.GRAPHQL_ROUTE_LEGACY);
|
|
44
|
-
graphqlRoute = graphql_1.GRAPHQL_ROUTE_LEGACY;
|
|
45
|
-
}
|
|
46
|
-
this.routes[graphqlRoute] = graphql_1.createGraphQLRoute(config.graphql, Clients, clients.options);
|
|
47
|
-
}
|
|
48
|
-
this.events = config.events
|
|
49
|
-
? ramda_1.map(events_1.createEventHandler(Clients, clients.options), config.events)
|
|
50
|
-
: {};
|
|
51
|
-
this.statusTrack = linked ? noop : global.metrics.statusTrack;
|
|
52
|
-
unhandled_1.addProcessListeners();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.Runtime = Runtime;
|
|
56
|
-
global.metrics = new MetricsAccumulator_1.MetricsAccumulator();
|
|
57
|
-
metrics.trackCache('graphql-runtime', graphql_1.graphqlRuntimeCacheStorage);
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { ClientsImplementation, IOClients } from '../../clients/IOClients';
|
|
2
|
-
import { InstanceOptions } from '../../HttpClient';
|
|
3
|
-
export declare const createEventHandler: <ClientsT extends IOClients, StateT, CustomT>(Clients: ClientsImplementation<ClientsT>, options: Record<string, InstanceOptions>) => (handler: import("koa-compose").Middleware<import("../typings").EventContext<ClientsT, StateT>> | import("koa-compose").Middleware<import("../typings").EventContext<ClientsT, StateT>>[]) => import("koa-compose").ComposedMiddleware<import("../typings").EventContext<IOClients, {}>>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ramda_1 = require("ramda");
|
|
4
|
-
const clients_1 = require("../http/middlewares/clients");
|
|
5
|
-
const error_1 = require("../http/middlewares/error");
|
|
6
|
-
const timings_1 = require("../http/middlewares/timings");
|
|
7
|
-
const compose_1 = require("../utils/compose");
|
|
8
|
-
exports.createEventHandler = (Clients, options) => {
|
|
9
|
-
return (handler) => {
|
|
10
|
-
const middlewares = Array.isArray(handler) ? handler : [handler];
|
|
11
|
-
const pipeline = [clients_1.clients(Clients, options), timings_1.timings, error_1.error, contextAdapter(middlewares)];
|
|
12
|
-
return compose_1.composeForEvents(pipeline);
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
function contextAdapter(middlewares) {
|
|
16
|
-
return async function middlewareCascade(ctx) {
|
|
17
|
-
const ctxEvent = ramda_1.merge(ramda_1.pick(['clients', 'state', 'vtex', 'timings', 'metrics'], ctx), Object.assign({}, ctx.vtex, { body: ctx.state.body, key: ctx.vtex.eventInfo ? ctx.vtex.eventInfo.key : '', sender: ctx.vtex.eventInfo ? ctx.vtex.eventInfo.sender : '', subject: ctx.vtex.eventInfo ? ctx.vtex.eventInfo.subject : '' }));
|
|
18
|
-
await compose_1.composeForEvents(middlewares)(ctxEvent);
|
|
19
|
-
ctx.status = 204;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ClientsImplementation, IOClients } from '../../clients/IOClients';
|
|
2
|
-
import { InstanceOptions } from '../../HttpClient';
|
|
3
|
-
import { GraphQLOptions } from '../typings';
|
|
4
|
-
export declare const GRAPHQL_ROUTE_LEGACY = "__graphql";
|
|
5
|
-
export declare const GRAPHQL_ROUTE = "graphql";
|
|
6
|
-
export declare const createGraphQLRoute: <ClientsT extends IOClients, StateT, CustomT>(graphql: GraphQLOptions<ClientsT, StateT, CustomT>, Clients: ClientsImplementation<ClientsT>, options: Record<string, InstanceOptions>) => import("koa-compose").Middleware<import("../typings").ServiceContext<ClientsT, StateT, CustomT>>;
|
|
7
|
-
export { graphqlRuntimeCacheStorage } from './middlewares/run';
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const http_1 = require("../http");
|
|
4
|
-
const error_1 = require("./middlewares/error");
|
|
5
|
-
const formatters_1 = require("./middlewares/formatters");
|
|
6
|
-
const query_1 = require("./middlewares/query");
|
|
7
|
-
const response_1 = require("./middlewares/response");
|
|
8
|
-
const run_1 = require("./middlewares/run");
|
|
9
|
-
const schema_1 = require("./middlewares/schema");
|
|
10
|
-
const timings_1 = require("./middlewares/timings");
|
|
11
|
-
const upload_1 = require("./middlewares/upload");
|
|
12
|
-
exports.GRAPHQL_ROUTE_LEGACY = '__graphql';
|
|
13
|
-
exports.GRAPHQL_ROUTE = 'graphql';
|
|
14
|
-
exports.createGraphQLRoute = (graphql, Clients, options) => {
|
|
15
|
-
const injectGraphql = async (ctx, next) => {
|
|
16
|
-
ctx.graphql = Object.assign({}, graphql);
|
|
17
|
-
await next();
|
|
18
|
-
delete ctx.graphql;
|
|
19
|
-
};
|
|
20
|
-
return http_1.createHttpRoute(Clients, options)([
|
|
21
|
-
injectGraphql,
|
|
22
|
-
timings_1.graphqlTimings,
|
|
23
|
-
error_1.graphqlError,
|
|
24
|
-
upload_1.upload,
|
|
25
|
-
query_1.parseQuery,
|
|
26
|
-
formatters_1.createFormatters,
|
|
27
|
-
schema_1.injectSchema,
|
|
28
|
-
run_1.run,
|
|
29
|
-
response_1.response,
|
|
30
|
-
]);
|
|
31
|
-
};
|
|
32
|
-
var run_2 = require("./middlewares/run");
|
|
33
|
-
exports.graphqlRuntimeCacheStorage = run_2.graphqlRuntimeCacheStorage;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ramda_1 = require("ramda");
|
|
4
|
-
const Logger_1 = require("../../../clients/Logger");
|
|
5
|
-
const constants_1 = require("../../../constants");
|
|
6
|
-
const RequestCancelledError_1 = require("../../../errors/RequestCancelledError");
|
|
7
|
-
const array_1 = require("../utils/array");
|
|
8
|
-
const pathname_1 = require("../utils/pathname");
|
|
9
|
-
const CACHE_CONTROL_HEADER = 'cache-control';
|
|
10
|
-
const META_HEADER = 'x-vtex-meta';
|
|
11
|
-
const ETAG_HEADER = 'etag';
|
|
12
|
-
const TWO_SECONDS_S = 2;
|
|
13
|
-
const arrayHasError = ramda_1.any(ramda_1.has('errors'));
|
|
14
|
-
const filterErrors = ramda_1.filter(ramda_1.has('errors'));
|
|
15
|
-
const chainErrors = ramda_1.chain(ramda_1.prop('errors'));
|
|
16
|
-
const hasError = ramda_1.compose(arrayHasError, array_1.toArray);
|
|
17
|
-
const parseError = ramda_1.compose(chainErrors, filterErrors, array_1.toArray);
|
|
18
|
-
const parseErrorResponse = (response) => {
|
|
19
|
-
if (hasError(response)) {
|
|
20
|
-
return parseError(response);
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
};
|
|
24
|
-
async function graphqlError(ctx, next) {
|
|
25
|
-
const { vtex: { production, route: { id, }, }, } = ctx;
|
|
26
|
-
let graphQLErrors = null;
|
|
27
|
-
try {
|
|
28
|
-
await next();
|
|
29
|
-
graphQLErrors = parseErrorResponse(ctx.graphql.graphqlResponse || {});
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
if (e.code === RequestCancelledError_1.cancelledErrorCode) {
|
|
33
|
-
ctx.status = RequestCancelledError_1.cancelledRequestStatus;
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const formatError = ctx.graphql.formatters.formatError;
|
|
37
|
-
if (e.isGraphQLError) {
|
|
38
|
-
const response = JSON.parse(e.message);
|
|
39
|
-
graphQLErrors = parseError(response);
|
|
40
|
-
ctx.body = response;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
graphQLErrors = [formatError(e)];
|
|
44
|
-
ctx.body = { errors: graphQLErrors };
|
|
45
|
-
}
|
|
46
|
-
// Add response
|
|
47
|
-
ctx.status = e.statusCode || 500;
|
|
48
|
-
if (e.headers) {
|
|
49
|
-
ctx.set(e.headers);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
finally {
|
|
53
|
-
if (graphQLErrors) {
|
|
54
|
-
const uniqueErrors = ramda_1.uniqBy((e) => {
|
|
55
|
-
if (e.extensions.exception && e.extensions.exception.request) {
|
|
56
|
-
return e.extensions.exception.request.path;
|
|
57
|
-
}
|
|
58
|
-
return e;
|
|
59
|
-
}, graphQLErrors);
|
|
60
|
-
// Reduce size of `variables` prop in the errors.
|
|
61
|
-
ramda_1.map((e) => {
|
|
62
|
-
if (e.query && e.query.variables) {
|
|
63
|
-
const stringifiedVariables = JSON.stringify(e.query.variables);
|
|
64
|
-
e.query.variables = stringifiedVariables.length <= 1024 ? stringifiedVariables : '[variables too long]';
|
|
65
|
-
}
|
|
66
|
-
}, uniqueErrors);
|
|
67
|
-
console.error(`[node-vtex-api graphql errors] total=${graphQLErrors.length} unique=${uniqueErrors.length}`, uniqueErrors);
|
|
68
|
-
ctx.graphql.status = 'error';
|
|
69
|
-
// Do not generate etag for errors
|
|
70
|
-
ctx.remove(META_HEADER);
|
|
71
|
-
ctx.remove(ETAG_HEADER);
|
|
72
|
-
// In production errors, add two second cache
|
|
73
|
-
if (production) {
|
|
74
|
-
ctx.set(CACHE_CONTROL_HEADER, `public, max-age=${TWO_SECONDS_S}`);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
ctx.set(CACHE_CONTROL_HEADER, `no-cache, no-store`);
|
|
78
|
-
}
|
|
79
|
-
// Log each error to splunk individually
|
|
80
|
-
ramda_1.forEach((err) => {
|
|
81
|
-
// Prevent logging cancellation error (it's not an error)
|
|
82
|
-
if (!err.extensions.exception || err.extensions.exception.code !== RequestCancelledError_1.cancelledErrorCode) {
|
|
83
|
-
// Add pathName to each error
|
|
84
|
-
if (err.path) {
|
|
85
|
-
err.pathName = pathname_1.generatePathName(err.path);
|
|
86
|
-
}
|
|
87
|
-
const log = Object.assign({}, err, { routeId: id });
|
|
88
|
-
// Grab level from originalError, default to "error" level.
|
|
89
|
-
let level = err.extensions.exception && err.extensions.exception.level;
|
|
90
|
-
if (!level || !(level === Logger_1.LogLevel.Error || level === Logger_1.LogLevel.Warn)) {
|
|
91
|
-
level = Logger_1.LogLevel.Error;
|
|
92
|
-
}
|
|
93
|
-
ctx.vtex.logger.log(log, level);
|
|
94
|
-
}
|
|
95
|
-
if (!constants_1.LINKED && err.extensions.exception && err.extensions.exception.sensitive) {
|
|
96
|
-
delete err.extensions.exception.sensitive;
|
|
97
|
-
}
|
|
98
|
-
}, uniqueErrors);
|
|
99
|
-
// Expose graphQLErrors with pathNames to timings middleware
|
|
100
|
-
ctx.graphql.graphQLErrors = uniqueErrors;
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
ctx.graphql.status = 'success';
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
exports.graphqlError = graphqlError;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const apollo_server_errors_1 = require("apollo-server-errors");
|
|
4
|
-
const ramda_1 = require("ramda");
|
|
5
|
-
const error_1 = require("../../../utils/error");
|
|
6
|
-
const ERROR_FIELD_WHITELIST = ['message', 'path', 'stack', 'extensions', 'statusCode', 'name', 'headers', 'originalError', 'code'];
|
|
7
|
-
// formatError overrides the default option in runHttpQuery, which
|
|
8
|
-
// does not keep track of the error stack. All non-enumerable
|
|
9
|
-
// properties of Error (including stack) need to be returned
|
|
10
|
-
// explicitly, otherwise will not show up after a JSON.stringify call
|
|
11
|
-
const createFormatError = (details) => (error) => {
|
|
12
|
-
const formattedError = ramda_1.pick(ERROR_FIELD_WHITELIST, error);
|
|
13
|
-
if (!formattedError.extensions) {
|
|
14
|
-
formattedError.extensions = {
|
|
15
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
if (formattedError.originalError) {
|
|
19
|
-
formattedError.originalError = error_1.cleanError(formattedError.originalError);
|
|
20
|
-
if (formattedError.stack === formattedError.originalError.stack) {
|
|
21
|
-
delete formattedError.originalError.stack;
|
|
22
|
-
}
|
|
23
|
-
if (!formattedError.extensions.exception) {
|
|
24
|
-
formattedError.extensions.exception = Object.assign({ message: formattedError.originalError.message, name: formattedError.originalError.name }, ramda_1.omit(error_1.SENSITIVE_EXCEPTION_FIELDS, formattedError.originalError), { sensitive: ramda_1.pick(error_1.SENSITIVE_EXCEPTION_FIELDS, formattedError.originalError) });
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
const mergedExceptions = Object.assign({}, formattedError.originalError, formattedError.extensions.exception);
|
|
28
|
-
const extendedException = Object.assign({ message: formattedError.originalError.message, name: formattedError.originalError.name }, ramda_1.omit(error_1.SENSITIVE_EXCEPTION_FIELDS, mergedExceptions), { sensitive: ramda_1.pick(error_1.SENSITIVE_EXCEPTION_FIELDS, mergedExceptions) });
|
|
29
|
-
formattedError.extensions.exception = error_1.cleanError(extendedException);
|
|
30
|
-
}
|
|
31
|
-
// Make originalError not enumerable to prevent duplicated log and response information
|
|
32
|
-
Object.defineProperty(formattedError, 'originalError', { enumerable: false });
|
|
33
|
-
}
|
|
34
|
-
Object.assign(formattedError, details);
|
|
35
|
-
return formattedError;
|
|
36
|
-
};
|
|
37
|
-
const createFormatResponse = (formatter) => (response) => {
|
|
38
|
-
const { errors = null } = response || {};
|
|
39
|
-
return Object.assign({}, response, { errors: Array.isArray(errors) ? apollo_server_errors_1.formatApolloErrors(errors, { formatter }) : undefined });
|
|
40
|
-
};
|
|
41
|
-
async function createFormatters(ctx, next) {
|
|
42
|
-
const { headers: { 'x-forwarded-host': forwardedHost, 'x-forwarded-proto': forwardedProto, 'x-vtex-platform': platform, }, vtex: { operationId, requestId, }, } = ctx;
|
|
43
|
-
// Do not log variables for file uploads
|
|
44
|
-
const variables = ctx.request.is('multipart/form-data')
|
|
45
|
-
? '[GraphQL Upload]'
|
|
46
|
-
: ctx.graphql.query && ctx.graphql.query.variables;
|
|
47
|
-
const query = Object.assign({}, ctx.graphql.query, { variables });
|
|
48
|
-
const details = {
|
|
49
|
-
forwardedHost,
|
|
50
|
-
forwardedProto,
|
|
51
|
-
operationId,
|
|
52
|
-
platform,
|
|
53
|
-
query,
|
|
54
|
-
requestId,
|
|
55
|
-
};
|
|
56
|
-
const formatError = createFormatError(details);
|
|
57
|
-
const formatResponse = createFormatResponse(formatError);
|
|
58
|
-
ctx.graphql.formatters = {
|
|
59
|
-
formatError,
|
|
60
|
-
formatResponse,
|
|
61
|
-
};
|
|
62
|
-
await next();
|
|
63
|
-
}
|
|
64
|
-
exports.createFormatters = createFormatters;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const co_body_1 = require("co-body");
|
|
4
|
-
const ramda_1 = require("ramda");
|
|
5
|
-
const url_1 = require("url");
|
|
6
|
-
const constants_1 = require("../../../constants");
|
|
7
|
-
const parseVariables = (query) => {
|
|
8
|
-
if (query && query[constants_1.BODY_HASH]) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
if (query && typeof query.variables === 'string') {
|
|
12
|
-
query.variables = JSON.parse(query.variables);
|
|
13
|
-
}
|
|
14
|
-
return query;
|
|
15
|
-
};
|
|
16
|
-
const queryFromUrl = ramda_1.compose(parseVariables, ramda_1.prop('query'), ramda_1.partialRight(url_1.parse, [true]));
|
|
17
|
-
async function parseQuery(ctx, next) {
|
|
18
|
-
const { request, req } = ctx;
|
|
19
|
-
let query;
|
|
20
|
-
if (request.is('multipart/form-data')) {
|
|
21
|
-
query = request.body;
|
|
22
|
-
}
|
|
23
|
-
else if (request.method.toUpperCase() === 'POST') {
|
|
24
|
-
query = await co_body_1.json(req);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
query = queryFromUrl(request.url) || await co_body_1.json(req);
|
|
28
|
-
}
|
|
29
|
-
ctx.graphql.query = query;
|
|
30
|
-
await next();
|
|
31
|
-
}
|
|
32
|
-
exports.parseQuery = parseQuery;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ramda_1 = require("ramda");
|
|
4
|
-
const constants_1 = require("../../../constants");
|
|
5
|
-
const cacheControl_1 = require("../utils/cacheControl");
|
|
6
|
-
const DEV_FIELDS = ['data', 'errors', 'extensions'];
|
|
7
|
-
const PROD_FIELDS = ['data', 'errors'];
|
|
8
|
-
function setVaryHeaders(ctx, scope, segment) {
|
|
9
|
-
ctx.vary(constants_1.FORWARDED_HOST_HEADER);
|
|
10
|
-
if (segment) {
|
|
11
|
-
ctx.vary(constants_1.SEGMENT_HEADER);
|
|
12
|
-
}
|
|
13
|
-
if (scope === 'private' || ctx.query.scope === 'private') {
|
|
14
|
-
ctx.vary(constants_1.SESSION_HEADER);
|
|
15
|
-
}
|
|
16
|
-
else if (ctx.vtex.sessionToken) {
|
|
17
|
-
ctx.vtex.logger.warn({
|
|
18
|
-
message: 'GraphQL resolver receiving session token without private scope',
|
|
19
|
-
userAgent: ctx.get('user-agent'),
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
async function response(ctx, next) {
|
|
24
|
-
const { responseInit, graphqlResponse } = ctx.graphql;
|
|
25
|
-
const { production } = ctx.vtex;
|
|
26
|
-
const { maxAge = '', scope = '', segment = null, } = graphqlResponse ? cacheControl_1.cacheControl(graphqlResponse, ctx) : {};
|
|
27
|
-
const cacheControlHeader = ramda_1.reject(ramda_1.isEmpty, [maxAge, scope]).join(',');
|
|
28
|
-
ctx.set(Object.assign({}, responseInit && responseInit.headers, { 'Cache-Control': cacheControlHeader }));
|
|
29
|
-
if (ctx.method.toUpperCase() === 'GET') {
|
|
30
|
-
setVaryHeaders(ctx, scope, segment);
|
|
31
|
-
}
|
|
32
|
-
const fields = production ? PROD_FIELDS : DEV_FIELDS;
|
|
33
|
-
ctx.body = ramda_1.pick(fields, graphqlResponse);
|
|
34
|
-
await next();
|
|
35
|
-
}
|
|
36
|
-
exports.response = response;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { LRUCache } from '../../../caches';
|
|
2
|
-
import { GraphQLServiceContext } from '../typings';
|
|
3
|
-
export declare const graphqlRuntimeCacheStorage: LRUCache<string, string>;
|
|
4
|
-
export declare function run(ctx: GraphQLServiceContext, next: () => Promise<void>): Promise<void>;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const apollo_server_core_1 = require("apollo-server-core");
|
|
4
|
-
const caches_1 = require("../../../caches");
|
|
5
|
-
const maxAgeEnum_1 = require("../utils/maxAgeEnum");
|
|
6
|
-
exports.graphqlRuntimeCacheStorage = new caches_1.LRUCache({
|
|
7
|
-
max: 100,
|
|
8
|
-
});
|
|
9
|
-
const persistedQueries = {
|
|
10
|
-
cache: exports.graphqlRuntimeCacheStorage,
|
|
11
|
-
};
|
|
12
|
-
const linked = !!process.env.VTEX_APP_LINK;
|
|
13
|
-
async function run(ctx, next) {
|
|
14
|
-
const { method, graphql, request, } = ctx;
|
|
15
|
-
const { dataSources, formatters, query, schema, } = graphql;
|
|
16
|
-
const { formatError, formatResponse, } = formatters;
|
|
17
|
-
// We don't want resolvers to have access to the GraphQL context,
|
|
18
|
-
// so we delete it here and restore it after execution.
|
|
19
|
-
delete ctx.graphql;
|
|
20
|
-
try {
|
|
21
|
-
const { graphqlResponse, responseInit } = await apollo_server_core_1.runHttpQuery([], {
|
|
22
|
-
method,
|
|
23
|
-
options: {
|
|
24
|
-
cacheControl: {
|
|
25
|
-
calculateHttpHeaders: true,
|
|
26
|
-
defaultMaxAge: maxAgeEnum_1.defaultMaxAgeFromCtx(ctx),
|
|
27
|
-
stripFormattedExtensions: false,
|
|
28
|
-
},
|
|
29
|
-
context: ctx,
|
|
30
|
-
dataSources,
|
|
31
|
-
debug: linked,
|
|
32
|
-
documentStore: exports.graphqlRuntimeCacheStorage,
|
|
33
|
-
formatError,
|
|
34
|
-
formatResponse,
|
|
35
|
-
parseOptions: {
|
|
36
|
-
noLocation: !linked,
|
|
37
|
-
},
|
|
38
|
-
persistedQueries,
|
|
39
|
-
schema,
|
|
40
|
-
tracing: linked,
|
|
41
|
-
},
|
|
42
|
-
query: query,
|
|
43
|
-
request,
|
|
44
|
-
});
|
|
45
|
-
ctx.graphql = graphql;
|
|
46
|
-
ctx.graphql.responseInit = responseInit;
|
|
47
|
-
ctx.graphql.graphqlResponse = JSON.parse(graphqlResponse);
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
ctx.graphql = graphql;
|
|
51
|
-
throw err;
|
|
52
|
-
}
|
|
53
|
-
await next();
|
|
54
|
-
}
|
|
55
|
-
exports.run = run;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const schema_1 = require("../schema");
|
|
4
|
-
async function injectSchema(ctx, next) {
|
|
5
|
-
ctx.graphql.schema = schema_1.makeSchema(ctx);
|
|
6
|
-
await next();
|
|
7
|
-
}
|
|
8
|
-
exports.injectSchema = injectSchema;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
async function graphqlTimings(ctx, next) {
|
|
4
|
-
const start = process.hrtime();
|
|
5
|
-
// Errors will be caught by the next middleware so we don't have to catch.
|
|
6
|
-
await next();
|
|
7
|
-
// Batch success or error metric for entire operation
|
|
8
|
-
metrics.batch(`graphql-operation-${ctx.graphql.status}`, process.hrtime(start));
|
|
9
|
-
}
|
|
10
|
-
exports.graphqlTimings = graphqlTimings;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { GraphQLServiceContext } from '../typings';
|
|
2
|
-
declare module 'graphql-upload' {
|
|
3
|
-
function graphqlUploadKoa(options: ApolloUploadOptions): (ctx: GraphQLServiceContext, next: () => Promise<any>) => Promise<void>;
|
|
4
|
-
}
|
|
5
|
-
declare function graphqlUploadKoaMiddleware(ctx: GraphQLServiceContext, next: () => Promise<any>): Promise<void>;
|
|
6
|
-
export declare const upload: typeof graphqlUploadKoaMiddleware;
|
|
7
|
-
export {};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fs_extra_1 = require("fs-extra");
|
|
4
|
-
const graphql_tools_1 = require("graphql-tools");
|
|
5
|
-
const ramda_1 = require("ramda");
|
|
6
|
-
const messagesLoader_1 = require("./messagesLoader");
|
|
7
|
-
const schemaDirectives_1 = require("./schemaDirectives");
|
|
8
|
-
const typeDefs_1 = require("./typeDefs");
|
|
9
|
-
const cache = {
|
|
10
|
-
executableSchema: null,
|
|
11
|
-
schemaMetaData: null,
|
|
12
|
-
typeDefs: null,
|
|
13
|
-
};
|
|
14
|
-
let appTypeDefs;
|
|
15
|
-
try {
|
|
16
|
-
appTypeDefs = fs_extra_1.readFileSync('./service/schema.graphql', 'utf8');
|
|
17
|
-
// tslint:disable-next-line:no-empty
|
|
18
|
-
}
|
|
19
|
-
catch (err) { }
|
|
20
|
-
exports.makeSchema = (ctx) => {
|
|
21
|
-
const { graphql: { resolvers: appResolvers, schemaDirectives: appDirectives, }, clients: { segment }, vtex: { locale }, } = ctx;
|
|
22
|
-
if (cache.executableSchema) {
|
|
23
|
-
return cache.executableSchema;
|
|
24
|
-
}
|
|
25
|
-
const schemaMetaData = extractSchemaMetaData(appTypeDefs);
|
|
26
|
-
// The target translation locale is only necessary if this GraphQL app uses the `IOMessage` resolver.
|
|
27
|
-
const getLocaleTo = async () => {
|
|
28
|
-
if (locale) {
|
|
29
|
-
return locale;
|
|
30
|
-
}
|
|
31
|
-
const { cultureInfo } = await segment.getSegment();
|
|
32
|
-
return cultureInfo;
|
|
33
|
-
};
|
|
34
|
-
const resolverContext = {
|
|
35
|
-
getLocaleTo,
|
|
36
|
-
translationsLoader: messagesLoader_1.messagesLoader(ctx.clients),
|
|
37
|
-
};
|
|
38
|
-
const executableSchema = graphql_tools_1.makeExecutableSchema({
|
|
39
|
-
resolvers: Object.assign({}, appResolvers, typeDefs_1.nativeResolvers(resolverContext)),
|
|
40
|
-
schemaDirectives: Object.assign({}, appDirectives, schemaDirectives_1.nativeSchemaDirectives),
|
|
41
|
-
typeDefs: getOrSetTypeDefs(schemaMetaData),
|
|
42
|
-
});
|
|
43
|
-
if (isSchemaCacheable(schemaMetaData)) {
|
|
44
|
-
cache.executableSchema = executableSchema;
|
|
45
|
-
}
|
|
46
|
-
return executableSchema;
|
|
47
|
-
};
|
|
48
|
-
const getOrSetTypeDefs = (schemaMetaData) => {
|
|
49
|
-
if (!cache.typeDefs) {
|
|
50
|
-
cache.typeDefs = [
|
|
51
|
-
appTypeDefs,
|
|
52
|
-
typeDefs_1.nativeTypeDefs(schemaMetaData),
|
|
53
|
-
].join('\n\n');
|
|
54
|
-
}
|
|
55
|
-
return cache.typeDefs;
|
|
56
|
-
};
|
|
57
|
-
const hasScalar = (typeDefs) => (scalar) => new RegExp(`scalar(\\s)+${scalar}(\\s\\n)+`).test(typeDefs);
|
|
58
|
-
const extractSchemaMetaData = (typeDefs) => {
|
|
59
|
-
if (!cache.schemaMetaData) {
|
|
60
|
-
const scalars = ramda_1.keys(typeDefs_1.scalarResolversMap);
|
|
61
|
-
const scalarsPresentInSchema = ramda_1.map(hasScalar(typeDefs), scalars);
|
|
62
|
-
cache.schemaMetaData = ramda_1.zipObj(scalars, scalarsPresentInSchema);
|
|
63
|
-
}
|
|
64
|
-
return cache.schemaMetaData;
|
|
65
|
-
};
|
|
66
|
-
const isSchemaCacheable = (schemaMetaData) => !ramda_1.any(scalar => schemaMetaData[scalar], typeDefs_1.shouldNotCacheWhenSchemaHas);
|