@vtex/api 6.48.0 → 6.48.1-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gen/manifest.schema +0 -3
- package/lib/{clients/apps → HttpClient}/AppClient.d.ts +3 -3
- package/lib/{clients/apps → HttpClient}/AppClient.js +5 -10
- package/lib/{clients/apps → HttpClient}/AppGraphQLClient.d.ts +3 -3
- package/lib/{clients/apps → HttpClient}/AppGraphQLClient.js +5 -10
- package/lib/{clients/external → HttpClient}/ExternalClient.d.ts +3 -3
- package/lib/{clients/external → HttpClient}/ExternalClient.js +2 -9
- package/lib/HttpClient/GraphQLClient.d.ts +1 -2
- package/lib/HttpClient/GraphQLClient.js +1 -4
- package/lib/HttpClient/HttpClient.d.ts +5 -6
- package/lib/HttpClient/HttpClient.js +21 -63
- package/lib/{clients → HttpClient}/IOClient.d.ts +4 -4
- package/lib/HttpClient/IOClient.js +14 -0
- package/lib/{clients → HttpClient}/IOGraphQLClient.d.ts +4 -4
- package/lib/{clients → HttpClient}/IOGraphQLClient.js +2 -2
- package/lib/{clients/infra → HttpClient}/InfraClient.d.ts +3 -3
- package/lib/{clients/infra → HttpClient}/InfraClient.js +4 -9
- package/lib/{clients/janus → HttpClient}/JanusClient.d.ts +3 -3
- package/lib/{clients/janus → HttpClient}/JanusClient.js +3 -7
- package/lib/HttpClient/factories/index.d.ts +8 -0
- package/lib/HttpClient/factories/index.js +31 -0
- package/lib/HttpClient/index.d.ts +7 -1
- package/lib/HttpClient/index.js +7 -1
- package/lib/HttpClient/middlewares/cache.d.ts +2 -8
- package/lib/HttpClient/middlewares/cache.js +31 -120
- package/lib/HttpClient/middlewares/cancellationToken.d.ts +1 -1
- package/lib/HttpClient/middlewares/cancellationToken.js +1 -2
- package/lib/HttpClient/middlewares/memoization.js +1 -8
- package/lib/HttpClient/middlewares/metrics.js +31 -12
- package/lib/HttpClient/middlewares/recorder.d.ts +1 -1
- package/lib/HttpClient/middlewares/recorder.js +13 -16
- package/lib/HttpClient/middlewares/request.d.ts +10 -0
- package/lib/HttpClient/middlewares/request.js +87 -0
- package/lib/HttpClient/typings.d.ts +9 -43
- package/lib/IODataSource.d.ts +27 -0
- package/lib/IODataSource.js +46 -0
- package/lib/caches/LRUCache.js +1 -5
- package/lib/caches/LRUDiskCache.js +1 -5
- package/lib/clients/Apps.d.ts +84 -0
- package/lib/clients/Apps.js +326 -0
- package/lib/clients/Assets.d.ts +21 -0
- package/lib/clients/{infra/Assets.js → Assets.js} +19 -74
- package/lib/clients/Billing.d.ts +11 -0
- package/lib/clients/{apps/Billing.js → Billing.js} +3 -8
- package/lib/clients/BillingMetrics.d.ts +12 -0
- package/lib/clients/BillingMetrics.js +10 -0
- package/lib/clients/{apps/Builder.d.ts → Builder.d.ts} +11 -12
- package/lib/clients/{apps/Builder.js → Builder.js} +22 -49
- package/lib/clients/Events.d.ts +6 -0
- package/lib/clients/Events.js +19 -0
- package/lib/clients/Housekeeper.d.ts +11 -0
- package/lib/clients/Housekeeper.js +24 -0
- package/lib/clients/ID.d.ts +22 -0
- package/lib/clients/ID.js +48 -0
- package/lib/clients/IOClients.d.ts +24 -28
- package/lib/clients/IOClients.js +28 -35
- package/lib/clients/LicenseManager.d.ts +6 -0
- package/lib/clients/{janus/LicenseManager.js → LicenseManager.js} +8 -23
- package/lib/clients/Logger.d.ts +27 -0
- package/lib/clients/Logger.js +32 -0
- package/lib/clients/Messages.d.ts +18 -0
- package/lib/clients/Messages.js +20 -0
- package/lib/clients/MessagesGraphQL.d.ts +63 -0
- package/lib/clients/MessagesGraphQL.js +50 -0
- package/lib/clients/Metadata.d.ts +25 -0
- package/lib/clients/Metadata.js +53 -0
- package/lib/clients/Registry.d.ts +61 -0
- package/lib/clients/{infra/Registry.js → Registry.js} +33 -93
- package/lib/clients/Router.d.ts +33 -0
- package/lib/clients/Router.js +50 -0
- package/lib/clients/{janus/Segment.d.ts → Segment.d.ts} +11 -7
- package/lib/clients/Segment.js +69 -0
- package/lib/clients/{janus/Session.d.ts → Session.d.ts} +4 -4
- package/lib/clients/{janus/Session.js → Session.js} +13 -24
- package/lib/clients/{apps/Settings.d.ts → Settings.d.ts} +4 -5
- package/lib/clients/{apps/Settings.js → Settings.js} +20 -14
- package/lib/clients/Sphinx.d.ts +12 -0
- package/lib/clients/Sphinx.js +19 -0
- package/lib/clients/{janus/Tenant.d.ts → Tenant.d.ts} +7 -6
- package/lib/clients/Tenant.js +13 -0
- package/lib/clients/VBase.d.ts +57 -0
- package/lib/clients/VBase.js +116 -0
- package/lib/clients/Workspaces.d.ts +17 -0
- package/lib/clients/Workspaces.js +38 -0
- package/lib/clients/index.d.ts +21 -9
- package/lib/clients/index.js +21 -12
- package/lib/constants.d.ts +1 -49
- package/lib/constants.js +1 -54
- package/lib/errors/ResolverError.d.ts +1 -1
- package/lib/errors/ResolverError.js +2 -2
- package/lib/errors/ResolverWarning.d.ts +1 -1
- package/lib/errors/ResolverWarning.js +2 -2
- package/lib/index.d.ts +7 -9
- package/lib/index.js +6 -8
- package/lib/metrics/MetricsAccumulator.d.ts +18 -1
- package/lib/metrics/MetricsAccumulator.js +22 -38
- package/lib/responses.d.ts +44 -3
- package/lib/service/Runtime.d.ts +18 -0
- package/lib/service/Runtime.js +57 -0
- package/lib/service/{worker/runtime/Service.d.ts → Service.d.ts} +5 -5
- package/lib/service/{worker/runtime/Service.js → Service.js} +1 -2
- package/lib/service/events/index.d.ts +3 -0
- package/lib/service/events/index.js +21 -0
- package/lib/service/graphql/index.d.ts +7 -0
- package/lib/service/graphql/index.js +33 -0
- package/lib/service/graphql/middlewares/error.js +107 -0
- package/lib/service/graphql/middlewares/formatters.d.ts +2 -0
- package/lib/service/graphql/middlewares/formatters.js +64 -0
- package/lib/service/graphql/middlewares/query.d.ts +2 -0
- package/lib/service/graphql/middlewares/query.js +32 -0
- package/lib/service/graphql/middlewares/response.js +36 -0
- package/lib/service/graphql/middlewares/run.d.ts +4 -0
- package/lib/service/graphql/middlewares/run.js +55 -0
- package/lib/service/graphql/middlewares/schema.d.ts +2 -0
- package/lib/service/graphql/middlewares/schema.js +8 -0
- package/lib/service/graphql/middlewares/timings.d.ts +2 -0
- package/lib/service/graphql/middlewares/timings.js +10 -0
- package/lib/service/graphql/middlewares/upload.d.ts +7 -0
- package/lib/service/graphql/schema/index.d.ts +3 -0
- package/lib/service/graphql/schema/index.js +66 -0
- package/lib/service/graphql/schema/messagesLoader.d.ts +4 -0
- package/lib/service/graphql/schema/messagesLoader.js +41 -0
- package/lib/service/graphql/schema/messagesLoaderV2.d.ts +5 -0
- package/lib/service/graphql/schema/messagesLoaderV2.js +44 -0
- package/lib/service/{worker/runtime/graphql → graphql}/schema/schemaDirectives/Auth.d.ts +0 -1
- package/lib/service/{worker/runtime/graphql → graphql}/schema/schemaDirectives/Auth.js +10 -16
- package/lib/service/{worker/runtime/graphql → graphql}/schema/schemaDirectives/Sanitize.d.ts +0 -1
- package/lib/service/{worker/runtime/graphql → graphql}/schema/schemaDirectives/Sanitize.js +0 -6
- package/lib/service/{worker/runtime/graphql → graphql}/schema/schemaDirectives/SmartCacheDirective.d.ts +0 -1
- package/lib/service/{worker/runtime/graphql → graphql}/schema/schemaDirectives/SmartCacheDirective.js +3 -8
- package/lib/service/{worker/runtime/graphql/schema/schemaDirectives/TranslateTo.d.ts → graphql/schema/schemaDirectives/Translatable.d.ts} +1 -2
- package/lib/service/graphql/schema/schemaDirectives/Translatable.js +54 -0
- package/lib/service/graphql/schema/schemaDirectives/TranslatableV2.d.ts +13 -0
- package/lib/service/graphql/schema/schemaDirectives/TranslatableV2.js +67 -0
- package/lib/service/graphql/schema/schemaDirectives/index.d.ts +13 -0
- package/lib/service/graphql/schema/schemaDirectives/index.js +17 -0
- package/lib/service/graphql/schema/typeDefs/index.d.ts +16 -0
- package/lib/service/graphql/schema/typeDefs/index.js +21 -0
- package/lib/service/graphql/schema/typeDefs/ioMessage.d.ts +8 -0
- package/lib/service/graphql/schema/typeDefs/ioMessage.js +33 -0
- package/lib/service/{worker/runtime/graphql → graphql}/schema/typeDefs/sanitizedString.js +1 -5
- package/lib/service/graphql/typings.d.ts +21 -0
- package/lib/service/graphql/utils/cacheControl.d.ts +6 -0
- package/lib/service/graphql/utils/cacheControl.js +38 -0
- package/lib/service/graphql/utils/maxAgeEnum.d.ts +6 -0
- package/lib/service/graphql/utils/maxAgeEnum.js +17 -0
- package/lib/service/http/index.d.ts +3 -0
- package/lib/service/http/index.js +18 -0
- package/lib/service/http/middlewares/authTokens.d.ts +3 -0
- package/lib/service/http/middlewares/cancellationToken.d.ts +3 -0
- package/lib/service/{worker/runtime/http → http}/middlewares/cancellationToken.js +1 -2
- package/lib/service/http/middlewares/clients.d.ts +4 -0
- package/lib/service/http/middlewares/error.d.ts +3 -0
- package/lib/service/{worker/runtime/http → http}/middlewares/error.js +10 -19
- package/lib/service/{worker/runtime/http → http}/middlewares/requestStats.d.ts +3 -3
- package/lib/service/http/middlewares/setCookie.d.ts +3 -0
- package/lib/service/http/middlewares/timings.d.ts +3 -0
- package/lib/service/{worker/runtime/http → http}/middlewares/timings.js +8 -21
- package/lib/service/http/middlewares/vary.d.ts +3 -0
- package/lib/service/{worker/runtime/http → http}/middlewares/vary.js +3 -3
- package/lib/service/logger/index.d.ts +28 -2
- package/lib/service/logger/index.js +68 -5
- package/lib/service/method.d.ts +9 -0
- package/lib/service/{worker/runtime/typings.d.ts → typings.d.ts} +36 -70
- package/lib/service/utils/compose.d.ts +4 -0
- package/lib/service/{worker/runtime/utils → utils}/compose.js +2 -2
- package/lib/utils/MineWinsConflictsResolver.d.ts +4 -6
- package/lib/utils/MineWinsConflictsResolver.js +17 -34
- package/lib/utils/MineWinsConflictsResolver.test.d.ts +1 -0
- package/lib/utils/MineWinsConflictsResolver.test.js +134 -0
- package/lib/utils/app.d.ts +1 -3
- package/lib/utils/app.js +1 -3
- package/lib/utils/appsStaleIfError.d.ts +1 -1
- package/lib/utils/appsStaleIfError.js +2 -2
- package/lib/utils/billingOptions.d.ts +3 -36
- package/lib/utils/billingOptions.js +3 -7
- package/lib/utils/binding.d.ts +3 -3
- package/lib/utils/cancel.d.ts +2 -2
- package/lib/utils/cancel.js +1 -2
- package/lib/utils/log.d.ts +3 -1
- package/lib/utils/log.js +2 -2
- package/lib/utils/message.js +1 -4
- package/lib/utils/tenant.d.ts +3 -3
- package/lib/utils/time.d.ts +2 -4
- package/lib/utils/time.js +2 -9
- package/lib/utils/unhandled.d.ts +1 -0
- package/lib/{service/worker/listeners.js → utils/unhandled.js} +15 -9
- package/package.json +2 -2
- package/CHANGELOG.md +0 -1858
- package/lib/HttpClient/agents.d.ts +0 -3
- package/lib/HttpClient/agents.js +0 -24
- package/lib/HttpClient/middlewares/request/HttpAgentSingleton.d.ts +0 -11
- package/lib/HttpClient/middlewares/request/HttpAgentSingleton.js +0 -30
- package/lib/HttpClient/middlewares/request/index.d.ts +0 -18
- package/lib/HttpClient/middlewares/request/index.js +0 -84
- package/lib/HttpClient/middlewares/request/setupAxios/index.d.ts +0 -1
- package/lib/HttpClient/middlewares/request/setupAxios/index.js +0 -20
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.d.ts +0 -2
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +0 -53
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.d.ts +0 -2
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +0 -7
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.d.ts +0 -8
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.js +0 -53
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.d.ts +0 -4
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +0 -29
- package/lib/HttpClient/middlewares/tracing.d.ts +0 -15
- package/lib/HttpClient/middlewares/tracing.js +0 -56
- package/lib/clients/IOClient.js +0 -19
- package/lib/clients/apps/Billing.d.ts +0 -12
- package/lib/clients/apps/MessagesGraphQL.d.ts +0 -61
- package/lib/clients/apps/MessagesGraphQL.js +0 -121
- package/lib/clients/apps/catalogGraphQL/brand.d.ts +0 -13
- package/lib/clients/apps/catalogGraphQL/brand.js +0 -18
- package/lib/clients/apps/catalogGraphQL/category.d.ts +0 -11
- package/lib/clients/apps/catalogGraphQL/category.js +0 -16
- package/lib/clients/apps/catalogGraphQL/index.d.ts +0 -22
- package/lib/clients/apps/catalogGraphQL/index.js +0 -88
- package/lib/clients/apps/catalogGraphQL/product.d.ts +0 -25
- package/lib/clients/apps/catalogGraphQL/product.js +0 -30
- package/lib/clients/apps/catalogGraphQL/sku.d.ts +0 -26
- package/lib/clients/apps/catalogGraphQL/sku.js +0 -30
- package/lib/clients/apps/index.d.ts +0 -7
- package/lib/clients/apps/index.js +0 -12
- package/lib/clients/external/ID.d.ts +0 -23
- package/lib/clients/external/ID.js +0 -60
- package/lib/clients/external/Masterdata.d.ts +0 -94
- package/lib/clients/external/Masterdata.js +0 -224
- package/lib/clients/external/PaymentProvider.d.ts +0 -31
- package/lib/clients/external/PaymentProvider.js +0 -42
- package/lib/clients/external/index.d.ts +0 -4
- package/lib/clients/external/index.js +0 -9
- package/lib/clients/infra/Apps.d.ts +0 -88
- package/lib/clients/infra/Apps.js +0 -508
- package/lib/clients/infra/Assets.d.ts +0 -34
- package/lib/clients/infra/BillingMetrics.d.ts +0 -13
- package/lib/clients/infra/BillingMetrics.js +0 -15
- package/lib/clients/infra/Events.d.ts +0 -12
- package/lib/clients/infra/Events.js +0 -33
- package/lib/clients/infra/Housekeeper.d.ts +0 -10
- package/lib/clients/infra/Housekeeper.js +0 -30
- package/lib/clients/infra/Registry.d.ts +0 -59
- package/lib/clients/infra/Router.d.ts +0 -34
- package/lib/clients/infra/Router.js +0 -81
- package/lib/clients/infra/Sphinx.d.ts +0 -13
- package/lib/clients/infra/Sphinx.js +0 -29
- package/lib/clients/infra/VBase.d.ts +0 -60
- package/lib/clients/infra/VBase.js +0 -196
- package/lib/clients/infra/Workspaces.d.ts +0 -18
- package/lib/clients/infra/Workspaces.js +0 -65
- package/lib/clients/infra/index.d.ts +0 -11
- package/lib/clients/infra/index.js +0 -16
- package/lib/clients/janus/LicenseManager.d.ts +0 -7
- package/lib/clients/janus/Segment.js +0 -88
- package/lib/clients/janus/Tenant.js +0 -28
- package/lib/clients/janus/index.d.ts +0 -5
- package/lib/clients/janus/index.js +0 -10
- package/lib/service/index.d.ts +0 -2
- package/lib/service/index.js +0 -30
- package/lib/service/loaders.d.ts +0 -8
- package/lib/service/loaders.js +0 -54
- package/lib/service/logger/console.d.ts +0 -10
- package/lib/service/logger/console.js +0 -36
- package/lib/service/logger/logger.d.ts +0 -29
- package/lib/service/logger/logger.js +0 -61
- package/lib/service/logger/metricsLogger.d.ts +0 -40
- package/lib/service/logger/metricsLogger.js +0 -149
- package/lib/service/master.d.ts +0 -2
- package/lib/service/master.js +0 -87
- package/lib/service/metrics/requestMetricsMiddleware.d.ts +0 -2
- package/lib/service/metrics/requestMetricsMiddleware.js +0 -44
- package/lib/service/tracing/TracerSingleton.d.ts +0 -7
- package/lib/service/tracing/TracerSingleton.js +0 -48
- package/lib/service/tracing/metrics/MetricNames.d.ts +0 -60
- package/lib/service/tracing/metrics/MetricNames.js +0 -44
- package/lib/service/tracing/metrics/instruments.d.ts +0 -9
- package/lib/service/tracing/metrics/instruments.js +0 -11
- package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.d.ts +0 -9
- package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +0 -25
- package/lib/service/tracing/tracingMiddlewares.d.ts +0 -5
- package/lib/service/tracing/tracingMiddlewares.js +0 -107
- package/lib/service/worker/index.d.ts +0 -11
- package/lib/service/worker/index.js +0 -195
- package/lib/service/worker/listeners.d.ts +0 -3
- package/lib/service/worker/runtime/builtIn/handlers.d.ts +0 -4
- package/lib/service/worker/runtime/builtIn/handlers.js +0 -30
- package/lib/service/worker/runtime/builtIn/middlewares.d.ts +0 -4
- package/lib/service/worker/runtime/builtIn/middlewares.js +0 -40
- package/lib/service/worker/runtime/events/index.d.ts +0 -4
- package/lib/service/worker/runtime/events/index.js +0 -46
- package/lib/service/worker/runtime/events/middlewares/body.d.ts +0 -3
- package/lib/service/worker/runtime/events/middlewares/body.js +0 -22
- package/lib/service/worker/runtime/events/middlewares/context.d.ts +0 -3
- package/lib/service/worker/runtime/events/middlewares/context.js +0 -22
- package/lib/service/worker/runtime/events/router.d.ts +0 -2
- package/lib/service/worker/runtime/events/router.js +0 -27
- package/lib/service/worker/runtime/graphql/index.d.ts +0 -6
- package/lib/service/worker/runtime/graphql/index.js +0 -27
- package/lib/service/worker/runtime/graphql/middlewares/context.d.ts +0 -2
- package/lib/service/worker/runtime/graphql/middlewares/context.js +0 -16
- package/lib/service/worker/runtime/graphql/middlewares/error.js +0 -93
- package/lib/service/worker/runtime/graphql/middlewares/query.d.ts +0 -2
- package/lib/service/worker/runtime/graphql/middlewares/query.js +0 -52
- package/lib/service/worker/runtime/graphql/middlewares/response.js +0 -38
- package/lib/service/worker/runtime/graphql/middlewares/run.d.ts +0 -2
- package/lib/service/worker/runtime/graphql/middlewares/run.js +0 -19
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.d.ts +0 -4
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +0 -28
- package/lib/service/worker/runtime/graphql/middlewares/upload.d.ts +0 -4
- package/lib/service/worker/runtime/graphql/schema/index.d.ts +0 -7
- package/lib/service/worker/runtime/graphql/schema/index.js +0 -31
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +0 -6
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +0 -79
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.d.ts +0 -7
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.js +0 -37
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.d.ts +0 -11
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +0 -61
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.d.ts +0 -7
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.js +0 -40
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.d.ts +0 -6
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +0 -34
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.d.ts +0 -7
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +0 -39
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +0 -33
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.d.ts +0 -22
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +0 -36
- package/lib/service/worker/runtime/graphql/schema/typeDefs/index.d.ts +0 -7
- package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +0 -12
- package/lib/service/worker/runtime/graphql/typings.d.ts +0 -31
- package/lib/service/worker/runtime/graphql/utils/cacheControl.d.ts +0 -1
- package/lib/service/worker/runtime/graphql/utils/cacheControl.js +0 -32
- package/lib/service/worker/runtime/graphql/utils/error.d.ts +0 -1
- package/lib/service/worker/runtime/graphql/utils/error.js +0 -76
- package/lib/service/worker/runtime/graphql/utils/translations.d.ts +0 -14
- package/lib/service/worker/runtime/graphql/utils/translations.js +0 -38
- package/lib/service/worker/runtime/http/index.d.ts +0 -5
- package/lib/service/worker/runtime/http/index.js +0 -58
- package/lib/service/worker/runtime/http/middlewares/authTokens.d.ts +0 -3
- package/lib/service/worker/runtime/http/middlewares/cancellationToken.d.ts +0 -3
- package/lib/service/worker/runtime/http/middlewares/clients.d.ts +0 -4
- package/lib/service/worker/runtime/http/middlewares/context.d.ts +0 -4
- package/lib/service/worker/runtime/http/middlewares/context.js +0 -36
- package/lib/service/worker/runtime/http/middlewares/error.d.ts +0 -2
- package/lib/service/worker/runtime/http/middlewares/rateLimit.d.ts +0 -6
- package/lib/service/worker/runtime/http/middlewares/rateLimit.js +0 -42
- package/lib/service/worker/runtime/http/middlewares/setCookie.d.ts +0 -3
- package/lib/service/worker/runtime/http/middlewares/settings.d.ts +0 -9
- package/lib/service/worker/runtime/http/middlewares/settings.js +0 -44
- package/lib/service/worker/runtime/http/middlewares/timings.d.ts +0 -3
- package/lib/service/worker/runtime/http/middlewares/vary.d.ts +0 -3
- package/lib/service/worker/runtime/http/router.d.ts +0 -2
- package/lib/service/worker/runtime/http/router.js +0 -23
- package/lib/service/worker/runtime/http/routes.d.ts +0 -19
- package/lib/service/worker/runtime/http/routes.js +0 -12
- package/lib/service/worker/runtime/method.d.ts +0 -9
- package/lib/service/worker/runtime/statusTrack.d.ts +0 -14
- package/lib/service/worker/runtime/statusTrack.js +0 -37
- package/lib/service/worker/runtime/utils/compose.d.ts +0 -5
- package/lib/service/worker/runtime/utils/context.d.ts +0 -2
- package/lib/service/worker/runtime/utils/context.js +0 -40
- package/lib/service/worker/runtime/utils/diff.d.ts +0 -12
- package/lib/service/worker/runtime/utils/diff.js +0 -21
- package/lib/service/worker/runtime/utils/recorder.d.ts +0 -8
- package/lib/service/worker/runtime/utils/recorder.js +0 -37
- package/lib/service/worker/runtime/utils/tokenBucket.d.ts +0 -2
- package/lib/service/worker/runtime/utils/tokenBucket.js +0 -16
- package/lib/tracing/LogEvents.d.ts +0 -31
- package/lib/tracing/LogEvents.js +0 -3
- package/lib/tracing/LogFields.d.ts +0 -66
- package/lib/tracing/LogFields.js +0 -3
- package/lib/tracing/Tags.d.ts +0 -81
- package/lib/tracing/Tags.js +0 -7
- package/lib/tracing/UserLandTracer.d.ts +0 -27
- package/lib/tracing/UserLandTracer.js +0 -56
- package/lib/tracing/errorReporting/ErrorReport.d.ts +0 -31
- package/lib/tracing/errorReporting/ErrorReport.js +0 -70
- package/lib/tracing/index.d.ts +0 -9
- package/lib/tracing/index.js +0 -19
- package/lib/tracing/spanReference/SpanReferenceTypes.d.ts +0 -4
- package/lib/tracing/spanReference/SpanReferenceTypes.js +0 -7
- package/lib/tracing/spanReference/createSpanReference.d.ts +0 -3
- package/lib/tracing/spanReference/createSpanReference.js +0 -8
- package/lib/tracing/utils.d.ts +0 -13
- package/lib/tracing/utils.js +0 -40
- package/lib/utils/conflicts.mock.d.ts +0 -17
- package/lib/utils/conflicts.mock.js +0 -27
- /package/lib/service/{worker/runtime/graphql → graphql}/middlewares/error.d.ts +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/middlewares/response.d.ts +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/middlewares/upload.js +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/schema/typeDefs/ioUpload.d.ts +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/schema/typeDefs/ioUpload.js +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/schema/typeDefs/sanitizedString.d.ts +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/typings.js +0 -0
- /package/lib/service/{worker/runtime/utils/toArray.d.ts → graphql/utils/array.d.ts} +0 -0
- /package/lib/service/{worker/runtime/utils/toArray.js → graphql/utils/array.js} +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/utils/pathname.d.ts +0 -0
- /package/lib/service/{worker/runtime/graphql → graphql}/utils/pathname.js +0 -0
- /package/lib/service/{worker/runtime/http → http}/middlewares/authTokens.js +0 -0
- /package/lib/service/{worker/runtime/http → http}/middlewares/clients.js +0 -0
- /package/lib/service/{worker/runtime/http → http}/middlewares/requestStats.js +0 -0
- /package/lib/service/{worker/runtime/http → http}/middlewares/setCookie.js +0 -0
- /package/lib/service/{worker/runtime/method.js → method.js} +0 -0
- /package/lib/service/{worker/runtime/typings.js → typings.js} +0 -0
|
@@ -1,7 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function __export(m) {
|
|
3
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
-
}
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const error_1 = require("../../utils/error");
|
|
4
|
+
const log_1 = require("../../utils/log");
|
|
5
|
+
const linked = !!process.env.VTEX_APP_LINK;
|
|
6
|
+
const app = process.env.VTEX_APP_ID;
|
|
7
|
+
const EMPTY_MESSAGE = 'Logger.log was called with null or undefined message';
|
|
8
|
+
const appName = process.env.VTEX_APP_NAME;
|
|
9
|
+
const vendor = process.env.VTEX_APP_VENDOR;
|
|
10
|
+
var LogLevel;
|
|
11
|
+
(function (LogLevel) {
|
|
12
|
+
LogLevel["Debug"] = "debug";
|
|
13
|
+
LogLevel["Info"] = "info";
|
|
14
|
+
LogLevel["Warn"] = "warn";
|
|
15
|
+
LogLevel["Error"] = "error";
|
|
16
|
+
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
|
|
17
|
+
class Logger {
|
|
18
|
+
constructor(ctx) {
|
|
19
|
+
this.executed = false;
|
|
20
|
+
this.debug = (message) => this.log(message, LogLevel.Debug);
|
|
21
|
+
this.info = (message) => this.log(message, LogLevel.Info);
|
|
22
|
+
this.warn = (warning) => this.log(warning, LogLevel.Warn);
|
|
23
|
+
this.error = (error) => this.log(error, LogLevel.Error);
|
|
24
|
+
this.log = (message, level) => {
|
|
25
|
+
const data = message ? error_1.cleanError(message) : EMPTY_MESSAGE;
|
|
26
|
+
log_1.cleanLog(data);
|
|
27
|
+
/* tslint:disable:object-literal-sort-keys */
|
|
28
|
+
const inflatedLog = {
|
|
29
|
+
__VTEX_IO_LOG: true,
|
|
30
|
+
level,
|
|
31
|
+
app,
|
|
32
|
+
account: this.account,
|
|
33
|
+
workspace: this.workspace,
|
|
34
|
+
production: this.production,
|
|
35
|
+
data,
|
|
36
|
+
operationId: this.operationId,
|
|
37
|
+
requestId: this.requestId,
|
|
38
|
+
};
|
|
39
|
+
if (this.isThirdPartyApp()) {
|
|
40
|
+
Object.assign(inflatedLog, {
|
|
41
|
+
__SKIDDER_TOPIC_1: `skidder.vendor.${vendor}`,
|
|
42
|
+
__SKIDDER_TOPIC_2: `skidder.app.${vendor}.${appName}`,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
console.log(JSON.stringify(inflatedLog));
|
|
46
|
+
// Warn the developer how to retrieve the error in splunk
|
|
47
|
+
this.logSplunkQuery();
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Logs splunk query so the developer can search for the errors in splunk.
|
|
51
|
+
* This function runs only once in the lifetime of the Logger class so we
|
|
52
|
+
* don't mess up with the developer's terminal
|
|
53
|
+
*/
|
|
54
|
+
this.logSplunkQuery = () => {
|
|
55
|
+
if (!this.executed && linked) {
|
|
56
|
+
console.log(`Try this query at Splunk to retrieve error log: 'index=io_vtex_logs app="${app}" account=${this.account} workspace=${this.workspace} level=error OR level=warn'`);
|
|
57
|
+
this.executed = true;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
this.account = ctx.account;
|
|
61
|
+
this.workspace = ctx.workspace;
|
|
62
|
+
this.requestId = ctx.requestId;
|
|
63
|
+
this.operationId = ctx.operationId;
|
|
64
|
+
this.production = ctx.production;
|
|
65
|
+
}
|
|
66
|
+
isThirdPartyApp() {
|
|
67
|
+
return 'vtex' !== vendor && 'gocommerce' !== vendor;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.Logger = Logger;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IOClients } from '../clients/IOClients';
|
|
2
|
+
import { RouteHandler, ServiceContext } from './typings';
|
|
3
|
+
declare type HTTPMethods = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH' | 'DEFAULT';
|
|
4
|
+
declare type MethodOptions<ClientsT extends IOClients = IOClients, StateT = void, CustomT = void> = Partial<Record<HTTPMethods, RouteHandler<ClientsT, StateT, CustomT> | Array<RouteHandler<ClientsT, StateT, CustomT>>>>;
|
|
5
|
+
export declare function method<ClientsT extends IOClients = IOClients, StateT = void, CustomT = void>(options: MethodOptions<ClientsT, StateT, CustomT>): {
|
|
6
|
+
(ctx: ServiceContext<ClientsT, StateT, CustomT>, next: () => Promise<any>): Promise<void>;
|
|
7
|
+
skipTimer: boolean;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -1,37 +1,29 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import { DataSource } from 'apollo-datasource';
|
|
2
3
|
import { CancelTokenSource } from 'axios';
|
|
3
4
|
import DataLoader from 'dataloader';
|
|
4
5
|
import { GraphQLFieldConfig, GraphQLFieldResolver, GraphQLScalarType } from 'graphql';
|
|
5
6
|
import { SchemaDirectiveVisitor } from 'graphql-tools';
|
|
6
7
|
import { ParameterizedContext } from 'koa';
|
|
7
8
|
import { Middleware } from 'koa-compose';
|
|
8
|
-
import { Span, Tracer } from 'opentracing';
|
|
9
9
|
import { ParsedUrlQuery } from 'querystring';
|
|
10
|
-
import { ClientsImplementation, IOClients } from '
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { MessagesLoaderV2 } from './graphql/schema/messagesLoaderV2';
|
|
19
|
-
import { Recorder } from './utils/recorder';
|
|
10
|
+
import { ClientsImplementation, IOClients } from '../clients/IOClients';
|
|
11
|
+
import { IOMessageV2 } from '../clients/MessagesGraphQL';
|
|
12
|
+
import { InstanceOptions } from '../HttpClient';
|
|
13
|
+
import { Recorder } from '../HttpClient/middlewares/recorder';
|
|
14
|
+
import { Binding } from '../utils/binding';
|
|
15
|
+
import { IOMessage } from '../utils/message';
|
|
16
|
+
import { Tenant } from '../utils/tenant';
|
|
17
|
+
import { Logger } from './logger';
|
|
20
18
|
declare type ServerTiming = Record<string, string>;
|
|
21
|
-
export declare type Maybe<T> = T | null | undefined;
|
|
22
|
-
export interface TracingContext {
|
|
23
|
-
tracer: Tracer;
|
|
24
|
-
currentSpan: Span | undefined;
|
|
25
|
-
}
|
|
26
19
|
export interface Context<T extends IOClients> {
|
|
27
20
|
clients: T;
|
|
28
21
|
vtex: IOContext;
|
|
22
|
+
dataSources?: DataSources;
|
|
29
23
|
timings: Record<string, [number, number]>;
|
|
30
24
|
metrics: Record<string, [number, number]>;
|
|
31
25
|
previousTimerStart: [number, number];
|
|
32
|
-
requestHandlerName?: string;
|
|
33
26
|
serverTiming?: ServerTiming;
|
|
34
|
-
tracing?: TracingContext;
|
|
35
27
|
}
|
|
36
28
|
export interface EventContext<T extends IOClients, StateT = any> {
|
|
37
29
|
clients: T;
|
|
@@ -51,43 +43,35 @@ declare type KnownKeys<T> = {
|
|
|
51
43
|
} ? U : never;
|
|
52
44
|
interface Loaders {
|
|
53
45
|
messages?: DataLoader<IOMessage, string>;
|
|
54
|
-
messagesV2?:
|
|
55
|
-
immutableMessagesV2?: MessagesLoaderV2;
|
|
46
|
+
messagesV2?: DataLoader<IOMessageV2, string>;
|
|
56
47
|
}
|
|
57
|
-
export declare type ServiceContext<ClientsT extends IOClients = IOClients, StateT
|
|
58
|
-
loaders
|
|
48
|
+
export declare type ServiceContext<ClientsT extends IOClients = IOClients, StateT = void, CustomT = void> = Pick<ParameterizedContext<StateT, Context<ClientsT>>, KnownKeys<ParameterizedContext<StateT, Context<ClientsT>>>> & CustomT & {
|
|
49
|
+
loaders: Loaders;
|
|
59
50
|
};
|
|
60
|
-
export declare type RouteHandler<ClientsT extends IOClients = IOClients, StateT
|
|
51
|
+
export declare type RouteHandler<ClientsT extends IOClients = IOClients, StateT = void, CustomT = void> = Middleware<ServiceContext<ClientsT, StateT, CustomT>>;
|
|
61
52
|
export declare type EventHandler<ClientsT extends IOClients = IOClients, StateT = void> = Middleware<EventContext<ClientsT, StateT>>;
|
|
62
|
-
export declare type Resolver<ClientsT extends IOClients = IOClients, StateT
|
|
63
|
-
export declare type Handler = RouteHandler<IOClients, RecorderState, ParamsContext>;
|
|
64
|
-
export interface HttpRoute {
|
|
65
|
-
handler: RouteHandler;
|
|
66
|
-
path: string;
|
|
67
|
-
}
|
|
68
|
-
export interface RecorderState {
|
|
69
|
-
recorder: Recorder;
|
|
70
|
-
body: any;
|
|
71
|
-
}
|
|
72
|
-
export interface ParamsContext {
|
|
73
|
-
params: any;
|
|
74
|
-
metricsLogger: MetricsLogger;
|
|
75
|
-
}
|
|
53
|
+
export declare type Resolver<ClientsT extends IOClients = IOClients, StateT = void, CustomT = void> = GraphQLFieldResolver<any, ServiceContext<ClientsT, StateT, CustomT>, any> | GraphQLFieldConfig<any, ServiceContext<ClientsT, StateT, CustomT>, any>;
|
|
76
54
|
export interface ClientsConfig<ClientsT extends IOClients = IOClients> {
|
|
77
55
|
implementation?: ClientsImplementation<ClientsT>;
|
|
78
56
|
options: Record<string, InstanceOptions>;
|
|
79
57
|
}
|
|
80
|
-
export
|
|
58
|
+
export declare type DataSourcesGenerator = () => {
|
|
59
|
+
[name: string]: DataSource<ServiceContext>;
|
|
60
|
+
};
|
|
61
|
+
export interface GraphQLOptions<ClientsT extends IOClients = IOClients, StateT = void, CustomT = void> {
|
|
81
62
|
resolvers: Record<string, Record<string, Resolver<ClientsT, StateT, CustomT>> | GraphQLScalarType>;
|
|
82
|
-
|
|
63
|
+
dataSources?: DataSourcesGenerator;
|
|
83
64
|
schemaDirectives?: Record<string, typeof SchemaDirectiveVisitor>;
|
|
84
65
|
}
|
|
85
|
-
export interface ServiceConfig<ClientsT extends IOClients = IOClients, StateT
|
|
66
|
+
export interface ServiceConfig<ClientsT extends IOClients = IOClients, StateT = void, CustomT = void> {
|
|
86
67
|
clients?: ClientsConfig<ClientsT>;
|
|
87
|
-
events?:
|
|
68
|
+
events?: any;
|
|
88
69
|
graphql?: GraphQLOptions<ClientsT, StateT, CustomT>;
|
|
89
70
|
routes?: Record<string, RouteHandler<ClientsT, StateT, CustomT> | Array<RouteHandler<ClientsT, StateT, CustomT>>>;
|
|
90
71
|
}
|
|
72
|
+
export interface DataSources {
|
|
73
|
+
[name: string]: DataSource<ServiceContext>;
|
|
74
|
+
}
|
|
91
75
|
export interface Cancellation {
|
|
92
76
|
cancelable: boolean;
|
|
93
77
|
cancelled: boolean;
|
|
@@ -108,7 +92,6 @@ export interface IOContext {
|
|
|
108
92
|
declarer?: string;
|
|
109
93
|
id: string;
|
|
110
94
|
params: ParsedUrlQuery;
|
|
111
|
-
type: 'public' | 'private' | 'event';
|
|
112
95
|
};
|
|
113
96
|
userAgent: string;
|
|
114
97
|
workspace: string;
|
|
@@ -121,53 +104,36 @@ export interface IOContext {
|
|
|
121
104
|
logger: Logger;
|
|
122
105
|
eventInfo?: EventBody;
|
|
123
106
|
host?: string;
|
|
124
|
-
tenant?:
|
|
125
|
-
binding?:
|
|
107
|
+
tenant?: Tenant;
|
|
108
|
+
binding?: Binding;
|
|
126
109
|
cancellation?: Cancellation;
|
|
127
|
-
settings?: any;
|
|
128
|
-
tracer: IUserLandTracer;
|
|
129
110
|
}
|
|
130
111
|
export interface EventBody {
|
|
131
112
|
sender: string;
|
|
132
113
|
subject: string;
|
|
133
114
|
key: string;
|
|
134
115
|
}
|
|
135
|
-
export declare type RouteSettingsType = 'pure' | 'workspace' | 'userAndWorkspace';
|
|
136
116
|
export interface ServiceRoute {
|
|
137
117
|
path: string;
|
|
118
|
+
method?: string[];
|
|
138
119
|
public?: boolean;
|
|
139
120
|
smartcache?: boolean;
|
|
140
|
-
extensible?: boolean;
|
|
141
|
-
settingsType?: RouteSettingsType;
|
|
142
|
-
rateLimitPerReplica?: RateLimitOptions;
|
|
143
|
-
}
|
|
144
|
-
export interface ServiceEvent {
|
|
145
|
-
keys?: string[];
|
|
146
|
-
sender?: string;
|
|
147
|
-
subject?: string;
|
|
148
|
-
settingsType?: RouteSettingsType;
|
|
149
|
-
rateLimitPerReplica?: RateLimitOptions;
|
|
150
121
|
}
|
|
151
|
-
export interface
|
|
152
|
-
perMinute?: number;
|
|
153
|
-
concurrent?: number;
|
|
154
|
-
}
|
|
155
|
-
export interface RawServiceJSON {
|
|
122
|
+
export interface ServiceDescriptor {
|
|
156
123
|
stack: 'nodejs';
|
|
157
124
|
memory: number;
|
|
158
125
|
ttl?: number;
|
|
159
126
|
timeout?: number;
|
|
160
127
|
runtimeArgs?: string[];
|
|
161
128
|
routes?: Record<string, ServiceRoute>;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
129
|
+
events: {
|
|
130
|
+
[handler: string]: {
|
|
131
|
+
keys?: string[];
|
|
132
|
+
sender?: string;
|
|
133
|
+
subject?: string;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
167
136
|
deterministicVary?: boolean;
|
|
168
137
|
}
|
|
169
|
-
export interface ServiceJSON extends RawServiceJSON {
|
|
170
|
-
workers: number;
|
|
171
|
-
}
|
|
172
138
|
export declare type JanusEnv = string;
|
|
173
139
|
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import koaCompose from 'koa-compose';
|
|
2
|
+
import { IOClients } from '../../clients/IOClients';
|
|
3
|
+
export declare const compose: <ClientsT extends IOClients, StateT, CustomT>(middlewares: koaCompose.Middleware<import("../typings").ServiceContext<ClientsT, StateT, CustomT>>[]) => koaCompose.ComposedMiddleware<import("../typings").ServiceContext<ClientsT, StateT, CustomT>>;
|
|
4
|
+
export declare const composeForEvents: <ClientsT extends IOClients, StateT>(middlewares: any[]) => koaCompose.ComposedMiddleware<import("../typings").EventContext<IOClients, {}>>;
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const koa_compose_1 = __importDefault(require("koa-compose"));
|
|
7
7
|
const ramda_1 = require("ramda");
|
|
8
|
-
const cancel_1 = require("
|
|
9
|
-
const time_1 = require("
|
|
8
|
+
const cancel_1 = require("../../utils/cancel");
|
|
9
|
+
const time_1 = require("../../utils/time");
|
|
10
10
|
exports.compose = (middlewares) => koa_compose_1.default(middlewares.map(ramda_1.pipe(time_1.timer, cancel_1.cancel)));
|
|
11
11
|
exports.composeForEvents = (middlewares) => koa_compose_1.default(middlewares.map(time_1.timerForEvents));
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConflictsResolver, VBase } from '../clients/infra/VBase';
|
|
1
|
+
import { ConflictsResolver, VBase } from '../clients/VBase';
|
|
3
2
|
declare type Configuration = Record<string, ConfigurationData | ConfigurationData[] | object> | ConfigurationData[];
|
|
4
3
|
declare type ConfigurationData = Record<string, object>;
|
|
5
|
-
export declare class MineWinsConflictsResolver
|
|
4
|
+
export declare class MineWinsConflictsResolver implements ConflictsResolver {
|
|
6
5
|
/***
|
|
7
6
|
* Take mine and merge with master keys that have no conflict
|
|
8
7
|
* We use base to decide wether a key was deleted or not
|
|
@@ -12,9 +11,8 @@ export declare class MineWinsConflictsResolver<T> implements ConflictsResolver<T
|
|
|
12
11
|
private filePath;
|
|
13
12
|
private comparableKeys;
|
|
14
13
|
constructor(client: VBase, bucket: string, filePath: string, comparableKeys?: string[]);
|
|
15
|
-
resolve(
|
|
16
|
-
|
|
17
|
-
protected mergeMineWins(base: Configuration, master: Configuration, mine: Configuration): Record<string, object | Record<string, object> | Record<string, object>[]> | Record<string, object>[];
|
|
14
|
+
resolve(): Promise<any>;
|
|
15
|
+
protected mergeMineWins(base: Configuration, master: Configuration, mine: Configuration): Configuration;
|
|
18
16
|
private parseConflict;
|
|
19
17
|
private serializeContentByMimetype;
|
|
20
18
|
private parseContentByMimetype;
|
|
@@ -10,15 +10,12 @@ class MineWinsConflictsResolver {
|
|
|
10
10
|
this.filePath = filePath;
|
|
11
11
|
this.comparableKeys = comparableKeys;
|
|
12
12
|
}
|
|
13
|
-
async resolve(
|
|
14
|
-
return await this.client.getConflicts(this.bucket).then(
|
|
13
|
+
async resolve() {
|
|
14
|
+
return await this.client.getConflicts(this.bucket).then(data => {
|
|
15
15
|
const { data: conflicts } = data;
|
|
16
|
-
const selectedConflict = conflicts.find(
|
|
16
|
+
const selectedConflict = conflicts.find(conflict => conflict.path === this.filePath);
|
|
17
17
|
if (!selectedConflict) {
|
|
18
|
-
|
|
19
|
-
message: 'No conflict could be found.',
|
|
20
|
-
status: 404,
|
|
21
|
-
};
|
|
18
|
+
return {};
|
|
22
19
|
}
|
|
23
20
|
selectedConflict.base.parsedContent = this.parseConflict(selectedConflict.base);
|
|
24
21
|
selectedConflict.master.parsedContent = this.parseConflict(selectedConflict.master);
|
|
@@ -27,17 +24,6 @@ class MineWinsConflictsResolver {
|
|
|
27
24
|
return resolved;
|
|
28
25
|
});
|
|
29
26
|
}
|
|
30
|
-
async resolveAll() {
|
|
31
|
-
const conflictsResponse = await this.client.getConflicts(this.bucket);
|
|
32
|
-
const { data: conflicts } = conflictsResponse;
|
|
33
|
-
const resolvedConflicts = conflicts.map((conflict) => {
|
|
34
|
-
conflict.base.parsedContent = this.parseConflict(conflict.base);
|
|
35
|
-
conflict.master.parsedContent = this.parseConflict(conflict.master);
|
|
36
|
-
conflict.mine.parsedContent = this.parseConflict(conflict.mine);
|
|
37
|
-
return this.resolveConflictMineWins(conflict);
|
|
38
|
-
});
|
|
39
|
-
return resolvedConflicts;
|
|
40
|
-
}
|
|
41
27
|
mergeMineWins(base, master, mine) {
|
|
42
28
|
if (util_1.isArray(master)) {
|
|
43
29
|
return this.mergeMineWinsArray((base || []), master, (mine || []));
|
|
@@ -67,22 +53,19 @@ class MineWinsConflictsResolver {
|
|
|
67
53
|
}
|
|
68
54
|
resolveConflictMineWins(conflict) {
|
|
69
55
|
if (!conflict) {
|
|
70
|
-
|
|
71
|
-
message: 'No conflict could be found.',
|
|
72
|
-
status: 404,
|
|
73
|
-
};
|
|
56
|
+
return {};
|
|
74
57
|
}
|
|
75
58
|
const { base, master, mine, path } = conflict;
|
|
76
|
-
|
|
59
|
+
this.mergeMineWins(base.parsedContent, master.parsedContent, mine.parsedContent);
|
|
77
60
|
const mergedContent = {
|
|
78
|
-
content: js_base64_1.Base64.encode(this.serializeContentByMimetype(
|
|
61
|
+
content: js_base64_1.Base64.encode(this.serializeContentByMimetype(mine.parsedContent, conflict.mine.mimeType)),
|
|
79
62
|
mimeType: conflict.mine.mimeType,
|
|
80
63
|
};
|
|
81
64
|
this.client.resolveConflict(this.bucket, path, mergedContent);
|
|
82
|
-
return
|
|
65
|
+
return mine.parsedContent;
|
|
83
66
|
}
|
|
84
67
|
mergeMineWinsObject(base, master, mine) {
|
|
85
|
-
const merged = {
|
|
68
|
+
const merged = Object.assign({}, master, mine);
|
|
86
69
|
Object.entries(merged).forEach(([key, value]) => {
|
|
87
70
|
if (master[key] == null && base && base[key] != null && ramda_1.equals(value, base[key])) {
|
|
88
71
|
delete merged[key]; // value deleted from master with no conflict
|
|
@@ -105,10 +88,10 @@ class MineWinsConflictsResolver {
|
|
|
105
88
|
return mine;
|
|
106
89
|
}
|
|
107
90
|
removeMasterDeletedElements(base, master, mine) {
|
|
108
|
-
base.forEach(
|
|
91
|
+
base.forEach(baseItem => {
|
|
109
92
|
const foundInMaster = this.isObjectInArray(baseItem, master);
|
|
110
93
|
if (!foundInMaster) {
|
|
111
|
-
const foundInMine = mine.findIndex(
|
|
94
|
+
const foundInMine = mine.findIndex(mineItem => ramda_1.equals(mineItem, baseItem));
|
|
112
95
|
if (foundInMine > -1) {
|
|
113
96
|
mine.splice(foundInMine, 1);
|
|
114
97
|
}
|
|
@@ -116,21 +99,21 @@ class MineWinsConflictsResolver {
|
|
|
116
99
|
});
|
|
117
100
|
}
|
|
118
101
|
isObjectInArray(obj, array) {
|
|
119
|
-
return array.find(
|
|
102
|
+
return array.find(item => ramda_1.equals(item, obj));
|
|
120
103
|
}
|
|
121
104
|
appendMasterAddedElements(base, master, mine) {
|
|
122
|
-
master.forEach(
|
|
105
|
+
master.forEach(item => {
|
|
123
106
|
if (this.shouldAddToMine(item, base, mine)) {
|
|
124
107
|
mine.push(item);
|
|
125
108
|
}
|
|
126
109
|
});
|
|
127
110
|
}
|
|
128
111
|
shouldAddToMine(item, base, mine) {
|
|
129
|
-
if (this.comparableKeys && Object.keys(item).some(
|
|
130
|
-
return (!mine.some(
|
|
131
|
-
!base.some(
|
|
112
|
+
if (this.comparableKeys && Object.keys(item).some(key => this.comparableKeys.includes(key))) {
|
|
113
|
+
return (!mine.some(mineItem => this.comparableKeys.some(key => ramda_1.eqProps(key, item, mineItem))) &&
|
|
114
|
+
!base.some(baseItem => this.comparableKeys.some(key => ramda_1.eqProps(key, item, baseItem))));
|
|
132
115
|
}
|
|
133
|
-
return !mine.some(
|
|
116
|
+
return !mine.some(mineItem => ramda_1.equals(mineItem, item)) && !base.some(baseItem => ramda_1.equals(baseItem, item));
|
|
134
117
|
}
|
|
135
118
|
}
|
|
136
119
|
exports.MineWinsConflictsResolver = MineWinsConflictsResolver;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
3
|
+
if (mod && mod.__esModule) return mod;
|
|
4
|
+
var result = {};
|
|
5
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
6
|
+
result["default"] = mod;
|
|
7
|
+
return result;
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const TypeMoq = __importStar(require("typemoq"));
|
|
11
|
+
const MineWinsConflictsResolver_1 = require("./MineWinsConflictsResolver");
|
|
12
|
+
describe('MineWinsConflictsResolver', () => {
|
|
13
|
+
const VBaseMock = TypeMoq.Mock.ofType();
|
|
14
|
+
const resolver = new (class extends MineWinsConflictsResolver_1.MineWinsConflictsResolver {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(VBaseMock.object, 'test', '/test', ['a']);
|
|
17
|
+
}
|
|
18
|
+
mergeMineWins(base, master, mine) {
|
|
19
|
+
return super.mergeMineWins(base, master, mine);
|
|
20
|
+
}
|
|
21
|
+
})();
|
|
22
|
+
it('Should merge object master and mine additions', async () => {
|
|
23
|
+
const master = { a: 1 };
|
|
24
|
+
const base = {};
|
|
25
|
+
const mine = { b: 2 };
|
|
26
|
+
const expected = { a: 1, b: 2 };
|
|
27
|
+
const result = resolver.mergeMineWins(base, master, mine);
|
|
28
|
+
expect(result).toEqual(expected);
|
|
29
|
+
});
|
|
30
|
+
it('Should keep mine object over master on keys conflict', async () => {
|
|
31
|
+
const master = { a: 0, b: 1 };
|
|
32
|
+
const base = {};
|
|
33
|
+
const mine = { b: 2, c: 3 };
|
|
34
|
+
const expected = { a: 0, b: 2, c: 3 };
|
|
35
|
+
const result = resolver.mergeMineWins(base, master, mine);
|
|
36
|
+
expect(result).toEqual(expected);
|
|
37
|
+
});
|
|
38
|
+
it('Should only add master object to mine if it wasn deleted', async () => {
|
|
39
|
+
const master = { b: 1 };
|
|
40
|
+
const base = { b: 1 };
|
|
41
|
+
const mine = {};
|
|
42
|
+
const expected = {};
|
|
43
|
+
const result = resolver.mergeMineWins(base, master, mine);
|
|
44
|
+
expect(result).toEqual(expected);
|
|
45
|
+
});
|
|
46
|
+
it('Should delete object from mine when it is deleted from master and there is no conflict', async () => {
|
|
47
|
+
const master = {};
|
|
48
|
+
const base = { a: 1 };
|
|
49
|
+
const mine = { a: 1, b: 2 };
|
|
50
|
+
const expected = { b: 2 };
|
|
51
|
+
const result = resolver.mergeMineWins(base, master, mine);
|
|
52
|
+
expect(result).toEqual(expected);
|
|
53
|
+
});
|
|
54
|
+
it('Should keep mine object when it is deleted from master and there is conflict', async () => {
|
|
55
|
+
const master = {};
|
|
56
|
+
const base = { a: 1 };
|
|
57
|
+
const mine = { a: 2 };
|
|
58
|
+
const expected = { a: 2 };
|
|
59
|
+
const result = resolver.mergeMineWins(base, master, mine);
|
|
60
|
+
expect(result).toEqual(expected);
|
|
61
|
+
});
|
|
62
|
+
it('Should append master array values to mine arrays when they dont already exist', async () => {
|
|
63
|
+
const master = [{ a: 1 }];
|
|
64
|
+
const base = [{}];
|
|
65
|
+
const mine = [{ b: 2 }];
|
|
66
|
+
const expected = [{ b: 2 }, { a: 1 }];
|
|
67
|
+
const result = resolver.mergeMineWins(base, master, mine);
|
|
68
|
+
expect(result).toEqual(expected);
|
|
69
|
+
const master1 = { a: [{ z: [{ stuff0: 0 }, { stuff1: 1 }] }] };
|
|
70
|
+
const base1 = { a: [{ z: [{ stuff0: 0 }] }] };
|
|
71
|
+
const mine1 = { a: [{ z: [{ stuff0: 0 }] }] };
|
|
72
|
+
const expected1 = { a: [{ z: [{ stuff0: 0 }, { stuff1: 1 }] }] };
|
|
73
|
+
const result1 = resolver.mergeMineWins(base1, master1, mine1);
|
|
74
|
+
expect(result1).toEqual(expected1);
|
|
75
|
+
const master2 = { b: [{ z: [{ stuff0: 0 }, { stuff1: 1 }] }] };
|
|
76
|
+
const base2 = { b: [{ z: [{ stuff0: 0 }] }] };
|
|
77
|
+
const mine2 = { b: [{ z: [{ stuff0: 0 }] }] };
|
|
78
|
+
const expected2 = { b: [{ z: [{ stuff0: 0 }, { stuff1: 1 }] }] };
|
|
79
|
+
const result2 = resolver.mergeMineWins(base2, master2, mine2);
|
|
80
|
+
expect(result2).toEqual(expected2);
|
|
81
|
+
});
|
|
82
|
+
it('Should not append master array values when they already exist in mine', async () => {
|
|
83
|
+
const master = [{ a: 1 }, { b: 2 }];
|
|
84
|
+
const base = [{}];
|
|
85
|
+
const mine = [{ b: 2 }];
|
|
86
|
+
const expected = [{ b: 2 }, { a: 1 }];
|
|
87
|
+
const result = resolver.mergeMineWins(base, master, mine);
|
|
88
|
+
expect(result).toEqual(expected);
|
|
89
|
+
});
|
|
90
|
+
it('Should keep mine array values in case of conflicts on comparableKeys', async () => {
|
|
91
|
+
const master = [{ a: 1, c: 3 }, { b: 2 }];
|
|
92
|
+
const base = [];
|
|
93
|
+
const mine = [{ a: 1 }];
|
|
94
|
+
const expected = [{ a: 1 }, { b: 2 }];
|
|
95
|
+
const result = resolver.mergeMineWins(base, master, mine);
|
|
96
|
+
expect(result).toEqual(expected);
|
|
97
|
+
});
|
|
98
|
+
it('Should delete from mine array values deleted from master with no conflict', async () => {
|
|
99
|
+
const master = [];
|
|
100
|
+
const base = [{ a: 1 }];
|
|
101
|
+
const mine = [{ a: 1 }, { b: 2 }];
|
|
102
|
+
const expected = [{ b: 2 }];
|
|
103
|
+
const result = resolver.mergeMineWins(base, master, mine);
|
|
104
|
+
expect(result).toEqual(expected);
|
|
105
|
+
});
|
|
106
|
+
it('Should only append array value to mine if it wasnt deleted from it', async () => {
|
|
107
|
+
const master = [{ b: 1 }];
|
|
108
|
+
const base = [{ b: 1 }];
|
|
109
|
+
const mine = [];
|
|
110
|
+
const expected = [];
|
|
111
|
+
const result = resolver.mergeMineWins(base, master, mine);
|
|
112
|
+
expect(result).toEqual(expected);
|
|
113
|
+
});
|
|
114
|
+
it('Should work with nullable inner objects', async () => {
|
|
115
|
+
const master = { a: [{ b: 1 }] };
|
|
116
|
+
const base = {};
|
|
117
|
+
const mine = {};
|
|
118
|
+
const expected = { a: [{ b: 1 }] };
|
|
119
|
+
const result = resolver.mergeMineWins(base, master, mine);
|
|
120
|
+
expect(result).toEqual(expected);
|
|
121
|
+
const master2 = { a: { b: 1 } };
|
|
122
|
+
const base2 = {};
|
|
123
|
+
const mine2 = {};
|
|
124
|
+
const expected2 = { a: { b: 1 } };
|
|
125
|
+
const result2 = resolver.mergeMineWins(base2, master2, mine2);
|
|
126
|
+
expect(result2).toEqual(expected2);
|
|
127
|
+
const master3 = { a: { b: 1 } };
|
|
128
|
+
const base3 = { a: {} };
|
|
129
|
+
const mine3 = {};
|
|
130
|
+
const expected3 = {};
|
|
131
|
+
const result3 = resolver.mergeMineWins(base3, master3, mine3);
|
|
132
|
+
expect(result3).toEqual(expected3);
|
|
133
|
+
});
|
|
134
|
+
});
|
package/lib/utils/app.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppMetaInfo } from '../clients/
|
|
1
|
+
import { AppMetaInfo } from '../clients/Apps';
|
|
2
2
|
export declare const removeBuild: (id: string) => string;
|
|
3
3
|
export declare const removeVersionFromAppId: (appId: string) => string;
|
|
4
4
|
export declare const extractVersionFromAppId: (appId: string) => string;
|
|
@@ -13,8 +13,6 @@ export declare const versionToMajorRange: (version: string) => string;
|
|
|
13
13
|
export declare const formatMajorLocator: (name: string, version: string) => string;
|
|
14
14
|
export declare const appIdToAppAtMajor: (appId: string) => string;
|
|
15
15
|
export declare const isValidAppIdOrLocator: (appId: string) => boolean;
|
|
16
|
-
export declare const sameMajor: (v1: string, v2: string) => boolean;
|
|
17
|
-
export declare const majorEqualAndGreaterThan: (v1: string, v2: string) => boolean;
|
|
18
16
|
export interface ParsedLocator {
|
|
19
17
|
name: string;
|
|
20
18
|
version: string;
|
package/lib/utils/app.js
CHANGED
|
@@ -23,7 +23,7 @@ exports.parseAppId = (appId) => {
|
|
|
23
23
|
version: splittedVersion[0],
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
exports.formatAppId = ({ locator, build }) =>
|
|
26
|
+
exports.formatAppId = ({ locator, build }) => build ? `${locator}+${build}` : locator;
|
|
27
27
|
exports.satisfies = (appId, version) => {
|
|
28
28
|
const { version: appVer } = exports.parseAppId(appId);
|
|
29
29
|
return semver_1.default.satisfies(appVer, version);
|
|
@@ -44,5 +44,3 @@ const APP_ID_REGEX = /^[\w\-]+\.[\w\-]+@(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-
|
|
|
44
44
|
exports.isValidAppIdOrLocator = (appId) => {
|
|
45
45
|
return APP_ID_REGEX.test(appId);
|
|
46
46
|
};
|
|
47
|
-
exports.sameMajor = (v1, v2) => exports.versionToMajor(v1) === exports.versionToMajor(v2);
|
|
48
|
-
exports.majorEqualAndGreaterThan = (v1, v2) => exports.sameMajor(v1, v2) && semver_1.default.gt(v1, v2);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { AppMetaInfo, Apps } from '..';
|
|
3
3
|
import { CacheLayer } from '../caches';
|
|
4
4
|
import { Logger } from '../service/logger';
|
|
5
|
-
export declare const getMetaInfoKey: (account: string
|
|
5
|
+
export declare const getMetaInfoKey: (account: string) => string;
|
|
6
6
|
export declare const updateMetaInfoCache: (cacheStorage: CacheLayer<string, AppMetaInfo[]>, account: string, workspace: string, dependencies: AppMetaInfo[], logger: Logger) => Promise<void>;
|
|
7
7
|
export declare const saveVersion: (app: string, cacheStorage: CacheLayer<string, string>) => Promise<void>;
|
|
8
8
|
export declare const getFallbackFile: (app: string, path: string, cacheStorage: CacheLayer<string, string>, apps: Apps) => Promise<{
|
|
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
const crypto_1 = __importDefault(require("crypto"));
|
|
14
14
|
const ramda_1 = require("ramda");
|
|
15
15
|
const semver = __importStar(require("semver"));
|
|
16
|
-
exports.getMetaInfoKey = (account
|
|
16
|
+
exports.getMetaInfoKey = (account) => `${account}-meta-infos`;
|
|
17
17
|
const hashMD5 = (text) => crypto_1.default
|
|
18
18
|
.createHash('md5')
|
|
19
19
|
.update(text)
|
|
@@ -22,7 +22,7 @@ exports.updateMetaInfoCache = async (cacheStorage, account, workspace, dependenc
|
|
|
22
22
|
if (workspace !== 'master') {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
const key = exports.getMetaInfoKey(account
|
|
25
|
+
const key = exports.getMetaInfoKey(account);
|
|
26
26
|
const hash = hashMD5(dependencies.toString());
|
|
27
27
|
try {
|
|
28
28
|
const storedDependencies = await cacheStorage.get(key) || '';
|
|
@@ -1,36 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
support: Support;
|
|
5
|
-
availableCountries: string[];
|
|
6
|
-
plans?: Plan[];
|
|
7
|
-
}
|
|
8
|
-
export declare enum BILLING_TYPE {
|
|
9
|
-
FREE = "free",
|
|
10
|
-
BILLABLE = "billable",
|
|
11
|
-
SPONSORED = "sponsored"
|
|
12
|
-
}
|
|
13
|
-
export interface PriceMetric {
|
|
14
|
-
id: string;
|
|
15
|
-
ranges: Range[];
|
|
16
|
-
customUrl: string;
|
|
17
|
-
}
|
|
18
|
-
export interface Range {
|
|
19
|
-
exclusiveFrom: number;
|
|
20
|
-
inclusiveTo?: number;
|
|
21
|
-
multiplier: number;
|
|
22
|
-
}
|
|
23
|
-
export interface Plan {
|
|
24
|
-
id: string;
|
|
25
|
-
currency: string;
|
|
26
|
-
price: Price;
|
|
27
|
-
}
|
|
28
|
-
export interface Price {
|
|
29
|
-
subscription?: number;
|
|
30
|
-
metrics?: PriceMetric[];
|
|
31
|
-
}
|
|
32
|
-
export interface Support {
|
|
33
|
-
email: string;
|
|
34
|
-
url?: string;
|
|
35
|
-
phone?: string;
|
|
36
|
-
}
|
|
1
|
+
import { BillingOptions, CalculationItem, FixedCalculationItem, FreeBillingOptions } from '../responses';
|
|
2
|
+
export declare const isFreeBillingOptions: (billingOptions: BillingOptions) => billingOptions is FreeBillingOptions;
|
|
3
|
+
export declare const isFixedCalculationItem: (item: CalculationItem) => item is FixedCalculationItem;
|