@vtex/api 6.45.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1685 -0
- package/README.md +65 -0
- package/gen/manifest.schema +189 -0
- package/lib/HttpClient/GraphQLClient.d.ts +28 -0
- package/lib/HttpClient/GraphQLClient.js +30 -0
- package/lib/HttpClient/HttpClient.d.ts +29 -0
- package/lib/HttpClient/HttpClient.js +130 -0
- package/lib/HttpClient/agents.d.ts +3 -0
- package/lib/HttpClient/agents.js +24 -0
- package/lib/HttpClient/index.d.ts +6 -0
- package/lib/HttpClient/index.js +14 -0
- package/lib/HttpClient/middlewares/cache.d.ts +35 -0
- package/lib/HttpClient/middlewares/cache.js +173 -0
- package/lib/HttpClient/middlewares/cancellationToken.d.ts +3 -0
- package/lib/HttpClient/middlewares/cancellationToken.js +72 -0
- package/lib/HttpClient/middlewares/inflight.d.ts +5 -0
- package/lib/HttpClient/middlewares/inflight.js +50 -0
- package/lib/HttpClient/middlewares/memoization.d.ts +7 -0
- package/lib/HttpClient/middlewares/memoization.js +40 -0
- package/lib/HttpClient/middlewares/metrics.d.ts +9 -0
- package/lib/HttpClient/middlewares/metrics.js +110 -0
- package/lib/HttpClient/middlewares/notFound.d.ts +7 -0
- package/lib/HttpClient/middlewares/notFound.js +20 -0
- package/lib/HttpClient/middlewares/recorder.d.ts +3 -0
- package/lib/HttpClient/middlewares/recorder.js +21 -0
- package/lib/HttpClient/middlewares/request/HttpAgentSingleton.d.ts +14 -0
- package/lib/HttpClient/middlewares/request/HttpAgentSingleton.js +37 -0
- package/lib/HttpClient/middlewares/request/index.d.ts +18 -0
- package/lib/HttpClient/middlewares/request/index.js +83 -0
- package/lib/HttpClient/middlewares/request/setupAxios/index.d.ts +1 -0
- package/lib/HttpClient/middlewares/request/setupAxios/index.js +20 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.d.ts +2 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +48 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.d.ts +2 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +7 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.d.ts +8 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.js +51 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.d.ts +4 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +29 -0
- package/lib/HttpClient/middlewares/tracing.d.ts +15 -0
- package/lib/HttpClient/middlewares/tracing.js +54 -0
- package/lib/HttpClient/typings.d.ts +123 -0
- package/lib/HttpClient/typings.js +11 -0
- package/lib/caches/CacheLayer.d.ts +7 -0
- package/lib/caches/CacheLayer.js +2 -0
- package/lib/caches/DiskCache.d.ts +17 -0
- package/lib/caches/DiskCache.js +70 -0
- package/lib/caches/LRUCache.d.ts +16 -0
- package/lib/caches/LRUCache.js +48 -0
- package/lib/caches/LRUDiskCache.d.ts +21 -0
- package/lib/caches/LRUDiskCache.js +132 -0
- package/lib/caches/MultilayeredCache.d.ts +14 -0
- package/lib/caches/MultilayeredCache.js +68 -0
- package/lib/caches/index.d.ts +6 -0
- package/lib/caches/index.js +9 -0
- package/lib/caches/typings.d.ts +48 -0
- package/lib/caches/typings.js +2 -0
- package/lib/clients/IOClient.d.ts +13 -0
- package/lib/clients/IOClient.js +19 -0
- package/lib/clients/IOClients.d.ts +37 -0
- package/lib/clients/IOClients.js +89 -0
- package/lib/clients/IOGraphQLClient.d.ts +13 -0
- package/lib/clients/IOGraphQLClient.js +16 -0
- package/lib/clients/apps/AppClient.d.ts +9 -0
- package/lib/clients/apps/AppClient.js +34 -0
- package/lib/clients/apps/AppGraphQLClient.d.ts +9 -0
- package/lib/clients/apps/AppGraphQLClient.js +34 -0
- package/lib/clients/apps/Billing.d.ts +12 -0
- package/lib/clients/apps/Billing.js +21 -0
- package/lib/clients/apps/Builder.d.ts +45 -0
- package/lib/clients/apps/Builder.js +114 -0
- package/lib/clients/apps/MessagesGraphQL.d.ts +61 -0
- package/lib/clients/apps/MessagesGraphQL.js +121 -0
- package/lib/clients/apps/Settings.d.ts +14 -0
- package/lib/clients/apps/Settings.js +38 -0
- package/lib/clients/apps/catalogGraphQL/brand.d.ts +13 -0
- package/lib/clients/apps/catalogGraphQL/brand.js +18 -0
- package/lib/clients/apps/catalogGraphQL/category.d.ts +11 -0
- package/lib/clients/apps/catalogGraphQL/category.js +16 -0
- package/lib/clients/apps/catalogGraphQL/index.d.ts +22 -0
- package/lib/clients/apps/catalogGraphQL/index.js +88 -0
- package/lib/clients/apps/catalogGraphQL/product.d.ts +25 -0
- package/lib/clients/apps/catalogGraphQL/product.js +30 -0
- package/lib/clients/apps/catalogGraphQL/sku.d.ts +26 -0
- package/lib/clients/apps/catalogGraphQL/sku.js +30 -0
- package/lib/clients/apps/index.d.ts +7 -0
- package/lib/clients/apps/index.js +12 -0
- package/lib/clients/external/ExternalClient.d.ts +9 -0
- package/lib/clients/external/ExternalClient.js +21 -0
- package/lib/clients/external/ID.d.ts +23 -0
- package/lib/clients/external/ID.js +60 -0
- package/lib/clients/external/Masterdata.d.ts +93 -0
- package/lib/clients/external/Masterdata.js +223 -0
- package/lib/clients/external/PaymentProvider.d.ts +31 -0
- package/lib/clients/external/PaymentProvider.js +42 -0
- package/lib/clients/external/index.d.ts +4 -0
- package/lib/clients/external/index.js +9 -0
- package/lib/clients/index.d.ts +9 -0
- package/lib/clients/index.js +17 -0
- package/lib/clients/infra/Apps.d.ts +88 -0
- package/lib/clients/infra/Apps.js +508 -0
- package/lib/clients/infra/Assets.d.ts +34 -0
- package/lib/clients/infra/Assets.js +165 -0
- package/lib/clients/infra/BillingMetrics.d.ts +13 -0
- package/lib/clients/infra/BillingMetrics.js +15 -0
- package/lib/clients/infra/Events.d.ts +12 -0
- package/lib/clients/infra/Events.js +33 -0
- package/lib/clients/infra/Housekeeper.d.ts +10 -0
- package/lib/clients/infra/Housekeeper.js +30 -0
- package/lib/clients/infra/InfraClient.d.ts +9 -0
- package/lib/clients/infra/InfraClient.js +34 -0
- package/lib/clients/infra/Metadata.d.ts +26 -0
- package/lib/clients/infra/Metadata.js +83 -0
- package/lib/clients/infra/Registry.d.ts +59 -0
- package/lib/clients/infra/Registry.js +207 -0
- package/lib/clients/infra/Router.d.ts +34 -0
- package/lib/clients/infra/Router.js +81 -0
- package/lib/clients/infra/Sphinx.d.ts +13 -0
- package/lib/clients/infra/Sphinx.js +29 -0
- package/lib/clients/infra/VBase.d.ts +60 -0
- package/lib/clients/infra/VBase.js +171 -0
- package/lib/clients/infra/Workspaces.d.ts +18 -0
- package/lib/clients/infra/Workspaces.js +65 -0
- package/lib/clients/infra/index.d.ts +12 -0
- package/lib/clients/infra/index.js +17 -0
- package/lib/clients/janus/JanusClient.d.ts +21 -0
- package/lib/clients/janus/JanusClient.js +30 -0
- package/lib/clients/janus/LicenseManager.d.ts +7 -0
- package/lib/clients/janus/LicenseManager.js +58 -0
- package/lib/clients/janus/Segment.d.ts +36 -0
- package/lib/clients/janus/Segment.js +79 -0
- package/lib/clients/janus/Session.d.ts +15 -0
- package/lib/clients/janus/Session.js +75 -0
- package/lib/clients/janus/Tenant.d.ts +29 -0
- package/lib/clients/janus/Tenant.js +28 -0
- package/lib/clients/janus/index.d.ts +5 -0
- package/lib/clients/janus/index.js +10 -0
- package/lib/constants.d.ts +59 -0
- package/lib/constants.js +65 -0
- package/lib/errors/AuthenticationError.d.ts +18 -0
- package/lib/errors/AuthenticationError.js +24 -0
- package/lib/errors/ForbiddenError.d.ts +18 -0
- package/lib/errors/ForbiddenError.js +24 -0
- package/lib/errors/NotFoundError.d.ts +18 -0
- package/lib/errors/NotFoundError.js +24 -0
- package/lib/errors/RequestCancelledError.d.ts +6 -0
- package/lib/errors/RequestCancelledError.js +11 -0
- package/lib/errors/ResolverError.d.ts +29 -0
- package/lib/errors/ResolverError.js +35 -0
- package/lib/errors/ResolverWarning.d.ts +21 -0
- package/lib/errors/ResolverWarning.js +28 -0
- package/lib/errors/TooManyRequestsError.d.ts +4 -0
- package/lib/errors/TooManyRequestsError.js +9 -0
- package/lib/errors/UserInputError.d.ts +18 -0
- package/lib/errors/UserInputError.js +24 -0
- package/lib/errors/customGraphQLError.d.ts +4 -0
- package/lib/errors/customGraphQLError.js +9 -0
- package/lib/errors/index.d.ts +8 -0
- package/lib/errors/index.js +13 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +21 -0
- package/lib/metrics/MetricsAccumulator.d.ts +35 -0
- package/lib/metrics/MetricsAccumulator.js +125 -0
- package/lib/responses.d.ts +79 -0
- package/lib/responses.js +2 -0
- package/lib/service/index.d.ts +2 -0
- package/lib/service/index.js +30 -0
- package/lib/service/loaders.d.ts +8 -0
- package/lib/service/loaders.js +54 -0
- package/lib/service/logger/console.d.ts +10 -0
- package/lib/service/logger/console.js +36 -0
- package/lib/service/logger/index.d.ts +2 -0
- package/lib/service/logger/index.js +7 -0
- package/lib/service/logger/logger.d.ts +35 -0
- package/lib/service/logger/logger.js +73 -0
- package/lib/service/logger/metricsLogger.d.ts +40 -0
- package/lib/service/logger/metricsLogger.js +149 -0
- package/lib/service/master.d.ts +2 -0
- package/lib/service/master.js +91 -0
- package/lib/service/tracing/TracerSingleton.d.ts +7 -0
- package/lib/service/tracing/TracerSingleton.js +54 -0
- package/lib/service/tracing/metrics/MetricNames.d.ts +60 -0
- package/lib/service/tracing/metrics/MetricNames.js +44 -0
- package/lib/service/tracing/metrics/instruments.d.ts +9 -0
- package/lib/service/tracing/metrics/instruments.js +11 -0
- package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.d.ts +9 -0
- package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +25 -0
- package/lib/service/tracing/tracingMiddlewares.d.ts +5 -0
- package/lib/service/tracing/tracingMiddlewares.js +119 -0
- package/lib/service/worker/index.d.ts +11 -0
- package/lib/service/worker/index.js +193 -0
- package/lib/service/worker/listeners.d.ts +3 -0
- package/lib/service/worker/listeners.js +43 -0
- package/lib/service/worker/runtime/Service.d.ts +17 -0
- package/lib/service/worker/runtime/Service.js +23 -0
- package/lib/service/worker/runtime/builtIn/handlers.d.ts +4 -0
- package/lib/service/worker/runtime/builtIn/handlers.js +27 -0
- package/lib/service/worker/runtime/builtIn/middlewares.d.ts +4 -0
- package/lib/service/worker/runtime/builtIn/middlewares.js +40 -0
- package/lib/service/worker/runtime/events/index.d.ts +4 -0
- package/lib/service/worker/runtime/events/index.js +46 -0
- package/lib/service/worker/runtime/events/middlewares/body.d.ts +3 -0
- package/lib/service/worker/runtime/events/middlewares/body.js +22 -0
- package/lib/service/worker/runtime/events/middlewares/context.d.ts +3 -0
- package/lib/service/worker/runtime/events/middlewares/context.js +22 -0
- package/lib/service/worker/runtime/events/router.d.ts +2 -0
- package/lib/service/worker/runtime/events/router.js +27 -0
- package/lib/service/worker/runtime/graphql/index.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/index.js +27 -0
- package/lib/service/worker/runtime/graphql/middlewares/context.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/middlewares/context.js +16 -0
- package/lib/service/worker/runtime/graphql/middlewares/error.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/middlewares/error.js +93 -0
- package/lib/service/worker/runtime/graphql/middlewares/query.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/middlewares/query.js +52 -0
- package/lib/service/worker/runtime/graphql/middlewares/response.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/middlewares/response.js +38 -0
- package/lib/service/worker/runtime/graphql/middlewares/run.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/middlewares/run.js +19 -0
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.d.ts +4 -0
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +28 -0
- package/lib/service/worker/runtime/graphql/middlewares/upload.d.ts +4 -0
- package/lib/service/worker/runtime/graphql/middlewares/upload.js +12 -0
- package/lib/service/worker/runtime/graphql/schema/index.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/index.js +31 -0
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +79 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Auth.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Auth.js +73 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.js +37 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.d.ts +11 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +61 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.js +40 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Sanitize.d.ts +9 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Sanitize.js +35 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +34 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/SmartCacheDirective.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/SmartCacheDirective.js +29 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +39 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +33 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.d.ts +22 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +36 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/index.d.ts +7 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +12 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/ioUpload.d.ts +3 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/ioUpload.js +16 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/sanitizedString.d.ts +10 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/sanitizedString.js +39 -0
- package/lib/service/worker/runtime/graphql/typings.d.ts +31 -0
- package/lib/service/worker/runtime/graphql/typings.js +2 -0
- package/lib/service/worker/runtime/graphql/utils/cacheControl.d.ts +1 -0
- package/lib/service/worker/runtime/graphql/utils/cacheControl.js +32 -0
- package/lib/service/worker/runtime/graphql/utils/error.d.ts +1 -0
- package/lib/service/worker/runtime/graphql/utils/error.js +76 -0
- package/lib/service/worker/runtime/graphql/utils/pathname.d.ts +1 -0
- package/lib/service/worker/runtime/graphql/utils/pathname.js +7 -0
- package/lib/service/worker/runtime/graphql/utils/translations.d.ts +14 -0
- package/lib/service/worker/runtime/graphql/utils/translations.js +38 -0
- package/lib/service/worker/runtime/http/index.d.ts +5 -0
- package/lib/service/worker/runtime/http/index.js +58 -0
- package/lib/service/worker/runtime/http/middlewares/authTokens.d.ts +3 -0
- package/lib/service/worker/runtime/http/middlewares/authTokens.js +12 -0
- package/lib/service/worker/runtime/http/middlewares/cancellationToken.d.ts +3 -0
- package/lib/service/worker/runtime/http/middlewares/cancellationToken.js +18 -0
- package/lib/service/worker/runtime/http/middlewares/clients.d.ts +4 -0
- package/lib/service/worker/runtime/http/middlewares/clients.js +12 -0
- package/lib/service/worker/runtime/http/middlewares/context.d.ts +4 -0
- package/lib/service/worker/runtime/http/middlewares/context.js +36 -0
- package/lib/service/worker/runtime/http/middlewares/error.d.ts +2 -0
- package/lib/service/worker/runtime/http/middlewares/error.js +84 -0
- package/lib/service/worker/runtime/http/middlewares/rateLimit.d.ts +6 -0
- package/lib/service/worker/runtime/http/middlewares/rateLimit.js +42 -0
- package/lib/service/worker/runtime/http/middlewares/requestStats.d.ts +17 -0
- package/lib/service/worker/runtime/http/middlewares/requestStats.js +40 -0
- package/lib/service/worker/runtime/http/middlewares/setCookie.d.ts +3 -0
- package/lib/service/worker/runtime/http/middlewares/setCookie.js +52 -0
- package/lib/service/worker/runtime/http/middlewares/settings.d.ts +9 -0
- package/lib/service/worker/runtime/http/middlewares/settings.js +43 -0
- package/lib/service/worker/runtime/http/middlewares/timings.d.ts +3 -0
- package/lib/service/worker/runtime/http/middlewares/timings.js +45 -0
- package/lib/service/worker/runtime/http/middlewares/vary.d.ts +3 -0
- package/lib/service/worker/runtime/http/middlewares/vary.js +52 -0
- package/lib/service/worker/runtime/http/router.d.ts +2 -0
- package/lib/service/worker/runtime/http/router.js +23 -0
- package/lib/service/worker/runtime/http/routes.d.ts +19 -0
- package/lib/service/worker/runtime/http/routes.js +12 -0
- package/lib/service/worker/runtime/method.d.ts +9 -0
- package/lib/service/worker/runtime/method.js +23 -0
- package/lib/service/worker/runtime/statusTrack.d.ts +14 -0
- package/lib/service/worker/runtime/statusTrack.js +37 -0
- package/lib/service/worker/runtime/typings.d.ts +172 -0
- package/lib/service/worker/runtime/typings.js +2 -0
- package/lib/service/worker/runtime/utils/compose.d.ts +5 -0
- package/lib/service/worker/runtime/utils/compose.js +11 -0
- package/lib/service/worker/runtime/utils/context.d.ts +2 -0
- package/lib/service/worker/runtime/utils/context.js +40 -0
- package/lib/service/worker/runtime/utils/diff.d.ts +12 -0
- package/lib/service/worker/runtime/utils/diff.js +21 -0
- package/lib/service/worker/runtime/utils/recorder.d.ts +8 -0
- package/lib/service/worker/runtime/utils/recorder.js +37 -0
- package/lib/service/worker/runtime/utils/toArray.d.ts +1 -0
- package/lib/service/worker/runtime/utils/toArray.js +3 -0
- package/lib/service/worker/runtime/utils/tokenBucket.d.ts +2 -0
- package/lib/service/worker/runtime/utils/tokenBucket.js +16 -0
- package/lib/tracing/LogEvents.d.ts +31 -0
- package/lib/tracing/LogEvents.js +3 -0
- package/lib/tracing/LogFields.d.ts +61 -0
- package/lib/tracing/LogFields.js +3 -0
- package/lib/tracing/Tags.d.ts +79 -0
- package/lib/tracing/Tags.js +7 -0
- package/lib/tracing/UserLandTracer.d.ts +27 -0
- package/lib/tracing/UserLandTracer.js +55 -0
- package/lib/tracing/errorReporting/ErrorReport.d.ts +31 -0
- package/lib/tracing/errorReporting/ErrorReport.js +61 -0
- package/lib/tracing/index.d.ts +9 -0
- package/lib/tracing/index.js +19 -0
- package/lib/tracing/spanReference/SpanReferenceTypes.d.ts +4 -0
- package/lib/tracing/spanReference/SpanReferenceTypes.js +7 -0
- package/lib/tracing/spanReference/createSpanReference.d.ts +3 -0
- package/lib/tracing/spanReference/createSpanReference.js +8 -0
- package/lib/tracing/utils.d.ts +13 -0
- package/lib/tracing/utils.js +40 -0
- package/lib/utils/MineWinsConflictsResolver.d.ts +28 -0
- package/lib/utils/MineWinsConflictsResolver.js +130 -0
- package/lib/utils/app.d.ts +23 -0
- package/lib/utils/app.js +48 -0
- package/lib/utils/appsStaleIfError.d.ts +11 -0
- package/lib/utils/appsStaleIfError.js +63 -0
- package/lib/utils/billingOptions.d.ts +36 -0
- package/lib/utils/billingOptions.js +9 -0
- package/lib/utils/binding.d.ts +13 -0
- package/lib/utils/binding.js +38 -0
- package/lib/utils/cancel.d.ts +3 -0
- package/lib/utils/cancel.js +12 -0
- package/lib/utils/domain.d.ts +1 -0
- package/lib/utils/domain.js +5 -0
- package/lib/utils/error.d.ts +8 -0
- package/lib/utils/error.js +94 -0
- package/lib/utils/index.d.ts +9 -0
- package/lib/utils/index.js +14 -0
- package/lib/utils/message.d.ts +25 -0
- package/lib/utils/message.js +23 -0
- package/lib/utils/renameBy.d.ts +1 -0
- package/lib/utils/renameBy.js +4 -0
- package/lib/utils/retry.d.ts +4 -0
- package/lib/utils/retry.js +32 -0
- package/lib/utils/status.d.ts +1 -0
- package/lib/utils/status.js +11 -0
- package/lib/utils/tenant.d.ts +5 -0
- package/lib/utils/tenant.js +6 -0
- package/lib/utils/throwOnGraphQLErrors.d.ts +2 -0
- package/lib/utils/throwOnGraphQLErrors.js +15 -0
- package/lib/utils/time.d.ts +31 -0
- package/lib/utils/time.js +118 -0
- package/package.json +127 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const __1 = require("../..");
|
|
4
|
+
const HttpClient_1 = require("../../HttpClient");
|
|
5
|
+
const ExternalClient_1 = require("./ExternalClient");
|
|
6
|
+
const routes = {
|
|
7
|
+
document: (dataEntity, id) => `${dataEntity}/documents/${id}`,
|
|
8
|
+
documents: (dataEntity) => `${dataEntity}/documents`,
|
|
9
|
+
publicSchema: (dataEntity, schema) => `${dataEntity}/schemas/${schema}/public`,
|
|
10
|
+
schema: (dataEntity, schema) => `${dataEntity}/schemas/${schema}`,
|
|
11
|
+
scroll: (dataEntity) => `${dataEntity}/scroll`,
|
|
12
|
+
search: (dataEntity) => `${dataEntity}/search`,
|
|
13
|
+
};
|
|
14
|
+
class MasterData extends ExternalClient_1.ExternalClient {
|
|
15
|
+
constructor(ctx, options) {
|
|
16
|
+
super(`http://api.vtex.com/api/dataentities`, ctx, {
|
|
17
|
+
...options,
|
|
18
|
+
headers: {
|
|
19
|
+
Accept: 'application/json',
|
|
20
|
+
VtexIdclientAutCookie: ctx.authToken,
|
|
21
|
+
'x-vtex-api-appService': ctx.userAgent,
|
|
22
|
+
...options === null || options === void 0 ? void 0 : options.headers,
|
|
23
|
+
},
|
|
24
|
+
params: {
|
|
25
|
+
an: ctx.account,
|
|
26
|
+
...options === null || options === void 0 ? void 0 : options.params,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
getSchema({ dataEntity, schema }, tracingConfig) {
|
|
31
|
+
const metric = 'masterdata-getSchema';
|
|
32
|
+
return this.http.get(routes.schema(dataEntity, schema), {
|
|
33
|
+
metric,
|
|
34
|
+
tracing: {
|
|
35
|
+
requestSpanNameSuffix: metric,
|
|
36
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
createOrUpdateSchema({ dataEntity, schemaName, schemaBody }, tracingConfig) {
|
|
41
|
+
const metric = 'masterdata-createOrUpdateSchema';
|
|
42
|
+
return this.http.put(routes.schema(dataEntity, schemaName), schemaBody, {
|
|
43
|
+
metric,
|
|
44
|
+
tracing: {
|
|
45
|
+
requestSpanNameSuffix: metric,
|
|
46
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
getPublicSchema({ dataEntity, schema }, tracingConfig) {
|
|
51
|
+
const metric = 'masterdata-getPublicSchema';
|
|
52
|
+
return this.http.get(routes.publicSchema(dataEntity, schema), {
|
|
53
|
+
metric,
|
|
54
|
+
tracing: {
|
|
55
|
+
requestSpanNameSuffix: metric,
|
|
56
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
getDocument({ dataEntity, id, fields }, tracingConfig) {
|
|
61
|
+
const metric = 'masterdata-getDocument';
|
|
62
|
+
return this.http.get(routes.document(dataEntity, id), {
|
|
63
|
+
metric,
|
|
64
|
+
params: {
|
|
65
|
+
_fields: generateFieldsArg(fields),
|
|
66
|
+
},
|
|
67
|
+
tracing: {
|
|
68
|
+
requestSpanNameSuffix: metric,
|
|
69
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
createDocument({ dataEntity, fields, schema }, tracingConfig) {
|
|
74
|
+
const metric = 'masterdata-createDocument';
|
|
75
|
+
return this.http.post(routes.documents(dataEntity), fields, {
|
|
76
|
+
metric,
|
|
77
|
+
params: {
|
|
78
|
+
_schema: schema,
|
|
79
|
+
},
|
|
80
|
+
tracing: {
|
|
81
|
+
requestSpanNameSuffix: metric,
|
|
82
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
createOrUpdateEntireDocument({ dataEntity, fields, id, schema }, tracingConfig) {
|
|
87
|
+
const metric = 'masterdata-createOrUpdateEntireDocument';
|
|
88
|
+
return this.http.put(routes.documents(dataEntity), { id, ...fields }, {
|
|
89
|
+
metric,
|
|
90
|
+
params: {
|
|
91
|
+
_schema: schema,
|
|
92
|
+
},
|
|
93
|
+
tracing: {
|
|
94
|
+
requestSpanNameSuffix: metric,
|
|
95
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
createOrUpdatePartialDocument({ dataEntity, fields, id, schema }, tracingConfig) {
|
|
100
|
+
const metric = 'masterdata-createOrUpdatePartialDocument';
|
|
101
|
+
return this.http.patch(routes.documents(dataEntity), { id, ...fields }, {
|
|
102
|
+
metric,
|
|
103
|
+
params: {
|
|
104
|
+
_schema: schema,
|
|
105
|
+
},
|
|
106
|
+
tracing: {
|
|
107
|
+
requestSpanNameSuffix: metric,
|
|
108
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
updateEntireDocument({ dataEntity, id, fields, schema }, tracingConfig) {
|
|
113
|
+
const metric = 'masterdata-updateEntireDocument';
|
|
114
|
+
return this.http.put(routes.document(dataEntity, id), fields, {
|
|
115
|
+
metric,
|
|
116
|
+
params: {
|
|
117
|
+
_schema: schema,
|
|
118
|
+
},
|
|
119
|
+
tracing: {
|
|
120
|
+
requestSpanNameSuffix: metric,
|
|
121
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
updatePartialDocument({ dataEntity, id, fields, schema }, tracingConfig) {
|
|
126
|
+
const metric = 'masterdata-updatePartialDocument';
|
|
127
|
+
return this.http.patch(routes.document(dataEntity, id), fields, {
|
|
128
|
+
metric,
|
|
129
|
+
params: {
|
|
130
|
+
_schema: schema,
|
|
131
|
+
},
|
|
132
|
+
tracing: {
|
|
133
|
+
requestSpanNameSuffix: metric,
|
|
134
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
searchDocuments({ dataEntity, fields, where, pagination, schema, sort }, tracingConfig) {
|
|
139
|
+
const metric = 'masterdata-searchDocuments';
|
|
140
|
+
return this.http.get(routes.search(dataEntity), {
|
|
141
|
+
cacheable: HttpClient_1.CacheType.None,
|
|
142
|
+
headers: paginationArgsToHeaders(pagination),
|
|
143
|
+
metric,
|
|
144
|
+
params: {
|
|
145
|
+
_fields: generateFieldsArg(fields),
|
|
146
|
+
_schema: schema,
|
|
147
|
+
_sort: sort,
|
|
148
|
+
_where: where,
|
|
149
|
+
},
|
|
150
|
+
tracing: {
|
|
151
|
+
requestSpanNameSuffix: metric,
|
|
152
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
async searchDocumentsWithPaginationInfo({ dataEntity, fields, where, pagination, schema, sort }, tracingConfig) {
|
|
157
|
+
const metric = 'masterdata-searchDocumentsWithPagination';
|
|
158
|
+
const result = await this.http.getRaw(routes.search(dataEntity), {
|
|
159
|
+
cacheable: HttpClient_1.CacheType.None,
|
|
160
|
+
headers: paginationArgsToHeaders(pagination),
|
|
161
|
+
metric,
|
|
162
|
+
params: {
|
|
163
|
+
_fields: generateFieldsArg(fields),
|
|
164
|
+
_schema: schema,
|
|
165
|
+
_sort: sort,
|
|
166
|
+
_where: where,
|
|
167
|
+
},
|
|
168
|
+
tracing: {
|
|
169
|
+
requestSpanNameSuffix: metric,
|
|
170
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
const headers = result.headers;
|
|
174
|
+
const restContentRange = headers['rest-content-range'];
|
|
175
|
+
const total = Number(restContentRange.split('/')[1]);
|
|
176
|
+
const paginationInfo = { ...pagination, total };
|
|
177
|
+
return { data: result.data, pagination: paginationInfo };
|
|
178
|
+
}
|
|
179
|
+
scrollDocuments({ dataEntity, fields, mdToken, schema, size, sort }, tracingConfig) {
|
|
180
|
+
const metric = 'masterdata-scrollDocuments';
|
|
181
|
+
return this.http
|
|
182
|
+
.getRaw(routes.scroll(dataEntity), {
|
|
183
|
+
cacheable: HttpClient_1.CacheType.None,
|
|
184
|
+
metric,
|
|
185
|
+
params: {
|
|
186
|
+
_fields: generateFieldsArg(fields),
|
|
187
|
+
_schema: schema,
|
|
188
|
+
_size: size,
|
|
189
|
+
_sort: sort,
|
|
190
|
+
_token: mdToken,
|
|
191
|
+
},
|
|
192
|
+
tracing: {
|
|
193
|
+
requestSpanNameSuffix: metric,
|
|
194
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
195
|
+
},
|
|
196
|
+
})
|
|
197
|
+
.then(({ headers: { 'x-vtex-md-token': resToken }, data }) => ({ mdToken: resToken, data }));
|
|
198
|
+
}
|
|
199
|
+
deleteDocument({ dataEntity, id }, tracingConfig) {
|
|
200
|
+
const metric = 'masterdata-deleteDocument';
|
|
201
|
+
return this.http.delete(routes.document(dataEntity, id), {
|
|
202
|
+
metric,
|
|
203
|
+
tracing: {
|
|
204
|
+
requestSpanNameSuffix: metric,
|
|
205
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
exports.MasterData = MasterData;
|
|
211
|
+
function paginationArgsToHeaders({ page, pageSize }) {
|
|
212
|
+
if (page < 1) {
|
|
213
|
+
throw new __1.UserInputError('Smallest page value is 1');
|
|
214
|
+
}
|
|
215
|
+
const startIndex = (page - 1) * pageSize;
|
|
216
|
+
const endIndex = startIndex + pageSize;
|
|
217
|
+
return {
|
|
218
|
+
'REST-Range': `resources=${startIndex}-${endIndex}`,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function generateFieldsArg(fields) {
|
|
222
|
+
return fields.join(',');
|
|
223
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { InstanceOptions, IOContext, Maybe } from '../..';
|
|
2
|
+
import { RequestTracingConfig } from '../../HttpClient';
|
|
3
|
+
import { ExternalClient } from './ExternalClient';
|
|
4
|
+
export declare class PaymentProvider extends ExternalClient {
|
|
5
|
+
protected context: IOContext;
|
|
6
|
+
constructor(context: IOContext, options?: InstanceOptions);
|
|
7
|
+
callback: (transactionId: string, paymentId: string, callback: AuthorizationCallback, tracingConfig?: RequestTracingConfig | undefined) => Promise<unknown>;
|
|
8
|
+
inbound: <TRequest, TResponse>(transactionId: string, paymentId: string, action: string, payload: TRequest, tracingConfig?: RequestTracingConfig | undefined) => Promise<TResponse>;
|
|
9
|
+
}
|
|
10
|
+
export interface AuthorizationCallback {
|
|
11
|
+
paymentId: string;
|
|
12
|
+
status: string;
|
|
13
|
+
tid: string;
|
|
14
|
+
authorizationId?: Maybe<string>;
|
|
15
|
+
nsu?: Maybe<string>;
|
|
16
|
+
acquirer: string;
|
|
17
|
+
paymentUrl?: Maybe<string>;
|
|
18
|
+
paymentAppData?: Maybe<{
|
|
19
|
+
appName: string;
|
|
20
|
+
payload: string;
|
|
21
|
+
}>;
|
|
22
|
+
identificationNumber?: Maybe<string>;
|
|
23
|
+
identificationNumberFormatted?: Maybe<string>;
|
|
24
|
+
barCodeImageType?: Maybe<string>;
|
|
25
|
+
barCodeImageNumber?: Maybe<string>;
|
|
26
|
+
code?: Maybe<string>;
|
|
27
|
+
message?: Maybe<string>;
|
|
28
|
+
delayToAutoSettle?: Maybe<number>;
|
|
29
|
+
delayToAutoSettleAfterAntifraud?: Maybe<number>;
|
|
30
|
+
delayToCancel?: Maybe<number>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ExternalClient_1 = require("./ExternalClient");
|
|
4
|
+
const routes = {
|
|
5
|
+
callback: (transactionId, paymentId) => `${routes.payment(transactionId, paymentId)}/notification`,
|
|
6
|
+
inbound: (transactionId, paymentId, action) => `${routes.payment(transactionId, paymentId)}/inbound-request/${action}`,
|
|
7
|
+
payment: (transactionId, paymentId) => `/transactions/${transactionId}/payments/${paymentId}`,
|
|
8
|
+
};
|
|
9
|
+
class PaymentProvider extends ExternalClient_1.ExternalClient {
|
|
10
|
+
constructor(context, options) {
|
|
11
|
+
var _a;
|
|
12
|
+
super(`http://${context.account}.vtexpayments.com.br/payment-provider`, context, {
|
|
13
|
+
...(options !== null && options !== void 0 ? options : {}),
|
|
14
|
+
headers: {
|
|
15
|
+
...((_a = options === null || options === void 0 ? void 0 : options.headers) !== null && _a !== void 0 ? _a : {}),
|
|
16
|
+
'X-Vtex-Use-Https': 'true',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
this.context = context;
|
|
20
|
+
this.callback = (transactionId, paymentId, callback, tracingConfig) => {
|
|
21
|
+
const metric = 'gateway-callback';
|
|
22
|
+
return this.http.post(routes.callback(transactionId, paymentId), callback, {
|
|
23
|
+
metric,
|
|
24
|
+
tracing: {
|
|
25
|
+
requestSpanNameSuffix: metric,
|
|
26
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
this.inbound = (transactionId, paymentId, action, payload, tracingConfig) => {
|
|
31
|
+
const metric = 'gateway-inbound-request';
|
|
32
|
+
return this.http.post(routes.inbound(transactionId, paymentId, action), payload, {
|
|
33
|
+
metric,
|
|
34
|
+
tracing: {
|
|
35
|
+
requestSpanNameSuffix: metric,
|
|
36
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.PaymentProvider = PaymentProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function __export(m) {
|
|
3
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
+
}
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
__export(require("./ExternalClient"));
|
|
7
|
+
__export(require("./ID"));
|
|
8
|
+
__export(require("./PaymentProvider"));
|
|
9
|
+
__export(require("./Masterdata"));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './apps';
|
|
2
|
+
export * from './external';
|
|
3
|
+
export * from './infra';
|
|
4
|
+
export * from './janus';
|
|
5
|
+
export * from './IOClient';
|
|
6
|
+
export * from './IOClients';
|
|
7
|
+
export * from './IOGraphQLClient';
|
|
8
|
+
import promclient from 'prom-client';
|
|
9
|
+
export { promclient };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function __export(m) {
|
|
3
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
+
}
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
__export(require("./apps"));
|
|
10
|
+
__export(require("./external"));
|
|
11
|
+
__export(require("./infra"));
|
|
12
|
+
__export(require("./janus"));
|
|
13
|
+
__export(require("./IOClient"));
|
|
14
|
+
__export(require("./IOClients"));
|
|
15
|
+
__export(require("./IOGraphQLClient"));
|
|
16
|
+
const prom_client_1 = __importDefault(require("prom-client"));
|
|
17
|
+
exports.promclient = prom_client_1.default;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage } from 'http';
|
|
3
|
+
import { Readable, Writable } from 'stream';
|
|
4
|
+
import { ZlibOptions } from 'zlib';
|
|
5
|
+
import { InstanceOptions, RequestTracingConfig } from '../../HttpClient';
|
|
6
|
+
import { AppBundleLinked, AppFilesList, AppManifest } from '../../responses';
|
|
7
|
+
import { IOContext } from '../../service/worker/runtime/typings';
|
|
8
|
+
import { InfraClient } from './InfraClient';
|
|
9
|
+
export declare class Apps extends InfraClient {
|
|
10
|
+
private _routes;
|
|
11
|
+
private diskCache;
|
|
12
|
+
private memoryCache;
|
|
13
|
+
private get routes();
|
|
14
|
+
constructor(context: IOContext, options?: InstanceOptions);
|
|
15
|
+
installApp: (descriptor: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<void> | Promise<AppInstallResponse>;
|
|
16
|
+
uninstallApp: (app: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<import("../..").IOResponse<void>>;
|
|
17
|
+
acknowledgeApp: (app: string, service: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
|
|
18
|
+
link: (app: string, files: Change[], { zlib }?: ZipOptions, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppBundleLinked>;
|
|
19
|
+
patch: (app: string, changes: Change[], { zlib }?: ZipOptions, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
|
|
20
|
+
unlink: (app: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<import("../..").IOResponse<void>>;
|
|
21
|
+
unlinkAll: (tracingConfig?: RequestTracingConfig | undefined) => Promise<import("../..").IOResponse<void>>;
|
|
22
|
+
saveAppSettings: (app: string, settings: any, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
|
|
23
|
+
listApps: ({ oldVersion, since, service }?: ListAppsOptions, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppsList>;
|
|
24
|
+
listAppFiles: (app: string, { prefix, nextMarker }?: ListFilesOptions, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppFilesList>;
|
|
25
|
+
listLinks: (tracingConfig?: RequestTracingConfig | undefined) => Promise<string[]>;
|
|
26
|
+
getAppFile: (app: string, path: string, staleIfError?: boolean | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
|
|
27
|
+
data: Buffer;
|
|
28
|
+
headers: any;
|
|
29
|
+
}>;
|
|
30
|
+
getAppJSON: <T extends object | null>(app: string, path: string, nullIfNotFound?: boolean | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<T>;
|
|
31
|
+
getFileFromApps: <T extends object | null>(app: string, path: string, nullIfNotFound?: boolean | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<T>;
|
|
32
|
+
getAppFileStream: (app: string, path: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<IncomingMessage>;
|
|
33
|
+
getApp: (app: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppManifest>;
|
|
34
|
+
getAppSettings: (app: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<any>;
|
|
35
|
+
getAllAppsSettings: (listAppsOptions?: ListAppsOptions, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppsSettings>;
|
|
36
|
+
getAppBundle: (app: string, bundlePath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig | undefined) => Promise<Readable>;
|
|
37
|
+
unpackAppBundle: (app: string, bundlePath: string, unpackPath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig | undefined) => Promise<Writable>;
|
|
38
|
+
getAppsMetaInfos: (filter?: string | undefined, staleWhileRevalidate?: boolean, tracingConfig?: RequestTracingConfig | undefined) => Promise<AppMetaInfo[]>;
|
|
39
|
+
getDependencies: (filter?: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<Record<string, string[]>>;
|
|
40
|
+
updateDependencies: (tracingConfig?: RequestTracingConfig | undefined) => Promise<Record<string, string[]>>;
|
|
41
|
+
updateDependency: (name: string, version: string, registry: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
|
|
42
|
+
resolveDependencies: (apps: string[], registries: string[], filter?: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<any>;
|
|
43
|
+
resolveDependenciesWithManifest: (manifest: AppManifest, filter?: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<Record<string, string[]>>;
|
|
44
|
+
private installRuntime;
|
|
45
|
+
}
|
|
46
|
+
interface ZipOptions {
|
|
47
|
+
zlib?: ZlibOptions;
|
|
48
|
+
}
|
|
49
|
+
export interface AppMetaInfo {
|
|
50
|
+
id: string;
|
|
51
|
+
settingsSchema?: Record<string, any>;
|
|
52
|
+
_resolvedDependencies: Record<string, string>;
|
|
53
|
+
_isRoot: boolean;
|
|
54
|
+
_buildFeatures: Record<string, string[]>;
|
|
55
|
+
}
|
|
56
|
+
export interface WorkspaceMetaInfo {
|
|
57
|
+
apps: AppMetaInfo[];
|
|
58
|
+
}
|
|
59
|
+
export interface AppsListItem {
|
|
60
|
+
app: string;
|
|
61
|
+
id: string;
|
|
62
|
+
location: string;
|
|
63
|
+
}
|
|
64
|
+
export interface AppsList {
|
|
65
|
+
data: AppsListItem[];
|
|
66
|
+
}
|
|
67
|
+
export interface Change {
|
|
68
|
+
path: string;
|
|
69
|
+
content: string | Readable | Buffer;
|
|
70
|
+
}
|
|
71
|
+
export interface ListAppsOptions {
|
|
72
|
+
oldVersion?: string;
|
|
73
|
+
context?: string[];
|
|
74
|
+
since?: string;
|
|
75
|
+
service?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface ListFilesOptions {
|
|
78
|
+
prefix?: string;
|
|
79
|
+
context?: string[];
|
|
80
|
+
nextMarker?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface AppsSettings {
|
|
83
|
+
[app: string]: any;
|
|
84
|
+
}
|
|
85
|
+
export interface AppInstallResponse {
|
|
86
|
+
message: string;
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
@@ -0,0 +1,508 @@
|
|
|
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 archiver_1 = __importDefault(require("archiver"));
|
|
7
|
+
const tar_fs_1 = require("tar-fs");
|
|
8
|
+
const zlib_1 = require("zlib");
|
|
9
|
+
const HttpClient_1 = require("../../HttpClient");
|
|
10
|
+
const utils_1 = require("../../utils");
|
|
11
|
+
const appsStaleIfError_1 = require("../../utils/appsStaleIfError");
|
|
12
|
+
const InfraClient_1 = require("./InfraClient");
|
|
13
|
+
const createRoutes = ({ account, workspace }) => {
|
|
14
|
+
const routes = {
|
|
15
|
+
Acknowledge: (app, service) => `${routes.App(app)}/acknowledge/${service}`,
|
|
16
|
+
App: (app) => `${routes.Apps()}/${app}`,
|
|
17
|
+
AppBundle: (locator, path) => `${routes.AppOrRegistry(locator)}/bundle/${path}`,
|
|
18
|
+
AppOrRegistry: ({ name, version, build }) => build
|
|
19
|
+
? `${routes.Apps()}/${name}@${version}+${build}`
|
|
20
|
+
: `${routes.Registry()}/${name}/${version}`,
|
|
21
|
+
Apps: () => `${routes.Workspace}/apps`,
|
|
22
|
+
Dependencies: () => `${routes.Workspace}/dependencies`,
|
|
23
|
+
File: (locator, path) => `${routes.Files(locator)}/${path}`,
|
|
24
|
+
FileFromApps: (app, path) => `${routes.Workspace}/apps/${app}/files/${path}`,
|
|
25
|
+
Files: (locator) => `${routes.AppOrRegistry(locator)}/files`,
|
|
26
|
+
Link: (app) => `${routes.Workspace}/v2/links/${app}`,
|
|
27
|
+
Links: () => `${routes.Workspace}/links`,
|
|
28
|
+
Master: `/${account}/master`,
|
|
29
|
+
Meta: () => `${routes.Workspace}/v2/apps`,
|
|
30
|
+
Registry: () => `${routes.Master}/registry`,
|
|
31
|
+
ResolveDependencies: () => `${routes.Workspace}/dependencies/_resolve`,
|
|
32
|
+
ResolveDependenciesWithManifest: () => `${routes.Workspace}/v2/apps/_resolve`,
|
|
33
|
+
Settings: (app) => `${routes.App(app)}/settings`,
|
|
34
|
+
Unlink: (app) => `${routes.Links()}/${app}`,
|
|
35
|
+
Workspace: `/${account}/${workspace}`,
|
|
36
|
+
};
|
|
37
|
+
return routes;
|
|
38
|
+
};
|
|
39
|
+
const getVendorAndName = ({ id }) => utils_1.removeVersionFromAppId(id);
|
|
40
|
+
const notFound = (e) => {
|
|
41
|
+
if (e.response && e.response.status === 404) {
|
|
42
|
+
return {};
|
|
43
|
+
}
|
|
44
|
+
throw e;
|
|
45
|
+
};
|
|
46
|
+
const zipObj = (keys, values) => {
|
|
47
|
+
let idx = 0;
|
|
48
|
+
const len = Math.min(keys.length, values.length);
|
|
49
|
+
const out = {};
|
|
50
|
+
while (idx < len) {
|
|
51
|
+
out[keys[idx]] = values[idx];
|
|
52
|
+
idx += 1;
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
};
|
|
56
|
+
// 🚨🚨🚨
|
|
57
|
+
// In order to make changes in here, please also change the colossus App so we
|
|
58
|
+
// share the same cache key and do NOT call Apps unecessarily
|
|
59
|
+
const workspaceFields = [
|
|
60
|
+
'_activationDate',
|
|
61
|
+
'_buildFeatures',
|
|
62
|
+
'_isRoot',
|
|
63
|
+
'_resolvedDependencies',
|
|
64
|
+
'credentialType',
|
|
65
|
+
'link',
|
|
66
|
+
'name',
|
|
67
|
+
'registry',
|
|
68
|
+
'settingsSchema',
|
|
69
|
+
'vendor',
|
|
70
|
+
'version',
|
|
71
|
+
].join(',');
|
|
72
|
+
class Apps extends InfraClient_1.InfraClient {
|
|
73
|
+
constructor(context, options) {
|
|
74
|
+
super('apps@0.x', context, options, true);
|
|
75
|
+
this.installApp = (descriptor, tracingConfig) => {
|
|
76
|
+
if (descriptor.startsWith('infra:service-')) {
|
|
77
|
+
return this.installRuntime(descriptor, tracingConfig);
|
|
78
|
+
}
|
|
79
|
+
const metric = 'apps-install';
|
|
80
|
+
return this.http.post(this.routes.Apps(), { id: descriptor }, {
|
|
81
|
+
metric,
|
|
82
|
+
tracing: {
|
|
83
|
+
requestSpanNameSuffix: metric,
|
|
84
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
this.uninstallApp = (app, tracingConfig) => {
|
|
89
|
+
const metric = 'apps-uninstall';
|
|
90
|
+
return this.http.delete(this.routes.App(app), {
|
|
91
|
+
metric,
|
|
92
|
+
tracing: {
|
|
93
|
+
requestSpanNameSuffix: metric,
|
|
94
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
this.acknowledgeApp = (app, service, tracingConfig) => {
|
|
99
|
+
const metric = 'apps-ack';
|
|
100
|
+
return this.http.put(this.routes.Acknowledge(app, service), null, {
|
|
101
|
+
metric,
|
|
102
|
+
tracing: {
|
|
103
|
+
requestSpanNameSuffix: metric,
|
|
104
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
this.link = async (app, files, { zlib } = {}, tracingConfig) => {
|
|
109
|
+
if (!(files[0] && files[0].path)) {
|
|
110
|
+
throw new Error('Argument files must be an array of {path, content}, where content can be a String, a Buffer or a ReadableStream.');
|
|
111
|
+
}
|
|
112
|
+
const emptyChanges = files.filter(file => !file.content);
|
|
113
|
+
if (emptyChanges.length > 0) {
|
|
114
|
+
throw new Error(`Missing content for paths: ${emptyChanges.map(e => e.path).join('; ')}`);
|
|
115
|
+
}
|
|
116
|
+
const indexOfManifest = files.findIndex(({ path }) => path === 'manifest.json');
|
|
117
|
+
if (indexOfManifest === -1) {
|
|
118
|
+
throw new Error('No manifest.json file found in files.');
|
|
119
|
+
}
|
|
120
|
+
const zip = archiver_1.default('zip', { zlib });
|
|
121
|
+
// Throw stream errors so they reject the promise chain.
|
|
122
|
+
zip.on('error', (e) => {
|
|
123
|
+
throw e;
|
|
124
|
+
});
|
|
125
|
+
const metric = 'apps-link';
|
|
126
|
+
const request = this.http.put(this.routes.Link(app), zip, {
|
|
127
|
+
headers: { 'Content-Type': 'application/zip' },
|
|
128
|
+
metric,
|
|
129
|
+
tracing: {
|
|
130
|
+
requestSpanNameSuffix: metric,
|
|
131
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
files.forEach(({ content, path }) => zip.append(content, { name: path }));
|
|
135
|
+
const finalize = zip.finalize();
|
|
136
|
+
try {
|
|
137
|
+
const [response] = await Promise.all([request, finalize]);
|
|
138
|
+
response.bundleSize = zip.pointer();
|
|
139
|
+
return response;
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
e.bundleSize = zip.pointer();
|
|
143
|
+
throw e;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
this.patch = async (app, changes, { zlib } = {}, tracingConfig) => {
|
|
147
|
+
if (!(changes[0] && changes[0].path)) {
|
|
148
|
+
throw new Error('Argument changes must be an array of {path, content}, where content can be a String, a Buffer or a ReadableStream.');
|
|
149
|
+
}
|
|
150
|
+
const files = changes.filter(change => !!change.content);
|
|
151
|
+
const deletedFiles = changes
|
|
152
|
+
.filter(change => !change.content)
|
|
153
|
+
.map(change => change.path)
|
|
154
|
+
.join(':');
|
|
155
|
+
const zip = archiver_1.default('zip', { zlib });
|
|
156
|
+
// Throw stream errors so they reject the promise chain.
|
|
157
|
+
zip.on('error', (e) => {
|
|
158
|
+
throw e;
|
|
159
|
+
});
|
|
160
|
+
const metric = 'apps-patch';
|
|
161
|
+
const request = this.http.patch(this.routes.Link(app), zip, {
|
|
162
|
+
headers: { 'Content-Type': 'application/zip' },
|
|
163
|
+
metric,
|
|
164
|
+
params: { deletedFiles },
|
|
165
|
+
tracing: {
|
|
166
|
+
requestSpanNameSuffix: metric,
|
|
167
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
files.forEach(({ content, path }) => zip.append(content, { name: path }));
|
|
171
|
+
const finalize = zip.finalize();
|
|
172
|
+
const [response] = await Promise.all([request, finalize]);
|
|
173
|
+
return response;
|
|
174
|
+
};
|
|
175
|
+
this.unlink = (app, tracingConfig) => {
|
|
176
|
+
return this.http.delete(this.routes.Unlink(app), {
|
|
177
|
+
tracing: {
|
|
178
|
+
requestSpanNameSuffix: 'apps-unlink',
|
|
179
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
this.unlinkAll = (tracingConfig) => {
|
|
184
|
+
return this.http.delete(this.routes.Links(), {
|
|
185
|
+
tracing: {
|
|
186
|
+
requestSpanNameSuffix: 'apps-unlink-all',
|
|
187
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
this.saveAppSettings = (app, settings, tracingConfig) => {
|
|
192
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
193
|
+
const metric = 'apps-save';
|
|
194
|
+
return this.http.put(this.routes.Settings(app), settings, {
|
|
195
|
+
headers,
|
|
196
|
+
metric,
|
|
197
|
+
tracing: {
|
|
198
|
+
requestSpanNameSuffix: metric,
|
|
199
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
this.listApps = ({ oldVersion, since, service } = {}, tracingConfig) => {
|
|
204
|
+
const params = {
|
|
205
|
+
oldVersion,
|
|
206
|
+
service,
|
|
207
|
+
since,
|
|
208
|
+
};
|
|
209
|
+
const metric = 'apps-list';
|
|
210
|
+
const inflightKey = HttpClient_1.inflightUrlWithQuery;
|
|
211
|
+
return this.http.get(this.routes.Apps(), {
|
|
212
|
+
inflightKey,
|
|
213
|
+
metric,
|
|
214
|
+
params,
|
|
215
|
+
tracing: {
|
|
216
|
+
requestSpanNameSuffix: metric,
|
|
217
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
this.listAppFiles = (app, { prefix, nextMarker } = {}, tracingConfig) => {
|
|
222
|
+
const locator = utils_1.parseAppId(app);
|
|
223
|
+
const linked = !!locator.build;
|
|
224
|
+
const params = {
|
|
225
|
+
marker: nextMarker,
|
|
226
|
+
prefix,
|
|
227
|
+
};
|
|
228
|
+
const metric = linked ? 'apps-list-files' : 'registry-list-files';
|
|
229
|
+
const inflightKey = HttpClient_1.inflightUrlWithQuery;
|
|
230
|
+
return this.http.get(this.routes.Files(locator), {
|
|
231
|
+
inflightKey,
|
|
232
|
+
metric,
|
|
233
|
+
params,
|
|
234
|
+
tracing: {
|
|
235
|
+
requestSpanNameSuffix: metric,
|
|
236
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
this.listLinks = (tracingConfig) => {
|
|
241
|
+
const inflightKey = HttpClient_1.inflightURL;
|
|
242
|
+
const metric = 'apps-list-links';
|
|
243
|
+
return this.http.get(this.routes.Links(), {
|
|
244
|
+
inflightKey,
|
|
245
|
+
metric,
|
|
246
|
+
tracing: {
|
|
247
|
+
requestSpanNameSuffix: metric,
|
|
248
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
};
|
|
252
|
+
this.getAppFile = (app, path, staleIfError, tracingConfig) => {
|
|
253
|
+
const { logger } = this.context;
|
|
254
|
+
const locator = utils_1.parseAppId(app);
|
|
255
|
+
const linked = !!locator.build;
|
|
256
|
+
const inflightKey = HttpClient_1.inflightURL;
|
|
257
|
+
if (staleIfError && this.memoryCache) {
|
|
258
|
+
appsStaleIfError_1.saveVersion(app, this.memoryCache);
|
|
259
|
+
}
|
|
260
|
+
const metric = linked ? 'apps-get-file' : 'registry-get-file';
|
|
261
|
+
try {
|
|
262
|
+
return this.http.getBuffer(this.routes.File(locator, path), {
|
|
263
|
+
cacheable: linked ? HttpClient_1.CacheType.Memory : HttpClient_1.CacheType.Disk,
|
|
264
|
+
inflightKey,
|
|
265
|
+
metric,
|
|
266
|
+
tracing: {
|
|
267
|
+
requestSpanNameSuffix: metric,
|
|
268
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
logger.error({ error, message: 'getAppFile failed', app, path });
|
|
274
|
+
if (staleIfError && this.memoryCache) {
|
|
275
|
+
return appsStaleIfError_1.getFallbackFile(app, path, this.memoryCache, this);
|
|
276
|
+
}
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
this.getAppJSON = (app, path, nullIfNotFound, tracingConfig) => {
|
|
281
|
+
const locator = utils_1.parseAppId(app);
|
|
282
|
+
const linked = !!locator.build;
|
|
283
|
+
const inflightKey = HttpClient_1.inflightURL;
|
|
284
|
+
const metric = linked ? 'apps-get-json' : 'registry-get-json';
|
|
285
|
+
return this.http.get(this.routes.File(locator, path), {
|
|
286
|
+
cacheable: linked ? HttpClient_1.CacheType.Memory : HttpClient_1.CacheType.Any,
|
|
287
|
+
inflightKey,
|
|
288
|
+
metric,
|
|
289
|
+
nullIfNotFound,
|
|
290
|
+
tracing: {
|
|
291
|
+
requestSpanNameSuffix: metric,
|
|
292
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
this.getFileFromApps = (app, path, nullIfNotFound, tracingConfig) => {
|
|
297
|
+
const inflightKey = HttpClient_1.inflightURL;
|
|
298
|
+
const metric = 'get-file-from-apps';
|
|
299
|
+
return this.http.get(this.routes.FileFromApps(app, path), {
|
|
300
|
+
cacheable: HttpClient_1.CacheType.Memory,
|
|
301
|
+
inflightKey,
|
|
302
|
+
metric,
|
|
303
|
+
nullIfNotFound,
|
|
304
|
+
tracing: {
|
|
305
|
+
requestSpanNameSuffix: metric,
|
|
306
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
this.getAppFileStream = (app, path, tracingConfig) => {
|
|
311
|
+
const locator = utils_1.parseAppId(app);
|
|
312
|
+
const metric = locator.build ? 'apps-get-file-s' : 'registry-get-file-s';
|
|
313
|
+
return this.http.getStream(this.routes.File(locator, path), {
|
|
314
|
+
metric,
|
|
315
|
+
tracing: {
|
|
316
|
+
requestSpanNameSuffix: metric,
|
|
317
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
this.getApp = (app, tracingConfig) => {
|
|
322
|
+
const metric = 'apps-get-app';
|
|
323
|
+
const inflightKey = HttpClient_1.inflightURL;
|
|
324
|
+
return this.http.get(this.routes.App(app), {
|
|
325
|
+
inflightKey,
|
|
326
|
+
metric,
|
|
327
|
+
tracing: {
|
|
328
|
+
requestSpanNameSuffix: metric,
|
|
329
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
330
|
+
},
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
this.getAppSettings = (app, tracingConfig) => {
|
|
334
|
+
const inflightKey = HttpClient_1.inflightURL;
|
|
335
|
+
const metric = 'apps-get-settings';
|
|
336
|
+
return this.http.get(this.routes.Settings(app), {
|
|
337
|
+
inflightKey,
|
|
338
|
+
metric,
|
|
339
|
+
tracing: {
|
|
340
|
+
requestSpanNameSuffix: metric,
|
|
341
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
this.getAllAppsSettings = (listAppsOptions = {}, tracingConfig) => {
|
|
346
|
+
return this.listApps(listAppsOptions, tracingConfig).then(({ data: installedApps }) => {
|
|
347
|
+
const names = installedApps.map(getVendorAndName);
|
|
348
|
+
const settingsPromises = names.map(vendorAndName => this.getAppSettings(vendorAndName, tracingConfig).catch(notFound));
|
|
349
|
+
return Promise.all(settingsPromises).then((settings) => {
|
|
350
|
+
return zipObj(names, settings);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
};
|
|
354
|
+
this.getAppBundle = (app, bundlePath, generatePackageJson, tracingConfig) => {
|
|
355
|
+
const locator = utils_1.parseAppId(app);
|
|
356
|
+
const params = generatePackageJson && { _packageJSONEngine: 'npm', _packageJSONFilter: 'vtex.render-builder@x' };
|
|
357
|
+
const metric = locator.build ? 'apps-get-bundle' : 'registry-get-bundle';
|
|
358
|
+
return this.http.getStream(this.routes.AppBundle(locator, bundlePath), {
|
|
359
|
+
headers: {
|
|
360
|
+
Accept: 'application/x-gzip',
|
|
361
|
+
'Accept-Encoding': 'gzip',
|
|
362
|
+
},
|
|
363
|
+
metric,
|
|
364
|
+
params,
|
|
365
|
+
tracing: {
|
|
366
|
+
requestSpanNameSuffix: metric,
|
|
367
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
};
|
|
371
|
+
this.unpackAppBundle = (app, bundlePath, unpackPath, generatePackageJson, tracingConfig) => {
|
|
372
|
+
return this.getAppBundle(app, bundlePath, generatePackageJson, tracingConfig)
|
|
373
|
+
.then(stream => stream
|
|
374
|
+
.pipe(zlib_1.createGunzip())
|
|
375
|
+
.pipe(tar_fs_1.extract(unpackPath)));
|
|
376
|
+
};
|
|
377
|
+
this.getAppsMetaInfos = async (filter, staleWhileRevalidate = true, tracingConfig) => {
|
|
378
|
+
var _a;
|
|
379
|
+
const { account, production, recorder, workspace, logger } = this.context;
|
|
380
|
+
const metric = 'get-apps-meta';
|
|
381
|
+
const inflightKey = HttpClient_1.inflightURL;
|
|
382
|
+
const key = appsStaleIfError_1.getMetaInfoKey(account, workspace);
|
|
383
|
+
const cachedResponse = production && staleWhileRevalidate
|
|
384
|
+
? await ((_a = this.diskCache) === null || _a === void 0 ? void 0 : _a.get(key))
|
|
385
|
+
: undefined;
|
|
386
|
+
if (cachedResponse && recorder) {
|
|
387
|
+
recorder.record(cachedResponse.headers);
|
|
388
|
+
}
|
|
389
|
+
const metaInfoPromise = this.http
|
|
390
|
+
.getRaw(this.routes.Meta(), {
|
|
391
|
+
ignoreRecorder: Boolean(cachedResponse),
|
|
392
|
+
inflightKey,
|
|
393
|
+
metric,
|
|
394
|
+
params: { fields: workspaceFields },
|
|
395
|
+
tracing: {
|
|
396
|
+
requestSpanNameSuffix: metric,
|
|
397
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
398
|
+
},
|
|
399
|
+
})
|
|
400
|
+
.then(response => {
|
|
401
|
+
const { data, headers: responseHeaders } = response;
|
|
402
|
+
if (this.diskCache && production) {
|
|
403
|
+
this.diskCache.set(key, {
|
|
404
|
+
appsMetaInfo: data.apps || [],
|
|
405
|
+
headers: responseHeaders,
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
return response;
|
|
409
|
+
});
|
|
410
|
+
let appsMetaInfo;
|
|
411
|
+
if (cachedResponse) {
|
|
412
|
+
appsMetaInfo = cachedResponse.appsMetaInfo;
|
|
413
|
+
metaInfoPromise.catch(error => {
|
|
414
|
+
logger.warn({ message: 'Unable to update stale cache', error });
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
appsMetaInfo = await metaInfoPromise.then(response => response.data.apps);
|
|
419
|
+
}
|
|
420
|
+
if (filter) {
|
|
421
|
+
return appsMetaInfo.filter(appMeta => { var _a; return (_a = appMeta === null || appMeta === void 0 ? void 0 : appMeta._resolvedDependencies) === null || _a === void 0 ? void 0 : _a.filter; });
|
|
422
|
+
}
|
|
423
|
+
return appsMetaInfo;
|
|
424
|
+
};
|
|
425
|
+
this.getDependencies = (filter = '', tracingConfig) => {
|
|
426
|
+
const params = { filter };
|
|
427
|
+
const metric = 'apps-get-deps';
|
|
428
|
+
const inflightKey = HttpClient_1.inflightUrlWithQuery;
|
|
429
|
+
return this.http.get(this.routes.Dependencies(), {
|
|
430
|
+
inflightKey,
|
|
431
|
+
metric,
|
|
432
|
+
params,
|
|
433
|
+
tracing: {
|
|
434
|
+
requestSpanNameSuffix: metric,
|
|
435
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
436
|
+
},
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
this.updateDependencies = (tracingConfig) => {
|
|
440
|
+
const metric = 'apps-update-deps';
|
|
441
|
+
return this.http.put(this.routes.Dependencies(), null, {
|
|
442
|
+
metric,
|
|
443
|
+
tracing: {
|
|
444
|
+
requestSpanNameSuffix: metric,
|
|
445
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
446
|
+
},
|
|
447
|
+
});
|
|
448
|
+
};
|
|
449
|
+
this.updateDependency = (name, version, registry, tracingConfig) => {
|
|
450
|
+
const metric = 'apps-update-dep';
|
|
451
|
+
return this.http.patch(this.routes.Apps(), [{ name, version, registry }], {
|
|
452
|
+
metric,
|
|
453
|
+
tracing: {
|
|
454
|
+
requestSpanNameSuffix: metric,
|
|
455
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
456
|
+
},
|
|
457
|
+
});
|
|
458
|
+
};
|
|
459
|
+
this.resolveDependencies = (apps, registries, filter = '', tracingConfig) => {
|
|
460
|
+
const params = { apps, registries, filter };
|
|
461
|
+
const metric = 'apps-resolve-deps';
|
|
462
|
+
const inflightKey = HttpClient_1.inflightUrlWithQuery;
|
|
463
|
+
return this.http.get(this.routes.ResolveDependencies(), {
|
|
464
|
+
inflightKey,
|
|
465
|
+
metric,
|
|
466
|
+
params,
|
|
467
|
+
tracing: {
|
|
468
|
+
requestSpanNameSuffix: metric,
|
|
469
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
470
|
+
},
|
|
471
|
+
});
|
|
472
|
+
};
|
|
473
|
+
this.resolveDependenciesWithManifest = (manifest, filter = '', tracingConfig) => {
|
|
474
|
+
const params = { filter };
|
|
475
|
+
const metric = 'apps-resolve-deps-m';
|
|
476
|
+
return this.http.post(this.routes.ResolveDependenciesWithManifest(), manifest, {
|
|
477
|
+
metric,
|
|
478
|
+
params,
|
|
479
|
+
tracing: {
|
|
480
|
+
requestSpanNameSuffix: metric,
|
|
481
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
482
|
+
},
|
|
483
|
+
});
|
|
484
|
+
};
|
|
485
|
+
this.installRuntime = (descriptor, tracingConfig) => {
|
|
486
|
+
const { account, workspace } = this.context;
|
|
487
|
+
const [name, version] = descriptor.split('@');
|
|
488
|
+
return this.http.patch(`http://apps.aws-us-east-1.vtex.io/${account}/${workspace}/apps`, [
|
|
489
|
+
{
|
|
490
|
+
name,
|
|
491
|
+
version,
|
|
492
|
+
},
|
|
493
|
+
], {
|
|
494
|
+
tracing: {
|
|
495
|
+
requestSpanNameSuffix: 'apps-install-runtime',
|
|
496
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
497
|
+
},
|
|
498
|
+
});
|
|
499
|
+
};
|
|
500
|
+
this.diskCache = options && options.diskCache;
|
|
501
|
+
this.memoryCache = options && options.memoryCache;
|
|
502
|
+
this._routes = createRoutes(context);
|
|
503
|
+
}
|
|
504
|
+
get routes() {
|
|
505
|
+
return this._routes;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
exports.Apps = Apps;
|