@vtex/api 6.48.0 → 6.48.1-beta
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 +0 -3
- package/lib/{clients/apps → HttpClient}/AppClient.d.ts +3 -3
- package/lib/{clients/apps → HttpClient}/AppClient.js +5 -10
- package/lib/{clients/apps → HttpClient}/AppGraphQLClient.d.ts +3 -3
- package/lib/{clients/apps → HttpClient}/AppGraphQLClient.js +5 -10
- package/lib/{clients/external → HttpClient}/ExternalClient.d.ts +3 -3
- package/lib/{clients/external → HttpClient}/ExternalClient.js +2 -9
- package/lib/HttpClient/GraphQLClient.d.ts +1 -2
- package/lib/HttpClient/GraphQLClient.js +1 -4
- package/lib/HttpClient/HttpClient.d.ts +5 -6
- package/lib/HttpClient/HttpClient.js +21 -63
- package/lib/{clients → HttpClient}/IOClient.d.ts +4 -4
- package/lib/HttpClient/IOClient.js +14 -0
- package/lib/{clients → HttpClient}/IOGraphQLClient.d.ts +4 -4
- package/lib/{clients → HttpClient}/IOGraphQLClient.js +2 -2
- package/lib/{clients/infra → HttpClient}/InfraClient.d.ts +3 -3
- package/lib/{clients/infra → HttpClient}/InfraClient.js +4 -9
- package/lib/{clients/janus → HttpClient}/JanusClient.d.ts +3 -3
- package/lib/{clients/janus → HttpClient}/JanusClient.js +3 -7
- package/lib/HttpClient/factories/index.d.ts +8 -0
- package/lib/HttpClient/factories/index.js +31 -0
- package/lib/HttpClient/index.d.ts +7 -1
- package/lib/HttpClient/index.js +7 -1
- package/lib/HttpClient/middlewares/cache.d.ts +2 -8
- package/lib/HttpClient/middlewares/cache.js +31 -120
- package/lib/HttpClient/middlewares/cancellationToken.d.ts +1 -1
- package/lib/HttpClient/middlewares/cancellationToken.js +1 -2
- package/lib/HttpClient/middlewares/memoization.js +1 -8
- package/lib/HttpClient/middlewares/metrics.js +31 -12
- package/lib/HttpClient/middlewares/recorder.d.ts +1 -1
- package/lib/HttpClient/middlewares/recorder.js +13 -16
- package/lib/HttpClient/middlewares/request.d.ts +10 -0
- package/lib/HttpClient/middlewares/request.js +87 -0
- package/lib/HttpClient/typings.d.ts +9 -43
- package/lib/IODataSource.d.ts +27 -0
- package/lib/IODataSource.js +46 -0
- package/lib/caches/LRUCache.js +1 -5
- package/lib/caches/LRUDiskCache.js +1 -5
- package/lib/clients/Apps.d.ts +84 -0
- package/lib/clients/Apps.js +326 -0
- package/lib/clients/Assets.d.ts +21 -0
- package/lib/clients/{infra/Assets.js → Assets.js} +19 -74
- package/lib/clients/Billing.d.ts +11 -0
- package/lib/clients/{apps/Billing.js → Billing.js} +3 -8
- package/lib/clients/BillingMetrics.d.ts +12 -0
- package/lib/clients/BillingMetrics.js +10 -0
- package/lib/clients/{apps/Builder.d.ts → Builder.d.ts} +11 -12
- package/lib/clients/{apps/Builder.js → Builder.js} +22 -49
- package/lib/clients/Events.d.ts +6 -0
- package/lib/clients/Events.js +19 -0
- package/lib/clients/Housekeeper.d.ts +11 -0
- package/lib/clients/Housekeeper.js +24 -0
- package/lib/clients/ID.d.ts +22 -0
- package/lib/clients/ID.js +48 -0
- package/lib/clients/IOClients.d.ts +24 -28
- package/lib/clients/IOClients.js +28 -35
- package/lib/clients/LicenseManager.d.ts +6 -0
- package/lib/clients/{janus/LicenseManager.js → LicenseManager.js} +8 -23
- package/lib/clients/Logger.d.ts +27 -0
- package/lib/clients/Logger.js +32 -0
- package/lib/clients/Messages.d.ts +18 -0
- package/lib/clients/Messages.js +20 -0
- package/lib/clients/MessagesGraphQL.d.ts +63 -0
- package/lib/clients/MessagesGraphQL.js +50 -0
- package/lib/clients/Metadata.d.ts +25 -0
- package/lib/clients/Metadata.js +53 -0
- package/lib/clients/Registry.d.ts +61 -0
- package/lib/clients/{infra/Registry.js → Registry.js} +33 -93
- package/lib/clients/Router.d.ts +33 -0
- package/lib/clients/Router.js +50 -0
- package/lib/clients/{janus/Segment.d.ts → Segment.d.ts} +11 -7
- package/lib/clients/Segment.js +69 -0
- package/lib/clients/{janus/Session.d.ts → Session.d.ts} +4 -4
- package/lib/clients/{janus/Session.js → Session.js} +13 -24
- package/lib/clients/{apps/Settings.d.ts → Settings.d.ts} +4 -5
- package/lib/clients/{apps/Settings.js → Settings.js} +20 -14
- package/lib/clients/Sphinx.d.ts +12 -0
- package/lib/clients/Sphinx.js +19 -0
- package/lib/clients/{janus/Tenant.d.ts → Tenant.d.ts} +7 -6
- package/lib/clients/Tenant.js +13 -0
- package/lib/clients/VBase.d.ts +57 -0
- package/lib/clients/VBase.js +116 -0
- package/lib/clients/Workspaces.d.ts +17 -0
- package/lib/clients/Workspaces.js +38 -0
- package/lib/clients/index.d.ts +21 -9
- package/lib/clients/index.js +21 -12
- package/lib/constants.d.ts +1 -49
- package/lib/constants.js +1 -54
- package/lib/errors/ResolverError.d.ts +1 -1
- package/lib/errors/ResolverError.js +2 -2
- package/lib/errors/ResolverWarning.d.ts +1 -1
- package/lib/errors/ResolverWarning.js +2 -2
- package/lib/index.d.ts +7 -9
- package/lib/index.js +6 -8
- package/lib/metrics/MetricsAccumulator.d.ts +18 -1
- package/lib/metrics/MetricsAccumulator.js +22 -38
- package/lib/responses.d.ts +44 -3
- package/lib/service/Runtime.d.ts +18 -0
- package/lib/service/Runtime.js +57 -0
- package/lib/service/{worker/runtime/Service.d.ts → Service.d.ts} +5 -5
- package/lib/service/{worker/runtime/Service.js → Service.js} +1 -2
- package/lib/service/events/index.d.ts +3 -0
- package/lib/service/events/index.js +21 -0
- package/lib/service/graphql/index.d.ts +7 -0
- package/lib/service/graphql/index.js +33 -0
- package/lib/service/graphql/middlewares/error.js +107 -0
- package/lib/service/graphql/middlewares/formatters.d.ts +2 -0
- package/lib/service/graphql/middlewares/formatters.js +64 -0
- package/lib/service/graphql/middlewares/query.d.ts +2 -0
- package/lib/service/graphql/middlewares/query.js +32 -0
- package/lib/service/graphql/middlewares/response.js +36 -0
- package/lib/service/graphql/middlewares/run.d.ts +4 -0
- package/lib/service/graphql/middlewares/run.js +55 -0
- package/lib/service/graphql/middlewares/schema.d.ts +2 -0
- package/lib/service/graphql/middlewares/schema.js +8 -0
- package/lib/service/graphql/middlewares/timings.d.ts +2 -0
- package/lib/service/graphql/middlewares/timings.js +10 -0
- package/lib/service/graphql/middlewares/upload.d.ts +7 -0
- package/lib/service/graphql/schema/index.d.ts +3 -0
- package/lib/service/graphql/schema/index.js +66 -0
- package/lib/service/graphql/schema/messagesLoader.d.ts +4 -0
- package/lib/service/graphql/schema/messagesLoader.js +41 -0
- package/lib/service/graphql/schema/messagesLoaderV2.d.ts +5 -0
- package/lib/service/graphql/schema/messagesLoaderV2.js +44 -0
- package/lib/service/{worker/runtime/graphql → graphql}/schema/schemaDirectives/Auth.d.ts +0 -1
- package/lib/service/{worker/runtime/graphql → graphql}/schema/schemaDirectives/Auth.js +10 -16
- package/lib/service/{worker/runtime/graphql → graphql}/schema/schemaDirectives/Sanitize.d.ts +0 -1
- package/lib/service/{worker/runtime/graphql → graphql}/schema/schemaDirectives/Sanitize.js +0 -6
- package/lib/service/{worker/runtime/graphql → graphql}/schema/schemaDirectives/SmartCacheDirective.d.ts +0 -1
- package/lib/service/{worker/runtime/graphql → graphql}/schema/schemaDirectives/SmartCacheDirective.js +3 -8
- package/lib/service/{worker/runtime/graphql/schema/schemaDirectives/TranslateTo.d.ts → graphql/schema/schemaDirectives/Translatable.d.ts} +1 -2
- package/lib/service/graphql/schema/schemaDirectives/Translatable.js +54 -0
- package/lib/service/graphql/schema/schemaDirectives/TranslatableV2.d.ts +13 -0
- package/lib/service/graphql/schema/schemaDirectives/TranslatableV2.js +67 -0
- package/lib/service/graphql/schema/schemaDirectives/index.d.ts +13 -0
- package/lib/service/graphql/schema/schemaDirectives/index.js +17 -0
- package/lib/service/graphql/schema/typeDefs/index.d.ts +16 -0
- package/lib/service/graphql/schema/typeDefs/index.js +21 -0
- package/lib/service/graphql/schema/typeDefs/ioMessage.d.ts +8 -0
- package/lib/service/graphql/schema/typeDefs/ioMessage.js +33 -0
- package/lib/service/{worker/runtime/graphql → graphql}/schema/typeDefs/sanitizedString.js +1 -5
- package/lib/service/graphql/typings.d.ts +21 -0
- package/lib/service/graphql/utils/cacheControl.d.ts +6 -0
- package/lib/service/graphql/utils/cacheControl.js +38 -0
- package/lib/service/graphql/utils/maxAgeEnum.d.ts +6 -0
- package/lib/service/graphql/utils/maxAgeEnum.js +17 -0
- package/lib/service/http/index.d.ts +3 -0
- package/lib/service/http/index.js +18 -0
- package/lib/service/http/middlewares/authTokens.d.ts +3 -0
- package/lib/service/http/middlewares/cancellationToken.d.ts +3 -0
- package/lib/service/{worker/runtime/http → http}/middlewares/cancellationToken.js +1 -2
- package/lib/service/http/middlewares/clients.d.ts +4 -0
- package/lib/service/http/middlewares/error.d.ts +3 -0
- package/lib/service/{worker/runtime/http → http}/middlewares/error.js +10 -19
- package/lib/service/{worker/runtime/http → http}/middlewares/requestStats.d.ts +3 -3
- package/lib/service/http/middlewares/setCookie.d.ts +3 -0
- package/lib/service/http/middlewares/timings.d.ts +3 -0
- package/lib/service/{worker/runtime/http → http}/middlewares/timings.js +8 -21
- package/lib/service/http/middlewares/vary.d.ts +3 -0
- package/lib/service/{worker/runtime/http → http}/middlewares/vary.js +3 -3
- package/lib/service/logger/index.d.ts +28 -2
- package/lib/service/logger/index.js +68 -5
- package/lib/service/method.d.ts +9 -0
- package/lib/service/{worker/runtime/typings.d.ts → typings.d.ts} +36 -70
- package/lib/service/utils/compose.d.ts +4 -0
- package/lib/service/{worker/runtime/utils → utils}/compose.js +2 -2
- package/lib/utils/MineWinsConflictsResolver.d.ts +4 -6
- package/lib/utils/MineWinsConflictsResolver.js +17 -34
- package/lib/utils/MineWinsConflictsResolver.test.d.ts +1 -0
- package/lib/utils/MineWinsConflictsResolver.test.js +134 -0
- package/lib/utils/app.d.ts +1 -3
- package/lib/utils/app.js +1 -3
- package/lib/utils/appsStaleIfError.d.ts +1 -1
- package/lib/utils/appsStaleIfError.js +2 -2
- package/lib/utils/billingOptions.d.ts +3 -36
- package/lib/utils/billingOptions.js +3 -7
- package/lib/utils/binding.d.ts +3 -3
- package/lib/utils/cancel.d.ts +2 -2
- package/lib/utils/cancel.js +1 -2
- package/lib/utils/log.d.ts +3 -1
- package/lib/utils/log.js +2 -2
- package/lib/utils/message.js +1 -4
- package/lib/utils/tenant.d.ts +3 -3
- package/lib/utils/time.d.ts +2 -4
- package/lib/utils/time.js +2 -9
- package/lib/utils/unhandled.d.ts +1 -0
- package/lib/{service/worker/listeners.js → utils/unhandled.js} +15 -9
- package/package.json +2 -2
- package/CHANGELOG.md +0 -1858
- package/lib/HttpClient/agents.d.ts +0 -3
- package/lib/HttpClient/agents.js +0 -24
- package/lib/HttpClient/middlewares/request/HttpAgentSingleton.d.ts +0 -11
- package/lib/HttpClient/middlewares/request/HttpAgentSingleton.js +0 -30
- package/lib/HttpClient/middlewares/request/index.d.ts +0 -18
- package/lib/HttpClient/middlewares/request/index.js +0 -84
- package/lib/HttpClient/middlewares/request/setupAxios/index.d.ts +0 -1
- package/lib/HttpClient/middlewares/request/setupAxios/index.js +0 -20
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.d.ts +0 -2
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +0 -53
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.d.ts +0 -2
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +0 -7
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.d.ts +0 -8
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.js +0 -53
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.d.ts +0 -4
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +0 -29
- package/lib/HttpClient/middlewares/tracing.d.ts +0 -15
- package/lib/HttpClient/middlewares/tracing.js +0 -56
- package/lib/clients/IOClient.js +0 -19
- package/lib/clients/apps/Billing.d.ts +0 -12
- package/lib/clients/apps/MessagesGraphQL.d.ts +0 -61
- package/lib/clients/apps/MessagesGraphQL.js +0 -121
- package/lib/clients/apps/catalogGraphQL/brand.d.ts +0 -13
- package/lib/clients/apps/catalogGraphQL/brand.js +0 -18
- package/lib/clients/apps/catalogGraphQL/category.d.ts +0 -11
- package/lib/clients/apps/catalogGraphQL/category.js +0 -16
- package/lib/clients/apps/catalogGraphQL/index.d.ts +0 -22
- package/lib/clients/apps/catalogGraphQL/index.js +0 -88
- package/lib/clients/apps/catalogGraphQL/product.d.ts +0 -25
- package/lib/clients/apps/catalogGraphQL/product.js +0 -30
- package/lib/clients/apps/catalogGraphQL/sku.d.ts +0 -26
- package/lib/clients/apps/catalogGraphQL/sku.js +0 -30
- package/lib/clients/apps/index.d.ts +0 -7
- package/lib/clients/apps/index.js +0 -12
- package/lib/clients/external/ID.d.ts +0 -23
- package/lib/clients/external/ID.js +0 -60
- package/lib/clients/external/Masterdata.d.ts +0 -94
- package/lib/clients/external/Masterdata.js +0 -224
- package/lib/clients/external/PaymentProvider.d.ts +0 -31
- package/lib/clients/external/PaymentProvider.js +0 -42
- package/lib/clients/external/index.d.ts +0 -4
- package/lib/clients/external/index.js +0 -9
- package/lib/clients/infra/Apps.d.ts +0 -88
- package/lib/clients/infra/Apps.js +0 -508
- package/lib/clients/infra/Assets.d.ts +0 -34
- package/lib/clients/infra/BillingMetrics.d.ts +0 -13
- package/lib/clients/infra/BillingMetrics.js +0 -15
- package/lib/clients/infra/Events.d.ts +0 -12
- package/lib/clients/infra/Events.js +0 -33
- package/lib/clients/infra/Housekeeper.d.ts +0 -10
- package/lib/clients/infra/Housekeeper.js +0 -30
- package/lib/clients/infra/Registry.d.ts +0 -59
- package/lib/clients/infra/Router.d.ts +0 -34
- package/lib/clients/infra/Router.js +0 -81
- package/lib/clients/infra/Sphinx.d.ts +0 -13
- package/lib/clients/infra/Sphinx.js +0 -29
- package/lib/clients/infra/VBase.d.ts +0 -60
- package/lib/clients/infra/VBase.js +0 -196
- package/lib/clients/infra/Workspaces.d.ts +0 -18
- package/lib/clients/infra/Workspaces.js +0 -65
- package/lib/clients/infra/index.d.ts +0 -11
- package/lib/clients/infra/index.js +0 -16
- package/lib/clients/janus/LicenseManager.d.ts +0 -7
- package/lib/clients/janus/Segment.js +0 -88
- package/lib/clients/janus/Tenant.js +0 -28
- package/lib/clients/janus/index.d.ts +0 -5
- package/lib/clients/janus/index.js +0 -10
- package/lib/service/index.d.ts +0 -2
- package/lib/service/index.js +0 -30
- package/lib/service/loaders.d.ts +0 -8
- package/lib/service/loaders.js +0 -54
- package/lib/service/logger/console.d.ts +0 -10
- package/lib/service/logger/console.js +0 -36
- package/lib/service/logger/logger.d.ts +0 -29
- package/lib/service/logger/logger.js +0 -61
- package/lib/service/logger/metricsLogger.d.ts +0 -40
- package/lib/service/logger/metricsLogger.js +0 -149
- package/lib/service/master.d.ts +0 -2
- package/lib/service/master.js +0 -87
- package/lib/service/metrics/requestMetricsMiddleware.d.ts +0 -2
- package/lib/service/metrics/requestMetricsMiddleware.js +0 -44
- package/lib/service/tracing/TracerSingleton.d.ts +0 -7
- package/lib/service/tracing/TracerSingleton.js +0 -48
- package/lib/service/tracing/metrics/MetricNames.d.ts +0 -60
- package/lib/service/tracing/metrics/MetricNames.js +0 -44
- package/lib/service/tracing/metrics/instruments.d.ts +0 -9
- package/lib/service/tracing/metrics/instruments.js +0 -11
- package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.d.ts +0 -9
- package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +0 -25
- package/lib/service/tracing/tracingMiddlewares.d.ts +0 -5
- package/lib/service/tracing/tracingMiddlewares.js +0 -107
- package/lib/service/worker/index.d.ts +0 -11
- package/lib/service/worker/index.js +0 -195
- package/lib/service/worker/listeners.d.ts +0 -3
- package/lib/service/worker/runtime/builtIn/handlers.d.ts +0 -4
- package/lib/service/worker/runtime/builtIn/handlers.js +0 -30
- package/lib/service/worker/runtime/builtIn/middlewares.d.ts +0 -4
- package/lib/service/worker/runtime/builtIn/middlewares.js +0 -40
- package/lib/service/worker/runtime/events/index.d.ts +0 -4
- package/lib/service/worker/runtime/events/index.js +0 -46
- package/lib/service/worker/runtime/events/middlewares/body.d.ts +0 -3
- package/lib/service/worker/runtime/events/middlewares/body.js +0 -22
- package/lib/service/worker/runtime/events/middlewares/context.d.ts +0 -3
- package/lib/service/worker/runtime/events/middlewares/context.js +0 -22
- package/lib/service/worker/runtime/events/router.d.ts +0 -2
- package/lib/service/worker/runtime/events/router.js +0 -27
- package/lib/service/worker/runtime/graphql/index.d.ts +0 -6
- package/lib/service/worker/runtime/graphql/index.js +0 -27
- package/lib/service/worker/runtime/graphql/middlewares/context.d.ts +0 -2
- package/lib/service/worker/runtime/graphql/middlewares/context.js +0 -16
- package/lib/service/worker/runtime/graphql/middlewares/error.js +0 -93
- package/lib/service/worker/runtime/graphql/middlewares/query.d.ts +0 -2
- package/lib/service/worker/runtime/graphql/middlewares/query.js +0 -52
- package/lib/service/worker/runtime/graphql/middlewares/response.js +0 -38
- package/lib/service/worker/runtime/graphql/middlewares/run.d.ts +0 -2
- package/lib/service/worker/runtime/graphql/middlewares/run.js +0 -19
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.d.ts +0 -4
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +0 -28
- package/lib/service/worker/runtime/graphql/middlewares/upload.d.ts +0 -4
- package/lib/service/worker/runtime/graphql/schema/index.d.ts +0 -7
- package/lib/service/worker/runtime/graphql/schema/index.js +0 -31
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +0 -6
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +0 -79
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.d.ts +0 -7
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.js +0 -37
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.d.ts +0 -11
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +0 -61
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.d.ts +0 -7
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.js +0 -40
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.d.ts +0 -6
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +0 -34
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.d.ts +0 -7
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +0 -39
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +0 -33
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.d.ts +0 -22
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +0 -36
- package/lib/service/worker/runtime/graphql/schema/typeDefs/index.d.ts +0 -7
- package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +0 -12
- package/lib/service/worker/runtime/graphql/typings.d.ts +0 -31
- package/lib/service/worker/runtime/graphql/utils/cacheControl.d.ts +0 -1
- package/lib/service/worker/runtime/graphql/utils/cacheControl.js +0 -32
- package/lib/service/worker/runtime/graphql/utils/error.d.ts +0 -1
- package/lib/service/worker/runtime/graphql/utils/error.js +0 -76
- package/lib/service/worker/runtime/graphql/utils/translations.d.ts +0 -14
- package/lib/service/worker/runtime/graphql/utils/translations.js +0 -38
- package/lib/service/worker/runtime/http/index.d.ts +0 -5
- package/lib/service/worker/runtime/http/index.js +0 -58
- package/lib/service/worker/runtime/http/middlewares/authTokens.d.ts +0 -3
- package/lib/service/worker/runtime/http/middlewares/cancellationToken.d.ts +0 -3
- package/lib/service/worker/runtime/http/middlewares/clients.d.ts +0 -4
- package/lib/service/worker/runtime/http/middlewares/context.d.ts +0 -4
- package/lib/service/worker/runtime/http/middlewares/context.js +0 -36
- package/lib/service/worker/runtime/http/middlewares/error.d.ts +0 -2
- package/lib/service/worker/runtime/http/middlewares/rateLimit.d.ts +0 -6
- package/lib/service/worker/runtime/http/middlewares/rateLimit.js +0 -42
- package/lib/service/worker/runtime/http/middlewares/setCookie.d.ts +0 -3
- package/lib/service/worker/runtime/http/middlewares/settings.d.ts +0 -9
- package/lib/service/worker/runtime/http/middlewares/settings.js +0 -44
- package/lib/service/worker/runtime/http/middlewares/timings.d.ts +0 -3
- package/lib/service/worker/runtime/http/middlewares/vary.d.ts +0 -3
- package/lib/service/worker/runtime/http/router.d.ts +0 -2
- package/lib/service/worker/runtime/http/router.js +0 -23
- package/lib/service/worker/runtime/http/routes.d.ts +0 -19
- package/lib/service/worker/runtime/http/routes.js +0 -12
- package/lib/service/worker/runtime/method.d.ts +0 -9
- package/lib/service/worker/runtime/statusTrack.d.ts +0 -14
- package/lib/service/worker/runtime/statusTrack.js +0 -37
- package/lib/service/worker/runtime/utils/compose.d.ts +0 -5
- package/lib/service/worker/runtime/utils/context.d.ts +0 -2
- package/lib/service/worker/runtime/utils/context.js +0 -40
- package/lib/service/worker/runtime/utils/diff.d.ts +0 -12
- package/lib/service/worker/runtime/utils/diff.js +0 -21
- package/lib/service/worker/runtime/utils/recorder.d.ts +0 -8
- package/lib/service/worker/runtime/utils/recorder.js +0 -37
- package/lib/service/worker/runtime/utils/tokenBucket.d.ts +0 -2
- package/lib/service/worker/runtime/utils/tokenBucket.js +0 -16
- package/lib/tracing/LogEvents.d.ts +0 -31
- package/lib/tracing/LogEvents.js +0 -3
- package/lib/tracing/LogFields.d.ts +0 -66
- package/lib/tracing/LogFields.js +0 -3
- package/lib/tracing/Tags.d.ts +0 -81
- package/lib/tracing/Tags.js +0 -7
- package/lib/tracing/UserLandTracer.d.ts +0 -27
- package/lib/tracing/UserLandTracer.js +0 -56
- package/lib/tracing/errorReporting/ErrorReport.d.ts +0 -31
- package/lib/tracing/errorReporting/ErrorReport.js +0 -70
- package/lib/tracing/index.d.ts +0 -9
- package/lib/tracing/index.js +0 -19
- package/lib/tracing/spanReference/SpanReferenceTypes.d.ts +0 -4
- package/lib/tracing/spanReference/SpanReferenceTypes.js +0 -7
- package/lib/tracing/spanReference/createSpanReference.d.ts +0 -3
- package/lib/tracing/spanReference/createSpanReference.js +0 -8
- package/lib/tracing/utils.d.ts +0 -13
- package/lib/tracing/utils.js +0 -40
- package/lib/utils/conflicts.mock.d.ts +0 -17
- package/lib/utils/conflicts.mock.js +0 -27
- /package/lib/service/{worker/runtime/graphql → graphql}/middlewares/error.d.ts +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/middlewares/response.d.ts +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/middlewares/upload.js +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/schema/typeDefs/ioUpload.d.ts +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/schema/typeDefs/ioUpload.js +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/schema/typeDefs/sanitizedString.d.ts +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/typings.js +0 -0
- /package/lib/service/{worker/runtime/utils/toArray.d.ts → graphql/utils/array.d.ts} +0 -0
- /package/lib/service/{worker/runtime/utils/toArray.js → graphql/utils/array.js} +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/utils/pathname.d.ts +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/utils/pathname.js +0 -0
- /package/lib/service/{worker/runtime/http → http}/middlewares/authTokens.js +0 -0
- /package/lib/service/{worker/runtime/http → http}/middlewares/clients.js +0 -0
- /package/lib/service/{worker/runtime/http → http}/middlewares/requestStats.js +0 -0
- /package/lib/service/{worker/runtime/http → http}/middlewares/setCookie.js +0 -0
- /package/lib/service/{worker/runtime/method.js → method.js} +0 -0
- /package/lib/service/{worker/runtime/typings.js → typings.js} +0 -0
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { IOClients } from '../../../../../clients/IOClients';
|
|
2
|
-
import { ParamsContext, RecorderState, ServiceContext } from '../../typings';
|
|
3
|
-
export declare function cancellationToken<T extends IOClients, U extends RecorderState, V extends ParamsContext>(ctx: ServiceContext<T, U, V>, next: () => Promise<void>): Promise<void>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ClientsImplementation, IOClients } from '../../../../../clients/IOClients';
|
|
2
|
-
import { InstanceOptions } from '../../../../../HttpClient';
|
|
3
|
-
import { ParamsContext, RecorderState, ServiceContext } from '../../typings';
|
|
4
|
-
export declare function clients<T extends IOClients, U extends RecorderState, V extends ParamsContext>(ClientsImpl: ClientsImplementation<T>, clientOptions: Record<string, InstanceOptions>): (ctx: ServiceContext<T, U, V>, next: () => Promise<void>) => Promise<void>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { IOClients } from '../../../../../clients/IOClients';
|
|
2
|
-
import { ParamsContext, RecorderState, ServiceContext, ServiceRoute } from './../../typings';
|
|
3
|
-
export declare const createPvtContextMiddleware: (routeId: string, { smartcache }: ServiceRoute) => <T extends IOClients, U extends RecorderState, V extends ParamsContext>(ctx: ServiceContext<T, U, V>, next: () => Promise<void>) => Promise<void>;
|
|
4
|
-
export declare const createPubContextMiddleware: (routeId: string, { smartcache }: ServiceRoute) => <T extends IOClients, U extends RecorderState, V extends ParamsContext>(ctx: ServiceContext<T, U, V>, next: () => Promise<void>) => Promise<void>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const querystring_1 = require("querystring");
|
|
4
|
-
const constants_1 = require("../../../../../constants");
|
|
5
|
-
const context_1 = require("../../utils/context");
|
|
6
|
-
exports.createPvtContextMiddleware = (routeId, { smartcache }) => {
|
|
7
|
-
return async function pvtContext(ctx, next) {
|
|
8
|
-
const { params, request: { header }, } = ctx;
|
|
9
|
-
ctx.vtex = {
|
|
10
|
-
...context_1.prepareHandlerCtx(header, ctx.tracing),
|
|
11
|
-
...(smartcache && { recorder: ctx.state.recorder }),
|
|
12
|
-
route: {
|
|
13
|
-
id: routeId,
|
|
14
|
-
params,
|
|
15
|
-
type: 'private',
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
await next();
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
exports.createPubContextMiddleware = (routeId, { smartcache }) => {
|
|
22
|
-
return async function pubContext(ctx, next) {
|
|
23
|
-
const { request: { header }, } = ctx;
|
|
24
|
-
ctx.vtex = {
|
|
25
|
-
...context_1.prepareHandlerCtx(header, ctx.tracing),
|
|
26
|
-
...(smartcache && { recorder: ctx.state.recorder }),
|
|
27
|
-
route: {
|
|
28
|
-
declarer: header[constants_1.COLOSSUS_ROUTE_DECLARER_HEADER],
|
|
29
|
-
id: routeId,
|
|
30
|
-
params: querystring_1.parse(header[constants_1.COLOSSUS_PARAMS_HEADER]),
|
|
31
|
-
type: 'public',
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
await next();
|
|
35
|
-
};
|
|
36
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import TokenBucket from 'tokenbucket';
|
|
2
|
-
import { ServiceContext } from '../../typings';
|
|
3
|
-
declare function noopMiddleware(_: ServiceContext, next: () => Promise<void>): Promise<void>;
|
|
4
|
-
export declare function perMinuteRateLimiter(rateLimit?: number, globalLimiter?: TokenBucket): typeof noopMiddleware;
|
|
5
|
-
export declare function concurrentRateLimiter(rateLimit?: number): typeof noopMiddleware;
|
|
6
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const errors_1 = require("../../../../../errors");
|
|
4
|
-
const tokenBucket_1 = require("../../utils/tokenBucket");
|
|
5
|
-
const responseMessageConcurrent = 'Rate Exceeded: Too many requests in execution';
|
|
6
|
-
const responseMessagePerMinute = 'Rate Exceeded: Too many requests per minute';
|
|
7
|
-
function noopMiddleware(_, next) {
|
|
8
|
-
return next();
|
|
9
|
-
}
|
|
10
|
-
function perMinuteRateLimiter(rateLimit, globalLimiter) {
|
|
11
|
-
if (!rateLimit && !globalLimiter) {
|
|
12
|
-
return noopMiddleware;
|
|
13
|
-
}
|
|
14
|
-
const tokenBucket = tokenBucket_1.createTokenBucket(rateLimit, globalLimiter);
|
|
15
|
-
return function perMinuteRateMiddleware(ctx, next) {
|
|
16
|
-
if (!tokenBucket.removeTokensSync(1)) {
|
|
17
|
-
throw new errors_1.TooManyRequestsError(responseMessagePerMinute);
|
|
18
|
-
}
|
|
19
|
-
return next();
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
exports.perMinuteRateLimiter = perMinuteRateLimiter;
|
|
23
|
-
function concurrentRateLimiter(rateLimit) {
|
|
24
|
-
if (!rateLimit) {
|
|
25
|
-
return noopMiddleware;
|
|
26
|
-
}
|
|
27
|
-
let reqsInExecution = 0;
|
|
28
|
-
const maxRequests = rateLimit;
|
|
29
|
-
return async function concurrentRateMiddleware(ctx, next) {
|
|
30
|
-
if (reqsInExecution >= maxRequests) {
|
|
31
|
-
throw new errors_1.TooManyRequestsError(responseMessageConcurrent);
|
|
32
|
-
}
|
|
33
|
-
reqsInExecution++;
|
|
34
|
-
try {
|
|
35
|
-
await next();
|
|
36
|
-
}
|
|
37
|
-
finally {
|
|
38
|
-
reqsInExecution--;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
exports.concurrentRateLimiter = concurrentRateLimiter;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { IOClients } from '../../../../../clients/IOClients';
|
|
2
|
-
import { ParamsContext, RecorderState, ServiceContext } from '../../typings';
|
|
3
|
-
export declare function removeSetCookie<T extends IOClients, U extends RecorderState, V extends ParamsContext>(ctx: ServiceContext<T, U, V>, next: () => Promise<void>): Promise<void>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AppMetaInfo, Apps } from '../../../../../clients/infra/Apps';
|
|
2
|
-
import { IOClients } from '../../../../../clients/IOClients';
|
|
3
|
-
import { RequestTracingConfig } from '../../../../../HttpClient';
|
|
4
|
-
import { Assets } from './../../../../../clients/infra/Assets';
|
|
5
|
-
import { ParamsContext, RecorderState, ServiceContext } from './../../typings';
|
|
6
|
-
export declare const getFilteredDependencies: (appAtMajor: string, dependencies: AppMetaInfo[]) => AppMetaInfo[];
|
|
7
|
-
export declare const getDependenciesHash: (dependencies: AppMetaInfo[]) => string;
|
|
8
|
-
export declare const getDependenciesSettings: (apps: Apps, assets: Assets, tracingConfig?: RequestTracingConfig | undefined) => Promise<Record<string, any>[]>;
|
|
9
|
-
export declare const getServiceSettings: () => <T extends IOClients, U extends RecorderState, V extends ParamsContext>(ctx: ServiceContext<T, U, V>, next: () => Promise<void>) => Promise<void>;
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
var _a;
|
|
37
|
-
const { clients: { apps, assets }, } = ctx;
|
|
38
|
-
const rootSpan = (_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.currentSpan;
|
|
39
|
-
const dependenciesSettings = await exports.getDependenciesSettings(apps, assets, { tracing: { rootSpan } });
|
|
40
|
-
// TODO: for now returning all settings, but the ideia is to do merge
|
|
41
|
-
ctx.vtex.settings = dependenciesSettings;
|
|
42
|
-
await next();
|
|
43
|
-
};
|
|
44
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
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>;
|
|
@@ -1,3 +0,0 @@
|
|
|
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>;
|
|
@@ -1,2 +0,0 @@
|
|
|
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>;
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,14 +0,0 @@
|
|
|
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;
|
|
@@ -1,37 +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 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, _c;
|
|
14
|
-
(_b = (_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.currentSpan) === null || _b === void 0 ? void 0 : _b.setOperationName('builtin:status-track');
|
|
15
|
-
if (!constants_1.LINKED) {
|
|
16
|
-
(_c = process.send) === null || _c === void 0 ? void 0 : _c.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
|
-
}));
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import koaCompose from 'koa-compose';
|
|
2
|
-
import { IOClients } from '../../../../clients/IOClients';
|
|
3
|
-
import { ParamsContext, RecorderState } from '../typings';
|
|
4
|
-
export declare const compose: <ClientsT extends IOClients, StateT extends RecorderState, CustomT extends ParamsContext>(middlewares: koaCompose.Middleware<import("../typings").ServiceContext<ClientsT, StateT, CustomT>>[]) => koaCompose.ComposedMiddleware<import("../typings").ServiceContext<ClientsT, StateT, CustomT>>;
|
|
5
|
-
export declare const composeForEvents: <ClientsT extends IOClients, StateT extends RecorderState>(middlewares: koaCompose.Middleware<import("../typings").EventContext<ClientsT, StateT>>[]) => koaCompose.ComposedMiddleware<import("../typings").EventContext<ClientsT, StateT>>;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { IOContext, TracingContext } from '../typings';
|
|
2
|
-
export declare const prepareHandlerCtx: (header: any, tracingContext?: TracingContext | undefined) => Pick<IOContext, "host" | "serverTiming" | "locale" | "account" | "workspace" | "region" | "logger" | "requestId" | "operationId" | "production" | "platform" | "authToken" | "adminUserAuthToken" | "storeUserAuthToken" | "product" | "recorder" | "userAgent" | "segmentToken" | "sessionToken" | "janusEnv" | "eventInfo" | "tenant" | "binding" | "cancellation" | "settings" | "tracer">;
|
|
@@ -1,40 +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 v4_1 = __importDefault(require("uuid/v4"));
|
|
7
|
-
const constants_1 = require("../../../../constants");
|
|
8
|
-
const UserLandTracer_1 = require("../../../../tracing/UserLandTracer");
|
|
9
|
-
const tenant_1 = require("../../../../utils/tenant");
|
|
10
|
-
const logger_1 = require("../../../logger");
|
|
11
|
-
const binding_1 = require("./../../../../utils/binding");
|
|
12
|
-
const getPlatform = (account) => {
|
|
13
|
-
return account.startsWith('gc-') ? 'gocommerce' : 'vtex';
|
|
14
|
-
};
|
|
15
|
-
exports.prepareHandlerCtx = (header, tracingContext) => {
|
|
16
|
-
var _a;
|
|
17
|
-
const partialContext = {
|
|
18
|
-
account: header[constants_1.ACCOUNT_HEADER],
|
|
19
|
-
authToken: header[constants_1.CREDENTIAL_HEADER],
|
|
20
|
-
binding: header[constants_1.BINDING_HEADER] ? binding_1.parseBindingHeaderValue(header[constants_1.BINDING_HEADER]) : undefined,
|
|
21
|
-
host: header[constants_1.FORWARDED_HOST_HEADER],
|
|
22
|
-
locale: header[constants_1.LOCALE_HEADER],
|
|
23
|
-
operationId: header[constants_1.OPERATION_ID_HEADER] || v4_1.default(),
|
|
24
|
-
platform: header[constants_1.PLATFORM_HEADER] || getPlatform(header[constants_1.ACCOUNT_HEADER]),
|
|
25
|
-
product: header[constants_1.PRODUCT_HEADER],
|
|
26
|
-
production: ((_a = header[constants_1.WORKSPACE_IS_PRODUCTION_HEADER]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'true' || false,
|
|
27
|
-
region: constants_1.REGION,
|
|
28
|
-
requestId: header[constants_1.REQUEST_ID_HEADER],
|
|
29
|
-
segmentToken: header[constants_1.SEGMENT_HEADER],
|
|
30
|
-
sessionToken: header[constants_1.SESSION_HEADER],
|
|
31
|
-
tenant: header[constants_1.TENANT_HEADER] ? tenant_1.parseTenantHeaderValue(header[constants_1.TENANT_HEADER]) : undefined,
|
|
32
|
-
tracer: new UserLandTracer_1.UserLandTracer(tracingContext === null || tracingContext === void 0 ? void 0 : tracingContext.tracer, tracingContext === null || tracingContext === void 0 ? void 0 : tracingContext.currentSpan),
|
|
33
|
-
userAgent: process.env.VTEX_APP_ID || '',
|
|
34
|
-
workspace: header[constants_1.WORKSPACE_HEADER],
|
|
35
|
-
};
|
|
36
|
-
return {
|
|
37
|
-
...partialContext,
|
|
38
|
-
logger: new logger_1.Logger(partialContext),
|
|
39
|
-
};
|
|
40
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
export interface Snapshot {
|
|
3
|
-
usage: NodeJS.CpuUsage;
|
|
4
|
-
time: number;
|
|
5
|
-
}
|
|
6
|
-
interface CpuUsage {
|
|
7
|
-
user: number;
|
|
8
|
-
system: number;
|
|
9
|
-
}
|
|
10
|
-
export declare function cpuSnapshot(): Snapshot;
|
|
11
|
-
export declare function snapshotDiff(curr: Snapshot, last: Snapshot): CpuUsage;
|
|
12
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function cpuSnapshot() {
|
|
4
|
-
return {
|
|
5
|
-
time: microtime(),
|
|
6
|
-
usage: process.cpuUsage(),
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
exports.cpuSnapshot = cpuSnapshot;
|
|
10
|
-
function snapshotDiff(curr, last) {
|
|
11
|
-
const timeDiff = curr.time - last.time;
|
|
12
|
-
return {
|
|
13
|
-
system: (curr.usage.system - last.usage.system) / timeDiff,
|
|
14
|
-
user: (curr.usage.user - last.usage.user) / timeDiff,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
exports.snapshotDiff = snapshotDiff;
|
|
18
|
-
function microtime() {
|
|
19
|
-
const hrTime = process.hrtime();
|
|
20
|
-
return hrTime[0] * 1000000 + hrTime[1] / 1000;
|
|
21
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ramda_1 = require("ramda");
|
|
4
|
-
const constants_1 = require("./../../../../constants");
|
|
5
|
-
const HEADERS = [constants_1.META_HEADER, constants_1.META_HEADER_BUCKET];
|
|
6
|
-
class Recorder {
|
|
7
|
-
constructor() {
|
|
8
|
-
this._record = HEADERS.reduce((acc, headerName) => {
|
|
9
|
-
acc[headerName] = new Set();
|
|
10
|
-
return acc;
|
|
11
|
-
}, {});
|
|
12
|
-
}
|
|
13
|
-
clear() {
|
|
14
|
-
HEADERS.forEach(headerName => this._record[headerName].clear());
|
|
15
|
-
}
|
|
16
|
-
record(headers) {
|
|
17
|
-
HEADERS.forEach(headerName => {
|
|
18
|
-
const h = headers === null || headers === void 0 ? void 0 : headers[headerName];
|
|
19
|
-
if (h) {
|
|
20
|
-
h.split(',').map(ramda_1.trim).forEach(hh => this._record[headerName].add(hh));
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
flush(ctx) {
|
|
25
|
-
HEADERS.forEach(headerName => {
|
|
26
|
-
const newValueSet = new Set(this._record[headerName]);
|
|
27
|
-
const currentValue = ctx.response.get(headerName);
|
|
28
|
-
const parsedCurrentValue = typeof currentValue === 'string' ? currentValue.split(',') : currentValue;
|
|
29
|
-
parsedCurrentValue.forEach(cur => newValueSet.add(ramda_1.trim(cur)));
|
|
30
|
-
const deduped = Array.from(newValueSet).filter(x => !!x);
|
|
31
|
-
if (deduped.length > 0) {
|
|
32
|
-
ctx.set(headerName, deduped);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.Recorder = Recorder;
|
|
@@ -1,16 +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 tokenbucket_1 = __importDefault(require("tokenbucket"));
|
|
7
|
-
function createTokenBucket(rateLimit, globalRateTokenBucket) {
|
|
8
|
-
return rateLimit ? new tokenbucket_1.default({
|
|
9
|
-
interval: 'minute',
|
|
10
|
-
parentBucket: globalRateTokenBucket,
|
|
11
|
-
size: Math.ceil(rateLimit / 2.0),
|
|
12
|
-
spread: true,
|
|
13
|
-
tokensToAddPerInterval: rateLimit,
|
|
14
|
-
}) : globalRateTokenBucket;
|
|
15
|
-
}
|
|
16
|
-
exports.createTokenBucket = createTokenBucket;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file has all events logged by the runtime's distributed tracing
|
|
3
|
-
* instrumentation. In the code you would see something like:
|
|
4
|
-
* ```
|
|
5
|
-
* span.log({ event: HttpEvents.CACHE_KEY_CREATE })
|
|
6
|
-
* ```
|
|
7
|
-
*/
|
|
8
|
-
export declare const enum HttpLogEvents {
|
|
9
|
-
/** Event holding the cache key created */
|
|
10
|
-
CACHE_KEY_CREATE = "cache-key-created",
|
|
11
|
-
/** Event representing that the memoization cache has just saved a response */
|
|
12
|
-
MEMOIZATION_CACHE_SAVED = "memoization-cache-saved",
|
|
13
|
-
/** Event representing that the memoization cache has just saved a error response */
|
|
14
|
-
MEMOIZATION_CACHE_SAVED_ERROR = "memoization-cache-saved-error",
|
|
15
|
-
/** Event holding information on a local cache hit that just happened */
|
|
16
|
-
LOCAL_CACHE_HIT_INFO = "local-cache-hit-info",
|
|
17
|
-
/** Event holding information on the cache config that will be used to decide whether or not to update the local cache */
|
|
18
|
-
CACHE_CONFIG = "cache-config",
|
|
19
|
-
/** Event informing the decision to not update or save to local cache */
|
|
20
|
-
NO_LOCAL_CACHE_SAVE = "no-local-cache-save",
|
|
21
|
-
/** Event holding information on the local cache save that just happened */
|
|
22
|
-
LOCAL_CACHE_SAVED = "local-cache-saved",
|
|
23
|
-
/** A request that is retryable just failed - this event will hold info on the retry that may happen */
|
|
24
|
-
SETUP_REQUEST_RETRY = "setup-request-retry"
|
|
25
|
-
}
|
|
26
|
-
export declare const enum RuntimeLogEvents {
|
|
27
|
-
/** Event representing that userland middlewares are about to start */
|
|
28
|
-
USER_MIDDLEWARES_START = "user-middlewares-start",
|
|
29
|
-
/** Event representing that userland middlewares just finished */
|
|
30
|
-
USER_MIDDLEWARES_FINISH = "user-middlewares-finish"
|
|
31
|
-
}
|
package/lib/tracing/LogEvents.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* When using span.log({ field1: string1, field2: object2, ... })
|
|
3
|
-
* The jaeger backend indexes for search the first-level fields that hold strings
|
|
4
|
-
* These fields then can be searched on jaeger-ui using: 'field1=string'
|
|
5
|
-
* This file concentrates all log fields used in node-vtex-api that hold
|
|
6
|
-
* strings and can be searched in the jaeger-ui
|
|
7
|
-
*/
|
|
8
|
-
export declare const enum ErrorReportLogFields {
|
|
9
|
-
/**
|
|
10
|
-
* ErrorReport class has some meta info on the error
|
|
11
|
-
* The following log fields hold this meta info
|
|
12
|
-
*/
|
|
13
|
-
ERROR_KIND = "error.kind",
|
|
14
|
-
ERROR_ID = "error.id",
|
|
15
|
-
ERROR_MESSAGE = "error.message",
|
|
16
|
-
ERROR_CODE = "error.code",
|
|
17
|
-
ERROR_STACK = "error.stack",
|
|
18
|
-
ERROR_METADATA_REPORT_COUNT = "error.metadata.reportCount",
|
|
19
|
-
ERROR_METADATA_METRICS_INSTANTIATION_TIME = "error.metadata.metrics.InstantiationTime",
|
|
20
|
-
/**
|
|
21
|
-
* VTEX's Infra errors adds error details to the response
|
|
22
|
-
* The following log fields are supposed to hold these fields
|
|
23
|
-
*/
|
|
24
|
-
ERROR_SERVER_CODE = "error.server.code",
|
|
25
|
-
ERROR_SERVER_REQUEST_ID = "error.server.request_id"
|
|
26
|
-
}
|
|
27
|
-
export declare const enum RuntimeLogFields {
|
|
28
|
-
/** Time in ms spent to run the user middlewares */
|
|
29
|
-
USER_MIDDLEWARES_DURATION = "user-middlewares-duration"
|
|
30
|
-
}
|
|
31
|
-
export declare const enum HttpCacheLogFields {
|
|
32
|
-
/** The generated cache key for Memoization or Local caches */
|
|
33
|
-
KEY = "key",
|
|
34
|
-
/** The generated cache key for local cache with the segment added to it */
|
|
35
|
-
KEY_WITH_SEGMENT = "key-with-segment",
|
|
36
|
-
/** The key that was just set on the cache */
|
|
37
|
-
KEY_SET = "key-set",
|
|
38
|
-
/** The type of cache: 'disk', 'memory' or 'memoization' */
|
|
39
|
-
CACHE_TYPE = "cache-type",
|
|
40
|
-
/** The etag for the current request used for caching decisions. Can be undefined. */
|
|
41
|
-
ETAG = "etag",
|
|
42
|
-
/** The expiration time in seconds of the current cache entry (either just saved or fetched from the storage) */
|
|
43
|
-
EXPIRATION_TIME = "expiration-time",
|
|
44
|
-
/** The http response type. Can be undefined. */
|
|
45
|
-
RESPONSE_TYPE = "response-type",
|
|
46
|
-
/** The http response encoding. Can be undefined. */
|
|
47
|
-
RESPONSE_ENCONDING = "response-encoding",
|
|
48
|
-
/**
|
|
49
|
-
* The forceMaxAge option on the incoming RequestConfig. This can be set to override no-cache or no-store headers.
|
|
50
|
-
* Can be undefined.
|
|
51
|
-
*/
|
|
52
|
-
FORCE_MAX_AGE = "force-max-age",
|
|
53
|
-
/** The calculated max-age the current response will have if stored */
|
|
54
|
-
CALCULATED_MAX_AGE = "calculated-max-age",
|
|
55
|
-
/** Content parsed from the incoming response headers */
|
|
56
|
-
AGE = "age",
|
|
57
|
-
NO_CACHE = "no-cache",
|
|
58
|
-
NO_STORE = "no-store",
|
|
59
|
-
MAX_AGE = "max-age"
|
|
60
|
-
}
|
|
61
|
-
export declare const enum HttpRetryLogFields {
|
|
62
|
-
/** The retry number scheduled (e.g, 1, 2, meaning that is the first or second retry) */
|
|
63
|
-
RETRY_NUMBER = "retry-number",
|
|
64
|
-
/** How much time in ms will be waited until this retry happens */
|
|
65
|
-
RETRY_IN = "retry-in"
|
|
66
|
-
}
|
package/lib/tracing/LogFields.js
DELETED