@vtex/api 6.47.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 -29
- package/lib/clients/IOClients.js +26 -36
- 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 +5 -11
- 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 -5
- package/lib/utils/MineWinsConflictsResolver.js +17 -23
- 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 -1846
- 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/Metadata.d.ts +0 -26
- package/lib/clients/infra/Metadata.js +0 -83
- 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 -12
- package/lib/clients/infra/index.js +0 -17
- 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,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { JanusClient } from './JanusClient';
|
|
1
|
+
import { JanusClient } from '../HttpClient';
|
|
3
2
|
export interface SegmentData {
|
|
4
3
|
campaigns?: any;
|
|
5
4
|
channel: number;
|
|
6
|
-
channelPrivacy?: 'public' | 'private';
|
|
7
5
|
priceTables?: any;
|
|
8
6
|
utm_campaign: string;
|
|
9
7
|
regionId?: string;
|
|
@@ -16,21 +14,27 @@ export interface SegmentData {
|
|
|
16
14
|
[key: string]: any;
|
|
17
15
|
}
|
|
18
16
|
export declare class Segment extends JanusClient {
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Please use `getSegment` or `getSegmentByToken` instead.
|
|
19
|
+
*
|
|
20
|
+
* @memberof Segment
|
|
21
|
+
*/
|
|
22
|
+
segment: (query?: Record<string, string> | undefined, token?: string | undefined) => Promise<SegmentData>;
|
|
19
23
|
/**
|
|
20
24
|
* Get the segment data using the current `ctx.vtex.segmentToken`
|
|
21
25
|
*
|
|
22
26
|
* @memberof Segment
|
|
23
27
|
*/
|
|
24
|
-
getSegment: (
|
|
28
|
+
getSegment: () => Promise<SegmentData>;
|
|
25
29
|
/**
|
|
26
30
|
* Get the segment data from this specific segment token
|
|
27
31
|
*
|
|
28
32
|
* @memberof Segment
|
|
29
33
|
*/
|
|
30
|
-
getSegmentByToken: (token: string | null
|
|
31
|
-
getOrCreateSegment: (query?: Record<string, string> | undefined, token?: string | undefined
|
|
34
|
+
getSegmentByToken: (token: string | null) => Promise<SegmentData>;
|
|
35
|
+
getOrCreateSegment: (query?: Record<string, string> | undefined, token?: string | undefined) => Promise<{
|
|
32
36
|
segmentData: SegmentData;
|
|
33
|
-
segmentToken: string |
|
|
37
|
+
segmentToken: string | undefined;
|
|
34
38
|
}>;
|
|
35
39
|
private rawSegment;
|
|
36
40
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ramda_1 = require("ramda");
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const HttpClient_1 = require("../HttpClient");
|
|
6
|
+
const Session_1 = require("./Session");
|
|
7
|
+
const SEGMENT_MAX_AGE_S = 60 * 60; // 60 minutes - segment is actually immutable
|
|
8
|
+
const ALLOWED_QUERY_PREFIXES = ['utm', 'cultureInfo', 'supportedLocales'];
|
|
9
|
+
const filterAndSortQuery = (query) => {
|
|
10
|
+
if (!query) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const filteredKeys = Object.keys(query)
|
|
14
|
+
.filter((k) => !!k && ALLOWED_QUERY_PREFIXES.some((prefix) => k.startsWith(prefix)))
|
|
15
|
+
.sort();
|
|
16
|
+
return filteredKeys.reduce((acc, val) => {
|
|
17
|
+
acc[val] = query[val];
|
|
18
|
+
return acc;
|
|
19
|
+
}, {});
|
|
20
|
+
};
|
|
21
|
+
const routes = {
|
|
22
|
+
base: '/api/segments',
|
|
23
|
+
segments: (token) => token ? `${routes.base}/${token}` : routes.base,
|
|
24
|
+
};
|
|
25
|
+
class Segment extends HttpClient_1.JanusClient {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Please use `getSegment` or `getSegmentByToken` instead.
|
|
30
|
+
*
|
|
31
|
+
* @memberof Segment
|
|
32
|
+
*/
|
|
33
|
+
this.segment = (query, token) => this.rawSegment(token || this.context.segmentToken, query).then(ramda_1.prop('data'));
|
|
34
|
+
/**
|
|
35
|
+
* Get the segment data using the current `ctx.vtex.segmentToken`
|
|
36
|
+
*
|
|
37
|
+
* @memberof Segment
|
|
38
|
+
*/
|
|
39
|
+
this.getSegment = () => this.rawSegment(this.context.segmentToken).then(ramda_1.prop('data'));
|
|
40
|
+
/**
|
|
41
|
+
* Get the segment data from this specific segment token
|
|
42
|
+
*
|
|
43
|
+
* @memberof Segment
|
|
44
|
+
*/
|
|
45
|
+
this.getSegmentByToken = (token) => this.rawSegment(token).then(ramda_1.prop('data'));
|
|
46
|
+
this.getOrCreateSegment = async (query, token) => {
|
|
47
|
+
const { data: segmentData, headers, } = await this.rawSegment(token, query);
|
|
48
|
+
return {
|
|
49
|
+
segmentData,
|
|
50
|
+
segmentToken: Session_1.extractSessionCookie(headers) || token,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
this.rawSegment = (token, query) => {
|
|
54
|
+
const { product } = this.context;
|
|
55
|
+
const filteredQuery = filterAndSortQuery(query);
|
|
56
|
+
return this.http.getRaw(routes.segments(token), ({
|
|
57
|
+
forceMaxAge: SEGMENT_MAX_AGE_S,
|
|
58
|
+
headers: {
|
|
59
|
+
'Content-Type': 'application/json',
|
|
60
|
+
[constants_1.PRODUCT_HEADER]: product || '',
|
|
61
|
+
},
|
|
62
|
+
inflightKey: HttpClient_1.inflightUrlWithQuery,
|
|
63
|
+
metric: token ? 'segment-get-token' : 'segment-get-new',
|
|
64
|
+
params: Object.assign({}, filteredQuery, { session_path: product || '' }),
|
|
65
|
+
}));
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.Segment = Segment;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { JanusClient } from './JanusClient';
|
|
1
|
+
import { JanusClient } from './../HttpClient';
|
|
3
2
|
export declare class Session extends JanusClient {
|
|
4
3
|
/**
|
|
5
4
|
* Get the session data using the given token
|
|
6
5
|
*/
|
|
7
|
-
getSession: (token: string, items: string[]
|
|
6
|
+
getSession: (token: string, items: string[]) => Promise<{
|
|
8
7
|
sessionData: any;
|
|
9
8
|
sessionToken: string;
|
|
10
9
|
}>;
|
|
11
10
|
/**
|
|
12
11
|
* Update the public portion of this session
|
|
13
12
|
*/
|
|
14
|
-
updateSession: (key: string, value: any, items: string[], token: any
|
|
13
|
+
updateSession: (key: string, value: any, items: string[], token: any) => Promise<void>;
|
|
15
14
|
}
|
|
15
|
+
export declare function extractSessionCookie(headers: Record<string, string>): string | null;
|
|
@@ -4,58 +4,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const cookie_1 = __importDefault(require("cookie"));
|
|
7
|
-
const
|
|
7
|
+
const HttpClient_1 = require("./../HttpClient");
|
|
8
8
|
const SESSION_COOKIE = 'vtex_session';
|
|
9
9
|
const routes = {
|
|
10
10
|
base: '/api/sessions',
|
|
11
11
|
};
|
|
12
|
-
class Session extends
|
|
12
|
+
class Session extends HttpClient_1.JanusClient {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
15
15
|
/**
|
|
16
16
|
* Get the session data using the given token
|
|
17
17
|
*/
|
|
18
|
-
this.getSession = async (token, items
|
|
19
|
-
|
|
20
|
-
const metric = 'session-get';
|
|
21
|
-
const { data: sessionData, headers } = await this.http.getRaw(routes.base, {
|
|
18
|
+
this.getSession = async (token, items) => {
|
|
19
|
+
const { data: sessionData, headers } = await this.http.getRaw(routes.base, ({
|
|
22
20
|
headers: {
|
|
23
21
|
'Content-Type': 'application/json',
|
|
24
|
-
Cookie: `vtex_session=${token};`,
|
|
22
|
+
'Cookie': `vtex_session=${token};`,
|
|
25
23
|
},
|
|
26
|
-
metric,
|
|
24
|
+
metric: 'session-get',
|
|
27
25
|
params: {
|
|
28
26
|
items: items.join(','),
|
|
29
27
|
},
|
|
30
|
-
|
|
31
|
-
requestSpanNameSuffix: metric,
|
|
32
|
-
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
33
|
-
},
|
|
34
|
-
});
|
|
28
|
+
}));
|
|
35
29
|
return {
|
|
36
30
|
sessionData,
|
|
37
|
-
sessionToken:
|
|
31
|
+
sessionToken: extractSessionCookie(headers) || token,
|
|
38
32
|
};
|
|
39
33
|
};
|
|
40
34
|
/**
|
|
41
35
|
* Update the public portion of this session
|
|
42
36
|
*/
|
|
43
|
-
this.updateSession = (key, value, items, token
|
|
37
|
+
this.updateSession = (key, value, items, token) => {
|
|
44
38
|
const data = { public: { [key]: { value } } };
|
|
45
|
-
const metric = 'session-update';
|
|
46
39
|
const config = {
|
|
47
40
|
headers: {
|
|
48
41
|
'Content-Type': 'application/json',
|
|
49
|
-
Cookie: `vtex_session=${token};`,
|
|
42
|
+
'Cookie': `vtex_session=${token};`,
|
|
50
43
|
},
|
|
51
|
-
metric,
|
|
44
|
+
metric: 'session-update',
|
|
52
45
|
params: {
|
|
53
46
|
items: items.join(','),
|
|
54
47
|
},
|
|
55
|
-
tracing: {
|
|
56
|
-
requestSpanNameSuffix: metric,
|
|
57
|
-
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
58
|
-
},
|
|
59
48
|
};
|
|
60
49
|
return this.http.post(routes.base, data, config);
|
|
61
50
|
};
|
|
@@ -63,8 +52,7 @@ class Session extends JanusClient_1.JanusClient {
|
|
|
63
52
|
}
|
|
64
53
|
exports.Session = Session;
|
|
65
54
|
function extractSessionCookie(headers) {
|
|
66
|
-
|
|
67
|
-
for (const setCookie of (_a = headers['set-cookie']) !== null && _a !== void 0 ? _a : []) {
|
|
55
|
+
for (const setCookie of headers['set-cookie'] || []) {
|
|
68
56
|
const parsedCookie = cookie_1.default.parse(setCookie);
|
|
69
57
|
const sessionCookie = parsedCookie[SESSION_COOKIE];
|
|
70
58
|
if (sessionCookie != null) {
|
|
@@ -73,3 +61,4 @@ function extractSessionCookie(headers) {
|
|
|
73
61
|
}
|
|
74
62
|
return null;
|
|
75
63
|
}
|
|
64
|
+
exports.extractSessionCookie = extractSessionCookie;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IOContext } from '
|
|
3
|
-
import { AppMetaInfo } from '
|
|
4
|
-
import { AppClient } from './AppClient';
|
|
1
|
+
import { AppClient, InstanceOptions } from '../HttpClient';
|
|
2
|
+
import { IOContext } from '../service/typings';
|
|
3
|
+
import { AppMetaInfo } from './Apps';
|
|
5
4
|
export interface SettingsParams {
|
|
6
5
|
merge?: boolean;
|
|
7
6
|
files?: string[];
|
|
@@ -10,5 +9,5 @@ export declare class Settings extends AppClient {
|
|
|
10
9
|
constructor(context: IOContext, options?: InstanceOptions);
|
|
11
10
|
getFilteredDependencies(appAtMajor: string, dependencies: AppMetaInfo[]): AppMetaInfo[];
|
|
12
11
|
getDependenciesHash(dependencies: AppMetaInfo[]): string;
|
|
13
|
-
getSettings(dependencies: AppMetaInfo[], appAtMajor: string, params?: SettingsParams
|
|
12
|
+
getSettings(dependencies: AppMetaInfo[], appAtMajor: string, params?: SettingsParams): Promise<any>;
|
|
14
13
|
}
|
|
@@ -1,37 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const crypto_1 = require("crypto");
|
|
3
4
|
const ramda_1 = require("ramda");
|
|
4
|
-
const HttpClient_1 = require("
|
|
5
|
-
const
|
|
6
|
-
const app_1 = require("../../utils/app");
|
|
7
|
-
const AppClient_1 = require("./AppClient");
|
|
5
|
+
const HttpClient_1 = require("../HttpClient");
|
|
6
|
+
const app_1 = require("../utils/app");
|
|
8
7
|
const LINKED_ROUTE = 'linked';
|
|
8
|
+
const dependsOnApp = (appAtMajor) => (a) => {
|
|
9
|
+
const [name, major] = appAtMajor.split('@');
|
|
10
|
+
const version = a._resolvedDependencies[name];
|
|
11
|
+
if (!version) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const [depMajor] = version.split('.');
|
|
15
|
+
return major === depMajor;
|
|
16
|
+
};
|
|
17
|
+
const joinIds = ramda_1.join('');
|
|
9
18
|
const containsLinks = ramda_1.any(app_1.isLinkedApp);
|
|
10
|
-
class Settings extends
|
|
19
|
+
class Settings extends HttpClient_1.AppClient {
|
|
11
20
|
constructor(context, options) {
|
|
12
21
|
super('vtex.settings-server@0.x', context, options);
|
|
13
22
|
}
|
|
14
23
|
getFilteredDependencies(appAtMajor, dependencies) {
|
|
15
|
-
|
|
24
|
+
const depends = dependsOnApp(appAtMajor);
|
|
25
|
+
return ramda_1.filter(depends, dependencies);
|
|
16
26
|
}
|
|
17
27
|
getDependenciesHash(dependencies) {
|
|
18
|
-
|
|
28
|
+
const dependingApps = ramda_1.pluck('id', dependencies);
|
|
29
|
+
return crypto_1.createHash('md5').update(joinIds(dependingApps)).digest('hex');
|
|
19
30
|
}
|
|
20
|
-
async getSettings(dependencies, appAtMajor, params
|
|
31
|
+
async getSettings(dependencies, appAtMajor, params) {
|
|
21
32
|
const filtered = this.getFilteredDependencies(appAtMajor, dependencies);
|
|
22
33
|
// Settings server exposes a smartCache-enabled route for when the workspace contains links.
|
|
23
34
|
const lastSegment = containsLinks(filtered)
|
|
24
35
|
? LINKED_ROUTE
|
|
25
36
|
: this.getDependenciesHash(filtered);
|
|
26
|
-
const metric = 'settings-get';
|
|
27
37
|
return this.http.get(`/settings/${appAtMajor}/${lastSegment}`, {
|
|
28
38
|
inflightKey: HttpClient_1.inflightUrlWithQuery,
|
|
29
|
-
metric,
|
|
39
|
+
metric: 'settings-get',
|
|
30
40
|
params,
|
|
31
|
-
tracing: {
|
|
32
|
-
requestSpanNameSuffix: metric,
|
|
33
|
-
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
34
|
-
},
|
|
35
41
|
});
|
|
36
42
|
}
|
|
37
43
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IOContext } from '../service/typings';
|
|
2
|
+
import { InfraClient, InstanceOptions } from './../HttpClient';
|
|
3
|
+
export declare class Sphinx extends InfraClient {
|
|
4
|
+
constructor(ioContext: IOContext, opts?: InstanceOptions);
|
|
5
|
+
validatePolicies: (policies: PolicyRequest[]) => Promise<void>;
|
|
6
|
+
isAdmin: (email: string) => Promise<boolean>;
|
|
7
|
+
}
|
|
8
|
+
export interface PolicyRequest {
|
|
9
|
+
name: string;
|
|
10
|
+
reason: string;
|
|
11
|
+
attrs: Record<string, string>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const HttpClient_1 = require("./../HttpClient");
|
|
4
|
+
class Sphinx extends HttpClient_1.InfraClient {
|
|
5
|
+
constructor(ioContext, opts) {
|
|
6
|
+
super('sphinx@0.x', ioContext, opts, false);
|
|
7
|
+
this.validatePolicies = (policies) => {
|
|
8
|
+
return this.http.post('/policies/validate', { policies }, {
|
|
9
|
+
metric: 'sphinx-validate-policy',
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
this.isAdmin = (email) => {
|
|
13
|
+
return this.http.get(`/user/${email}/isAdmin`, {
|
|
14
|
+
metric: 'sphinx-is-admin',
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.Sphinx = Sphinx;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { ExternalClient } from '../HttpClient/ExternalClient';
|
|
2
|
+
import { InstanceOptions, RequestConfig } from '../HttpClient/typings';
|
|
3
|
+
import { IOContext } from '../service/typings';
|
|
4
|
+
interface Binding {
|
|
5
5
|
id: string;
|
|
6
6
|
canonicalBaseAddress: string;
|
|
7
7
|
alternateBaseAddresses: string[];
|
|
@@ -12,7 +12,7 @@ export interface Binding {
|
|
|
12
12
|
extraContext: Record<string, any>;
|
|
13
13
|
targetProduct: string;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
interface Tenant {
|
|
16
16
|
id: string;
|
|
17
17
|
slug: string;
|
|
18
18
|
title: string;
|
|
@@ -23,7 +23,8 @@ export interface Tenant {
|
|
|
23
23
|
defaultLocale: string;
|
|
24
24
|
metadata: Record<string, string>;
|
|
25
25
|
}
|
|
26
|
-
export declare class TenantClient extends
|
|
26
|
+
export declare class TenantClient extends ExternalClient {
|
|
27
27
|
constructor(ctx: IOContext, opts?: InstanceOptions);
|
|
28
28
|
info: (config?: RequestConfig | undefined) => Promise<Tenant>;
|
|
29
29
|
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const HttpClient_1 = require("../HttpClient");
|
|
4
|
+
const ExternalClient_1 = require("../HttpClient/ExternalClient");
|
|
5
|
+
class TenantClient extends ExternalClient_1.ExternalClient {
|
|
6
|
+
constructor(ctx, opts) {
|
|
7
|
+
super('http://portal.vtexcommercestable.com.br/api/tenant', ctx, Object.assign({}, opts, { params: {
|
|
8
|
+
q: ctx.account,
|
|
9
|
+
} }));
|
|
10
|
+
this.info = (config) => this.http.get('/tenants', Object.assign({ inflightKey: HttpClient_1.inflightUrlWithQuery, memoizeable: true, metric: 'get-tenant-info' }, config));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.TenantClient = TenantClient;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage } from 'http';
|
|
3
|
+
import { Readable } from 'stream';
|
|
4
|
+
import { InfraClient, InstanceOptions } from '../HttpClient';
|
|
5
|
+
import { BucketMetadata, FileListItem } from '../responses';
|
|
6
|
+
import { IOContext } from '../service/typings';
|
|
7
|
+
export declare class VBase extends InfraClient {
|
|
8
|
+
constructor(context: IOContext, options?: InstanceOptions);
|
|
9
|
+
getBucket: (bucket: string) => Promise<BucketMetadata>;
|
|
10
|
+
resetBucket: (bucket: string) => Promise<import("../HttpClient").IOResponse<void>>;
|
|
11
|
+
listFiles: (bucket: string, opts?: string | VBaseOptions | undefined) => Promise<BucketFileList>;
|
|
12
|
+
getFile: (bucket: string, path: string) => Promise<{
|
|
13
|
+
data: Buffer;
|
|
14
|
+
headers: any;
|
|
15
|
+
}>;
|
|
16
|
+
getJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean | undefined, conflictsResolver?: ConflictsResolver | undefined) => Promise<{} | T>;
|
|
17
|
+
getFileStream: (bucket: string, path: string) => Promise<IncomingMessage>;
|
|
18
|
+
saveFile: (bucket: string, path: string, stream: Readable, gzip?: boolean, ttl?: number | undefined) => Promise<void>;
|
|
19
|
+
getFileMetadata: (bucket: string, path: string) => Promise<import("../HttpClient").IOResponse<void>>;
|
|
20
|
+
saveJSON: <T>(bucket: string, path: string, data: T) => Promise<void>;
|
|
21
|
+
saveZippedContent: (bucket: string, path: string, stream: Readable) => Promise<void>;
|
|
22
|
+
deleteFile: (bucket: string, path: string) => Promise<import("../HttpClient").IOResponse<void>>;
|
|
23
|
+
getConflicts: <T>(bucket: string) => Promise<T>;
|
|
24
|
+
resolveConflict: <T>(bucket: string, path: string, content: any) => Promise<T>;
|
|
25
|
+
private saveContent;
|
|
26
|
+
}
|
|
27
|
+
export interface BucketFileList {
|
|
28
|
+
data: FileListItem[];
|
|
29
|
+
next: string;
|
|
30
|
+
smartCacheHeaders: any;
|
|
31
|
+
}
|
|
32
|
+
export interface VBaseOptions {
|
|
33
|
+
prefix?: string;
|
|
34
|
+
_next?: string;
|
|
35
|
+
_limit?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface VBaseSaveOptions {
|
|
38
|
+
gzip?: boolean;
|
|
39
|
+
unzip?: boolean;
|
|
40
|
+
ttl?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface VBaseConflictData {
|
|
43
|
+
path: string;
|
|
44
|
+
base: VBaseConflict;
|
|
45
|
+
master: VBaseConflict;
|
|
46
|
+
mine: VBaseConflict;
|
|
47
|
+
}
|
|
48
|
+
export interface VBaseConflict {
|
|
49
|
+
contentOmitted: boolean;
|
|
50
|
+
deleted: boolean;
|
|
51
|
+
mimeType: string;
|
|
52
|
+
parsedContent?: any;
|
|
53
|
+
content: string;
|
|
54
|
+
}
|
|
55
|
+
export interface ConflictsResolver {
|
|
56
|
+
resolve: () => {};
|
|
57
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
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 mime_types_1 = __importDefault(require("mime-types"));
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const zlib_1 = require("zlib");
|
|
9
|
+
const HttpClient_1 = require("../HttpClient");
|
|
10
|
+
const appId = process.env.VTEX_APP_ID;
|
|
11
|
+
const [runningAppName] = appId ? appId.split('@') : [''];
|
|
12
|
+
const routes = {
|
|
13
|
+
Bucket: (bucket) => `/buckets/${runningAppName}/${bucket}`,
|
|
14
|
+
Conflicts: (bucket) => `/buckets/${runningAppName}/${bucket}/conflicts`,
|
|
15
|
+
File: (bucket, path) => `${routes.Bucket(bucket)}/files/${path}`,
|
|
16
|
+
Files: (bucket) => `${routes.Bucket(bucket)}/files`,
|
|
17
|
+
};
|
|
18
|
+
const isVBaseOptions = (opts) => {
|
|
19
|
+
return typeof opts !== 'string' && !(opts instanceof String);
|
|
20
|
+
};
|
|
21
|
+
class VBase extends HttpClient_1.InfraClient {
|
|
22
|
+
constructor(context, options) {
|
|
23
|
+
super('vbase@2.x', context, options);
|
|
24
|
+
this.getBucket = (bucket) => {
|
|
25
|
+
const inflightKey = HttpClient_1.inflightURL;
|
|
26
|
+
const metric = 'vbase-get-bucket';
|
|
27
|
+
return this.http.get(routes.Bucket(bucket), { metric, inflightKey });
|
|
28
|
+
};
|
|
29
|
+
this.resetBucket = (bucket) => {
|
|
30
|
+
return this.http.delete(routes.Files(bucket), { metric: 'vbase-reset-bucket' });
|
|
31
|
+
};
|
|
32
|
+
this.listFiles = (bucket, opts) => {
|
|
33
|
+
let params = {};
|
|
34
|
+
if (isVBaseOptions(opts)) {
|
|
35
|
+
params = opts;
|
|
36
|
+
}
|
|
37
|
+
else if (opts) {
|
|
38
|
+
params = { prefix: opts };
|
|
39
|
+
}
|
|
40
|
+
const metric = 'vbase-list';
|
|
41
|
+
const inflightKey = HttpClient_1.inflightUrlWithQuery;
|
|
42
|
+
return this.http.get(routes.Files(bucket), { params, metric, inflightKey });
|
|
43
|
+
};
|
|
44
|
+
this.getFile = (bucket, path) => {
|
|
45
|
+
const inflightKey = HttpClient_1.inflightURL;
|
|
46
|
+
const metric = 'vbase-get-file';
|
|
47
|
+
return this.http.getBuffer(routes.File(bucket, path), { metric, inflightKey });
|
|
48
|
+
};
|
|
49
|
+
this.getJSON = (bucket, path, nullIfNotFound, conflictsResolver) => {
|
|
50
|
+
const headers = conflictsResolver ? { 'X-Vtex-Detect-Conflicts': true } : {};
|
|
51
|
+
const inflightKey = HttpClient_1.inflightURL;
|
|
52
|
+
const metric = 'vbase-get-json';
|
|
53
|
+
return this.http.get(routes.File(bucket, path), { nullIfNotFound, metric, inflightKey, headers })
|
|
54
|
+
.catch((error) => {
|
|
55
|
+
const { response } = error;
|
|
56
|
+
if (response && response.status === 409 && conflictsResolver) {
|
|
57
|
+
return conflictsResolver.resolve();
|
|
58
|
+
}
|
|
59
|
+
throw error;
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
this.getFileStream = (bucket, path) => {
|
|
63
|
+
return this.http.getStream(routes.File(bucket, path), { metric: 'vbase-get-file-s' });
|
|
64
|
+
};
|
|
65
|
+
this.saveFile = (bucket, path, stream, gzip = true, ttl) => {
|
|
66
|
+
return this.saveContent(bucket, path, stream, { gzip, ttl });
|
|
67
|
+
};
|
|
68
|
+
this.getFileMetadata = (bucket, path) => {
|
|
69
|
+
return this.http.head(routes.File(bucket, path), { metric: 'vbase-get-file-metadata' });
|
|
70
|
+
};
|
|
71
|
+
this.saveJSON = (bucket, path, data) => {
|
|
72
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
73
|
+
const metric = 'vbase-save-json';
|
|
74
|
+
return this.http.put(routes.File(bucket, path), data, { headers, metric });
|
|
75
|
+
};
|
|
76
|
+
this.saveZippedContent = (bucket, path, stream) => {
|
|
77
|
+
return this.saveContent(bucket, path, stream, { unzip: true });
|
|
78
|
+
};
|
|
79
|
+
this.deleteFile = (bucket, path) => {
|
|
80
|
+
return this.http.delete(routes.File(bucket, path), { metric: 'vbase-delete-file' });
|
|
81
|
+
};
|
|
82
|
+
this.getConflicts = (bucket) => {
|
|
83
|
+
return this.http.get(routes.Conflicts(bucket), { metric: 'vbase-get-conflicts' });
|
|
84
|
+
};
|
|
85
|
+
this.resolveConflict = (bucket, path, content) => {
|
|
86
|
+
const data = [{
|
|
87
|
+
op: 'replace',
|
|
88
|
+
path,
|
|
89
|
+
value: content,
|
|
90
|
+
}];
|
|
91
|
+
return this.http.patch(routes.Conflicts(bucket), data, { metric: 'vbase-resolve-conflicts' });
|
|
92
|
+
};
|
|
93
|
+
this.saveContent = (bucket, path, stream, opts = {}) => {
|
|
94
|
+
if (!stream.pipe || !stream.on) {
|
|
95
|
+
throw new Error(`Argument stream must be a readable stream`);
|
|
96
|
+
}
|
|
97
|
+
const params = opts.unzip ? { unzip: opts.unzip } : {};
|
|
98
|
+
const headers = {};
|
|
99
|
+
let finalStream = stream;
|
|
100
|
+
headers['Content-Type'] = mime_types_1.default.contentType(path_1.basename(path)) || 'application/octet-stream';
|
|
101
|
+
if (opts.gzip) {
|
|
102
|
+
headers['Content-Encoding'] = 'gzip';
|
|
103
|
+
finalStream = stream.pipe(zlib_1.createGzip());
|
|
104
|
+
}
|
|
105
|
+
if (opts.ttl && Number.isInteger(opts.ttl)) {
|
|
106
|
+
headers['X-VTEX-TTL'] = opts.ttl;
|
|
107
|
+
}
|
|
108
|
+
const metric = 'vbase-save-blob';
|
|
109
|
+
return this.http.put(routes.File(bucket, path), finalStream, { headers, params, metric });
|
|
110
|
+
};
|
|
111
|
+
if (runningAppName === '') {
|
|
112
|
+
throw new Error(`Invalid path to access VBase. Variable VTEX_APP_ID is not available.`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.VBase = VBase;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InfraClient, InstanceOptions } from '../HttpClient';
|
|
2
|
+
import { IOContext } from '../service/typings';
|
|
3
|
+
export declare class Workspaces extends InfraClient {
|
|
4
|
+
constructor(context: IOContext, options?: InstanceOptions);
|
|
5
|
+
list: (account: string) => Promise<WorkspaceMetadata[]>;
|
|
6
|
+
get: (account: string, workspace: string) => Promise<WorkspaceMetadata>;
|
|
7
|
+
set: (account: string, workspace: string, metadata: Partial<WorkspaceMetadata>) => Promise<void>;
|
|
8
|
+
create: (account: string, workspace: string, production: boolean) => Promise<void>;
|
|
9
|
+
delete: (account: string, workspace: string) => Promise<import("../HttpClient").IOResponse<void>>;
|
|
10
|
+
reset: (account: string, workspace: string, metadata?: Partial<WorkspaceMetadata>) => Promise<void>;
|
|
11
|
+
promote: (account: string, workspace: string, conflictResolutionStrategy?: string | undefined) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface WorkspaceMetadata {
|
|
14
|
+
name: string;
|
|
15
|
+
weight: number;
|
|
16
|
+
production: boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../constants");
|
|
4
|
+
const HttpClient_1 = require("../HttpClient");
|
|
5
|
+
const routes = {
|
|
6
|
+
Account: (account) => `/${account}`,
|
|
7
|
+
Promote: (account) => `${routes.Workspace(account, constants_1.DEFAULT_WORKSPACE)}/_promote`,
|
|
8
|
+
Workspace: (account, workspace) => `${routes.Account(account)}/${workspace}`,
|
|
9
|
+
};
|
|
10
|
+
class Workspaces extends HttpClient_1.InfraClient {
|
|
11
|
+
constructor(context, options) {
|
|
12
|
+
super('router', context, options, true);
|
|
13
|
+
this.list = (account) => {
|
|
14
|
+
return this.http.get(routes.Account(account), { metric: 'workspaces-list' });
|
|
15
|
+
};
|
|
16
|
+
this.get = (account, workspace) => {
|
|
17
|
+
return this.http.get(routes.Workspace(account, workspace), { metric: 'workspaces-get' });
|
|
18
|
+
};
|
|
19
|
+
this.set = (account, workspace, metadata) => {
|
|
20
|
+
return this.http.put(routes.Workspace(account, workspace), metadata, { metric: 'workspaces-set' });
|
|
21
|
+
};
|
|
22
|
+
this.create = (account, workspace, production) => {
|
|
23
|
+
return this.http.post(routes.Account(account), { name: workspace, production }, { metric: 'workspaces-create' });
|
|
24
|
+
};
|
|
25
|
+
this.delete = (account, workspace) => {
|
|
26
|
+
return this.http.delete(routes.Workspace(account, workspace), { metric: 'workspaces-delete' });
|
|
27
|
+
};
|
|
28
|
+
this.reset = (account, workspace, metadata = {}) => {
|
|
29
|
+
const params = { reset: true };
|
|
30
|
+
const metric = 'workspaces-reset';
|
|
31
|
+
return this.http.put(routes.Workspace(account, workspace), metadata, { params, metric });
|
|
32
|
+
};
|
|
33
|
+
this.promote = (account, workspace, conflictResolutionStrategy) => {
|
|
34
|
+
return this.http.put(routes.Promote(account), { workspace, conflictResolutionStrategy }, { metric: 'workspaces-promote' });
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.Workspaces = Workspaces;
|
package/lib/clients/index.d.ts
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
|
|
9
|
-
export
|
|
1
|
+
export * from './Apps';
|
|
2
|
+
export * from './Assets';
|
|
3
|
+
export * from './Billing';
|
|
4
|
+
export * from './BillingMetrics';
|
|
5
|
+
export * from './Builder';
|
|
6
|
+
export * from './Events';
|
|
7
|
+
export * from './Housekeeper';
|
|
8
|
+
export * from './ID';
|
|
9
|
+
export * from './LicenseManager';
|
|
10
|
+
export * from './Logger';
|
|
11
|
+
export * from './Messages';
|
|
12
|
+
export * from './MessagesGraphQL';
|
|
13
|
+
export * from './Metadata';
|
|
14
|
+
export * from './Registry';
|
|
15
|
+
export * from './Router';
|
|
16
|
+
export * from './Segment';
|
|
17
|
+
export * from './Settings';
|
|
18
|
+
export * from './Session';
|
|
19
|
+
export * from './Sphinx';
|
|
20
|
+
export * from './VBase';
|
|
21
|
+
export * from './Workspaces';
|