@vtex/api 6.48.1-beta → 6.48.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gen/manifest.schema +5 -3
- package/lib/HttpClient/GraphQLClient.d.ts +3 -2
- package/lib/HttpClient/GraphQLClient.js +5 -1
- package/lib/HttpClient/HttpClient.d.ts +9 -7
- package/lib/HttpClient/HttpClient.js +70 -27
- package/lib/HttpClient/agents.d.ts +6 -0
- package/lib/HttpClient/agents.js +43 -0
- package/lib/HttpClient/index.d.ts +1 -7
- package/lib/HttpClient/index.js +22 -16
- package/lib/HttpClient/middlewares/cache.d.ts +9 -3
- package/lib/HttpClient/middlewares/cache.js +130 -35
- package/lib/HttpClient/middlewares/cancellationToken.d.ts +2 -2
- package/lib/HttpClient/middlewares/cancellationToken.js +5 -2
- package/lib/HttpClient/middlewares/inflight.d.ts +1 -1
- package/lib/HttpClient/middlewares/inflight.js +7 -3
- package/lib/HttpClient/middlewares/memoization.d.ts +1 -1
- package/lib/HttpClient/middlewares/memoization.js +13 -4
- package/lib/HttpClient/middlewares/metrics.js +25 -38
- package/lib/HttpClient/middlewares/notFound.d.ts +1 -1
- package/lib/HttpClient/middlewares/notFound.js +5 -2
- package/lib/HttpClient/middlewares/recorder.d.ts +1 -1
- package/lib/HttpClient/middlewares/recorder.js +21 -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 +88 -0
- package/lib/HttpClient/middlewares/request/setupAxios/index.d.ts +1 -0
- package/lib/HttpClient/middlewares/request/setupAxios/index.js +22 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.d.ts +2 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +55 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.d.ts +2 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +8 -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 +32 -0
- package/lib/HttpClient/middlewares/tracing.d.ts +15 -0
- package/lib/HttpClient/middlewares/tracing.js +62 -0
- package/lib/HttpClient/typings.d.ts +46 -12
- package/lib/HttpClient/typings.js +1 -0
- package/lib/caches/DiskCache.d.ts +1 -1
- package/lib/caches/DiskCache.js +3 -2
- package/lib/caches/LRUCache.d.ts +3 -3
- package/lib/caches/LRUCache.js +6 -1
- package/lib/caches/LRUDiskCache.d.ts +2 -2
- package/lib/caches/LRUDiskCache.js +8 -3
- package/lib/caches/MultilayeredCache.d.ts +2 -2
- package/lib/caches/MultilayeredCache.js +8 -7
- package/lib/caches/index.js +20 -7
- package/lib/caches/typings.d.ts +5 -5
- package/lib/clients/IOClient.d.ts +13 -0
- package/lib/clients/IOClient.js +20 -0
- package/lib/clients/IOClients.d.ts +29 -25
- 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} +51 -23
- 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/apps/Settings.js +39 -0
- 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 +23 -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 +20 -0
- package/lib/clients/index.d.ts +9 -21
- package/lib/clients/index.js +27 -24
- package/lib/clients/infra/Apps.d.ts +93 -0
- package/lib/clients/infra/Apps.js +511 -0
- package/lib/clients/infra/Assets.d.ts +35 -0
- package/lib/clients/infra/Assets.js +166 -0
- 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 +65 -0
- package/lib/clients/infra/Registry.js +209 -0
- 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 +61 -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 +27 -0
- package/lib/{HttpClient → clients/janus}/JanusClient.d.ts +4 -4
- package/lib/{HttpClient → clients/janus}/JanusClient.js +8 -3
- package/lib/clients/janus/LicenseManager.d.ts +7 -0
- package/lib/clients/janus/LicenseManager.js +59 -0
- 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} +7 -8
- package/lib/clients/janus/Tenant.js +29 -0
- package/lib/clients/janus/index.d.ts +5 -0
- package/lib/clients/janus/index.js +21 -0
- package/lib/constants.d.ts +50 -2
- 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 +4 -3
- 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 +22 -11
- package/lib/index.d.ts +9 -7
- package/lib/index.js +31 -16
- package/lib/metrics/MetricsAccumulator.d.ts +3 -20
- package/lib/metrics/MetricsAccumulator.js +44 -27
- package/lib/responses.d.ts +5 -46
- package/lib/service/index.d.ts +2 -0
- package/lib/service/index.js +35 -0
- package/lib/service/loaders.d.ts +8 -0
- package/lib/service/loaders.js +57 -0
- package/lib/service/logger/console.d.ts +10 -0
- package/lib/service/logger/console.js +40 -0
- package/lib/service/logger/index.d.ts +2 -28
- package/lib/service/logger/index.js +16 -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 +89 -0
- package/lib/service/metrics/requestMetricsMiddleware.d.ts +2 -0
- package/lib/service/metrics/requestMetricsMiddleware.js +46 -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 +19 -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 +117 -0
- package/lib/service/worker/index.d.ts +11 -0
- package/lib/service/worker/index.js +197 -0
- package/lib/service/worker/listeners.d.ts +3 -0
- package/lib/{utils/unhandled.js → service/worker/listeners.js} +12 -16
- 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 +34 -0
- package/lib/service/worker/runtime/builtIn/middlewares.d.ts +4 -0
- package/lib/service/worker/runtime/builtIn/middlewares.js +43 -0
- package/lib/service/worker/runtime/events/index.d.ts +4 -0
- package/lib/service/worker/runtime/events/index.js +48 -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 +29 -0
- package/lib/service/worker/runtime/graphql/index.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/index.js +29 -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 +54 -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 +21 -0
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.d.ts +5 -0
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +30 -0
- package/lib/service/worker/runtime/graphql/middlewares/upload.d.ts +4 -0
- package/lib/service/{graphql → worker/runtime/graphql}/middlewares/upload.js +2 -1
- package/lib/service/worker/runtime/graphql/schema/index.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/index.js +33 -0
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +81 -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 +14 -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 +8 -3
- 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 +34 -0
- package/lib/service/worker/runtime/graphql/utils/error.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/utils/error.js +78 -0
- package/lib/service/worker/runtime/graphql/utils/pathname.js +9 -0
- package/lib/service/worker/runtime/graphql/utils/translations.d.ts +14 -0
- package/lib/service/worker/runtime/graphql/utils/translations.js +42 -0
- package/lib/service/worker/runtime/http/index.d.ts +5 -0
- package/lib/service/worker/runtime/http/index.js +61 -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 +39 -0
- package/lib/service/worker/runtime/http/middlewares/error.d.ts +2 -0
- package/lib/service/{http → worker/runtime/http}/middlewares/error.js +29 -16
- 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 +6 -5
- package/lib/service/worker/runtime/http/middlewares/settings.d.ts +9 -0
- package/lib/service/worker/runtime/http/middlewares/settings.js +49 -0
- package/lib/service/worker/runtime/http/middlewares/timings.d.ts +3 -0
- package/lib/service/{http → worker/runtime/http}/middlewares/timings.js +25 -11
- 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 +25 -0
- package/lib/service/worker/runtime/http/routes.d.ts +19 -0
- package/lib/service/worker/runtime/http/routes.js +16 -0
- package/lib/service/worker/runtime/method.d.ts +9 -0
- package/lib/service/{method.js → worker/runtime/method.js} +2 -1
- package/lib/service/worker/runtime/statusTrack.d.ts +14 -0
- package/lib/service/worker/runtime/statusTrack.js +43 -0
- package/lib/service/worker/runtime/typings.d.ts +173 -0
- package/lib/service/worker/runtime/utils/compose.d.ts +5 -0
- package/lib/service/worker/runtime/utils/compose.js +14 -0
- package/lib/service/worker/runtime/utils/context.d.ts +5 -0
- package/lib/service/worker/runtime/utils/context.js +42 -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/worker/runtime/utils/toArray.js +5 -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/{service/graphql/utils/array.js → tracing/LogEvents.js} +1 -1
- 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 +58 -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 +42 -0
- package/lib/utils/MineWinsConflictsResolver.d.ts +7 -5
- package/lib/utils/MineWinsConflictsResolver.js +40 -22
- package/lib/utils/app.d.ts +3 -1
- package/lib/utils/app.js +40 -21
- package/lib/utils/appsStaleIfError.d.ts +2 -1
- package/lib/utils/appsStaleIfError.js +33 -12
- package/lib/utils/billingOptions.d.ts +36 -3
- package/lib/utils/billingOptions.js +9 -3
- package/lib/utils/binding.d.ts +3 -3
- package/lib/utils/binding.js +5 -2
- 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 +2 -1
- package/lib/utils/error.js +6 -4
- package/lib/utils/index.js +23 -12
- package/lib/utils/json.js +1 -0
- package/lib/utils/log.d.ts +1 -3
- package/lib/utils/log.js +6 -4
- package/lib/utils/message.js +11 -4
- package/lib/utils/renameBy.js +3 -1
- package/lib/utils/retry.js +10 -7
- package/lib/utils/status.js +3 -1
- package/lib/utils/tenant.d.ts +3 -3
- package/lib/utils/tenant.js +5 -2
- package/lib/utils/throwOnGraphQLErrors.js +1 -0
- package/lib/utils/time.d.ts +7 -7
- package/lib/utils/time.js +29 -12
- package/package.json +3 -3
- package/lib/HttpClient/IOClient.d.ts +0 -13
- 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/Assets.js +0 -110
- 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/LicenseManager.js +0 -43
- 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/Registry.js +0 -147
- 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/Settings.js +0 -44
- 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/graphql/utils/pathname.js +0 -7
- 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/typings.d.ts +0 -139
- package/lib/service/utils/compose.d.ts +0 -4
- package/lib/service/utils/compose.js +0 -11
- 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,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const dataloader_1 = __importDefault(require("dataloader"));
|
|
7
|
-
const ramda_1 = require("ramda");
|
|
8
|
-
const message_1 = require("../../../utils/message");
|
|
9
|
-
const sortByProvider = (indexedMessages) => ramda_1.sortBy(([_, message]) => message_1.providerFromMessage(message), indexedMessages);
|
|
10
|
-
const sortByIndex = (indexedTranslations) => ramda_1.sortBy(([index, _]) => Number(index), indexedTranslations);
|
|
11
|
-
exports.messagesLoader = (clients) => new dataloader_1.default(async (messages) => {
|
|
12
|
-
const to = messages[0].to;
|
|
13
|
-
const from = messages[0].from;
|
|
14
|
-
const indexedMessages = ramda_1.toPairs(messages);
|
|
15
|
-
const sortedIndexedMessages = sortByProvider(indexedMessages);
|
|
16
|
-
const originalIndexes = ramda_1.pluck(0, sortedIndexedMessages);
|
|
17
|
-
const sortedMessages = ramda_1.pluck(1, sortedIndexedMessages);
|
|
18
|
-
const messagesByProvider = {};
|
|
19
|
-
const indexByProvider = {};
|
|
20
|
-
sortedMessages.forEach((message, index) => {
|
|
21
|
-
const provider = message_1.providerFromMessage(message);
|
|
22
|
-
if (!messagesByProvider[provider]) {
|
|
23
|
-
messagesByProvider[provider] = [];
|
|
24
|
-
indexByProvider[provider] = [];
|
|
25
|
-
}
|
|
26
|
-
messagesByProvider[provider].push(ramda_1.pick(['id', 'content', 'description', 'behavior'], message));
|
|
27
|
-
indexByProvider[provider].push(index);
|
|
28
|
-
});
|
|
29
|
-
const messagesInput = ramda_1.compose(ramda_1.values, ramda_1.mapObjIndexed((messagesArray, provider) => ({
|
|
30
|
-
messages: ramda_1.map(message_1.removeProviderFromId, messagesArray),
|
|
31
|
-
provider,
|
|
32
|
-
})))(messagesByProvider);
|
|
33
|
-
const translations = await clients.messagesGraphQL.translate({
|
|
34
|
-
from,
|
|
35
|
-
messages: messagesInput,
|
|
36
|
-
to,
|
|
37
|
-
});
|
|
38
|
-
const indexedTranslations = ramda_1.zip(originalIndexes, translations);
|
|
39
|
-
const translationsInOriginalOrder = sortByIndex(indexedTranslations);
|
|
40
|
-
return ramda_1.pluck(1, translationsInOriginalOrder);
|
|
41
|
-
});
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import DataLoader from 'dataloader';
|
|
2
|
-
import { IOClients } from '../../../clients/IOClients';
|
|
3
|
-
import { IOMessageV2 } from './../../../clients/MessagesGraphQL';
|
|
4
|
-
export declare const messagesLoaderV2: (clients: IOClients) => DataLoader<IOMessageV2, string>;
|
|
5
|
-
export declare type MessagesLoaderV2 = ReturnType<typeof messagesLoaderV2>;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const dataloader_1 = __importDefault(require("dataloader"));
|
|
7
|
-
const ramda_1 = require("ramda");
|
|
8
|
-
const sortByContentAndFrom = (indexedMessages) => ramda_1.sortBy(([_, { content, from }]) => `__from:${from}__content:${content}`, indexedMessages);
|
|
9
|
-
const sortByIndex = (indexedTranslations) => ramda_1.sortBy(([index, _]) => Number(index), indexedTranslations);
|
|
10
|
-
const indexMessagesByFrom = (messages) => messages.reduce((acc, { from, context, content, behavior }) => {
|
|
11
|
-
const lastIndexed = acc.length && acc[acc.length - 1];
|
|
12
|
-
const formatted = {
|
|
13
|
-
behavior,
|
|
14
|
-
content,
|
|
15
|
-
context,
|
|
16
|
-
};
|
|
17
|
-
if (lastIndexed && lastIndexed.from === from) {
|
|
18
|
-
lastIndexed.messages.push(formatted);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
acc.push({
|
|
22
|
-
from,
|
|
23
|
-
messages: [formatted],
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return acc;
|
|
27
|
-
}, []);
|
|
28
|
-
exports.messagesLoaderV2 = (clients) => new dataloader_1.default(async (messages) => {
|
|
29
|
-
const to = messages[0].to;
|
|
30
|
-
const indexedMessages = ramda_1.toPairs(messages);
|
|
31
|
-
const sortedIndexedMessages = sortByContentAndFrom(indexedMessages);
|
|
32
|
-
const originalIndexes = ramda_1.pluck(0, sortedIndexedMessages);
|
|
33
|
-
const sortedMessages = ramda_1.pluck(1, sortedIndexedMessages);
|
|
34
|
-
const indexedByFrom = indexMessagesByFrom(sortedMessages);
|
|
35
|
-
const depTree = ramda_1.any(ioMessage => !!ioMessage.withAppsMetaInfo, messages) ? JSON.stringify(await clients.apps.getAppsMetaInfos()) : '';
|
|
36
|
-
const translations = await clients.messagesGraphQL.translateV2({
|
|
37
|
-
depTree,
|
|
38
|
-
indexedByFrom,
|
|
39
|
-
to,
|
|
40
|
-
});
|
|
41
|
-
const indexedTranslations = ramda_1.zip(originalIndexes, translations);
|
|
42
|
-
const translationsInOriginalOrder = sortByIndex(indexedTranslations);
|
|
43
|
-
return ramda_1.pluck(1, translationsInOriginalOrder);
|
|
44
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const bluebird_1 = require("bluebird");
|
|
4
|
-
const graphql_1 = require("graphql");
|
|
5
|
-
const graphql_tools_1 = require("graphql-tools");
|
|
6
|
-
const messagesLoader_1 = require("../messagesLoader");
|
|
7
|
-
class Translatable extends graphql_tools_1.SchemaDirectiveVisitor {
|
|
8
|
-
visitFieldDefinition(field) {
|
|
9
|
-
const { resolve = graphql_1.defaultFieldResolver } = field;
|
|
10
|
-
const { behavior = 'FULL' } = this.args;
|
|
11
|
-
field.resolve = async (root, args, context, info) => {
|
|
12
|
-
const { clients: { segment }, clients, vtex: { logger } } = context;
|
|
13
|
-
if (Math.random() < 0.1) {
|
|
14
|
-
logger.warn(`Translatable directive in use by: ${context.vtex.account} (Operation Id: ${context.vtex.operationId})`);
|
|
15
|
-
}
|
|
16
|
-
if (!context.loaders || !context.loaders.messages) {
|
|
17
|
-
context.loaders = Object.assign({}, context.loaders, { messages: messagesLoader_1.messagesLoader(clients) });
|
|
18
|
-
}
|
|
19
|
-
const response = await resolve(root, args, context, info);
|
|
20
|
-
const handler = handleSingleString(context, behavior);
|
|
21
|
-
return Array.isArray(response) ? await bluebird_1.map(response, handler) : await handler(response);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.Translatable = Translatable;
|
|
26
|
-
const handleSingleString = (context, behavior) => async (response) => {
|
|
27
|
-
// Messages only knows how to process non empty strings.
|
|
28
|
-
if ((typeof response !== 'string' && typeof response !== 'object') || Array.isArray(response) || response == null) {
|
|
29
|
-
return response;
|
|
30
|
-
}
|
|
31
|
-
const resObj = typeof response === 'string'
|
|
32
|
-
? {
|
|
33
|
-
content: response,
|
|
34
|
-
description: '',
|
|
35
|
-
from: undefined,
|
|
36
|
-
id: response,
|
|
37
|
-
}
|
|
38
|
-
: response;
|
|
39
|
-
const { content, from, id } = resObj;
|
|
40
|
-
const { clients: { segment }, vtex: { locale } } = context;
|
|
41
|
-
const to = locale != null
|
|
42
|
-
? locale
|
|
43
|
-
: (await segment.getSegment()).cultureInfo;
|
|
44
|
-
if (content == null && id == null) {
|
|
45
|
-
throw new Error(`@translatable directive needs a content or id to translate, but received ${JSON.stringify(response)}`);
|
|
46
|
-
}
|
|
47
|
-
// If the message is already in the target locale, return the content.
|
|
48
|
-
if (!to || from === to) {
|
|
49
|
-
return content;
|
|
50
|
-
}
|
|
51
|
-
return context.loaders.messages.load(Object.assign({}, resObj, { behavior,
|
|
52
|
-
from,
|
|
53
|
-
to }));
|
|
54
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { GraphQLField } from 'graphql';
|
|
2
|
-
import { SchemaDirectiveVisitor } from 'graphql-tools';
|
|
3
|
-
import { ServiceContext } from '../../../typings';
|
|
4
|
-
export declare class TranslatableV2 extends SchemaDirectiveVisitor {
|
|
5
|
-
visitFieldDefinition(field: GraphQLField<any, ServiceContext>): void;
|
|
6
|
-
}
|
|
7
|
-
export interface TranslatableMessageV2 {
|
|
8
|
-
from?: string;
|
|
9
|
-
content: string;
|
|
10
|
-
context?: string;
|
|
11
|
-
}
|
|
12
|
-
export declare const parseTranslatableStringV2: (rawMessage: string) => TranslatableMessageV2;
|
|
13
|
-
export declare const formatTranslatableStringV2: ({ from, content, context }: TranslatableMessageV2) => string;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const bluebird_1 = require("bluebird");
|
|
4
|
-
const graphql_1 = require("graphql");
|
|
5
|
-
const graphql_tools_1 = require("graphql-tools");
|
|
6
|
-
const ramda_1 = require("ramda");
|
|
7
|
-
const messagesLoaderV2_1 = require("../messagesLoaderV2");
|
|
8
|
-
const CONTEXT_REGEX = /\(\(\((?<context>(.)*)\)\)\)/;
|
|
9
|
-
const FROM_REGEX = /\<\<\<(?<from>(.)*)\>\>\>/;
|
|
10
|
-
const CONTENT_REGEX = /\(\(\((?<context>(.)*)\)\)\)|\<\<\<(?<from>(.)*)\>\>\>/g;
|
|
11
|
-
class TranslatableV2 extends graphql_tools_1.SchemaDirectiveVisitor {
|
|
12
|
-
visitFieldDefinition(field) {
|
|
13
|
-
const { resolve = graphql_1.defaultFieldResolver } = field;
|
|
14
|
-
const { behavior = 'FULL', withAppsMetaInfo = false } = this.args;
|
|
15
|
-
field.resolve = async (root, args, ctx, info) => {
|
|
16
|
-
if (!ctx.loaders || !ctx.loaders.messagesV2) {
|
|
17
|
-
ctx.loaders = Object.assign({}, ctx.loaders, { messagesV2: messagesLoaderV2_1.messagesLoaderV2(ctx.clients) });
|
|
18
|
-
}
|
|
19
|
-
const response = await resolve(root, args, ctx, info);
|
|
20
|
-
const { vtex, loaders: { messagesV2 } } = ctx;
|
|
21
|
-
const handler = handleSingleString(vtex, messagesV2, behavior, withAppsMetaInfo);
|
|
22
|
-
return Array.isArray(response) ? await bluebird_1.map(response, handler) : await handler(response);
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.TranslatableV2 = TranslatableV2;
|
|
27
|
-
exports.parseTranslatableStringV2 = (rawMessage) => {
|
|
28
|
-
const context = ramda_1.path(['groups', 'context'], rawMessage.match(CONTEXT_REGEX) || {});
|
|
29
|
-
const from = ramda_1.path(['groups', 'from'], rawMessage.match(FROM_REGEX) || {});
|
|
30
|
-
const content = rawMessage.replace(CONTENT_REGEX, '');
|
|
31
|
-
return {
|
|
32
|
-
content: content && content.trim(),
|
|
33
|
-
context: context && context.trim(),
|
|
34
|
-
from: from && from.trim(),
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
exports.formatTranslatableStringV2 = ({ from, content, context }) => `${content} ${context ? `(((${context})))` : ''} ${from ? `<<<${from}>>>` : ''}`;
|
|
38
|
-
const handleSingleString = (ctx, messagesV2, behavior, withAppsMetaInfo) => async (rawMessage) => {
|
|
39
|
-
// Messages only knows how to process non empty strings.
|
|
40
|
-
if (rawMessage == null) {
|
|
41
|
-
return rawMessage;
|
|
42
|
-
}
|
|
43
|
-
const { content, context, from: maybeFrom } = exports.parseTranslatableStringV2(rawMessage);
|
|
44
|
-
const { binding, locale: to, tenant } = ctx;
|
|
45
|
-
if (content == null) {
|
|
46
|
-
throw new Error(`@translatableV2 directive needs a content to translate, but received ${JSON.stringify(rawMessage)}`);
|
|
47
|
-
}
|
|
48
|
-
if (to == null) {
|
|
49
|
-
throw new Error('@translatableV2 directive needs the locale variable available in IOContext. You can do this by either setting \`ctx.vtex.locale\` directly or calling this app with \`x-vtex-locale\` header');
|
|
50
|
-
}
|
|
51
|
-
const from = maybeFrom || (binding && binding.locale) || (tenant && tenant.locale);
|
|
52
|
-
if (from == null) {
|
|
53
|
-
throw new Error('@translatableV2 directive needs a source language to translate from. You can do this by either setting \`ctx.vtex.tenant\` variable, call this app with the header \`x-vtex-tenant\` or format the string with the \`formatTranslatableStringV2\` function with the \`from\` option set');
|
|
54
|
-
}
|
|
55
|
-
// If the message is already in the target locale, return the content.
|
|
56
|
-
if (!to || from === to) {
|
|
57
|
-
return content;
|
|
58
|
-
}
|
|
59
|
-
return messagesV2.load({
|
|
60
|
-
behavior,
|
|
61
|
-
content,
|
|
62
|
-
context,
|
|
63
|
-
from,
|
|
64
|
-
to,
|
|
65
|
-
withAppsMetaInfo,
|
|
66
|
-
});
|
|
67
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Auth } from './Auth';
|
|
2
|
-
import { SanitizeDirective } from './Sanitize';
|
|
3
|
-
import { SmartCacheDirective } from './SmartCacheDirective';
|
|
4
|
-
import { Translatable } from './Translatable';
|
|
5
|
-
import { TranslatableV2 } from './TranslatableV2';
|
|
6
|
-
export { parseTranslatableStringV2, formatTranslatableStringV2 } from './TranslatableV2';
|
|
7
|
-
export declare const nativeSchemaDirectives: {
|
|
8
|
-
auth: typeof Auth;
|
|
9
|
-
sanitize: typeof SanitizeDirective;
|
|
10
|
-
smartcache: typeof SmartCacheDirective;
|
|
11
|
-
translatable: typeof Translatable;
|
|
12
|
-
translatableV2: typeof TranslatableV2;
|
|
13
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const Auth_1 = require("./Auth");
|
|
4
|
-
const Sanitize_1 = require("./Sanitize");
|
|
5
|
-
const SmartCacheDirective_1 = require("./SmartCacheDirective");
|
|
6
|
-
const Translatable_1 = require("./Translatable");
|
|
7
|
-
const TranslatableV2_1 = require("./TranslatableV2");
|
|
8
|
-
var TranslatableV2_2 = require("./TranslatableV2");
|
|
9
|
-
exports.parseTranslatableStringV2 = TranslatableV2_2.parseTranslatableStringV2;
|
|
10
|
-
exports.formatTranslatableStringV2 = TranslatableV2_2.formatTranslatableStringV2;
|
|
11
|
-
exports.nativeSchemaDirectives = {
|
|
12
|
-
auth: Auth_1.Auth,
|
|
13
|
-
sanitize: Sanitize_1.SanitizeDirective,
|
|
14
|
-
smartcache: SmartCacheDirective_1.SmartCacheDirective,
|
|
15
|
-
translatable: Translatable_1.Translatable,
|
|
16
|
-
translatableV2: TranslatableV2_1.TranslatableV2,
|
|
17
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { GraphQLScalarType } from 'graphql';
|
|
2
|
-
import { NativeResolverContext } from './ioMessage';
|
|
3
|
-
export declare const scalarResolversMap: {
|
|
4
|
-
'IOMessage': (ctx: NativeResolverContext) => GraphQLScalarType;
|
|
5
|
-
'IOSanitizedString': import("./sanitizedString").IOSanitizedStringType;
|
|
6
|
-
'IOUpload': GraphQLScalarType;
|
|
7
|
-
'Upload': GraphQLScalarType;
|
|
8
|
-
};
|
|
9
|
-
export declare const shouldNotCacheWhenSchemaHas: string[];
|
|
10
|
-
export declare const nativeResolvers: (ctx: NativeResolverContext) => {
|
|
11
|
-
'IOMessage': GraphQLScalarType;
|
|
12
|
-
'IOSanitizedString': import("./sanitizedString").IOSanitizedStringType;
|
|
13
|
-
'IOUpload': GraphQLScalarType;
|
|
14
|
-
'Upload': GraphQLScalarType;
|
|
15
|
-
};
|
|
16
|
-
export declare const nativeTypeDefs: (metaData: Record<string, boolean>) => string;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const apollo_server_core_1 = require("apollo-server-core");
|
|
4
|
-
const ramda_1 = require("ramda");
|
|
5
|
-
const ioMessage_1 = require("./ioMessage");
|
|
6
|
-
const ioUpload_1 = require("./ioUpload");
|
|
7
|
-
const sanitizedString_1 = require("./sanitizedString");
|
|
8
|
-
exports.scalarResolversMap = {
|
|
9
|
-
'IOMessage': ioMessage_1.resolvers,
|
|
10
|
-
'IOSanitizedString': sanitizedString_1.resolvers,
|
|
11
|
-
'IOUpload': ioUpload_1.resolvers,
|
|
12
|
-
'Upload': apollo_server_core_1.GraphQLUpload,
|
|
13
|
-
};
|
|
14
|
-
exports.shouldNotCacheWhenSchemaHas = ['IOMessage'];
|
|
15
|
-
exports.nativeResolvers = (ctx) => ({
|
|
16
|
-
'IOMessage': exports.scalarResolversMap.IOMessage(ctx),
|
|
17
|
-
'IOSanitizedString': exports.scalarResolversMap.IOSanitizedString,
|
|
18
|
-
'IOUpload': exports.scalarResolversMap.IOUpload,
|
|
19
|
-
'Upload': exports.scalarResolversMap.Upload,
|
|
20
|
-
});
|
|
21
|
-
exports.nativeTypeDefs = (metaData) => ramda_1.reduce((acc, scalar) => !metaData[scalar] ? `${acc}\nscalar ${scalar}\n` : acc, '', ramda_1.keys(exports.scalarResolversMap));
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import DataLoader from 'dataloader';
|
|
2
|
-
import { GraphQLScalarType } from 'graphql';
|
|
3
|
-
import { IOMessage } from '../../../../utils/message';
|
|
4
|
-
export interface NativeResolverContext {
|
|
5
|
-
getLocaleTo: () => Promise<string>;
|
|
6
|
-
translationsLoader: DataLoader<IOMessage, string>;
|
|
7
|
-
}
|
|
8
|
-
export declare const resolvers: (ctx: NativeResolverContext) => GraphQLScalarType;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const apollo_server_core_1 = require("apollo-server-core");
|
|
4
|
-
const graphql_1 = require("graphql");
|
|
5
|
-
const serialize = (ctx) => async (inputArgs) => {
|
|
6
|
-
const args = typeof inputArgs === 'string' ? { content: inputArgs, description: '', from: undefined, id: inputArgs } : inputArgs;
|
|
7
|
-
const { content, from } = args;
|
|
8
|
-
const { translationsLoader, getLocaleTo } = ctx;
|
|
9
|
-
const to = await getLocaleTo();
|
|
10
|
-
// If the message is already in the target locale, return the content.
|
|
11
|
-
if (!to || from === to) {
|
|
12
|
-
return content;
|
|
13
|
-
}
|
|
14
|
-
return await translationsLoader.load(Object.assign({}, args, { from,
|
|
15
|
-
to }));
|
|
16
|
-
};
|
|
17
|
-
const parseValue = (_) => {
|
|
18
|
-
throw new apollo_server_core_1.ApolloError('You cannot use IOMessage as input value', 'INVALID_INPUT_MESSAGE');
|
|
19
|
-
};
|
|
20
|
-
exports.resolvers = (ctx) => new graphql_1.GraphQLScalarType({
|
|
21
|
-
description: 'Internationalizeable String',
|
|
22
|
-
name: 'IOMessage',
|
|
23
|
-
parseLiteral(ast) {
|
|
24
|
-
switch (ast.kind) {
|
|
25
|
-
case graphql_1.Kind.STRING:
|
|
26
|
-
return ast.value;
|
|
27
|
-
default:
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
parseValue,
|
|
32
|
-
serialize: serialize(ctx),
|
|
33
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { HttpQueryRequest } from 'apollo-server-core';
|
|
2
|
-
import { HttpQueryResponse } from 'apollo-server-core/dist/runHttpQuery';
|
|
3
|
-
import { GraphQLSchema } from 'graphql';
|
|
4
|
-
import { GraphQLResponse } from 'graphql-extensions';
|
|
5
|
-
import { IOClients } from '../../clients/IOClients';
|
|
6
|
-
import { GraphQLOptions, ServiceContext } from '../typings';
|
|
7
|
-
export interface GraphQLContext {
|
|
8
|
-
graphql: GraphQLOptions<IOClients, any, any> & {
|
|
9
|
-
schema?: GraphQLSchema;
|
|
10
|
-
query?: HttpQueryRequest['query'];
|
|
11
|
-
graphqlResponse?: GraphQLResponse;
|
|
12
|
-
responseInit?: HttpQueryResponse['responseInit'];
|
|
13
|
-
status?: 'success' | 'error';
|
|
14
|
-
graphQLErrors?: any[];
|
|
15
|
-
formatters?: {
|
|
16
|
-
formatError: <T>(e: T) => T;
|
|
17
|
-
formatResponse: <T>(r: T) => T;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export declare type GraphQLServiceContext = ServiceContext<IOClients, any, GraphQLContext>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { GraphQLResponse } from 'graphql-extensions';
|
|
2
|
-
export declare const cacheControl: (response: GraphQLResponse, ctx: import("../../typings").ServiceContext<import("../../..").IOClients, any, import("../typings").GraphQLContext>) => {
|
|
3
|
-
maxAge: string;
|
|
4
|
-
scope: string;
|
|
5
|
-
segment: boolean | undefined;
|
|
6
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ramda_1 = require("ramda");
|
|
4
|
-
const domain_1 = require("../../../utils/domain");
|
|
5
|
-
const maxAgeEnum_1 = require("../utils/maxAgeEnum");
|
|
6
|
-
const linked = !!process.env.VTEX_APP_LINK;
|
|
7
|
-
const pluck = (p) => (list) => ramda_1.pluck(p, list);
|
|
8
|
-
const publicRegExp = ramda_1.compose((exp) => new RegExp(exp), (exp) => `.*${exp}.*`, ramda_1.replace('.', '\\.'));
|
|
9
|
-
const pickCacheControlHints = (response) => ramda_1.path(['extensions', 'cacheControl', 'hints'], response);
|
|
10
|
-
const minArray = (nums) => ramda_1.reduce(ramda_1.min, maxAgeEnum_1.maxAgeEnums.LONG, nums);
|
|
11
|
-
const minMaxAge = (hints) => ramda_1.compose(minArray, ramda_1.reject(ramda_1.isNil), pluck('maxAge'))(hints);
|
|
12
|
-
const anyPrivate = (hints) => ramda_1.compose(ramda_1.any(ramda_1.equals('PRIVATE')), pluck('scope'))(hints);
|
|
13
|
-
const anySegment = (hints) => ramda_1.compose(ramda_1.any(ramda_1.equals('SEGMENT')), pluck('scope'))(hints);
|
|
14
|
-
const isPrivateRoute = ({ request: { headers } }) => ramda_1.test(/_v\/graphql\/private\/v*/, headers['x-forwarded-path'] || '');
|
|
15
|
-
const isPublicEndpoint = ({ request: { headers } }) => {
|
|
16
|
-
if (headers.origin) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
const host = headers['x-forwarded-host'] || '';
|
|
20
|
-
return domain_1.PUBLIC_DOMAINS.some(endpoint => ramda_1.test(publicRegExp(endpoint), host));
|
|
21
|
-
};
|
|
22
|
-
exports.cacheControl = (response, ctx) => {
|
|
23
|
-
const { vtex: { production } } = ctx;
|
|
24
|
-
const hints = response && pickCacheControlHints(response);
|
|
25
|
-
const age = hints && minMaxAge(hints);
|
|
26
|
-
const isPrivate = hints && anyPrivate(hints);
|
|
27
|
-
const segment = hints && anySegment(hints);
|
|
28
|
-
const maxAge = linked
|
|
29
|
-
? 'no-store'
|
|
30
|
-
: (isPublicEndpoint(ctx) || !production)
|
|
31
|
-
? 'no-cache'
|
|
32
|
-
: `max-age=${age}`;
|
|
33
|
-
return {
|
|
34
|
-
maxAge,
|
|
35
|
-
scope: (isPrivate || isPrivateRoute(ctx)) ? 'private' : 'public',
|
|
36
|
-
segment,
|
|
37
|
-
};
|
|
38
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ramda_1 = require("ramda");
|
|
4
|
-
/*
|
|
5
|
-
* This file contains the enumeration -> int map for generating the max age
|
|
6
|
-
* in the graphql cacheControl
|
|
7
|
-
*/
|
|
8
|
-
exports.maxAgeEnums = {
|
|
9
|
-
LONG: 86400,
|
|
10
|
-
MEDIUM: 3600,
|
|
11
|
-
SHORT: 120,
|
|
12
|
-
};
|
|
13
|
-
exports.defaultMaxAgeFromCtx = (ctx) => {
|
|
14
|
-
const forwarded = ramda_1.path(['request', 'header', 'x-forwarded-path'], ctx);
|
|
15
|
-
const isPrivateRoute = forwarded && /_v\/graphql\/private\/v*/.test(forwarded);
|
|
16
|
-
return (isPrivateRoute) ? 0 : exports.maxAgeEnums.LONG;
|
|
17
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ramda_1 = require("ramda");
|
|
4
|
-
exports.generatePathName = (rpath) => {
|
|
5
|
-
const pathFieldNames = ramda_1.filter(value => typeof value === 'string', rpath);
|
|
6
|
-
return pathFieldNames.join('.');
|
|
7
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { ClientsImplementation, IOClients } from '../../clients/IOClients';
|
|
2
|
-
import { InstanceOptions } from '../../HttpClient';
|
|
3
|
-
export declare const createHttpRoute: <ClientsT extends IOClients, StateT, CustomT>(Clients: ClientsImplementation<ClientsT>, options: Record<string, InstanceOptions>) => (handler: import("koa-compose").Middleware<import("../typings").ServiceContext<ClientsT, StateT, CustomT>> | import("koa-compose").Middleware<import("../typings").ServiceContext<ClientsT, StateT, CustomT>>[]) => import("koa-compose").ComposedMiddleware<import("../typings").ServiceContext<ClientsT, StateT, CustomT>>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const compose_1 = require("../utils/compose");
|
|
4
|
-
const authTokens_1 = require("./middlewares/authTokens");
|
|
5
|
-
const cancellationToken_1 = require("./middlewares/cancellationToken");
|
|
6
|
-
const clients_1 = require("./middlewares/clients");
|
|
7
|
-
const error_1 = require("./middlewares/error");
|
|
8
|
-
const requestStats_1 = require("./middlewares/requestStats");
|
|
9
|
-
const setCookie_1 = require("./middlewares/setCookie");
|
|
10
|
-
const timings_1 = require("./middlewares/timings");
|
|
11
|
-
const vary_1 = require("./middlewares/vary");
|
|
12
|
-
exports.createHttpRoute = (Clients, options) => {
|
|
13
|
-
return (handler) => {
|
|
14
|
-
const middlewares = Array.isArray(handler) ? handler : [handler];
|
|
15
|
-
const pipeline = [cancellationToken_1.cancellationToken, requestStats_1.trackIncomingRequestStats, vary_1.vary, authTokens_1.authTokens, clients_1.clients(Clients, options), setCookie_1.removeSetCookie, timings_1.timings, error_1.error, ...middlewares];
|
|
16
|
-
return compose_1.compose(pipeline);
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ClientsImplementation, IOClients } from '../../../clients/IOClients';
|
|
2
|
-
import { InstanceOptions } from '../../../HttpClient';
|
|
3
|
-
import { ServiceContext } from '../../typings';
|
|
4
|
-
export declare function clients<T extends IOClients, U, V>(ClientsImpl: ClientsImplementation<T>, clientOptions: Record<string, InstanceOptions>): (ctx: ServiceContext<T, U, V>, next: () => Promise<any>) => Promise<void>;
|
package/lib/service/method.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IOClients } from '../clients/IOClients';
|
|
2
|
-
import { RouteHandler, ServiceContext } from './typings';
|
|
3
|
-
declare type HTTPMethods = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH' | 'DEFAULT';
|
|
4
|
-
declare type MethodOptions<ClientsT extends IOClients = IOClients, StateT = void, CustomT = void> = Partial<Record<HTTPMethods, RouteHandler<ClientsT, StateT, CustomT> | Array<RouteHandler<ClientsT, StateT, CustomT>>>>;
|
|
5
|
-
export declare function method<ClientsT extends IOClients = IOClients, StateT = void, CustomT = void>(options: MethodOptions<ClientsT, StateT, CustomT>): {
|
|
6
|
-
(ctx: ServiceContext<ClientsT, StateT, CustomT>, next: () => Promise<any>): Promise<void>;
|
|
7
|
-
skipTimer: boolean;
|
|
8
|
-
};
|
|
9
|
-
export {};
|