@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,18 @@
|
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import { ErrorLike } from './ResolverError';
|
|
3
|
+
import { ResolverWarning } from './ResolverWarning';
|
|
4
|
+
/**
|
|
5
|
+
* Indicates a requested resource was not found.
|
|
6
|
+
* ResolverWarnings are logged with level "warning" denoting they were handled by user code.
|
|
7
|
+
*
|
|
8
|
+
* @class NotFoundError
|
|
9
|
+
* @extends {ResolverWarning}
|
|
10
|
+
*/
|
|
11
|
+
export declare class NotFoundError extends ResolverWarning {
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of NotFoundError
|
|
15
|
+
* @param {(string | AxiosError | ErrorLike)} messageOrError Either a message string or the complete original error object.
|
|
16
|
+
*/
|
|
17
|
+
constructor(messageOrError: string | AxiosError | ErrorLike);
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ResolverWarning_1 = require("./ResolverWarning");
|
|
4
|
+
/**
|
|
5
|
+
* Indicates a requested resource was not found.
|
|
6
|
+
* ResolverWarnings are logged with level "warning" denoting they were handled by user code.
|
|
7
|
+
*
|
|
8
|
+
* @class NotFoundError
|
|
9
|
+
* @extends {ResolverWarning}
|
|
10
|
+
*/
|
|
11
|
+
class NotFoundError extends ResolverWarning_1.ResolverWarning {
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of NotFoundError
|
|
14
|
+
* @param {(string | AxiosError | ErrorLike)} messageOrError Either a message string or the complete original error object.
|
|
15
|
+
*/
|
|
16
|
+
constructor(messageOrError) {
|
|
17
|
+
super(messageOrError, 404, 'NOT_FOUND');
|
|
18
|
+
this.name = 'NotFoundError';
|
|
19
|
+
if (typeof messageOrError === 'string' || !messageOrError.stack) {
|
|
20
|
+
Error.captureStackTrace(this, NotFoundError);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.NotFoundError = NotFoundError;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cancelledRequestStatus = 499;
|
|
4
|
+
exports.cancelledErrorCode = 'request_cancelled';
|
|
5
|
+
class RequestCancelledError extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = exports.cancelledErrorCode;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.RequestCancelledError = RequestCancelledError;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import { LogLevel } from '../service/logger';
|
|
3
|
+
export interface ErrorLike {
|
|
4
|
+
name?: string;
|
|
5
|
+
message: string;
|
|
6
|
+
stack?: string;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The generic Error class to be thrown for caught errors inside resolvers.
|
|
11
|
+
* Errors with status code greater than or equal to 500 are logged as errors.
|
|
12
|
+
* All other status codes are logged as warnings. @see ResolverWarning
|
|
13
|
+
*
|
|
14
|
+
* @class ResolverError
|
|
15
|
+
* @extends {Error}
|
|
16
|
+
*/
|
|
17
|
+
export declare class ResolverError extends Error {
|
|
18
|
+
status: number;
|
|
19
|
+
code: string;
|
|
20
|
+
name: string;
|
|
21
|
+
level: LogLevel;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an instance of ResolverError
|
|
24
|
+
* @param {(string | AxiosError | ErrorLike)} messageOrError Either a message string or the complete original error object.
|
|
25
|
+
* @param {number} [status=500]
|
|
26
|
+
* @param {string} [code='RESOLVER_ERROR']
|
|
27
|
+
*/
|
|
28
|
+
constructor(messageOrError: string | AxiosError | ErrorLike, status?: number, code?: string);
|
|
29
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const logger_1 = require("../service/logger");
|
|
4
|
+
const error_1 = require("../utils/error");
|
|
5
|
+
/**
|
|
6
|
+
* The generic Error class to be thrown for caught errors inside resolvers.
|
|
7
|
+
* Errors with status code greater than or equal to 500 are logged as errors.
|
|
8
|
+
* All other status codes are logged as warnings. @see ResolverWarning
|
|
9
|
+
*
|
|
10
|
+
* @class ResolverError
|
|
11
|
+
* @extends {Error}
|
|
12
|
+
*/
|
|
13
|
+
class ResolverError extends Error {
|
|
14
|
+
/**
|
|
15
|
+
* Creates an instance of ResolverError
|
|
16
|
+
* @param {(string | AxiosError | ErrorLike)} messageOrError Either a message string or the complete original error object.
|
|
17
|
+
* @param {number} [status=500]
|
|
18
|
+
* @param {string} [code='RESOLVER_ERROR']
|
|
19
|
+
*/
|
|
20
|
+
constructor(messageOrError, status = 500, code = 'RESOLVER_ERROR') {
|
|
21
|
+
super(typeof messageOrError === 'string' ? messageOrError : messageOrError.message);
|
|
22
|
+
this.status = status;
|
|
23
|
+
this.code = code;
|
|
24
|
+
this.name = 'ResolverError';
|
|
25
|
+
this.level = logger_1.LogLevel.Error;
|
|
26
|
+
if (typeof messageOrError === 'object') {
|
|
27
|
+
// Copy original error properties without circular references
|
|
28
|
+
Object.assign(this, error_1.cleanError(messageOrError));
|
|
29
|
+
}
|
|
30
|
+
if (typeof messageOrError === 'string' || !messageOrError.stack) {
|
|
31
|
+
Error.captureStackTrace(this, ResolverError);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.ResolverError = ResolverError;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import { LogLevel } from '../service/logger';
|
|
3
|
+
import { ErrorLike, ResolverError } from './ResolverError';
|
|
4
|
+
/**
|
|
5
|
+
* Indicates a non-fatal error occurred and was handled.
|
|
6
|
+
* ResolverWarnings are logged with level "warning" denoting they were handled by user code.
|
|
7
|
+
*
|
|
8
|
+
* @class ResolverWarning
|
|
9
|
+
* @extends {ResolverError}
|
|
10
|
+
*/
|
|
11
|
+
export declare class ResolverWarning extends ResolverError {
|
|
12
|
+
status: number;
|
|
13
|
+
code: string;
|
|
14
|
+
name: string;
|
|
15
|
+
level: LogLevel;
|
|
16
|
+
/**
|
|
17
|
+
* Creates an instance of ResolverWarning
|
|
18
|
+
* @param {(string | AxiosError | ErrorLike)} messageOrError Either a message string or the complete original error object.
|
|
19
|
+
*/
|
|
20
|
+
constructor(messageOrError: string | AxiosError | ErrorLike, status?: number, code?: string);
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const logger_1 = require("../service/logger");
|
|
4
|
+
const ResolverError_1 = require("./ResolverError");
|
|
5
|
+
/**
|
|
6
|
+
* Indicates a non-fatal error occurred and was handled.
|
|
7
|
+
* ResolverWarnings are logged with level "warning" denoting they were handled by user code.
|
|
8
|
+
*
|
|
9
|
+
* @class ResolverWarning
|
|
10
|
+
* @extends {ResolverError}
|
|
11
|
+
*/
|
|
12
|
+
class ResolverWarning extends ResolverError_1.ResolverError {
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of ResolverWarning
|
|
15
|
+
* @param {(string | AxiosError | ErrorLike)} messageOrError Either a message string or the complete original error object.
|
|
16
|
+
*/
|
|
17
|
+
constructor(messageOrError, status = 422, code = 'RESOLVER_WARNING') {
|
|
18
|
+
super(messageOrError, status, code);
|
|
19
|
+
this.status = status;
|
|
20
|
+
this.code = code;
|
|
21
|
+
this.name = 'ResolverWarning';
|
|
22
|
+
this.level = logger_1.LogLevel.Warn;
|
|
23
|
+
if (typeof messageOrError === 'string' || !messageOrError.stack) {
|
|
24
|
+
Error.captureStackTrace(this, ResolverWarning);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.ResolverWarning = ResolverWarning;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tooManyRequestsStatus = 429;
|
|
4
|
+
class TooManyRequestsError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message || 'TOO_MANY_REQUESTS');
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.TooManyRequestsError = TooManyRequestsError;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import { ErrorLike } from './ResolverError';
|
|
3
|
+
import { ResolverWarning } from './ResolverWarning';
|
|
4
|
+
/**
|
|
5
|
+
* Indicates user input is not valid for this action.
|
|
6
|
+
* ResolverWarnings are logged with level "warning" denoting they were handled by user code.
|
|
7
|
+
*
|
|
8
|
+
* @class UserInputError
|
|
9
|
+
* @extends {ResolverWarning}
|
|
10
|
+
*/
|
|
11
|
+
export declare class UserInputError extends ResolverWarning {
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of UserInputError
|
|
15
|
+
* @param {(string | AxiosError | ErrorLike)} messageOrError Either a message string or the complete original error object.
|
|
16
|
+
*/
|
|
17
|
+
constructor(messageOrError: string | AxiosError | ErrorLike);
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ResolverWarning_1 = require("./ResolverWarning");
|
|
4
|
+
/**
|
|
5
|
+
* Indicates user input is not valid for this action.
|
|
6
|
+
* ResolverWarnings are logged with level "warning" denoting they were handled by user code.
|
|
7
|
+
*
|
|
8
|
+
* @class UserInputError
|
|
9
|
+
* @extends {ResolverWarning}
|
|
10
|
+
*/
|
|
11
|
+
class UserInputError extends ResolverWarning_1.ResolverWarning {
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of UserInputError
|
|
14
|
+
* @param {(string | AxiosError | ErrorLike)} messageOrError Either a message string or the complete original error object.
|
|
15
|
+
*/
|
|
16
|
+
constructor(messageOrError) {
|
|
17
|
+
super(messageOrError, 400, 'BAD_USER_INPUT');
|
|
18
|
+
this.name = 'UserInputError';
|
|
19
|
+
if (typeof messageOrError === 'string' || !messageOrError.stack) {
|
|
20
|
+
Error.captureStackTrace(this, UserInputError);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.UserInputError = UserInputError;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class CustomGraphQLError extends Error {
|
|
4
|
+
constructor(message, graphQLErrors) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.graphQLErrors = graphQLErrors;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.default = CustomGraphQLError;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './AuthenticationError';
|
|
2
|
+
export * from './ForbiddenError';
|
|
3
|
+
export * from './NotFoundError';
|
|
4
|
+
export * from './ResolverError';
|
|
5
|
+
export * from './ResolverWarning';
|
|
6
|
+
export * from './UserInputError';
|
|
7
|
+
export * from './RequestCancelledError';
|
|
8
|
+
export * from './TooManyRequestsError';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function __export(m) {
|
|
3
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
+
}
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
__export(require("./AuthenticationError"));
|
|
7
|
+
__export(require("./ForbiddenError"));
|
|
8
|
+
__export(require("./NotFoundError"));
|
|
9
|
+
__export(require("./ResolverError"));
|
|
10
|
+
__export(require("./ResolverWarning"));
|
|
11
|
+
__export(require("./UserInputError"));
|
|
12
|
+
__export(require("./RequestCancelledError"));
|
|
13
|
+
__export(require("./TooManyRequestsError"));
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './caches';
|
|
2
|
+
export * from './clients';
|
|
3
|
+
export * from './errors';
|
|
4
|
+
export * from './HttpClient';
|
|
5
|
+
export * from './metrics/MetricsAccumulator';
|
|
6
|
+
export * from './responses';
|
|
7
|
+
export * from './service/worker/runtime/Service';
|
|
8
|
+
export * from './service/worker/runtime/method';
|
|
9
|
+
export * from './service/worker/runtime/typings';
|
|
10
|
+
export * from './service/worker/runtime/graphql/schema/schemaDirectives';
|
|
11
|
+
export * from './service/worker/runtime/graphql/schema/messagesLoaderV2';
|
|
12
|
+
export * from './service/worker/runtime/utils/recorder';
|
|
13
|
+
export * from './service';
|
|
14
|
+
export * from './service/logger';
|
|
15
|
+
export * from './utils';
|
|
16
|
+
export * from './constants';
|
|
17
|
+
export * from './tracing';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function __export(m) {
|
|
3
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
+
}
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
process.env.FORCE_COLOR = '1';
|
|
7
|
+
__export(require("./caches"));
|
|
8
|
+
__export(require("./clients"));
|
|
9
|
+
__export(require("./errors"));
|
|
10
|
+
__export(require("./HttpClient"));
|
|
11
|
+
__export(require("./metrics/MetricsAccumulator"));
|
|
12
|
+
__export(require("./service/worker/runtime/Service"));
|
|
13
|
+
__export(require("./service/worker/runtime/method"));
|
|
14
|
+
__export(require("./service/worker/runtime/graphql/schema/schemaDirectives"));
|
|
15
|
+
__export(require("./service/worker/runtime/graphql/schema/messagesLoaderV2"));
|
|
16
|
+
__export(require("./service/worker/runtime/utils/recorder"));
|
|
17
|
+
__export(require("./service"));
|
|
18
|
+
__export(require("./service/logger"));
|
|
19
|
+
__export(require("./utils"));
|
|
20
|
+
__export(require("./constants"));
|
|
21
|
+
__export(require("./tracing"));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EnvMetric } from '../service/worker/runtime/statusTrack';
|
|
2
|
+
export interface Metric {
|
|
3
|
+
name: string;
|
|
4
|
+
[key: string]: number | string | null;
|
|
5
|
+
}
|
|
6
|
+
interface GetStats {
|
|
7
|
+
getStats(): {
|
|
8
|
+
[key: string]: number | boolean | string | undefined;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare class MetricsAccumulator {
|
|
12
|
+
private metricsMillis;
|
|
13
|
+
private extensions;
|
|
14
|
+
private cacheMap;
|
|
15
|
+
private onFlushMetrics;
|
|
16
|
+
constructor();
|
|
17
|
+
batchMetric: (name: string, timeMillis?: number | undefined, extensions?: Record<string, string | number> | undefined) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Batches a named metric which took `diffNs`.
|
|
20
|
+
*
|
|
21
|
+
* @param name Metric label.
|
|
22
|
+
* @param diffNs The result of calling process.hrtime() passing a previous process.hrtime() value.
|
|
23
|
+
* @param extensions Any other relevant properties of this metric.
|
|
24
|
+
*
|
|
25
|
+
* @see https://nodejs.org/api/process.html#process_process_hrtime_time
|
|
26
|
+
*/
|
|
27
|
+
batch: (name: string, diffNs?: [number, number] | undefined, extensions?: Record<string, string | number> | undefined) => void;
|
|
28
|
+
addOnFlushMetric: (metricFn: () => Metric | Metric[]) => void;
|
|
29
|
+
trackCache: (name: string, cacheInstance: GetStats) => void;
|
|
30
|
+
statusTrack: () => EnvMetric[];
|
|
31
|
+
private metricToAggregate;
|
|
32
|
+
private cacheToMetric;
|
|
33
|
+
private flushMetrics;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ramda_1 = require("ramda");
|
|
4
|
+
const stats_lite_1 = require("stats-lite");
|
|
5
|
+
const HttpAgentSingleton_1 = require("../HttpClient/middlewares/request/HttpAgentSingleton");
|
|
6
|
+
const requestStats_1 = require("../service/worker/runtime/http/middlewares/requestStats");
|
|
7
|
+
const time_1 = require("../utils/time");
|
|
8
|
+
// Production pods never handle development workspaces and vice-versa.
|
|
9
|
+
const production = process.env.VTEX_PRODUCTION === 'true';
|
|
10
|
+
let lastCpu = process.cpuUsage();
|
|
11
|
+
function cpuUsage() {
|
|
12
|
+
const diff = process.cpuUsage(lastCpu);
|
|
13
|
+
lastCpu = {
|
|
14
|
+
system: lastCpu.system + diff.system,
|
|
15
|
+
user: lastCpu.user + diff.user,
|
|
16
|
+
};
|
|
17
|
+
return diff;
|
|
18
|
+
}
|
|
19
|
+
function getIncomingRequestStats() {
|
|
20
|
+
const stats = requestStats_1.incomingRequestStats.get();
|
|
21
|
+
requestStats_1.incomingRequestStats.clear();
|
|
22
|
+
return stats;
|
|
23
|
+
}
|
|
24
|
+
class MetricsAccumulator {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.batchMetric = (name, timeMillis, extensions) => {
|
|
27
|
+
if (!this.metricsMillis[name]) {
|
|
28
|
+
this.metricsMillis[name] = [];
|
|
29
|
+
}
|
|
30
|
+
if (timeMillis != null) {
|
|
31
|
+
this.metricsMillis[name].push(timeMillis);
|
|
32
|
+
}
|
|
33
|
+
if (extensions) {
|
|
34
|
+
if (!this.extensions[name]) {
|
|
35
|
+
this.extensions[name] = {};
|
|
36
|
+
}
|
|
37
|
+
for (const [key, value] of Object.entries(extensions)) {
|
|
38
|
+
const existing = this.extensions[name][key];
|
|
39
|
+
if (typeof value === 'string' || typeof existing === 'string') {
|
|
40
|
+
this.extensions[name][key] = value;
|
|
41
|
+
}
|
|
42
|
+
else if (typeof value === 'number') {
|
|
43
|
+
this.extensions[name][key] = (existing || 0) + value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Batches a named metric which took `diffNs`.
|
|
50
|
+
*
|
|
51
|
+
* @param name Metric label.
|
|
52
|
+
* @param diffNs The result of calling process.hrtime() passing a previous process.hrtime() value.
|
|
53
|
+
* @param extensions Any other relevant properties of this metric.
|
|
54
|
+
*
|
|
55
|
+
* @see https://nodejs.org/api/process.html#process_process_hrtime_time
|
|
56
|
+
*/
|
|
57
|
+
this.batch = (name, diffNs, extensions) => {
|
|
58
|
+
this.batchMetric(name, diffNs ? time_1.hrToMillis(diffNs) : undefined, extensions);
|
|
59
|
+
};
|
|
60
|
+
this.addOnFlushMetric = (metricFn) => {
|
|
61
|
+
this.onFlushMetrics.push(metricFn);
|
|
62
|
+
};
|
|
63
|
+
this.trackCache = (name, cacheInstance) => {
|
|
64
|
+
this.cacheMap[name] = cacheInstance;
|
|
65
|
+
};
|
|
66
|
+
this.statusTrack = () => {
|
|
67
|
+
return this.flushMetrics();
|
|
68
|
+
};
|
|
69
|
+
this.metricToAggregate = (value, key) => {
|
|
70
|
+
const aggregate = {
|
|
71
|
+
name: key,
|
|
72
|
+
count: value.length,
|
|
73
|
+
max: Math.max(...value),
|
|
74
|
+
mean: stats_lite_1.mean(value),
|
|
75
|
+
median: stats_lite_1.median(value),
|
|
76
|
+
percentile95: stats_lite_1.percentile(value, 0.95),
|
|
77
|
+
percentile99: stats_lite_1.percentile(value, 0.99),
|
|
78
|
+
production,
|
|
79
|
+
...this.extensions[key],
|
|
80
|
+
};
|
|
81
|
+
delete this.metricsMillis[key];
|
|
82
|
+
delete this.extensions[key];
|
|
83
|
+
return aggregate;
|
|
84
|
+
};
|
|
85
|
+
this.cacheToMetric = (value, key) => ({
|
|
86
|
+
...value.getStats(),
|
|
87
|
+
name: `${key}-cache`,
|
|
88
|
+
production,
|
|
89
|
+
});
|
|
90
|
+
this.flushMetrics = () => {
|
|
91
|
+
const aggregateMetrics = ramda_1.values(ramda_1.mapObjIndexed(this.metricToAggregate, this.metricsMillis));
|
|
92
|
+
const systemMetrics = [
|
|
93
|
+
{
|
|
94
|
+
...cpuUsage(),
|
|
95
|
+
name: 'cpu',
|
|
96
|
+
production,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
...process.memoryUsage(),
|
|
100
|
+
name: 'memory',
|
|
101
|
+
production,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
...HttpAgentSingleton_1.HttpAgentSingleton.httpAgentStats(),
|
|
105
|
+
name: 'httpAgent',
|
|
106
|
+
production,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
...getIncomingRequestStats(),
|
|
110
|
+
name: 'incomingRequest',
|
|
111
|
+
production,
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
const onFlushMetrics = ramda_1.flatten(ramda_1.map(getMetric => getMetric(), this.onFlushMetrics));
|
|
115
|
+
const envFlushMetric = ramda_1.map(ramda_1.assoc('production', production), onFlushMetrics);
|
|
116
|
+
const cacheMetrics = ramda_1.values(ramda_1.mapObjIndexed(this.cacheToMetric, this.cacheMap));
|
|
117
|
+
return [...systemMetrics, ...aggregateMetrics, ...envFlushMetric, ...cacheMetrics];
|
|
118
|
+
};
|
|
119
|
+
this.metricsMillis = {};
|
|
120
|
+
this.extensions = {};
|
|
121
|
+
this.onFlushMetrics = [];
|
|
122
|
+
this.cacheMap = {};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.MetricsAccumulator = MetricsAccumulator;
|