@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
package/gen/manifest.schema
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { IOContext } from '../service/typings';
|
|
2
|
+
import { IOClient } from './IOClient';
|
|
3
|
+
import { InstanceOptions } from './typings';
|
|
4
4
|
/**
|
|
5
5
|
* Used to perform calls on apps you declared a dependency for in your manifest.
|
|
6
6
|
*/
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const IOClient_1 = require("../IOClient");
|
|
3
|
+
const IOClient_1 = require("./IOClient");
|
|
4
|
+
const typings_1 = require("./typings");
|
|
6
5
|
const useHttps = !process.env.VTEX_IO;
|
|
7
6
|
/**
|
|
8
7
|
* Used to perform calls on apps you declared a dependency for in your manifest.
|
|
@@ -16,19 +15,15 @@ class AppClient extends IOClient_1.IOClient {
|
|
|
16
15
|
let baseURL;
|
|
17
16
|
if (appVersion) {
|
|
18
17
|
const [major] = appVersion.split('.');
|
|
19
|
-
baseURL =
|
|
18
|
+
baseURL = `${protocol}://app.io.vtex.com/${vendor}.${name}/v${major}/${account}/${workspace}`;
|
|
20
19
|
}
|
|
21
20
|
else {
|
|
22
21
|
console.warn(`${account} in ${workspace} is using old routing for ${app}. Please change vendor.app to vendor.app@major in client ${(options && options.name) || ''}`);
|
|
23
22
|
const service = [name, vendor].join('.'); // messages.vtex
|
|
24
23
|
baseURL = `http://${service}.${region}.vtex.io/${account}/${workspace}`;
|
|
25
24
|
}
|
|
26
|
-
super(context, {
|
|
27
|
-
|
|
28
|
-
authType: typings_1.AuthType.bearer,
|
|
29
|
-
baseURL,
|
|
30
|
-
name,
|
|
31
|
-
});
|
|
25
|
+
super(context, Object.assign({}, options, { authType: typings_1.AuthType.bearer, baseURL,
|
|
26
|
+
name }));
|
|
32
27
|
}
|
|
33
28
|
}
|
|
34
29
|
exports.AppClient = AppClient;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { IOContext } from '../service/typings';
|
|
2
|
+
import { IOGraphQLClient } from './IOGraphQLClient';
|
|
3
|
+
import { InstanceOptions } from './typings';
|
|
4
4
|
/**
|
|
5
5
|
* Used to perform calls on apps you declared a dependency for in your manifest.
|
|
6
6
|
*/
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const IOGraphQLClient_1 = require("../IOGraphQLClient");
|
|
3
|
+
const IOGraphQLClient_1 = require("./IOGraphQLClient");
|
|
4
|
+
const typings_1 = require("./typings");
|
|
6
5
|
const useHttps = !process.env.VTEX_IO;
|
|
7
6
|
/**
|
|
8
7
|
* Used to perform calls on apps you declared a dependency for in your manifest.
|
|
@@ -16,19 +15,15 @@ class AppGraphQLClient extends IOGraphQLClient_1.IOGraphQLClient {
|
|
|
16
15
|
let baseURL;
|
|
17
16
|
if (appVersion) {
|
|
18
17
|
const [major] = appVersion.split('.');
|
|
19
|
-
baseURL =
|
|
18
|
+
baseURL = `${protocol}://app.io.vtex.com/${vendor}.${name}/v${major}/${account}/${workspace}/_v/graphql`;
|
|
20
19
|
}
|
|
21
20
|
else {
|
|
22
21
|
console.warn(`${account} in ${workspace} is using old routing for ${app}. Please change vendor.app to vendor.app@major in client ${(options && options.name) || ''}`);
|
|
23
22
|
const service = [name, vendor].join('.'); // messages.vtex
|
|
24
23
|
baseURL = `http://${service}.${region}.vtex.io/${account}/${workspace}/_v/graphql`;
|
|
25
24
|
}
|
|
26
|
-
super(context, {
|
|
27
|
-
|
|
28
|
-
authType: typings_1.AuthType.bearer,
|
|
29
|
-
baseURL,
|
|
30
|
-
name,
|
|
31
|
-
});
|
|
25
|
+
super(context, Object.assign({}, options, { authType: typings_1.AuthType.bearer, baseURL,
|
|
26
|
+
name }));
|
|
32
27
|
}
|
|
33
28
|
}
|
|
34
29
|
exports.AppGraphQLClient = AppGraphQLClient;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { IOContext } from '../service/typings';
|
|
2
|
+
import { IOClient } from './IOClient';
|
|
3
|
+
import { InstanceOptions } from './typings';
|
|
4
4
|
/**
|
|
5
5
|
* Used to perform calls to external endpoints for which you have declared outbound access policies in your manifest.
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const IOClient_1 = require("
|
|
3
|
+
const IOClient_1 = require("./IOClient");
|
|
4
4
|
/**
|
|
5
5
|
* Used to perform calls to external endpoints for which you have declared outbound access policies in your manifest.
|
|
6
6
|
*/
|
|
@@ -8,14 +8,7 @@ class ExternalClient extends IOClient_1.IOClient {
|
|
|
8
8
|
constructor(baseURL, context, options) {
|
|
9
9
|
const { authToken } = context;
|
|
10
10
|
const headers = options && options.headers || {};
|
|
11
|
-
super(context, {
|
|
12
|
-
...options,
|
|
13
|
-
baseURL,
|
|
14
|
-
headers: {
|
|
15
|
-
...headers,
|
|
16
|
-
'Proxy-Authorization': authToken,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
11
|
+
super(context, Object.assign({}, options, { baseURL, headers: Object.assign({}, headers, { 'Proxy-Authorization': authToken }) }));
|
|
19
12
|
}
|
|
20
13
|
}
|
|
21
14
|
exports.ExternalClient = ExternalClient;
|
|
@@ -6,7 +6,6 @@ interface QueryOptions<Variables extends object> {
|
|
|
6
6
|
variables: Variables;
|
|
7
7
|
inflight?: boolean;
|
|
8
8
|
throwOnError?: boolean;
|
|
9
|
-
extensions?: Record<string, any>;
|
|
10
9
|
}
|
|
11
10
|
interface MutateOptions<Variables extends object> {
|
|
12
11
|
mutate: string;
|
|
@@ -22,7 +21,7 @@ export interface GraphQLResponse<T extends Serializable> {
|
|
|
22
21
|
export declare class GraphQLClient {
|
|
23
22
|
private http;
|
|
24
23
|
constructor(http: HttpClient);
|
|
25
|
-
query: <Data extends Serializable, Variables extends object>({ query, variables, inflight,
|
|
24
|
+
query: <Data extends Serializable, Variables extends object>({ query, variables, inflight, throwOnError }: QueryOptions<Variables>, config?: RequestConfig) => Promise<GraphQLResponse<Data>>;
|
|
26
25
|
mutate: <Data extends Serializable, Variables extends object>({ mutate, variables, throwOnError }: MutateOptions<Variables>, config?: RequestConfig) => Promise<GraphQLResponse<Data>>;
|
|
27
26
|
}
|
|
28
27
|
export {};
|
|
@@ -14,10 +14,7 @@ const throwOnGraphQLErrors = (message, response) => {
|
|
|
14
14
|
class GraphQLClient {
|
|
15
15
|
constructor(http) {
|
|
16
16
|
this.http = http;
|
|
17
|
-
this.query = ({ query, variables, inflight,
|
|
18
|
-
inflightKey: inflight !== false ? inflight_1.inflightUrlWithQuery : undefined,
|
|
19
|
-
...config,
|
|
20
|
-
})
|
|
17
|
+
this.query = ({ query, variables, inflight, throwOnError }, config = {}) => this.http.getWithBody(config.url || '', { query, variables }, Object.assign({ inflightKey: inflight !== false ? inflight_1.inflightUrlWithQuery : undefined }, config))
|
|
21
18
|
.then(graphqlResponse => throwOnError === false
|
|
22
19
|
? graphqlResponse
|
|
23
20
|
: throwOnGraphQLErrors(this.http.name, graphqlResponse));
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { AxiosResponse } from 'axios';
|
|
3
3
|
import { IncomingMessage } from 'http';
|
|
4
|
-
import { IOContext } from '../service/
|
|
4
|
+
import { IOContext } from '../service/typings';
|
|
5
5
|
import { InstanceOptions, IOResponse, RequestConfig } from './typings';
|
|
6
6
|
declare type ClientOptions = IOContext & Partial<InstanceOptions>;
|
|
7
7
|
export declare class HttpClient {
|
|
8
|
+
static forWorkspace: (service: string, context: IOContext, opts: InstanceOptions) => HttpClient;
|
|
9
|
+
static forRoot: (service: string, context: IOContext, opts: InstanceOptions) => HttpClient;
|
|
10
|
+
static forExternal: (baseURL: string, context: IOContext, opts: InstanceOptions) => HttpClient;
|
|
8
11
|
name: string;
|
|
9
|
-
private logger;
|
|
10
|
-
private cacheableType;
|
|
11
|
-
private memoizable;
|
|
12
12
|
private runMiddlewares;
|
|
13
13
|
constructor(opts: ClientOptions);
|
|
14
14
|
get: <T = any>(url: string, config?: RequestConfig) => Promise<T>;
|
|
@@ -20,13 +20,12 @@ export declare class HttpClient {
|
|
|
20
20
|
}>;
|
|
21
21
|
getStream: (url: string, config?: RequestConfig) => Promise<IncomingMessage>;
|
|
22
22
|
put: <T = void>(url: string, data?: any, config?: RequestConfig) => Promise<T>;
|
|
23
|
-
putRaw: <T = void>(url: string, data?: any, config?: RequestConfig) => Promise<IOResponse<T>>;
|
|
24
23
|
post: <T = void>(url: string, data?: any, config?: RequestConfig) => Promise<T>;
|
|
25
24
|
postRaw: <T = void>(url: string, data?: any, config?: RequestConfig) => Promise<IOResponse<T>>;
|
|
26
25
|
patch: <T = void>(url: string, data?: any, config?: RequestConfig) => Promise<T>;
|
|
27
26
|
head: (url: string, config?: RequestConfig) => Promise<IOResponse<void>>;
|
|
28
27
|
delete: <T = void>(url: string, config?: RequestConfig | undefined) => Promise<IOResponse<T>>;
|
|
29
|
-
protected request: (config: RequestConfig) => Promise<AxiosResponse<any>>;
|
|
28
|
+
protected request: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
|
|
30
29
|
private getConfig;
|
|
31
30
|
}
|
|
32
31
|
export {};
|
|
@@ -9,6 +9,7 @@ const p_limit_1 = __importDefault(require("p-limit"));
|
|
|
9
9
|
const constants_1 = require("../constants");
|
|
10
10
|
const binding_1 = require("../utils/binding");
|
|
11
11
|
const tenant_1 = require("../utils/tenant");
|
|
12
|
+
const factories_1 = require("./factories");
|
|
12
13
|
const cache_1 = require("./middlewares/cache");
|
|
13
14
|
const cancellationToken_1 = require("./middlewares/cancellationToken");
|
|
14
15
|
const inflight_1 = require("./middlewares/inflight");
|
|
@@ -17,7 +18,6 @@ const metrics_1 = require("./middlewares/metrics");
|
|
|
17
18
|
const notFound_1 = require("./middlewares/notFound");
|
|
18
19
|
const recorder_1 = require("./middlewares/recorder");
|
|
19
20
|
const request_1 = require("./middlewares/request");
|
|
20
|
-
const tracing_1 = require("./middlewares/tracing");
|
|
21
21
|
const DEFAULT_TIMEOUT_MS = 1000;
|
|
22
22
|
const noTransforms = [(data) => data];
|
|
23
23
|
class HttpClient {
|
|
@@ -31,63 +31,40 @@ class HttpClient {
|
|
|
31
31
|
return this.request(cacheableConfig);
|
|
32
32
|
};
|
|
33
33
|
this.getWithBody = (url, data, config = {}) => {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
return typeof v !== 'object' || v === null || Array.isArray(v) ? v :
|
|
37
|
-
Object.fromEntries(Object.entries(v).sort(([ka], [kb]) => ka < kb ? -1 : ka > kb ? 1 : 0));
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
// I don't believe this will ever happen, but just in case
|
|
41
|
-
// Also, I didn't include error as I am unsure if it would have sensitive information
|
|
42
|
-
this.logger.warn({ message: 'Error while sorting object for cache key' });
|
|
43
|
-
return v;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const bodyHash = crypto_1.createHash('md5').update(JSON.stringify(data, deterministicReplacer)).digest('hex');
|
|
47
|
-
const cacheableConfig = this.getConfig(url, {
|
|
48
|
-
...config,
|
|
49
|
-
data,
|
|
50
|
-
params: {
|
|
51
|
-
...config.params,
|
|
52
|
-
[constants_1.BODY_HASH]: bodyHash,
|
|
53
|
-
},
|
|
54
|
-
});
|
|
34
|
+
const bodyHash = crypto_1.createHash('md5').update(JSON.stringify(data, null, 2)).digest('hex');
|
|
35
|
+
const cacheableConfig = this.getConfig(url, Object.assign({}, config, { data, params: Object.assign({}, config.params, { [constants_1.BODY_HASH]: bodyHash }) }));
|
|
55
36
|
return this.request(cacheableConfig).then(response => response.data);
|
|
56
37
|
};
|
|
57
38
|
this.getBuffer = (url, config = {}) => {
|
|
58
|
-
const bufferConfig = { cacheable: cache_1.CacheType.Disk,
|
|
39
|
+
const bufferConfig = Object.assign({ cacheable: cache_1.CacheType.Disk }, config, { url, responseType: 'arraybuffer', transformResponse: noTransforms });
|
|
59
40
|
return this.request(bufferConfig);
|
|
60
41
|
};
|
|
61
42
|
this.getStream = (url, config = {}) => {
|
|
62
|
-
const streamConfig = {
|
|
43
|
+
const streamConfig = Object.assign({}, config, { url, responseType: 'stream', transformResponse: noTransforms });
|
|
63
44
|
return this.request(streamConfig).then(response => response.data);
|
|
64
45
|
};
|
|
65
46
|
this.put = (url, data, config = {}) => {
|
|
66
|
-
const putConfig = {
|
|
47
|
+
const putConfig = Object.assign({}, config, { url, data, method: 'put' });
|
|
67
48
|
return this.request(putConfig).then(response => response.data);
|
|
68
49
|
};
|
|
69
|
-
this.putRaw = (url, data, config = {}) => {
|
|
70
|
-
const putConfig = { ...config, url, data, method: 'put' };
|
|
71
|
-
return this.request(putConfig);
|
|
72
|
-
};
|
|
73
50
|
this.post = (url, data, config = {}) => {
|
|
74
|
-
const postConfig = {
|
|
51
|
+
const postConfig = Object.assign({}, config, { url, data, method: 'post' });
|
|
75
52
|
return this.request(postConfig).then(response => response.data);
|
|
76
53
|
};
|
|
77
54
|
this.postRaw = (url, data, config = {}) => {
|
|
78
|
-
const postConfig = {
|
|
55
|
+
const postConfig = Object.assign({}, config, { url, data, method: 'post' });
|
|
79
56
|
return this.request(postConfig);
|
|
80
57
|
};
|
|
81
58
|
this.patch = (url, data, config = {}) => {
|
|
82
|
-
const patchConfig = {
|
|
59
|
+
const patchConfig = Object.assign({}, config, { url, data, method: 'patch' });
|
|
83
60
|
return this.request(patchConfig).then(response => response.data);
|
|
84
61
|
};
|
|
85
62
|
this.head = (url, config = {}) => {
|
|
86
|
-
const headConfig = {
|
|
63
|
+
const headConfig = Object.assign({}, config, { url, method: 'head' });
|
|
87
64
|
return this.request(headConfig);
|
|
88
65
|
};
|
|
89
66
|
this.delete = (url, config) => {
|
|
90
|
-
const deleteConfig = {
|
|
67
|
+
const deleteConfig = Object.assign({}, config, { url, method: 'delete' });
|
|
91
68
|
return this.request(deleteConfig);
|
|
92
69
|
};
|
|
93
70
|
this.request = async (config) => {
|
|
@@ -95,51 +72,32 @@ class HttpClient {
|
|
|
95
72
|
await this.runMiddlewares(context);
|
|
96
73
|
return context.response;
|
|
97
74
|
};
|
|
98
|
-
this.getConfig = (url, config = {}) => ({
|
|
99
|
-
|
|
100
|
-
memoizable: this.memoizable,
|
|
101
|
-
...config,
|
|
102
|
-
url,
|
|
103
|
-
});
|
|
104
|
-
const { baseURL, authToken, authType, memoryCache, diskCache, memoizable = true, asyncSetCache, locale, name, metrics, product, serverTiming, recorder, userAgent, timeout = DEFAULT_TIMEOUT_MS, segmentToken, sessionToken, retries, concurrency, headers: defaultHeaders, host, params, operationId, tenant, binding, verbose, cancellation, exponentialTimeoutCoefficient, initialBackoffDelay, exponentialBackoffCoefficient, httpsAgent, tracer, logger, cacheableType = cache_1.CacheType.Memory, } = opts;
|
|
75
|
+
this.getConfig = (url, config = {}) => (Object.assign({ cacheable: cache_1.CacheType.Memory, memoizable: true }, config, { url }));
|
|
76
|
+
const { baseURL, authToken, authType, memoryCache, diskCache, locale, name, metrics, product, serverTiming, recorder, userAgent, timeout = DEFAULT_TIMEOUT_MS, segmentToken, sessionToken, retries, concurrency, headers: defaultHeaders, host, params, operationId, tenant, binding, verbose, cancellation, } = opts;
|
|
105
77
|
this.name = name || baseURL || 'unknown';
|
|
106
|
-
this.logger = logger;
|
|
107
|
-
this.cacheableType = cacheableType;
|
|
108
|
-
this.memoizable = memoizable;
|
|
109
78
|
const limit = concurrency && concurrency > 0 && p_limit_1.default(concurrency) || undefined;
|
|
110
|
-
const headers = {
|
|
111
|
-
...defaultHeaders,
|
|
112
|
-
'Accept-Encoding': 'gzip',
|
|
113
|
-
'User-Agent': userAgent,
|
|
114
|
-
...host ? { [constants_1.FORWARDED_HOST_HEADER]: host } : null,
|
|
115
|
-
...tenant ? { [constants_1.TENANT_HEADER]: tenant_1.formatTenantHeaderValue(tenant) } : null,
|
|
116
|
-
...binding ? { [constants_1.BINDING_HEADER]: binding_1.formatBindingHeaderValue(binding) } : null,
|
|
117
|
-
...locale ? { [constants_1.LOCALE_HEADER]: locale } : null,
|
|
118
|
-
...operationId ? { 'x-vtex-operation-id': operationId } : null,
|
|
119
|
-
...product ? { [constants_1.PRODUCT_HEADER]: product } : null,
|
|
120
|
-
...segmentToken ? { [constants_1.SEGMENT_HEADER]: segmentToken } : null,
|
|
121
|
-
...sessionToken ? { [constants_1.SESSION_HEADER]: sessionToken } : null,
|
|
122
|
-
};
|
|
79
|
+
const headers = Object.assign({}, defaultHeaders, { 'Accept-Encoding': 'gzip', 'User-Agent': userAgent }, host ? { [constants_1.FORWARDED_HOST_HEADER]: host } : null, tenant ? { [constants_1.TENANT_HEADER]: tenant_1.formatTenantHeaderValue(tenant) } : null, binding ? { [constants_1.BINDING_HEADER]: binding_1.formatBindingHeaderValue(binding) } : null, locale ? { [constants_1.LOCALE_HEADER]: locale } : null, operationId ? { 'x-vtex-operation-id': operationId } : null, product ? { [constants_1.PRODUCT_HEADER]: product } : null, segmentToken ? { [constants_1.SEGMENT_HEADER]: segmentToken } : null, sessionToken ? { [constants_1.SESSION_HEADER]: sessionToken } : null);
|
|
123
80
|
if (authType && authToken) {
|
|
124
81
|
headers['Authorization'] = `${authType} ${authToken}`; // tslint:disable-line
|
|
125
82
|
}
|
|
126
83
|
const memoizedCache = new Map();
|
|
127
|
-
this.runMiddlewares = koa_compose_1.default([
|
|
128
|
-
|
|
129
|
-
...(opts.middlewares || []),
|
|
130
|
-
request_1.defaultsMiddleware({ baseURL, rawHeaders: headers, params, timeout, retries, verbose, exponentialTimeoutCoefficient, initialBackoffDelay, exponentialBackoffCoefficient, httpsAgent }),
|
|
84
|
+
this.runMiddlewares = koa_compose_1.default([...opts.middlewares || [],
|
|
85
|
+
request_1.defaultsMiddleware(baseURL, headers, params, timeout, retries, verbose),
|
|
131
86
|
metrics_1.metricsMiddleware({ metrics, serverTiming, name }),
|
|
132
87
|
memoization_1.memoizationMiddleware({ memoizedCache }),
|
|
133
88
|
...recorder ? [recorder_1.recorderMiddleware(recorder)] : [],
|
|
134
89
|
cancellationToken_1.cancellationToken(cancellation),
|
|
135
90
|
inflight_1.singleFlightMiddleware,
|
|
136
91
|
notFound_1.acceptNotFoundMiddleware,
|
|
137
|
-
...memoryCache ? [cache_1.cacheMiddleware({ type: cache_1.CacheType.Memory, storage: memoryCache
|
|
138
|
-
...diskCache ? [cache_1.cacheMiddleware({ type: cache_1.CacheType.Disk, storage: diskCache
|
|
92
|
+
...memoryCache ? [cache_1.cacheMiddleware({ type: cache_1.CacheType.Memory, storage: memoryCache })] : [],
|
|
93
|
+
...diskCache ? [cache_1.cacheMiddleware({ type: cache_1.CacheType.Disk, storage: diskCache })] : [],
|
|
139
94
|
notFound_1.notFoundFallbackMiddleware,
|
|
140
95
|
request_1.routerCacheMiddleware,
|
|
141
96
|
request_1.requestMiddleware(limit),
|
|
142
97
|
]);
|
|
143
98
|
}
|
|
144
99
|
}
|
|
100
|
+
HttpClient.forWorkspace = factories_1.forWorkspace;
|
|
101
|
+
HttpClient.forRoot = factories_1.forRoot;
|
|
102
|
+
HttpClient.forExternal = factories_1.forExternal;
|
|
145
103
|
exports.HttpClient = HttpClient;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IOContext } from '../service/
|
|
2
|
-
import { HttpClient } from '
|
|
3
|
-
import { InstanceOptions } from '
|
|
1
|
+
import { IOContext } from '../service/typings';
|
|
2
|
+
import { HttpClient } from './HttpClient';
|
|
3
|
+
import { InstanceOptions } from './typings';
|
|
4
4
|
export declare type IOClientConstructor = new (context: IOContext, options?: InstanceOptions) => IOClient;
|
|
5
5
|
/**
|
|
6
|
-
* A client that can be instantiated by the
|
|
6
|
+
* A client that can be instantiated by the Service runtime layer.
|
|
7
7
|
*/
|
|
8
8
|
export declare class IOClient {
|
|
9
9
|
protected context: IOContext;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const HttpClient_1 = require("./HttpClient");
|
|
4
|
+
/**
|
|
5
|
+
* A client that can be instantiated by the Service runtime layer.
|
|
6
|
+
*/
|
|
7
|
+
class IOClient {
|
|
8
|
+
constructor(context, options) {
|
|
9
|
+
this.context = context;
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.http = new HttpClient_1.HttpClient(Object.assign({ name: this.constructor.name }, context, options, { metrics: options && options.metrics }));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.IOClient = IOClient;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { IOContext } from '../service/worker/runtime/typings';
|
|
1
|
+
import { IOContext } from '../service/typings';
|
|
2
|
+
import { GraphQLClient } from './GraphQLClient';
|
|
4
3
|
import { IOClient } from './IOClient';
|
|
4
|
+
import { InstanceOptions } from './typings';
|
|
5
5
|
/**
|
|
6
|
-
* A GraphQL client that can be instantiated by the
|
|
6
|
+
* A GraphQL client that can be instantiated by the Service runtime layer.
|
|
7
7
|
*/
|
|
8
8
|
export declare class IOGraphQLClient extends IOClient {
|
|
9
9
|
protected context: IOContext;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const GraphQLClient_1 = require("
|
|
3
|
+
const GraphQLClient_1 = require("./GraphQLClient");
|
|
4
4
|
const IOClient_1 = require("./IOClient");
|
|
5
5
|
/**
|
|
6
|
-
* A GraphQL client that can be instantiated by the
|
|
6
|
+
* A GraphQL client that can be instantiated by the Service runtime layer.
|
|
7
7
|
*/
|
|
8
8
|
class IOGraphQLClient extends IOClient_1.IOClient {
|
|
9
9
|
constructor(context, options) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { IOContext } from '../service/typings';
|
|
2
|
+
import { IOClient } from './IOClient';
|
|
3
|
+
import { InstanceOptions } from './typings';
|
|
4
4
|
/**
|
|
5
5
|
* Used to perform calls on infra apps (e.g. sphinx, apps, vbase).
|
|
6
6
|
*/
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const typings_1 = require("
|
|
5
|
-
const
|
|
6
|
-
const useHttps = !constants_1.IS_IO;
|
|
3
|
+
const IOClient_1 = require("./IOClient");
|
|
4
|
+
const typings_1 = require("./typings");
|
|
5
|
+
const useHttps = !process.env.VTEX_IO;
|
|
7
6
|
/**
|
|
8
7
|
* Used to perform calls on infra apps (e.g. sphinx, apps, vbase).
|
|
9
8
|
*/
|
|
@@ -24,11 +23,7 @@ class InfraClient extends IOClient_1.IOClient {
|
|
|
24
23
|
console.warn(`${account} in ${workspace} is using old routing for ${app}. This will stop working soon`);
|
|
25
24
|
baseURL = `http://${app}.${region}.vtex.io${isRoot ? '' : `/${account}/${workspace}`}`;
|
|
26
25
|
}
|
|
27
|
-
super(context, {
|
|
28
|
-
...options,
|
|
29
|
-
authType: typings_1.AuthType.bearer,
|
|
30
|
-
baseURL,
|
|
31
|
-
});
|
|
26
|
+
super(context, Object.assign({}, options, { authType: typings_1.AuthType.bearer, baseURL }));
|
|
32
27
|
}
|
|
33
28
|
}
|
|
34
29
|
exports.InfraClient = InfraClient;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { IOContext } from '../service/typings';
|
|
2
|
+
import { ExternalClient } from './ExternalClient';
|
|
3
|
+
import { InstanceOptions } from './typings';
|
|
4
4
|
declare type Environment = 'stable' | 'beta';
|
|
5
5
|
/**
|
|
6
6
|
* Used to perform calls on APIs in the VTEX Janus infrastructure, to which you must declare an outbound policy.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ExternalClient_1 = require("
|
|
3
|
+
const ExternalClient_1 = require("./ExternalClient");
|
|
4
4
|
/**
|
|
5
5
|
* Used to perform calls on APIs in the VTEX Janus infrastructure, to which you must declare an outbound policy.
|
|
6
6
|
*
|
|
@@ -18,13 +18,9 @@ class JanusClient extends ExternalClient_1.ExternalClient {
|
|
|
18
18
|
constructor(context, options, environment) {
|
|
19
19
|
const { account } = context;
|
|
20
20
|
const env = context.janusEnv === 'beta' || environment === 'beta' ? 'beta' : 'stable';
|
|
21
|
-
super(`http://portal.vtexcommerce${env}.com.br`, context, {
|
|
22
|
-
...options,
|
|
23
|
-
params: {
|
|
21
|
+
super(`http://portal.vtexcommerce${env}.com.br`, context, Object.assign({}, options, { params: {
|
|
24
22
|
an: account,
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
});
|
|
23
|
+
} }));
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
26
|
exports.JanusClient = JanusClient;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IOContext } from '../../service/typings';
|
|
2
|
+
import { HttpClient } from '../HttpClient';
|
|
3
|
+
import { InstanceOptions } from '../typings';
|
|
4
|
+
export declare const rootURL: (service: string, { region }: IOContext, { baseURL }: InstanceOptions) => string;
|
|
5
|
+
export declare const workspaceURL: (service: string, context: IOContext, opts: InstanceOptions) => string;
|
|
6
|
+
export declare const forWorkspace: (service: string, context: IOContext, opts: InstanceOptions) => HttpClient;
|
|
7
|
+
export declare const forRoot: (service: string, context: IOContext, opts: InstanceOptions) => HttpClient;
|
|
8
|
+
export declare const forExternal: (baseURL: string, context: IOContext, opts: InstanceOptions) => HttpClient;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const HttpClient_1 = require("../HttpClient");
|
|
4
|
+
const typings_1 = require("../typings");
|
|
5
|
+
exports.rootURL = (service, { region }, { baseURL }) => {
|
|
6
|
+
if (baseURL) {
|
|
7
|
+
return 'http://' + baseURL;
|
|
8
|
+
}
|
|
9
|
+
if (region) {
|
|
10
|
+
return `http://${service}.${region}.vtex.io`;
|
|
11
|
+
}
|
|
12
|
+
throw new Error('Missing required: should specify either {region} or {baseURL}');
|
|
13
|
+
};
|
|
14
|
+
exports.workspaceURL = (service, context, opts) => {
|
|
15
|
+
const { account, workspace } = context;
|
|
16
|
+
if (!account || !workspace) {
|
|
17
|
+
throw new Error('Missing required arguments: {account, workspace}');
|
|
18
|
+
}
|
|
19
|
+
return exports.rootURL(service, context, opts) + `/${account}/${workspace}`;
|
|
20
|
+
};
|
|
21
|
+
exports.forWorkspace = (service, context, opts) => {
|
|
22
|
+
const baseURL = exports.workspaceURL(service, context, opts);
|
|
23
|
+
return new HttpClient_1.HttpClient(Object.assign({}, context, opts, { authType: typings_1.AuthType.bearer, baseURL }));
|
|
24
|
+
};
|
|
25
|
+
exports.forRoot = (service, context, opts) => {
|
|
26
|
+
const baseURL = exports.rootURL(service, context, opts);
|
|
27
|
+
return new HttpClient_1.HttpClient(Object.assign({}, context, opts, { authType: typings_1.AuthType.bearer, baseURL }));
|
|
28
|
+
};
|
|
29
|
+
exports.forExternal = (baseURL, context, opts) => {
|
|
30
|
+
return new HttpClient_1.HttpClient(Object.assign({}, context, opts, { baseURL }));
|
|
31
|
+
};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
export * from './AppClient';
|
|
2
|
+
export * from './ExternalClient';
|
|
1
3
|
export * from './HttpClient';
|
|
4
|
+
export * from './InfraClient';
|
|
5
|
+
export * from './IOClient';
|
|
6
|
+
export * from './JanusClient';
|
|
2
7
|
export * from './typings';
|
|
3
8
|
export * from './GraphQLClient';
|
|
4
|
-
export * from './
|
|
9
|
+
export * from './AppGraphQLClient';
|
|
10
|
+
export * from './IOGraphQLClient';
|
|
5
11
|
export { Cached, CacheType } from './middlewares/cache';
|
|
6
12
|
export { inflightURL, inflightUrlWithQuery } from './middlewares/inflight';
|
package/lib/HttpClient/index.js
CHANGED
|
@@ -3,10 +3,16 @@ function __export(m) {
|
|
|
3
3
|
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
4
|
}
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
__export(require("./AppClient"));
|
|
7
|
+
__export(require("./ExternalClient"));
|
|
6
8
|
__export(require("./HttpClient"));
|
|
9
|
+
__export(require("./InfraClient"));
|
|
10
|
+
__export(require("./IOClient"));
|
|
11
|
+
__export(require("./JanusClient"));
|
|
7
12
|
__export(require("./typings"));
|
|
8
13
|
__export(require("./GraphQLClient"));
|
|
9
|
-
__export(require("./
|
|
14
|
+
__export(require("./AppGraphQLClient"));
|
|
15
|
+
__export(require("./IOGraphQLClient"));
|
|
10
16
|
var cache_1 = require("./middlewares/cache");
|
|
11
17
|
exports.CacheType = cache_1.CacheType;
|
|
12
18
|
var inflight_1 = require("./middlewares/inflight");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
3
3
|
import { CacheLayer } from '../../caches/CacheLayer';
|
|
4
4
|
import { MiddlewareContext, RequestConfig } from '../typings';
|
|
5
|
-
export declare const cacheKey: (config: AxiosRequestConfig) => string;
|
|
5
|
+
export declare const cacheKey: (config: AxiosRequestConfig<any>) => string;
|
|
6
6
|
export declare function isLocallyCacheable(arg: RequestConfig, type: CacheType): arg is CacheableRequestConfig;
|
|
7
7
|
export declare enum CacheType {
|
|
8
8
|
None = 0,
|
|
@@ -10,17 +10,11 @@ export declare enum CacheType {
|
|
|
10
10
|
Disk = 2,
|
|
11
11
|
Any = 3
|
|
12
12
|
}
|
|
13
|
-
export declare const enum CacheResult {
|
|
14
|
-
HIT = "HIT",
|
|
15
|
-
MISS = "MISS",
|
|
16
|
-
STALE = "STALE"
|
|
17
|
-
}
|
|
18
13
|
interface CacheOptions {
|
|
19
14
|
type: CacheType;
|
|
20
15
|
storage: CacheLayer<string, Cached>;
|
|
21
|
-
asyncSet?: boolean;
|
|
22
16
|
}
|
|
23
|
-
export declare const cacheMiddleware: ({ type, storage
|
|
17
|
+
export declare const cacheMiddleware: ({ type, storage }: CacheOptions) => (ctx: MiddlewareContext, next: () => Promise<void>) => Promise<void>;
|
|
24
18
|
export interface Cached {
|
|
25
19
|
etag: string;
|
|
26
20
|
expiration: number;
|