@vtex/api 6.45.4
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/CHANGELOG.md +1685 -0
- package/README.md +65 -0
- package/gen/manifest.schema +189 -0
- package/lib/HttpClient/GraphQLClient.d.ts +28 -0
- package/lib/HttpClient/GraphQLClient.js +30 -0
- package/lib/HttpClient/HttpClient.d.ts +29 -0
- package/lib/HttpClient/HttpClient.js +130 -0
- package/lib/HttpClient/agents.d.ts +3 -0
- package/lib/HttpClient/agents.js +24 -0
- package/lib/HttpClient/index.d.ts +6 -0
- package/lib/HttpClient/index.js +14 -0
- package/lib/HttpClient/middlewares/cache.d.ts +35 -0
- package/lib/HttpClient/middlewares/cache.js +173 -0
- package/lib/HttpClient/middlewares/cancellationToken.d.ts +3 -0
- package/lib/HttpClient/middlewares/cancellationToken.js +72 -0
- package/lib/HttpClient/middlewares/inflight.d.ts +5 -0
- package/lib/HttpClient/middlewares/inflight.js +50 -0
- package/lib/HttpClient/middlewares/memoization.d.ts +7 -0
- package/lib/HttpClient/middlewares/memoization.js +40 -0
- package/lib/HttpClient/middlewares/metrics.d.ts +9 -0
- package/lib/HttpClient/middlewares/metrics.js +110 -0
- package/lib/HttpClient/middlewares/notFound.d.ts +7 -0
- package/lib/HttpClient/middlewares/notFound.js +20 -0
- package/lib/HttpClient/middlewares/recorder.d.ts +3 -0
- package/lib/HttpClient/middlewares/recorder.js +21 -0
- package/lib/HttpClient/middlewares/request/HttpAgentSingleton.d.ts +14 -0
- package/lib/HttpClient/middlewares/request/HttpAgentSingleton.js +37 -0
- package/lib/HttpClient/middlewares/request/index.d.ts +18 -0
- package/lib/HttpClient/middlewares/request/index.js +83 -0
- package/lib/HttpClient/middlewares/request/setupAxios/index.d.ts +1 -0
- package/lib/HttpClient/middlewares/request/setupAxios/index.js +20 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.d.ts +2 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +48 -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 +51 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.d.ts +4 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +29 -0
- package/lib/HttpClient/middlewares/tracing.d.ts +15 -0
- package/lib/HttpClient/middlewares/tracing.js +54 -0
- package/lib/HttpClient/typings.d.ts +123 -0
- package/lib/HttpClient/typings.js +11 -0
- package/lib/caches/CacheLayer.d.ts +7 -0
- package/lib/caches/CacheLayer.js +2 -0
- package/lib/caches/DiskCache.d.ts +17 -0
- package/lib/caches/DiskCache.js +70 -0
- package/lib/caches/LRUCache.d.ts +16 -0
- package/lib/caches/LRUCache.js +48 -0
- package/lib/caches/LRUDiskCache.d.ts +21 -0
- package/lib/caches/LRUDiskCache.js +132 -0
- package/lib/caches/MultilayeredCache.d.ts +14 -0
- package/lib/caches/MultilayeredCache.js +68 -0
- package/lib/caches/index.d.ts +6 -0
- package/lib/caches/index.js +9 -0
- package/lib/caches/typings.d.ts +48 -0
- package/lib/caches/typings.js +2 -0
- package/lib/clients/IOClient.d.ts +13 -0
- package/lib/clients/IOClient.js +19 -0
- package/lib/clients/IOClients.d.ts +37 -0
- package/lib/clients/IOClients.js +89 -0
- package/lib/clients/IOGraphQLClient.d.ts +13 -0
- package/lib/clients/IOGraphQLClient.js +16 -0
- package/lib/clients/apps/AppClient.d.ts +9 -0
- package/lib/clients/apps/AppClient.js +34 -0
- package/lib/clients/apps/AppGraphQLClient.d.ts +9 -0
- package/lib/clients/apps/AppGraphQLClient.js +34 -0
- package/lib/clients/apps/Billing.d.ts +12 -0
- package/lib/clients/apps/Billing.js +21 -0
- package/lib/clients/apps/Builder.d.ts +45 -0
- package/lib/clients/apps/Builder.js +114 -0
- package/lib/clients/apps/MessagesGraphQL.d.ts +61 -0
- package/lib/clients/apps/MessagesGraphQL.js +121 -0
- package/lib/clients/apps/Settings.d.ts +14 -0
- package/lib/clients/apps/Settings.js +38 -0
- package/lib/clients/apps/catalogGraphQL/brand.d.ts +13 -0
- package/lib/clients/apps/catalogGraphQL/brand.js +18 -0
- package/lib/clients/apps/catalogGraphQL/category.d.ts +11 -0
- package/lib/clients/apps/catalogGraphQL/category.js +16 -0
- package/lib/clients/apps/catalogGraphQL/index.d.ts +22 -0
- package/lib/clients/apps/catalogGraphQL/index.js +88 -0
- package/lib/clients/apps/catalogGraphQL/product.d.ts +25 -0
- package/lib/clients/apps/catalogGraphQL/product.js +30 -0
- package/lib/clients/apps/catalogGraphQL/sku.d.ts +26 -0
- package/lib/clients/apps/catalogGraphQL/sku.js +30 -0
- package/lib/clients/apps/index.d.ts +7 -0
- package/lib/clients/apps/index.js +12 -0
- package/lib/clients/external/ExternalClient.d.ts +9 -0
- package/lib/clients/external/ExternalClient.js +21 -0
- package/lib/clients/external/ID.d.ts +23 -0
- package/lib/clients/external/ID.js +60 -0
- package/lib/clients/external/Masterdata.d.ts +93 -0
- package/lib/clients/external/Masterdata.js +223 -0
- package/lib/clients/external/PaymentProvider.d.ts +31 -0
- package/lib/clients/external/PaymentProvider.js +42 -0
- package/lib/clients/external/index.d.ts +4 -0
- package/lib/clients/external/index.js +9 -0
- package/lib/clients/index.d.ts +9 -0
- package/lib/clients/index.js +17 -0
- package/lib/clients/infra/Apps.d.ts +88 -0
- package/lib/clients/infra/Apps.js +508 -0
- package/lib/clients/infra/Assets.d.ts +34 -0
- package/lib/clients/infra/Assets.js +165 -0
- package/lib/clients/infra/BillingMetrics.d.ts +13 -0
- package/lib/clients/infra/BillingMetrics.js +15 -0
- package/lib/clients/infra/Events.d.ts +12 -0
- package/lib/clients/infra/Events.js +33 -0
- package/lib/clients/infra/Housekeeper.d.ts +10 -0
- package/lib/clients/infra/Housekeeper.js +30 -0
- package/lib/clients/infra/InfraClient.d.ts +9 -0
- package/lib/clients/infra/InfraClient.js +34 -0
- package/lib/clients/infra/Metadata.d.ts +26 -0
- package/lib/clients/infra/Metadata.js +83 -0
- package/lib/clients/infra/Registry.d.ts +59 -0
- package/lib/clients/infra/Registry.js +207 -0
- package/lib/clients/infra/Router.d.ts +34 -0
- package/lib/clients/infra/Router.js +81 -0
- package/lib/clients/infra/Sphinx.d.ts +13 -0
- package/lib/clients/infra/Sphinx.js +29 -0
- package/lib/clients/infra/VBase.d.ts +60 -0
- package/lib/clients/infra/VBase.js +171 -0
- package/lib/clients/infra/Workspaces.d.ts +18 -0
- package/lib/clients/infra/Workspaces.js +65 -0
- package/lib/clients/infra/index.d.ts +12 -0
- package/lib/clients/infra/index.js +17 -0
- package/lib/clients/janus/JanusClient.d.ts +21 -0
- package/lib/clients/janus/JanusClient.js +30 -0
- package/lib/clients/janus/LicenseManager.d.ts +7 -0
- package/lib/clients/janus/LicenseManager.js +58 -0
- package/lib/clients/janus/Segment.d.ts +36 -0
- package/lib/clients/janus/Segment.js +79 -0
- package/lib/clients/janus/Session.d.ts +15 -0
- package/lib/clients/janus/Session.js +75 -0
- package/lib/clients/janus/Tenant.d.ts +29 -0
- package/lib/clients/janus/Tenant.js +28 -0
- package/lib/clients/janus/index.d.ts +5 -0
- package/lib/clients/janus/index.js +10 -0
- package/lib/constants.d.ts +59 -0
- package/lib/constants.js +65 -0
- package/lib/errors/AuthenticationError.d.ts +18 -0
- package/lib/errors/AuthenticationError.js +24 -0
- package/lib/errors/ForbiddenError.d.ts +18 -0
- package/lib/errors/ForbiddenError.js +24 -0
- package/lib/errors/NotFoundError.d.ts +18 -0
- package/lib/errors/NotFoundError.js +24 -0
- package/lib/errors/RequestCancelledError.d.ts +6 -0
- package/lib/errors/RequestCancelledError.js +11 -0
- package/lib/errors/ResolverError.d.ts +29 -0
- package/lib/errors/ResolverError.js +35 -0
- package/lib/errors/ResolverWarning.d.ts +21 -0
- package/lib/errors/ResolverWarning.js +28 -0
- package/lib/errors/TooManyRequestsError.d.ts +4 -0
- package/lib/errors/TooManyRequestsError.js +9 -0
- package/lib/errors/UserInputError.d.ts +18 -0
- package/lib/errors/UserInputError.js +24 -0
- package/lib/errors/customGraphQLError.d.ts +4 -0
- package/lib/errors/customGraphQLError.js +9 -0
- package/lib/errors/index.d.ts +8 -0
- package/lib/errors/index.js +13 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +21 -0
- package/lib/metrics/MetricsAccumulator.d.ts +35 -0
- package/lib/metrics/MetricsAccumulator.js +125 -0
- package/lib/responses.d.ts +79 -0
- package/lib/responses.js +2 -0
- package/lib/service/index.d.ts +2 -0
- package/lib/service/index.js +30 -0
- package/lib/service/loaders.d.ts +8 -0
- package/lib/service/loaders.js +54 -0
- package/lib/service/logger/console.d.ts +10 -0
- package/lib/service/logger/console.js +36 -0
- package/lib/service/logger/index.d.ts +2 -0
- package/lib/service/logger/index.js +7 -0
- package/lib/service/logger/logger.d.ts +35 -0
- package/lib/service/logger/logger.js +73 -0
- package/lib/service/logger/metricsLogger.d.ts +40 -0
- package/lib/service/logger/metricsLogger.js +149 -0
- package/lib/service/master.d.ts +2 -0
- package/lib/service/master.js +91 -0
- package/lib/service/tracing/TracerSingleton.d.ts +7 -0
- package/lib/service/tracing/TracerSingleton.js +54 -0
- package/lib/service/tracing/metrics/MetricNames.d.ts +60 -0
- package/lib/service/tracing/metrics/MetricNames.js +44 -0
- package/lib/service/tracing/metrics/instruments.d.ts +9 -0
- package/lib/service/tracing/metrics/instruments.js +11 -0
- package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.d.ts +9 -0
- package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +25 -0
- package/lib/service/tracing/tracingMiddlewares.d.ts +5 -0
- package/lib/service/tracing/tracingMiddlewares.js +119 -0
- package/lib/service/worker/index.d.ts +11 -0
- package/lib/service/worker/index.js +193 -0
- package/lib/service/worker/listeners.d.ts +3 -0
- package/lib/service/worker/listeners.js +43 -0
- package/lib/service/worker/runtime/Service.d.ts +17 -0
- package/lib/service/worker/runtime/Service.js +23 -0
- package/lib/service/worker/runtime/builtIn/handlers.d.ts +4 -0
- package/lib/service/worker/runtime/builtIn/handlers.js +27 -0
- package/lib/service/worker/runtime/builtIn/middlewares.d.ts +4 -0
- package/lib/service/worker/runtime/builtIn/middlewares.js +40 -0
- package/lib/service/worker/runtime/events/index.d.ts +4 -0
- package/lib/service/worker/runtime/events/index.js +46 -0
- package/lib/service/worker/runtime/events/middlewares/body.d.ts +3 -0
- package/lib/service/worker/runtime/events/middlewares/body.js +22 -0
- package/lib/service/worker/runtime/events/middlewares/context.d.ts +3 -0
- package/lib/service/worker/runtime/events/middlewares/context.js +22 -0
- package/lib/service/worker/runtime/events/router.d.ts +2 -0
- package/lib/service/worker/runtime/events/router.js +27 -0
- package/lib/service/worker/runtime/graphql/index.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/index.js +27 -0
- package/lib/service/worker/runtime/graphql/middlewares/context.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/middlewares/context.js +16 -0
- package/lib/service/worker/runtime/graphql/middlewares/error.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/middlewares/error.js +93 -0
- package/lib/service/worker/runtime/graphql/middlewares/query.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/middlewares/query.js +52 -0
- package/lib/service/worker/runtime/graphql/middlewares/response.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/middlewares/response.js +38 -0
- package/lib/service/worker/runtime/graphql/middlewares/run.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/middlewares/run.js +19 -0
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.d.ts +4 -0
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +28 -0
- package/lib/service/worker/runtime/graphql/middlewares/upload.d.ts +4 -0
- package/lib/service/worker/runtime/graphql/middlewares/upload.js +12 -0
- package/lib/service/worker/runtime/graphql/schema/index.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/index.js +31 -0
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +79 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Auth.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Auth.js +73 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.js +37 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.d.ts +11 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +61 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.js +40 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Sanitize.d.ts +9 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Sanitize.js +35 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +34 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/SmartCacheDirective.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/SmartCacheDirective.js +29 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +39 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +33 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.d.ts +22 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +36 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/index.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +12 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/ioUpload.d.ts +3 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/ioUpload.js +16 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/sanitizedString.d.ts +10 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/sanitizedString.js +39 -0
- package/lib/service/worker/runtime/graphql/typings.d.ts +31 -0
- package/lib/service/worker/runtime/graphql/typings.js +2 -0
- package/lib/service/worker/runtime/graphql/utils/cacheControl.d.ts +1 -0
- package/lib/service/worker/runtime/graphql/utils/cacheControl.js +32 -0
- package/lib/service/worker/runtime/graphql/utils/error.d.ts +1 -0
- package/lib/service/worker/runtime/graphql/utils/error.js +76 -0
- package/lib/service/worker/runtime/graphql/utils/pathname.d.ts +1 -0
- package/lib/service/worker/runtime/graphql/utils/pathname.js +7 -0
- package/lib/service/worker/runtime/graphql/utils/translations.d.ts +14 -0
- package/lib/service/worker/runtime/graphql/utils/translations.js +38 -0
- package/lib/service/worker/runtime/http/index.d.ts +5 -0
- package/lib/service/worker/runtime/http/index.js +58 -0
- package/lib/service/worker/runtime/http/middlewares/authTokens.d.ts +3 -0
- package/lib/service/worker/runtime/http/middlewares/authTokens.js +12 -0
- package/lib/service/worker/runtime/http/middlewares/cancellationToken.d.ts +3 -0
- package/lib/service/worker/runtime/http/middlewares/cancellationToken.js +18 -0
- package/lib/service/worker/runtime/http/middlewares/clients.d.ts +4 -0
- package/lib/service/worker/runtime/http/middlewares/clients.js +12 -0
- package/lib/service/worker/runtime/http/middlewares/context.d.ts +4 -0
- package/lib/service/worker/runtime/http/middlewares/context.js +36 -0
- package/lib/service/worker/runtime/http/middlewares/error.d.ts +2 -0
- package/lib/service/worker/runtime/http/middlewares/error.js +84 -0
- package/lib/service/worker/runtime/http/middlewares/rateLimit.d.ts +6 -0
- package/lib/service/worker/runtime/http/middlewares/rateLimit.js +42 -0
- package/lib/service/worker/runtime/http/middlewares/requestStats.d.ts +17 -0
- package/lib/service/worker/runtime/http/middlewares/requestStats.js +40 -0
- package/lib/service/worker/runtime/http/middlewares/setCookie.d.ts +3 -0
- package/lib/service/worker/runtime/http/middlewares/setCookie.js +52 -0
- package/lib/service/worker/runtime/http/middlewares/settings.d.ts +9 -0
- package/lib/service/worker/runtime/http/middlewares/settings.js +43 -0
- package/lib/service/worker/runtime/http/middlewares/timings.d.ts +3 -0
- package/lib/service/worker/runtime/http/middlewares/timings.js +45 -0
- package/lib/service/worker/runtime/http/middlewares/vary.d.ts +3 -0
- package/lib/service/worker/runtime/http/middlewares/vary.js +52 -0
- package/lib/service/worker/runtime/http/router.d.ts +2 -0
- package/lib/service/worker/runtime/http/router.js +23 -0
- package/lib/service/worker/runtime/http/routes.d.ts +19 -0
- package/lib/service/worker/runtime/http/routes.js +12 -0
- package/lib/service/worker/runtime/method.d.ts +9 -0
- package/lib/service/worker/runtime/method.js +23 -0
- package/lib/service/worker/runtime/statusTrack.d.ts +14 -0
- package/lib/service/worker/runtime/statusTrack.js +37 -0
- package/lib/service/worker/runtime/typings.d.ts +172 -0
- package/lib/service/worker/runtime/typings.js +2 -0
- package/lib/service/worker/runtime/utils/compose.d.ts +5 -0
- package/lib/service/worker/runtime/utils/compose.js +11 -0
- package/lib/service/worker/runtime/utils/context.d.ts +2 -0
- package/lib/service/worker/runtime/utils/context.js +40 -0
- package/lib/service/worker/runtime/utils/diff.d.ts +12 -0
- package/lib/service/worker/runtime/utils/diff.js +21 -0
- package/lib/service/worker/runtime/utils/recorder.d.ts +8 -0
- package/lib/service/worker/runtime/utils/recorder.js +37 -0
- package/lib/service/worker/runtime/utils/toArray.d.ts +1 -0
- package/lib/service/worker/runtime/utils/toArray.js +3 -0
- package/lib/service/worker/runtime/utils/tokenBucket.d.ts +2 -0
- package/lib/service/worker/runtime/utils/tokenBucket.js +16 -0
- package/lib/tracing/LogEvents.d.ts +31 -0
- package/lib/tracing/LogEvents.js +3 -0
- package/lib/tracing/LogFields.d.ts +61 -0
- package/lib/tracing/LogFields.js +3 -0
- package/lib/tracing/Tags.d.ts +79 -0
- package/lib/tracing/Tags.js +7 -0
- package/lib/tracing/UserLandTracer.d.ts +27 -0
- package/lib/tracing/UserLandTracer.js +55 -0
- package/lib/tracing/errorReporting/ErrorReport.d.ts +31 -0
- package/lib/tracing/errorReporting/ErrorReport.js +61 -0
- package/lib/tracing/index.d.ts +9 -0
- package/lib/tracing/index.js +19 -0
- package/lib/tracing/spanReference/SpanReferenceTypes.d.ts +4 -0
- package/lib/tracing/spanReference/SpanReferenceTypes.js +7 -0
- package/lib/tracing/spanReference/createSpanReference.d.ts +3 -0
- package/lib/tracing/spanReference/createSpanReference.js +8 -0
- package/lib/tracing/utils.d.ts +13 -0
- package/lib/tracing/utils.js +40 -0
- package/lib/utils/MineWinsConflictsResolver.d.ts +28 -0
- package/lib/utils/MineWinsConflictsResolver.js +130 -0
- package/lib/utils/app.d.ts +23 -0
- package/lib/utils/app.js +48 -0
- package/lib/utils/appsStaleIfError.d.ts +11 -0
- package/lib/utils/appsStaleIfError.js +63 -0
- package/lib/utils/billingOptions.d.ts +36 -0
- package/lib/utils/billingOptions.js +9 -0
- package/lib/utils/binding.d.ts +13 -0
- package/lib/utils/binding.js +38 -0
- package/lib/utils/cancel.d.ts +3 -0
- package/lib/utils/cancel.js +12 -0
- package/lib/utils/domain.d.ts +1 -0
- package/lib/utils/domain.js +5 -0
- package/lib/utils/error.d.ts +8 -0
- package/lib/utils/error.js +94 -0
- package/lib/utils/index.d.ts +9 -0
- package/lib/utils/index.js +14 -0
- package/lib/utils/message.d.ts +25 -0
- package/lib/utils/message.js +23 -0
- package/lib/utils/renameBy.d.ts +1 -0
- package/lib/utils/renameBy.js +4 -0
- package/lib/utils/retry.d.ts +4 -0
- package/lib/utils/retry.js +32 -0
- package/lib/utils/status.d.ts +1 -0
- package/lib/utils/status.js +11 -0
- package/lib/utils/tenant.d.ts +5 -0
- package/lib/utils/tenant.js +6 -0
- package/lib/utils/throwOnGraphQLErrors.d.ts +2 -0
- package/lib/utils/throwOnGraphQLErrors.js +15 -0
- package/lib/utils/time.d.ts +31 -0
- package/lib/utils/time.js +118 -0
- package/package.json +127 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const crypto_1 = require("crypto");
|
|
4
|
+
const ramda_1 = require("ramda");
|
|
5
|
+
const constants_1 = require("../../../../../constants");
|
|
6
|
+
const app_1 = require("./../../../../../utils/app");
|
|
7
|
+
const joinIds = ramda_1.join('');
|
|
8
|
+
const dependsOnApp = (appAtMajor) => (a) => {
|
|
9
|
+
const [name, major] = appAtMajor.split('@');
|
|
10
|
+
const majorInt = major.includes('.') ? major.split('.')[0] : major;
|
|
11
|
+
const version = a._resolvedDependencies[name];
|
|
12
|
+
if (!version) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const [depMajor] = version.split('.');
|
|
16
|
+
return majorInt === depMajor;
|
|
17
|
+
};
|
|
18
|
+
exports.getFilteredDependencies = (appAtMajor, dependencies) => {
|
|
19
|
+
const depends = dependsOnApp(appAtMajor);
|
|
20
|
+
return dependencies.filter(depends);
|
|
21
|
+
};
|
|
22
|
+
exports.getDependenciesHash = (dependencies) => {
|
|
23
|
+
const dependingApps = ramda_1.pluck('id', dependencies);
|
|
24
|
+
return crypto_1.createHash('md5')
|
|
25
|
+
.update(joinIds(dependingApps))
|
|
26
|
+
.digest('hex');
|
|
27
|
+
};
|
|
28
|
+
exports.getDependenciesSettings = async (apps, assets, tracingConfig) => {
|
|
29
|
+
const appId = constants_1.APP.ID;
|
|
30
|
+
const metaInfos = await apps.getAppsMetaInfos(undefined, undefined, tracingConfig);
|
|
31
|
+
const appAtMajor = app_1.appIdToAppAtMajor(appId);
|
|
32
|
+
return await assets.getSettings(metaInfos, appAtMajor, undefined, tracingConfig);
|
|
33
|
+
};
|
|
34
|
+
exports.getServiceSettings = () => {
|
|
35
|
+
return async function settingsContext(ctx, next) {
|
|
36
|
+
const { clients: { apps, assets }, } = ctx;
|
|
37
|
+
const rootSpan = ctx.tracing.currentSpan;
|
|
38
|
+
const dependenciesSettings = await exports.getDependenciesSettings(apps, assets, { tracing: { rootSpan } });
|
|
39
|
+
// TODO: for now returning all settings, but the ideia is to do merge
|
|
40
|
+
ctx.vtex.settings = dependenciesSettings;
|
|
41
|
+
await next();
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IOClients } from '../../../../../clients/IOClients';
|
|
2
|
+
import { ParamsContext, RecorderState, ServiceContext } from '../../typings';
|
|
3
|
+
export declare function timings<T extends IOClients, U extends RecorderState, V extends ParamsContext>(ctx: ServiceContext<T, U, V>, next: () => Promise<void>): Promise<void>;
|
|
@@ -0,0 +1,45 @@
|
|
|
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 chalk_1 = __importDefault(require("chalk"));
|
|
7
|
+
const constants_1 = require("../../../../../constants");
|
|
8
|
+
const status_1 = require("../../../../../utils/status");
|
|
9
|
+
const time_1 = require("../../../../../utils/time");
|
|
10
|
+
const APP_ELAPSED_TIME_LOCATOR = time_1.shrinkTimings(time_1.formatTimingName({
|
|
11
|
+
hopNumber: 0,
|
|
12
|
+
source: process.env.VTEX_APP_NAME,
|
|
13
|
+
target: '',
|
|
14
|
+
}));
|
|
15
|
+
const pid = chalk_1.default.magenta('[' + constants_1.PID + ']');
|
|
16
|
+
const formatDate = (date) => chalk_1.default.dim('[' + date.toISOString().split('T')[1] + ']');
|
|
17
|
+
const formatStatus = (status) => status >= 500 ? chalk_1.default.red(status.toString()) : (status >= 200 && status < 300 ? chalk_1.default.green(status.toString()) : status);
|
|
18
|
+
const formatMillis = (millis) => millis >= 500 ? chalk_1.default.red(millis.toString()) : millis >= 200 ? chalk_1.default.yellow(millis.toString()) : chalk_1.default.green(millis.toString());
|
|
19
|
+
const log = ({ vtex: { account, workspace, route: { id } }, path, method, status }, millis) => `${formatDate(new Date())}\t${pid}\t${account}/${workspace}:${id}\t${formatStatus(status)}\t${method}\t${path}\t${formatMillis(millis)} ms`;
|
|
20
|
+
const logBillingInfo = ({ account, workspace, production, route: { id, type } }, millis) => JSON.stringify({
|
|
21
|
+
'__VTEX_IO_BILLING': 'true',
|
|
22
|
+
'account': account,
|
|
23
|
+
'app': constants_1.APP.ID,
|
|
24
|
+
'handler': id,
|
|
25
|
+
'isLink': constants_1.LINKED,
|
|
26
|
+
'production': production,
|
|
27
|
+
'routeType': type === 'public' ? 'public_route' : 'private_route',
|
|
28
|
+
'timestamp': Date.now(),
|
|
29
|
+
'type': 'process-time',
|
|
30
|
+
'value': millis,
|
|
31
|
+
'vendor': constants_1.APP.VENDOR,
|
|
32
|
+
'workspace': workspace,
|
|
33
|
+
});
|
|
34
|
+
async function timings(ctx, next) {
|
|
35
|
+
// Errors will be caught by the next middleware so we don't have to catch.
|
|
36
|
+
await next();
|
|
37
|
+
const { status: statusCode, vtex: { route: { id } }, timings: { total }, vtex } = ctx;
|
|
38
|
+
const totalMillis = time_1.hrToMillis(total);
|
|
39
|
+
console.log(log(ctx, totalMillis));
|
|
40
|
+
console.log(logBillingInfo(vtex, totalMillis));
|
|
41
|
+
const status = status_1.statusLabel(statusCode);
|
|
42
|
+
// Only batch successful responses so metrics don't consider errors
|
|
43
|
+
metrics.batch(`http-handler-${id}`, status === 'success' ? total : undefined, { [status]: 1 });
|
|
44
|
+
}
|
|
45
|
+
exports.timings = timings;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IOClients } from '../../../../../clients/IOClients';
|
|
2
|
+
import { ParamsContext, RecorderState, ServiceContext } from '../../typings';
|
|
3
|
+
export declare function vary<T extends IOClients, U extends RecorderState, V extends ParamsContext>(ctx: ServiceContext<T, U, V>, next: () => Promise<void>): Promise<void>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../../../../../constants");
|
|
4
|
+
const cachingStrategies = [
|
|
5
|
+
{
|
|
6
|
+
forbidden: [],
|
|
7
|
+
path: '/_v/private/',
|
|
8
|
+
vary: [constants_1.SEGMENT_HEADER, constants_1.SESSION_HEADER],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
forbidden: [constants_1.SEGMENT_HEADER, constants_1.SESSION_HEADER],
|
|
12
|
+
path: '/_v/public/',
|
|
13
|
+
vary: [],
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
forbidden: [constants_1.SESSION_HEADER],
|
|
17
|
+
path: '/_v/segment/',
|
|
18
|
+
vary: [constants_1.SEGMENT_HEADER],
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
const shouldVaryByHeader = (ctx, header, strategy) => {
|
|
22
|
+
if (strategy && strategy.vary.includes(header)) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
if (process.env.DETERMINISTIC_VARY) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return !!ctx.get(header);
|
|
29
|
+
};
|
|
30
|
+
async function vary(ctx, next) {
|
|
31
|
+
const { method, path } = ctx;
|
|
32
|
+
const strategy = cachingStrategies.find((cachingStrategy) => path.indexOf(cachingStrategy.path) === 0);
|
|
33
|
+
if (strategy) {
|
|
34
|
+
strategy.forbidden.forEach((headerName) => {
|
|
35
|
+
delete ctx.headers[headerName];
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
// We don't need to vary non GET requests, since they are never cached
|
|
39
|
+
if (method.toUpperCase() !== 'GET') {
|
|
40
|
+
await next();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
ctx.vary(constants_1.LOCALE_HEADER);
|
|
44
|
+
if (shouldVaryByHeader(ctx, constants_1.SEGMENT_HEADER, strategy)) {
|
|
45
|
+
ctx.vary(constants_1.SEGMENT_HEADER);
|
|
46
|
+
}
|
|
47
|
+
if (shouldVaryByHeader(ctx, constants_1.SESSION_HEADER, strategy)) {
|
|
48
|
+
ctx.vary(constants_1.SESSION_HEADER);
|
|
49
|
+
}
|
|
50
|
+
await next();
|
|
51
|
+
}
|
|
52
|
+
exports.vary = vary;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { HttpRoute, ServiceContext } from '../typings';
|
|
2
|
+
export declare const routerFromPublicHttpHandlers: (routes: Record<string, HttpRoute>) => (ctx: ServiceContext<import("../../../..").IOClients, import("../typings").RecorderState, import("../typings").ParamsContext>, next: () => Promise<void>) => Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../../../../constants");
|
|
4
|
+
const logger_1 = require("../../../logger");
|
|
5
|
+
const console_1 = require("./../../../logger/console");
|
|
6
|
+
exports.routerFromPublicHttpHandlers = (routes) => {
|
|
7
|
+
return async (ctx, next) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const routeId = ctx.get(constants_1.COLOSSUS_ROUTE_ID_HEADER);
|
|
10
|
+
if (!routeId) {
|
|
11
|
+
return next();
|
|
12
|
+
}
|
|
13
|
+
const handler = (_a = routes[routeId]) === null || _a === void 0 ? void 0 : _a.handler;
|
|
14
|
+
if (!handler) {
|
|
15
|
+
const msg = `Handler with id '${routeId}' not implemented.`;
|
|
16
|
+
ctx.status = 501;
|
|
17
|
+
ctx.body = msg;
|
|
18
|
+
console_1.logOnceToDevConsole(msg, logger_1.LogLevel.Error);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
await handler(ctx, next);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ServiceJSON } from '../typings';
|
|
2
|
+
interface PrivateRouteInfo {
|
|
3
|
+
protocol?: 'http' | 'https';
|
|
4
|
+
vendor: string;
|
|
5
|
+
name: string;
|
|
6
|
+
major: string | number;
|
|
7
|
+
account: string;
|
|
8
|
+
workspace: string;
|
|
9
|
+
path?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const formatPrivateRoute: ({ protocol, vendor, name, major, account, workspace, path }: PrivateRouteInfo) => string;
|
|
12
|
+
export declare const formatPublicRoute: ({ workspace, account, endpoint, path }: {
|
|
13
|
+
workspace: string;
|
|
14
|
+
account: string;
|
|
15
|
+
endpoint: string;
|
|
16
|
+
path: string;
|
|
17
|
+
}) => string;
|
|
18
|
+
export declare const logAvailableRoutes: (service: ServiceJSON) => void;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../../../../constants");
|
|
4
|
+
exports.formatPrivateRoute = ({ protocol = 'https', vendor, name, major, account, workspace, path }) => `${protocol}://app.io.vtex.com/${vendor}.${name}/v${major}/${account}/${workspace}${path || ''}`;
|
|
5
|
+
exports.formatPublicRoute = ({ workspace, account, endpoint, path }) => `https://${workspace}--${account}.${endpoint}${path}`;
|
|
6
|
+
const getPath = ({ public: publicRoute, path }) => publicRoute
|
|
7
|
+
? exports.formatPublicRoute({ workspace: constants_1.WORKSPACE, account: constants_1.ACCOUNT, endpoint: constants_1.PUBLIC_ENDPOINT, path })
|
|
8
|
+
: exports.formatPrivateRoute({ protocol: 'https', vendor: constants_1.APP.VENDOR, name: constants_1.APP.NAME, major: constants_1.APP.MAJOR, account: constants_1.ACCOUNT, workspace: constants_1.WORKSPACE, path });
|
|
9
|
+
exports.logAvailableRoutes = (service) => {
|
|
10
|
+
const available = Object.values(service.routes || {}).reduce((acc, route) => `${acc}\n${getPath(route)}`, 'Available service routes:');
|
|
11
|
+
console.info(available);
|
|
12
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IOClients } from '../../../clients/IOClients';
|
|
2
|
+
import { ParamsContext, RecorderState, 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 extends RecorderState = RecorderState, CustomT extends ParamsContext = ParamsContext> = Partial<Record<HTTPMethods, RouteHandler<ClientsT, StateT, CustomT> | Array<RouteHandler<ClientsT, StateT, CustomT>>>>;
|
|
5
|
+
export declare function method<T extends IOClients, U extends RecorderState, V extends ParamsContext>(options: MethodOptions<T, U, V>): {
|
|
6
|
+
(ctx: ServiceContext<T, U, V>, next: () => Promise<void>): Promise<void>;
|
|
7
|
+
skipTimer: boolean;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ramda_1 = require("ramda");
|
|
4
|
+
const compose_1 = require("./utils/compose");
|
|
5
|
+
const TEN_SECONDS_S = 10;
|
|
6
|
+
function methodNotAllowed(ctx) {
|
|
7
|
+
ctx.status = 405;
|
|
8
|
+
ctx.set('cache-control', `public, max-age=${TEN_SECONDS_S}`);
|
|
9
|
+
}
|
|
10
|
+
function method(options) {
|
|
11
|
+
const handlers = ramda_1.mapObjIndexed(handler => compose_1.compose(Array.isArray(handler) ? handler : [handler]), options);
|
|
12
|
+
const inner = async function forMethod(ctx, next) {
|
|
13
|
+
const verb = ctx.method.toUpperCase();
|
|
14
|
+
const handler = handlers[verb] || handlers.DEFAULT || methodNotAllowed;
|
|
15
|
+
if (handler) {
|
|
16
|
+
await handler(ctx);
|
|
17
|
+
}
|
|
18
|
+
await next();
|
|
19
|
+
};
|
|
20
|
+
inner.skipTimer = true;
|
|
21
|
+
return inner;
|
|
22
|
+
}
|
|
23
|
+
exports.method = method;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ServiceContext } from './typings';
|
|
2
|
+
export declare type StatusTrack = () => EnvMetric[];
|
|
3
|
+
export interface NamedMetric {
|
|
4
|
+
name: string;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
export interface EnvMetric extends NamedMetric {
|
|
8
|
+
production: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const isStatusTrack: (message: any) => message is "statusTrack";
|
|
11
|
+
export declare const isStatusTrackBroadcast: (message: any) => message is "broadcastStatusTrack";
|
|
12
|
+
export declare const statusTrackHandler: (ctx: ServiceContext<import("../../..").IOClients, import("./typings").RecorderState, import("./typings").ParamsContext>) => Promise<void>;
|
|
13
|
+
export declare const trackStatus: () => void;
|
|
14
|
+
export declare const broadcastStatusTrack: () => void;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 cluster_1 = __importDefault(require("cluster"));
|
|
7
|
+
const constants_1 = require("../../../constants");
|
|
8
|
+
const BROADCAST_STATUS_TRACK = 'broadcastStatusTrack';
|
|
9
|
+
const STATUS_TRACK = 'statusTrack';
|
|
10
|
+
exports.isStatusTrack = (message) => message === STATUS_TRACK;
|
|
11
|
+
exports.isStatusTrackBroadcast = (message) => message === BROADCAST_STATUS_TRACK;
|
|
12
|
+
exports.statusTrackHandler = async (ctx) => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
(_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.currentSpan.setOperationName('builtin:status-track');
|
|
15
|
+
if (!constants_1.LINKED) {
|
|
16
|
+
(_b = process.send) === null || _b === void 0 ? void 0 : _b.call(process, BROADCAST_STATUS_TRACK);
|
|
17
|
+
}
|
|
18
|
+
ctx.body = [];
|
|
19
|
+
return;
|
|
20
|
+
};
|
|
21
|
+
exports.trackStatus = () => {
|
|
22
|
+
global.metrics.statusTrack().forEach(status => {
|
|
23
|
+
logStatus(status);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.broadcastStatusTrack = () => Object.values(cluster_1.default.workers).forEach(worker => worker === null || worker === void 0 ? void 0 : worker.send(STATUS_TRACK));
|
|
27
|
+
const logStatus = (status) => console.log(JSON.stringify({
|
|
28
|
+
__VTEX_IO_LOG: true,
|
|
29
|
+
account: constants_1.ACCOUNT,
|
|
30
|
+
app: constants_1.APP.ID,
|
|
31
|
+
isLink: constants_1.LINKED,
|
|
32
|
+
pid: process.pid,
|
|
33
|
+
production: constants_1.PRODUCTION,
|
|
34
|
+
status,
|
|
35
|
+
type: 'metric/status',
|
|
36
|
+
workspace: constants_1.WORKSPACE,
|
|
37
|
+
}));
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { CancelTokenSource } from 'axios';
|
|
3
|
+
import DataLoader from 'dataloader';
|
|
4
|
+
import { GraphQLFieldConfig, GraphQLFieldResolver, GraphQLScalarType } from 'graphql';
|
|
5
|
+
import { SchemaDirectiveVisitor } from 'graphql-tools';
|
|
6
|
+
import { ParameterizedContext } from 'koa';
|
|
7
|
+
import { Middleware } from 'koa-compose';
|
|
8
|
+
import { Span, Tracer } from 'opentracing';
|
|
9
|
+
import { ParsedUrlQuery } from 'querystring';
|
|
10
|
+
import { ClientsImplementation, IOClients } from '../../../clients/IOClients';
|
|
11
|
+
import { InstanceOptions } from '../../../HttpClient';
|
|
12
|
+
import { IUserLandTracer } from '../../../tracing/UserLandTracer';
|
|
13
|
+
import { BindingHeader } from '../../../utils/binding';
|
|
14
|
+
import { IOMessage } from '../../../utils/message';
|
|
15
|
+
import { TenantHeader } from '../../../utils/tenant';
|
|
16
|
+
import { Logger } from '../../logger';
|
|
17
|
+
import { MetricsLogger } from '../../logger/metricsLogger';
|
|
18
|
+
import { MessagesLoaderV2 } from './graphql/schema/messagesLoaderV2';
|
|
19
|
+
import { Recorder } from './utils/recorder';
|
|
20
|
+
declare type ServerTiming = Record<string, string>;
|
|
21
|
+
export declare type Maybe<T> = T | null | undefined;
|
|
22
|
+
export interface TracingContext {
|
|
23
|
+
tracer: Tracer;
|
|
24
|
+
currentSpan: Span;
|
|
25
|
+
}
|
|
26
|
+
export interface Context<T extends IOClients> {
|
|
27
|
+
clients: T;
|
|
28
|
+
vtex: IOContext;
|
|
29
|
+
timings: Record<string, [number, number]>;
|
|
30
|
+
metrics: Record<string, [number, number]>;
|
|
31
|
+
previousTimerStart: [number, number];
|
|
32
|
+
serverTiming?: ServerTiming;
|
|
33
|
+
tracing?: TracingContext;
|
|
34
|
+
}
|
|
35
|
+
export interface EventContext<T extends IOClients, StateT = any> {
|
|
36
|
+
clients: T;
|
|
37
|
+
state: StateT;
|
|
38
|
+
vtex: IOContext;
|
|
39
|
+
body: any;
|
|
40
|
+
timings: Record<string, [number, number]>;
|
|
41
|
+
metrics: Record<string, [number, number]>;
|
|
42
|
+
key: string;
|
|
43
|
+
sender: string;
|
|
44
|
+
subject: string;
|
|
45
|
+
}
|
|
46
|
+
declare type KnownKeys<T> = {
|
|
47
|
+
[K in keyof T]: string extends K ? never : number extends K ? never : K;
|
|
48
|
+
} extends {
|
|
49
|
+
[_ in keyof T]: infer U;
|
|
50
|
+
} ? U : never;
|
|
51
|
+
interface Loaders {
|
|
52
|
+
messages?: DataLoader<IOMessage, string>;
|
|
53
|
+
messagesV2?: MessagesLoaderV2;
|
|
54
|
+
immutableMessagesV2?: MessagesLoaderV2;
|
|
55
|
+
}
|
|
56
|
+
export declare type ServiceContext<ClientsT extends IOClients = IOClients, StateT extends RecorderState = RecorderState, CustomT extends ParamsContext = ParamsContext> = Pick<ParameterizedContext<StateT, Context<ClientsT>>, KnownKeys<ParameterizedContext<StateT, Context<ClientsT>>>> & CustomT & {
|
|
57
|
+
loaders?: Loaders;
|
|
58
|
+
};
|
|
59
|
+
export declare type RouteHandler<ClientsT extends IOClients = IOClients, StateT extends RecorderState = RecorderState, CustomT extends ParamsContext = ParamsContext> = Middleware<ServiceContext<ClientsT, StateT, CustomT>>;
|
|
60
|
+
export declare type EventHandler<ClientsT extends IOClients = IOClients, StateT = void> = Middleware<EventContext<ClientsT, StateT>>;
|
|
61
|
+
export declare type Resolver<ClientsT extends IOClients = IOClients, StateT extends RecorderState = RecorderState, CustomT extends ParamsContext = ParamsContext> = GraphQLFieldResolver<any, ServiceContext<ClientsT, StateT, CustomT>, any> | GraphQLFieldConfig<any, ServiceContext<ClientsT, StateT, CustomT>, any>;
|
|
62
|
+
export declare type Handler = RouteHandler<IOClients, RecorderState, ParamsContext>;
|
|
63
|
+
export interface HttpRoute {
|
|
64
|
+
handler: RouteHandler;
|
|
65
|
+
path: string;
|
|
66
|
+
}
|
|
67
|
+
export interface RecorderState {
|
|
68
|
+
recorder: Recorder;
|
|
69
|
+
body: any;
|
|
70
|
+
}
|
|
71
|
+
export interface ParamsContext {
|
|
72
|
+
params: any;
|
|
73
|
+
metricsLogger: MetricsLogger;
|
|
74
|
+
}
|
|
75
|
+
export interface ClientsConfig<ClientsT extends IOClients = IOClients> {
|
|
76
|
+
implementation?: ClientsImplementation<ClientsT>;
|
|
77
|
+
options: Record<string, InstanceOptions>;
|
|
78
|
+
}
|
|
79
|
+
export interface GraphQLOptions<ClientsT extends IOClients = IOClients, StateT extends RecorderState = RecorderState, CustomT extends ParamsContext = ParamsContext> {
|
|
80
|
+
resolvers: Record<string, Record<string, Resolver<ClientsT, StateT, CustomT>> | GraphQLScalarType>;
|
|
81
|
+
schema?: string;
|
|
82
|
+
schemaDirectives?: Record<string, typeof SchemaDirectiveVisitor>;
|
|
83
|
+
}
|
|
84
|
+
export interface ServiceConfig<ClientsT extends IOClients = IOClients, StateT extends RecorderState = RecorderState, CustomT extends ParamsContext = ParamsContext> {
|
|
85
|
+
clients?: ClientsConfig<ClientsT>;
|
|
86
|
+
events?: Record<string, EventHandler<ClientsT, StateT> | Array<EventHandler<ClientsT, StateT>>>;
|
|
87
|
+
graphql?: GraphQLOptions<ClientsT, StateT, CustomT>;
|
|
88
|
+
routes?: Record<string, RouteHandler<ClientsT, StateT, CustomT> | Array<RouteHandler<ClientsT, StateT, CustomT>>>;
|
|
89
|
+
}
|
|
90
|
+
export interface Cancellation {
|
|
91
|
+
cancelable: boolean;
|
|
92
|
+
cancelled: boolean;
|
|
93
|
+
source: CancelTokenSource;
|
|
94
|
+
}
|
|
95
|
+
export interface IOContext {
|
|
96
|
+
account: string;
|
|
97
|
+
platform: string;
|
|
98
|
+
authToken: string;
|
|
99
|
+
adminUserAuthToken?: string;
|
|
100
|
+
storeUserAuthToken?: string;
|
|
101
|
+
locale?: string;
|
|
102
|
+
production: boolean;
|
|
103
|
+
product: string;
|
|
104
|
+
recorder?: Recorder;
|
|
105
|
+
region: string;
|
|
106
|
+
route: {
|
|
107
|
+
declarer?: string;
|
|
108
|
+
id: string;
|
|
109
|
+
params: ParsedUrlQuery;
|
|
110
|
+
type: 'public' | 'private' | 'event';
|
|
111
|
+
};
|
|
112
|
+
userAgent: string;
|
|
113
|
+
workspace: string;
|
|
114
|
+
segmentToken?: string;
|
|
115
|
+
sessionToken?: string;
|
|
116
|
+
requestId: string;
|
|
117
|
+
operationId: string;
|
|
118
|
+
janusEnv?: JanusEnv;
|
|
119
|
+
serverTiming?: ServerTiming;
|
|
120
|
+
logger: Logger;
|
|
121
|
+
eventInfo?: EventBody;
|
|
122
|
+
host?: string;
|
|
123
|
+
tenant?: TenantHeader;
|
|
124
|
+
binding?: BindingHeader;
|
|
125
|
+
cancellation?: Cancellation;
|
|
126
|
+
settings?: any;
|
|
127
|
+
tracer: IUserLandTracer;
|
|
128
|
+
}
|
|
129
|
+
export interface EventBody {
|
|
130
|
+
sender: string;
|
|
131
|
+
subject: string;
|
|
132
|
+
key: string;
|
|
133
|
+
}
|
|
134
|
+
export declare type RouteSettingsType = 'pure' | 'workspace' | 'userAndWorkspace';
|
|
135
|
+
export interface ServiceRoute {
|
|
136
|
+
path: string;
|
|
137
|
+
public?: boolean;
|
|
138
|
+
smartcache?: boolean;
|
|
139
|
+
extensible?: boolean;
|
|
140
|
+
settingsType?: RouteSettingsType;
|
|
141
|
+
rateLimitPerReplica?: RateLimitOptions;
|
|
142
|
+
}
|
|
143
|
+
export interface ServiceEvent {
|
|
144
|
+
keys?: string[];
|
|
145
|
+
sender?: string;
|
|
146
|
+
subject?: string;
|
|
147
|
+
settingsType?: RouteSettingsType;
|
|
148
|
+
rateLimitPerReplica?: RateLimitOptions;
|
|
149
|
+
}
|
|
150
|
+
export interface RateLimitOptions {
|
|
151
|
+
perMinute?: number;
|
|
152
|
+
concurrent?: number;
|
|
153
|
+
}
|
|
154
|
+
export interface RawServiceJSON {
|
|
155
|
+
stack: 'nodejs';
|
|
156
|
+
memory: number;
|
|
157
|
+
ttl?: number;
|
|
158
|
+
timeout?: number;
|
|
159
|
+
runtimeArgs?: string[];
|
|
160
|
+
routes?: Record<string, ServiceRoute>;
|
|
161
|
+
rateLimitPerReplica?: RateLimitOptions;
|
|
162
|
+
events?: Record<string, ServiceEvent>;
|
|
163
|
+
minReplicas?: number;
|
|
164
|
+
maxReplicas?: number;
|
|
165
|
+
workers?: number;
|
|
166
|
+
deterministicVary?: boolean;
|
|
167
|
+
}
|
|
168
|
+
export interface ServiceJSON extends RawServiceJSON {
|
|
169
|
+
workers: number;
|
|
170
|
+
}
|
|
171
|
+
export declare type JanusEnv = string;
|
|
172
|
+
export {};
|